Lumiera  0.pre.03
»edit your freedom«
displayer.cpp
Go to the documentation of this file.
1 /*
2  Displayer - base class for displaying video
3 
4  Copyright (C) Lumiera.org
5  2000, Arne Schirmacher <arne@schirmacher.de>
6  2001-2007, Dan Dennedy <dan@dennedy.org>
7  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of
12  the License, or (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 
23 * *****************************************************/
24 
25 
38 #include "stage/gtk-base.hpp"
42 
43 namespace stage {
44 namespace output {
45 
46  bool
48  {
49  return false;
50  }
51 
54  {
55  return DISPLAY_NONE;
56  }
57 
58  int
60  {
61  return imageWidth;
62  }
63 
64  int
66  {
67  return imageHeight;
68  }
69 
70  void
72  int widget_width, int widget_height,
73  int image_width, int image_height,
74  int &video_x, int &video_y, int &video_width, int &video_height )
75  {
76  REQUIRE (widget_width >= 0);
77  REQUIRE (widget_height >= 0);
78  REQUIRE (image_width >= 0);
79  REQUIRE (image_height >= 0);
80 
81  double ratio_width = ( double ) widget_width / ( double ) image_width;
82  double ratio_height = ( double ) widget_height / ( double ) image_height;
83  double ratio_constant = ratio_height < ratio_width ?
84  ratio_height : ratio_width;
85  video_width = ( int ) ( image_width * ratio_constant + 0.5 );
86  video_height = ( int ) ( image_height * ratio_constant + 0.5 );
87  video_x = ( widget_width - video_width ) / 2;
88  video_y = ( widget_height - video_height ) / 2;
89 
90  ENSURE (video_x >= 0 && video_x < widget_width);
91  ENSURE (video_y >= 0 && video_y < widget_height);
92  ENSURE (video_width <= widget_width);
93  ENSURE (video_width <= widget_width);
94  }
95 
96 
97 }} // namespace stage::output
static void 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)
Calculates the coordinates for placing a video image inside a widget.
Definition: displayer.cpp:71
virtual int preferredHeight()
Expected height of input to put.
Definition: displayer.cpp:65
virtual DisplayerInput format()
Indicates the format required by the abstract put method.
Definition: displayer.cpp:53
virtual int preferredWidth()
Expected width of input to put.
Definition: displayer.cpp:59
Display video via GDK.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
virtual bool usable()
Indicates if this object can be used to render images on the running system.
Definition: displayer.cpp:47
The Displayer serves as base of all video display implementations.
DisplayerInput
Supported Displayer formats.
Definition: displayer.hpp:43
A set of basic GTK includes for the UI.
Implementation of video output via XVideo.