2008-05-05 23:21:58 +02:00
|
|
|
/*
|
2015-01-07 00:53:03 +01:00
|
|
|
Displayer - base class for displaying video
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-05-05 23:21:58 +02:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2000, Arne Schirmacher <arne@schirmacher.de>
|
|
|
|
|
2001-2007, Dan Dennedy <dan@dennedy.org>
|
|
|
|
|
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-05-05 23:21:58 +02:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2008-05-05 23:21:58 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-05-05 23:21:58 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-05-05 23:21:58 +02:00
|
|
|
* *****************************************************/
|
|
|
|
|
|
2015-01-07 00:53:03 +01:00
|
|
|
|
2016-11-03 18:22:31 +01:00
|
|
|
/** @file displayer.cpp
|
2016-11-06 14:19:14 +01:00
|
|
|
** Implementation of a displayer object, intended for creating
|
|
|
|
|
** a video display in the UI. This class was created as part of
|
|
|
|
|
** an initial draft of the user interface.
|
|
|
|
|
** @warning as of 2016 it is not clear, if this code will be
|
|
|
|
|
** evolved into the actual display facility, or be
|
|
|
|
|
** replaced and rewritten, when we're about to
|
|
|
|
|
** create a functional video display connected
|
|
|
|
|
** to the render engine.
|
2016-11-03 18:20:10 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2017-05-03 21:13:17 +02:00
|
|
|
#include "gui/gtk-base.hpp"
|
2014-08-17 07:02:48 +02:00
|
|
|
#include "gui/output/displayer.hpp"
|
|
|
|
|
#include "gui/output/xvdisplayer.hpp"
|
|
|
|
|
#include "gui/output/gdkdisplayer.hpp"
|
2008-05-05 23:21:58 +02:00
|
|
|
|
|
|
|
|
namespace gui {
|
|
|
|
|
namespace output {
|
2015-01-07 00:53:03 +01:00
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Displayer::usable()
|
2008-06-07 14:53:17 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-01-07 00:53:03 +01:00
|
|
|
|
|
|
|
|
DisplayerInput
|
|
|
|
|
Displayer::format()
|
2008-06-07 14:53:17 +02:00
|
|
|
{
|
|
|
|
|
return DISPLAY_NONE;
|
|
|
|
|
}
|
2015-01-07 00:53:03 +01:00
|
|
|
|
|
|
|
|
int
|
|
|
|
|
Displayer::preferredWidth()
|
2008-06-07 14:53:17 +02:00
|
|
|
{
|
|
|
|
|
return imageWidth;
|
|
|
|
|
}
|
2015-01-07 00:53:03 +01:00
|
|
|
|
|
|
|
|
int
|
|
|
|
|
Displayer::preferredHeight()
|
2008-06-07 14:53:17 +02:00
|
|
|
{
|
|
|
|
|
return imageHeight;
|
|
|
|
|
}
|
2015-01-07 00:53:03 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Displayer::calculateVideoLayout(
|
|
|
|
|
int widget_width, int widget_height,
|
|
|
|
|
int image_width, int image_height,
|
|
|
|
|
int &video_x, int &video_y, int &video_width, int &video_height )
|
2008-06-07 14:53:17 +02:00
|
|
|
{
|
2015-01-07 00:53:03 +01:00
|
|
|
REQUIRE (widget_width >= 0);
|
|
|
|
|
REQUIRE (widget_height >= 0);
|
|
|
|
|
REQUIRE (image_width >= 0);
|
|
|
|
|
REQUIRE (image_height >= 0);
|
2008-06-07 14:53:17 +02:00
|
|
|
|
|
|
|
|
double ratio_width = ( double ) widget_width / ( double ) image_width;
|
|
|
|
|
double ratio_height = ( double ) widget_height / ( double ) image_height;
|
|
|
|
|
double ratio_constant = ratio_height < ratio_width ?
|
|
|
|
|
ratio_height : ratio_width;
|
|
|
|
|
video_width = ( int ) ( image_width * ratio_constant + 0.5 );
|
|
|
|
|
video_height = ( int ) ( image_height * ratio_constant + 0.5 );
|
|
|
|
|
video_x = ( widget_width - video_width ) / 2;
|
|
|
|
|
video_y = ( widget_height - video_height ) / 2;
|
|
|
|
|
|
2015-01-07 00:53:03 +01:00
|
|
|
ENSURE (video_x >= 0 && video_x < widget_width);
|
|
|
|
|
ENSURE (video_y >= 0 && video_y < widget_height);
|
|
|
|
|
ENSURE (video_width <= widget_width);
|
|
|
|
|
ENSURE (video_width <= widget_width);
|
2008-06-07 14:53:17 +02:00
|
|
|
}
|
2015-01-07 00:53:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
}} // namespace gui::output
|