[MPlayer-cvslog] CVS: main/libvo vo_macosx.h, 1.2, 1.3 vo_macosx.m, 1.6, 1.7

Nicolas Plourde CVS syncmail at mplayerhq.hu
Thu May 26 01:39:01 CEST 2005


CVS change done by Nicolas Plourde CVS

Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv1351/libvo

Modified Files:
	vo_macosx.h vo_macosx.m 
Log Message:
create menu


Index: vo_macosx.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_macosx.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vo_macosx.h	2 May 2005 18:05:59 -0000	1.2
+++ vo_macosx.h	25 May 2005 23:38:59 -0000	1.3
@@ -30,6 +30,18 @@
     GLfloat upperLeft[2];
 	
 	BOOL mouseHide;
+	
+	//menu command id
+	NSMenuItem *kQuitCmd;
+	NSMenuItem *kHalfScreenCmd;
+	NSMenuItem *kNormalScreenCmd;
+	NSMenuItem *kDoubleScreenCmd;
+	NSMenuItem *kFullScreenCmd;
+	NSMenuItem *kKeepAspectCmd;
+	NSMenuItem *kAspectOrgCmd;
+	NSMenuItem *kAspectFullCmd;
+	NSMenuItem *kAspectWideCmd;
+	NSMenuItem *kPanScanCmd;
 }
 
 - (BOOL) acceptsFirstResponder;
@@ -38,6 +50,8 @@
 
 //window & rendering
 - (void) initOpenGLView;
+- (void) initMenu;
+- (void) menuAction:(id)sender;
 - (void) prepareOpenGL;
 - (void) render;
 - (void) reshape;

Index: vo_macosx.m
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_macosx.m,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- vo_macosx.m	4 May 2005 12:00:54 -0000	1.6
+++ vo_macosx.m	25 May 2005 23:38:59 -0000	1.7
@@ -301,6 +301,9 @@
 	NSRect frame = [self frame];
 	CVReturn error = kCVReturnSuccess;
 	
+	//init menu
+	[self initMenu];
+	
 	//create OpenGL Context
 	glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];	
 	
@@ -345,6 +348,166 @@
 }
 
 /*
+	Init Menu
+*/
+- (void)initMenu
+{
+	NSMenu *menu;
+	NSMenuItem *menuItem;
+	
+	[NSApp setMainMenu:[[NSMenu alloc] init]];
+
+//Create Movie Menu
+	menu = [[NSMenu alloc] initWithTitle:@"Movie"];
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem];
+	kHalfScreenCmd = menuItem;
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem];
+	kNormalScreenCmd = menuItem;
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem];
+	kDoubleScreenCmd = menuItem;
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem];
+	kFullScreenCmd = menuItem;
+	menuItem = [NSMenuItem separatorItem]; [menu addItem:menuItem];
+	
+		NSMenu	*aspectMenu;
+		aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"];
+		menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+		if(vo_keepaspect) [menuItem setState:NSOnState];
+		kKeepAspectCmd = menuItem;
+		menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+		if(vo_panscan) [menuItem setState:NSOnState];
+		kPanScanCmd = menuItem;
+		menuItem = [NSMenuItem separatorItem]; [aspectMenu addItem:menuItem];	
+		menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+		kAspectOrgCmd = menuItem;
+		menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem];
+		kAspectFullCmd = menuItem;
+		menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""];	[aspectMenu addItem:menuItem];
+		kAspectWideCmd = menuItem;
+		menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""];
+		[menuItem setSubmenu:aspectMenu];
+		[menu addItem:menuItem];
+		[aspectMenu release];
+	
+	//Add to menubar
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""];
+	[menuItem setSubmenu:menu];
+	[[NSApp mainMenu] addItem:menuItem];
+	
+//Create Window Menu
+	menu = [[NSMenu alloc] initWithTitle:@"Window"];
+	
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem];
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem];
+
+	//Add to menubar
+	menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
+	[menuItem setSubmenu:menu];
+	[[NSApp mainMenu] addItem:menuItem];
+	[NSApp setWindowsMenu:menu];
+	
+	[menu release];
+	[menuItem release];
+}
+
+/*
+	Menu Action
+ */
+- (void)menuAction:(id)sender
+{
+	uint32_t d_width;
+	uint32_t d_height;
+	NSRect frame;
+	
+	aspect((int *)&d_width, (int *)&d_height,A_NOZOOM);
+	//if(sender == kQuitCmd)
+	
+	if(sender == kHalfScreenCmd)
+	{
+		if(isFullscreen) {
+			vo_fs = (!(vo_fs)); [self fullscreen:YES];
+		}
+		
+		frame.size.width = (d_width/2);
+		frame.size.height = ((d_width/movie_aspect)/2);
+		[window setContentSize: frame.size];
+		[self reshape];
+	}
+	if(sender == kNormalScreenCmd)
+	{
+		if(isFullscreen) {
+			vo_fs = (!(vo_fs)); [self fullscreen:YES];
+		}
+		
+		frame.size.width = d_width;
+		frame.size.height = d_width/movie_aspect;
+		[window setContentSize: frame.size];
+		[self reshape];
+	}
+	if(sender == kDoubleScreenCmd)
+	{
+		if(isFullscreen) {
+			vo_fs = (!(vo_fs)); [self fullscreen:YES];
+		}
+		
+		frame.size.width = d_width*2;
+		frame.size.height = (d_width/movie_aspect)*2;
+		[window setContentSize: frame.size];
+		[self reshape];
+	}
+	if(sender == kFullScreenCmd)
+	{
+		vo_fs = (!(vo_fs));
+		[self fullscreen:YES];
+	}
+
+	if(sender == kKeepAspectCmd)
+	{
+		vo_keepaspect = (!(vo_keepaspect));
+		if(vo_keepaspect)
+			[kKeepAspectCmd setState:NSOnState];
+		else
+			[kKeepAspectCmd setState:NSOffState];
+	}
+	
+	if(sender == kPanScanCmd)
+	{
+		vo_panscan = (!(vo_panscan));
+		if(vo_panscan)
+			[kPanScanCmd setState:NSOnState];
+		else
+			[kPanScanCmd setState:NSOffState];
+	}
+	
+	if(sender == kAspectOrgCmd)
+	{
+		movie_aspect = old_movie_aspect;
+		frame.size.width = d_width;
+		frame.size.height = d_width/movie_aspect;
+		[window setContentSize: frame.size];
+		[self reshape];
+	}
+	
+	if(sender == kAspectFullCmd)
+	{
+		movie_aspect = 4.0f/3.0f;
+		frame.size.width = d_width;
+		frame.size.height = d_width/movie_aspect;
+		[window setContentSize: frame.size];
+		[self reshape];
+	}
+		
+	if(sender == kAspectWideCmd)
+	{
+		movie_aspect = 16.0f/9.0f;
+		frame.size.width = d_width;
+		frame.size.height = d_width/movie_aspect;
+		[window setContentSize: frame.size];
+		[self reshape];
+	}
+}
+
+/*
 	Setup OpenGL
 */
 - (void)prepareOpenGL




More information about the MPlayer-cvslog mailing list