lumiera_/src/gui/output/displayer.cpp

91 lines
2.5 KiB
C++
Raw Normal View History

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
/** @file §§§
** TODO §§§
*/
#include "gui/gtk-lumiera.hpp"
#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()
{
return false;
}
2015-01-07 00:53:03 +01:00
DisplayerInput
Displayer::format()
{
return DISPLAY_NONE;
}
2015-01-07 00:53:03 +01:00
int
Displayer::preferredWidth()
{
return imageWidth;
}
2015-01-07 00:53:03 +01:00
int
Displayer::preferredHeight()
{
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 )
{
2015-01-07 00:53:03 +01:00
REQUIRE (widget_width >= 0);
REQUIRE (widget_height >= 0);
REQUIRE (image_width >= 0);
REQUIRE (image_height >= 0);
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);
}
2015-01-07 00:53:03 +01:00
}} // namespace gui::output