Mercurial > mplayer.hg
comparison libvo/vo_macosx.m @ 15570:f197f4a60b20
create menu
author | nplourde |
---|---|
date | Wed, 25 May 2005 23:38:59 +0000 |
parents | 606d1aac2d85 |
children | ab43da229a76 |
comparison
equal
deleted
inserted
replaced
15569:dff7e79b194f | 15570:f197f4a60b20 |
---|---|
299 - (void) initOpenGLView | 299 - (void) initOpenGLView |
300 { | 300 { |
301 NSRect frame = [self frame]; | 301 NSRect frame = [self frame]; |
302 CVReturn error = kCVReturnSuccess; | 302 CVReturn error = kCVReturnSuccess; |
303 | 303 |
304 //init menu | |
305 [self initMenu]; | |
306 | |
304 //create OpenGL Context | 307 //create OpenGL Context |
305 glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil]; | 308 glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil]; |
306 | 309 |
307 | 310 |
308 //create window | 311 //create window |
340 error = CVOpenGLTextureCacheCreateTextureFromImage( NULL, textureCache, currentFrameBuffer, 0, &texture); | 343 error = CVOpenGLTextureCacheCreateTextureFromImage( NULL, textureCache, currentFrameBuffer, 0, &texture); |
341 if(error != kCVReturnSuccess) | 344 if(error != kCVReturnSuccess) |
342 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error); | 345 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error); |
343 | 346 |
344 isFullscreen = 0; | 347 isFullscreen = 0; |
348 } | |
349 | |
350 /* | |
351 Init Menu | |
352 */ | |
353 - (void)initMenu | |
354 { | |
355 NSMenu *menu; | |
356 NSMenuItem *menuItem; | |
357 | |
358 [NSApp setMainMenu:[[NSMenu alloc] init]]; | |
359 | |
360 //Create Movie Menu | |
361 menu = [[NSMenu alloc] initWithTitle:@"Movie"]; | |
362 menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem]; | |
363 kHalfScreenCmd = menuItem; | |
364 menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem]; | |
365 kNormalScreenCmd = menuItem; | |
366 menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem]; | |
367 kDoubleScreenCmd = menuItem; | |
368 menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem]; | |
369 kFullScreenCmd = menuItem; | |
370 menuItem = [NSMenuItem separatorItem]; [menu addItem:menuItem]; | |
371 | |
372 NSMenu *aspectMenu; | |
373 aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"]; | |
374 menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
375 if(vo_keepaspect) [menuItem setState:NSOnState]; | |
376 kKeepAspectCmd = menuItem; | |
377 menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
378 if(vo_panscan) [menuItem setState:NSOnState]; | |
379 kPanScanCmd = menuItem; | |
380 menuItem = [NSMenuItem separatorItem]; [aspectMenu addItem:menuItem]; | |
381 menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
382 kAspectOrgCmd = menuItem; | |
383 menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
384 kAspectFullCmd = menuItem; | |
385 menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
386 kAspectWideCmd = menuItem; | |
387 menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""]; | |
388 [menuItem setSubmenu:aspectMenu]; | |
389 [menu addItem:menuItem]; | |
390 [aspectMenu release]; | |
391 | |
392 //Add to menubar | |
393 menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""]; | |
394 [menuItem setSubmenu:menu]; | |
395 [[NSApp mainMenu] addItem:menuItem]; | |
396 | |
397 //Create Window Menu | |
398 menu = [[NSMenu alloc] initWithTitle:@"Window"]; | |
399 | |
400 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem]; | |
401 menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem]; | |
402 | |
403 //Add to menubar | |
404 menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; | |
405 [menuItem setSubmenu:menu]; | |
406 [[NSApp mainMenu] addItem:menuItem]; | |
407 [NSApp setWindowsMenu:menu]; | |
408 | |
409 [menu release]; | |
410 [menuItem release]; | |
411 } | |
412 | |
413 /* | |
414 Menu Action | |
415 */ | |
416 - (void)menuAction:(id)sender | |
417 { | |
418 uint32_t d_width; | |
419 uint32_t d_height; | |
420 NSRect frame; | |
421 | |
422 aspect((int *)&d_width, (int *)&d_height,A_NOZOOM); | |
423 //if(sender == kQuitCmd) | |
424 | |
425 if(sender == kHalfScreenCmd) | |
426 { | |
427 if(isFullscreen) { | |
428 vo_fs = (!(vo_fs)); [self fullscreen:YES]; | |
429 } | |
430 | |
431 frame.size.width = (d_width/2); | |
432 frame.size.height = ((d_width/movie_aspect)/2); | |
433 [window setContentSize: frame.size]; | |
434 [self reshape]; | |
435 } | |
436 if(sender == kNormalScreenCmd) | |
437 { | |
438 if(isFullscreen) { | |
439 vo_fs = (!(vo_fs)); [self fullscreen:YES]; | |
440 } | |
441 | |
442 frame.size.width = d_width; | |
443 frame.size.height = d_width/movie_aspect; | |
444 [window setContentSize: frame.size]; | |
445 [self reshape]; | |
446 } | |
447 if(sender == kDoubleScreenCmd) | |
448 { | |
449 if(isFullscreen) { | |
450 vo_fs = (!(vo_fs)); [self fullscreen:YES]; | |
451 } | |
452 | |
453 frame.size.width = d_width*2; | |
454 frame.size.height = (d_width/movie_aspect)*2; | |
455 [window setContentSize: frame.size]; | |
456 [self reshape]; | |
457 } | |
458 if(sender == kFullScreenCmd) | |
459 { | |
460 vo_fs = (!(vo_fs)); | |
461 [self fullscreen:YES]; | |
462 } | |
463 | |
464 if(sender == kKeepAspectCmd) | |
465 { | |
466 vo_keepaspect = (!(vo_keepaspect)); | |
467 if(vo_keepaspect) | |
468 [kKeepAspectCmd setState:NSOnState]; | |
469 else | |
470 [kKeepAspectCmd setState:NSOffState]; | |
471 } | |
472 | |
473 if(sender == kPanScanCmd) | |
474 { | |
475 vo_panscan = (!(vo_panscan)); | |
476 if(vo_panscan) | |
477 [kPanScanCmd setState:NSOnState]; | |
478 else | |
479 [kPanScanCmd setState:NSOffState]; | |
480 } | |
481 | |
482 if(sender == kAspectOrgCmd) | |
483 { | |
484 movie_aspect = old_movie_aspect; | |
485 frame.size.width = d_width; | |
486 frame.size.height = d_width/movie_aspect; | |
487 [window setContentSize: frame.size]; | |
488 [self reshape]; | |
489 } | |
490 | |
491 if(sender == kAspectFullCmd) | |
492 { | |
493 movie_aspect = 4.0f/3.0f; | |
494 frame.size.width = d_width; | |
495 frame.size.height = d_width/movie_aspect; | |
496 [window setContentSize: frame.size]; | |
497 [self reshape]; | |
498 } | |
499 | |
500 if(sender == kAspectWideCmd) | |
501 { | |
502 movie_aspect = 16.0f/9.0f; | |
503 frame.size.width = d_width; | |
504 frame.size.height = d_width/movie_aspect; | |
505 [window setContentSize: frame.size]; | |
506 [self reshape]; | |
507 } | |
345 } | 508 } |
346 | 509 |
347 /* | 510 /* |
348 Setup OpenGL | 511 Setup OpenGL |
349 */ | 512 */ |