[vlc-devel] commit: macosx: added an entry to Video-> Aspect-ratio to disable our AR-lock for one session. ( Felix Paul Kühne )

git version control git at videolan.org
Fri May 22 19:46:30 CEST 2009


vlc | branch: 1.0-bugfix | Felix Paul Kühne <fkuehne at videolan.org> | Fri May 22 19:46:13 2009 +0200| [2d63b67e97034199cbf8979bf714d3c8536af240] | committer: Felix Paul Kühne 

macosx: added an entry to Video->Aspect-ratio to disable our AR-lock for one session.

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d63b67e97034199cbf8979bf714d3c8536af240
---

 modules/gui/macosx/controls.h       |    3 +++
 modules/gui/macosx/controls.m       |   29 ++++++++++++++++++++++++++++-
 modules/gui/macosx/embeddedwindow.m |   13 ++++++++-----
 3 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/modules/gui/macosx/controls.h b/modules/gui/macosx/controls.h
index bd123bd..3708813 100644
--- a/modules/gui/macosx/controls.h
+++ b/modules/gui/macosx/controls.h
@@ -53,10 +53,12 @@
     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;
diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m
index 084c7f1..8b864e6 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -74,6 +74,7 @@
 {
     [super init];
     o_fs_panel = [[VLCFSPanel alloc] init];
+    b_lockAspectRatio = YES;
     return self;
 }
 
@@ -180,6 +181,11 @@
     return [[voutView retain] autorelease];
 }
 
+- (BOOL)aspectRatioIsLocked
+{
+    return b_lockAspectRatio;
+}
+
 - (IBAction)stop:(id)sender
 {
     intf_thread_t * p_intf = VLCIntf;
@@ -559,6 +565,16 @@
     }
 }
 
+- (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;
@@ -591,7 +607,6 @@
             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++;
         }
     }
 }
@@ -791,6 +806,18 @@
     /* 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 )
     {
diff --git a/modules/gui/macosx/embeddedwindow.m b/modules/gui/macosx/embeddedwindow.m
index b59ccf9..9409690 100644
--- a/modules/gui/macosx/embeddedwindow.m
+++ b/modules/gui/macosx/embeddedwindow.m
@@ -198,11 +198,14 @@
     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;
 }




More information about the vlc-devel mailing list