]> git.sesse.net Git - vlc/commitdiff
macosx: added an entry to Video->Aspect-ratio to disable our AR-lock for one session.
authorFelix Paul Kühne <fkuehne@videolan.org>
Fri, 22 May 2009 17:46:13 +0000 (19:46 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Fri, 22 May 2009 17:46:27 +0000 (19:46 +0200)
Based upon an idea by Philipp Biermann.

An actual vlc-option for this will be created in the master branch.

Note that this feature does only affect VLCEmbeddedWindow - our plain vout window enforces the AR.

modules/gui/macosx/controls.h
modules/gui/macosx/controls.m
modules/gui/macosx/embeddedwindow.m

index bd123bde20026886fb57b33e0a4444344aa3cb20..3708813f47af30ff616afb5dd2cd5281359a7f9e 100644 (file)
     IBOutlet id o_specificTime_mi;
 
     VLCFSPanel *o_fs_panel;
+    BOOL b_lockAspectRatio;
 }
 - (void)controlTintChanged;
 
 - (id)voutView;
+- (BOOL)aspectRatioIsLocked;
 
 - (IBAction)play:(id)sender;
 - (IBAction)stop:(id)sender;
@@ -91,6 +93,7 @@
 
 - (IBAction)telxTransparent:(id)sender;
 - (IBAction)telxNavLink:(id)sender;
+- (IBAction)lockVideosAspectRatio:(id)sender;
 - (IBAction)addSubtitleFile:(id)sender;
 
 - (BOOL)keyEvent:(NSEvent *)o_event;
index 084c7f1f4c7820854e97526600357dce3d0c0bdc..8b864e6f2bbc62fe03ea5ab437c0fdbc565a4c7b 100644 (file)
@@ -74,6 +74,7 @@
 {
     [super init];
     o_fs_panel = [[VLCFSPanel alloc] init];
+    b_lockAspectRatio = YES;
     return self;
 }
 
     return [[voutView retain] autorelease];
 }
 
+- (BOOL)aspectRatioIsLocked
+{
+    return b_lockAspectRatio;
+}
+
 - (IBAction)stop:(id)sender
 {
     intf_thread_t * p_intf = VLCIntf;
     }
 }
 
+- (IBAction)lockVideosAspectRatio:(id)sender
+{
+    if( [sender state] == NSOffState )
+        [sender setState: NSOnState];
+    else
+        [sender setState: NSOffState];
+
+    b_lockAspectRatio = !b_lockAspectRatio;
+}
+
 - (IBAction)addSubtitleFile:(id)sender
 {
     NSInteger i_returnValue = 0;
             if( input_AddSubtitle( p_input, [[[openPanel filenames] objectAtIndex: i] UTF8String], TRUE ) )
                 msg_Warn( VLCIntf, "unable to load subtitles from '%s'",
                          [[[openPanel filenames] objectAtIndex: i] UTF8String] );
-            i++;
         }
     }
 }
     /* make (un)sensitive */
     [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
 
+    /* Aspect Ratio */
+    if( [[o_parent title] isEqualToString: _NS("Aspect-ratio")] == YES )
+    {
+        NSMenuItem *o_lmi_tmp2;
+        o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
+        [o_lmi_tmp2 setTarget: self];
+        [o_lmi_tmp2 setEnabled: YES];
+        [o_lmi_tmp2 setState: b_lockAspectRatio];
+        [o_parent setEnabled: YES];
+        [o_menu addItem: [NSMenuItem separatorItem]];
+    }
+
     /* special case for the subtitles items */
     if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES )
     {
index b59ccf94b74d47259380b60762b9e92e7ee938fc..9409690b4ef548c5e6c0083b699c59ba630720b0 100644 (file)
     if( videoRatio.height == 0. || videoRatio.width == 0. )
         return proposedFrameSize;
 
-    NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil];
-    NSRect contentRect = [self contentRectForFrameRect:[self frame]];
-    float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height;
-    float marginx = contentRect.size.width - viewRect.size.width;
-    proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy;
+    if( [[[VLCMain sharedInstance] controls] aspectRatioIsLocked] )
+    {
+        NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil];
+        NSRect contentRect = [self contentRectForFrameRect:[self frame]];
+        float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height;
+        float marginx = contentRect.size.width - viewRect.size.width;
+        proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy;
+    }
 
     return proposedFrameSize;
 }