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)
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   **Lumiera** is free software; you can redistribute it and/or modify it
10   under the terms of the GNU General Public License as published by the
11   Free Software Foundation; either version 2 of the License, or (at your
12   option) any later version. See the file COPYING for further details.
13 
14 * *****************************************************************/
15 
16 
29 #include "stage/gtk-base.hpp"
33 
34 namespace stage {
35 namespace output {
36 
37  bool
39  {
40  return false;
41  }
42 
45  {
46  return DISPLAY_NONE;
47  }
48 
49  int
51  {
52  return imageWidth;
53  }
54 
55  int
57  {
58  return imageHeight;
59  }
60 
61  void
63  int widget_width, int widget_height,
64  int image_width, int image_height,
65  int &video_x, int &video_y, int &video_width, int &video_height )
66  {
67  REQUIRE (widget_width >= 0);
68  REQUIRE (widget_height >= 0);
69  REQUIRE (image_width >= 0);
70  REQUIRE (image_height >= 0);
71 
72  double ratio_width = ( double ) widget_width / ( double ) image_width;
73  double ratio_height = ( double ) widget_height / ( double ) image_height;
74  double ratio_constant = ratio_height < ratio_width ?
75  ratio_height : ratio_width;
76  video_width = ( int ) ( image_width * ratio_constant + 0.5 );
77  video_height = ( int ) ( image_height * ratio_constant + 0.5 );
78  video_x = ( widget_width - video_width ) / 2;
79  video_y = ( widget_height - video_height ) / 2;
80 
81  ENSURE (video_x >= 0 && video_x < widget_width);
82  ENSURE (video_y >= 0 && video_y < widget_height);
83  ENSURE (video_width <= widget_width);
84  ENSURE (video_width <= widget_width);
85  }
86 
87 
88 }} // 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:62
virtual int preferredHeight()
Expected height of input to put.
Definition: displayer.cpp:56
virtual DisplayerInput format()
Indicates the format required by the abstract put method.
Definition: displayer.cpp:44
virtual int preferredWidth()
Expected width of input to put.
Definition: displayer.cpp:50
Display video via GDK.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
virtual bool usable()
Indicates if this object can be used to render images on the running system.
Definition: displayer.cpp:38
The Displayer serves as base of all video display implementations.
DisplayerInput
Supported Displayer formats.
Definition: displayer.hpp:34
A set of basic GTK includes for the UI.
Implementation of video output via XVideo.