Mercurial > mplayer.hg
changeset 13792:d603c33bb3d3
menu option to set desired movie aspect & keep aspect on window resize
author | nplourde |
---|---|
date | Thu, 28 Oct 2004 22:03:26 +0000 |
parents | 4f08a94405ad |
children | 631b0b664ece |
files | libvo/vo_quartz.c |
diffstat | 1 files changed, 70 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_quartz.c Thu Oct 28 21:48:41 2004 +0000 +++ b/libvo/vo_quartz.c Thu Oct 28 22:03:26 2004 +0000 @@ -72,6 +72,9 @@ extern int vo_fs; // user want fullscreen static int vo_quartz_fs; // we are in fullscreen extern float monitor_aspect; +extern int vo_keepaspect; //keep aspect ratio when resizing +extern float movie_aspect; +static float old_movie_aspect; static int winLevel = 1; int levelList[] = @@ -106,6 +109,10 @@ static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode static Rect deviceRect; // size of the display device +static MenuRef windMenu; +static MenuRef movMenu; +static MenuRef aspectMenu; + static int border = 20; enum { @@ -113,7 +120,11 @@ kHalfScreenCmd = 2, kNormalScreenCmd = 3, kDoubleScreenCmd = 4, - kFullScreenCmd = 5 + kFullScreenCmd = 5, + kKeepAspectCmd = 6, + kAspectOrgCmd = 7, + kAspectFullCmd = 8, + kAspectWideCmd = 9 }; #include "osdep/keycodes.h" @@ -367,6 +378,29 @@ vo_fs = (!(vo_fs)); window_fullscreen(); break; + case kKeepAspectCmd: + vo_keepaspect = (!(vo_keepaspect)); + CheckMenuItem (aspectMenu, 1, vo_keepaspect); + break; + + case kAspectOrgCmd: + movie_aspect = old_movie_aspect; + SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect)+border,1); + window_resized(); + break; + + case kAspectFullCmd: + movie_aspect = 4.0f/3.0f; + SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect)+border,1); + window_resized(); + break; + + case kAspectWideCmd: + movie_aspect = 16.0f/9.0f; + SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect)+border,1); + window_resized(); + break; + default: result = eventNotHandledErr; break; @@ -411,22 +445,24 @@ CFStringRef titleKey; CFStringRef windowTitle; OSStatus result; + + MenuItemIndex index; + CFStringRef movMenuTitle; + CFStringRef aspMenuTitle; SetRect(&winRect, 0, 0, d_width, d_height); SetRect(&oldWinRect, 0, 0, d_width, d_height); SetRect(&dstRect, 0, 0, d_width, d_height); - MenuRef windMenu; + //Create Window Menu CreateStandardWindowMenu(0, &windMenu); InsertMenu(windMenu, 0); - MenuRef movMenu; + //Create Movie Menu CreateNewMenu (1004, 0, &movMenu); - - CFStringRef movMenuTitle = CFSTR("Movie"); + movMenuTitle = CFSTR("Movie"); SetMenuTitleWithCFString(movMenu, movMenuTitle); - MenuItemIndex index; AppendMenuItemTextWithCFString(movMenu, CFSTR("Half Size"), 0, kHalfScreenCmd, &index); SetMenuItemCommandKey(movMenu, index, 0, '0'); @@ -439,6 +475,23 @@ AppendMenuItemTextWithCFString(movMenu, CFSTR("Full Size"), 0, kFullScreenCmd, &index); SetMenuItemCommandKey(movMenu, index, 0, 'F'); + AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, NULL, &index); + + AppendMenuItemTextWithCFString(movMenu, CFSTR("Aspect Ratio"), 0, NULL, &index); + + ////Create Aspect Ratio Sub Menu + CreateNewMenu (0, 0, &aspectMenu); + aspMenuTitle = CFSTR("Aspect Ratio"); + SetMenuTitleWithCFString(aspectMenu, aspMenuTitle); + SetMenuItemHierarchicalMenu(movMenu, 6, aspectMenu); + + AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Keep"), 0, kKeepAspectCmd, &index); + CheckMenuItem (aspectMenu, 1, vo_keepaspect); + AppendMenuItemTextWithCFString(aspectMenu, NULL, kMenuItemAttrSeparator, NULL, &index); + AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Original"), 0, kAspectOrgCmd, &index); + AppendMenuItemTextWithCFString(aspectMenu, CFSTR("4:3"), 0, kAspectFullCmd, &index); + AppendMenuItemTextWithCFString(aspectMenu, CFSTR("16:9"), 0, kAspectWideCmd, &index); + InsertMenu(movMenu, GetMenuID(windMenu)); //insert before Window menu DrawMenuBar(); @@ -529,6 +582,9 @@ aspect_save_prescale(d_width,d_height); aspect_save_screenres(device_width, device_height); + movie_aspect = (float)imgRect.right/(float)imgRect.bottom; + old_movie_aspect = movie_aspect; + aspect(&d_width,&d_height,A_NOZOOM); if(image_data) @@ -1088,7 +1144,10 @@ GetPortBounds( GetWindowPort(theWindow), &winRect ); + if(vo_keepaspect) + { aspect( &d_width, &d_height, A_NOZOOM); + d_height = ((float)d_width/movie_aspect); aspectX = (float)((float)winRect.right/(float)d_width); aspectY = (float)((float)(winRect.bottom-border)/(float)d_height); @@ -1103,6 +1162,11 @@ padding = ((winRect.bottom-border) - d_height*aspectX)/2; SetRect(&dstRect, 0, padding, (d_width*aspectX), d_height*aspectX+padding); } + } + else + { + SetRect(&dstRect, 0, 0, winRect.right, winRect.bottom-border); + } //Clear Background tmpBounds = CGRectMake( 0, border, winRect.right, winRect.bottom);