00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "../gtk-lumiera.hpp"
00026 #include "displayer.hpp"
00027 #include "xvdisplayer.hpp"
00028 #include "gdkdisplayer.hpp"
00029
00030 namespace gui {
00031 namespace output {
00032
00033 bool
00034 Displayer::usable()
00035 {
00036 return false;
00037 }
00038
00039 DisplayerInput
00040 Displayer::format()
00041 {
00042 return DISPLAY_NONE;
00043 }
00044
00045 int
00046 Displayer::preferredWidth()
00047 {
00048 return imageWidth;
00049 }
00050
00051 int
00052 Displayer::preferredHeight()
00053 {
00054 return imageHeight;
00055 }
00056
00057 void
00058 Displayer::calculateVideoLayout(
00059 int widget_width, int widget_height,
00060 int image_width, int image_height,
00061 int &video_x, int &video_y, int &video_width, int &video_height )
00062 {
00063 REQUIRE(widget_width >= 0);
00064 REQUIRE(widget_height >= 0);
00065 REQUIRE(image_width >= 0);
00066 REQUIRE(image_height >= 0);
00067
00068 double ratio_width = ( double ) widget_width / ( double ) image_width;
00069 double ratio_height = ( double ) widget_height / ( double ) image_height;
00070 double ratio_constant = ratio_height < ratio_width ?
00071 ratio_height : ratio_width;
00072 video_width = ( int ) ( image_width * ratio_constant + 0.5 );
00073 video_height = ( int ) ( image_height * ratio_constant + 0.5 );
00074 video_x = ( widget_width - video_width ) / 2;
00075 video_y = ( widget_height - video_height ) / 2;
00076
00077 ENSURE(video_x >= 0 && video_x < widget_width)
00078 ENSURE(video_y >= 0 && video_y < widget_height)
00079 ENSURE(video_width <= widget_width)
00080 ENSURE(video_width <= widget_width)
00081 }
00082
00083 }
00084 }