[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx:[735] trunk/fuse/fusepb/views/DisplayOpenGLVi
Brought to you by:
fredm
From: <fr...@us...> - 2013-03-24 06:27:30
|
Revision: 735 http://sourceforge.net/p/fuse-for-macosx/code/735 Author: fredm Date: 2013-03-24 06:27:29 +0000 (Sun, 24 Mar 2013) Log Message: ----------- Really fix fullscreen panorama setting for 16:9 and other ratio screens. Modified Paths: -------------- trunk/fuse/fusepb/views/DisplayOpenGLView.m Modified: trunk/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- trunk/fuse/fusepb/views/DisplayOpenGLView.m 2013-03-14 11:36:06 UTC (rev 734) +++ trunk/fuse/fusepb/views/DisplayOpenGLView.m 2013-03-24 06:27:29 UTC (rev 735) @@ -68,9 +68,62 @@ static int get_offset( int window_width, int window_height, - int image_width, int image_height ) { - float ratio = window_width/image_width; - return ((ratio * image_height) - window_height) / (ratio * 2); + int image_width, int image_height, float* width_adjustment ) { + static const float FULL_IMAGE_RATIO = 4./3.; + static const float TOP_BORDER_HAIRCUT = 24.; + static const float MINIMAL_HEIGHT = 240.-TOP_BORDER_HAIRCUT*2.; + static const float MINIMAL_TOP_BOTTOM_RATIO = 320./MINIMAL_HEIGHT; + static const float SIDE_BORDER_HAIRCUT = 31.; + static const float MINIMAL_WIDTH = 320.-SIDE_BORDER_HAIRCUT*2.; + static const float MINIMAL_LEFT_RIGHT_RATIO = MINIMAL_WIDTH/240.; + float ratio = window_width/(float)window_height; + *width_adjustment = 0.; + if( fabs( ratio - FULL_IMAGE_RATIO ) < 0.01f ) { + /* no change, we are already at 4:3 */ + return 0; + } + + if( !settings_current.full_screen_panorama ) { + // if wider then desirable then use max height and have black bars on left + // and right borders + if( ratio > FULL_IMAGE_RATIO ) { + float height_scale = window_height / (float)image_height; + float height_ratio = window_height * FULL_IMAGE_RATIO; + *width_adjustment = (window_width - height_ratio)/(2.*height_scale); + return 0; + } + // if narrower than desirable then use max width and have black bars on top + // and bottom of frame + float width_scale = window_width / (float)image_width; + float width_ratio = window_width / FULL_IMAGE_RATIO; + return (width_ratio - window_height)/(2.*width_scale); + } + if( ratio > MINIMAL_TOP_BOTTOM_RATIO ) { + // Truncate the top and bottom borders as much as possible and put black + // bars on the left and right borders to cover the remainder + float height_scale = window_height / MINIMAL_HEIGHT; + float height_ratio = window_height * MINIMAL_TOP_BOTTOM_RATIO; + *width_adjustment = (window_width - height_ratio)/(2.*height_scale); + return TOP_BORDER_HAIRCUT; + } else if( ratio > FULL_IMAGE_RATIO ) { + // Similar to above but need to appropriately scale the amount of border + // truncation assuming that full width will be used + float width_scale = window_width / (float)image_width; + float height_pixels = window_width / FULL_IMAGE_RATIO; + return (height_pixels - window_height) / (2.*width_scale); + } else if( ratio < MINIMAL_LEFT_RIGHT_RATIO ) { + // here we have maximum border truncation and black bars top and bottom + float width_scale = window_width / MINIMAL_WIDTH; + float width_ratio = window_width / MINIMAL_LEFT_RIGHT_RATIO; + *width_adjustment = -SIDE_BORDER_HAIRCUT; + return (width_ratio - window_height)/(2.*width_scale); + } + // here we have a little bit of truncation of the left and right borders and + // leave the top and bottom borders alone + float height_scale = window_height / (float)image_height; + float width_pixels = window_height * FULL_IMAGE_RATIO; + *width_adjustment = (window_width - width_pixels) / (2.*height_scale); + return 0; } @implementation DisplayOpenGLView @@ -444,47 +497,14 @@ if( settings_current.full_screen ) { /* how much of the top and bottom borders should be eliminated? */ NSRect rect = [self bounds]; - float bounds_ratio = rect.size.width/rect.size.height; + float width_adjustment = 0.0; - if( fabs( bounds_ratio - target_ratio ) < 0.01f ) { - /* no change, we are already at 4:3 */ - } else if( settings_current.full_screen_panorama ) { - /* Cap panorama to 16:10 as less truncates paper area TODO: properly - access border area of source images */ - if( bounds_ratio > 1.6 ) bounds_ratio = 1.6; - - if( bounds_ratio > target_ratio ) { - /* if wider than ideal, truncate border until we get to main section - then resize */ - border_x_offset = - get_offset( rect.size.width, rect.size.height, - screenTex[currentScreenTex].image_width, - screenTex[currentScreenTex].image_height); - } else { - /* if taller than ideal, truncate border until we get to main section - then resize */ - border_y_offset = - get_offset( rect.size.height, rect.size.width, - screenTex[currentScreenTex].image_height, - screenTex[currentScreenTex].image_width); - } - } else { - if( bounds_ratio > target_ratio ) { - /* if wider than ideal, truncate border until we get to main section - then resize */ - border_y_offset = - get_offset( rect.size.width, rect.size.height, - screenTex[currentScreenTex].image_width, - screenTex[currentScreenTex].image_height); - } else { - /* if taller than ideal, truncate border until we get to main section - then resize */ - border_x_offset = - get_offset( rect.size.height, rect.size.width, - screenTex[currentScreenTex].image_height, - screenTex[currentScreenTex].image_width); - } - } + border_x_offset = + get_offset( rect.size.width, rect.size.height, + screenTex[currentScreenTex].image_width, + screenTex[currentScreenTex].image_height, + &width_adjustment ); + border_y_offset = width_adjustment; } /* Bind, update and draw new image */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |