Commit 2d63b67e authored by Felix Paul Kühne's avatar 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.
parent d7c3f5b6
...@@ -53,10 +53,12 @@ ...@@ -53,10 +53,12 @@
IBOutlet id o_specificTime_mi; IBOutlet id o_specificTime_mi;
VLCFSPanel *o_fs_panel; VLCFSPanel *o_fs_panel;
BOOL b_lockAspectRatio;
} }
- (void)controlTintChanged; - (void)controlTintChanged;
- (id)voutView; - (id)voutView;
- (BOOL)aspectRatioIsLocked;
- (IBAction)play:(id)sender; - (IBAction)play:(id)sender;
- (IBAction)stop:(id)sender; - (IBAction)stop:(id)sender;
...@@ -91,6 +93,7 @@ ...@@ -91,6 +93,7 @@
- (IBAction)telxTransparent:(id)sender; - (IBAction)telxTransparent:(id)sender;
- (IBAction)telxNavLink:(id)sender; - (IBAction)telxNavLink:(id)sender;
- (IBAction)lockVideosAspectRatio:(id)sender;
- (IBAction)addSubtitleFile:(id)sender; - (IBAction)addSubtitleFile:(id)sender;
- (BOOL)keyEvent:(NSEvent *)o_event; - (BOOL)keyEvent:(NSEvent *)o_event;
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
{ {
[super init]; [super init];
o_fs_panel = [[VLCFSPanel alloc] init]; o_fs_panel = [[VLCFSPanel alloc] init];
b_lockAspectRatio = YES;
return self; return self;
} }
...@@ -180,6 +181,11 @@ ...@@ -180,6 +181,11 @@
return [[voutView retain] autorelease]; return [[voutView retain] autorelease];
} }
- (BOOL)aspectRatioIsLocked
{
return b_lockAspectRatio;
}
- (IBAction)stop:(id)sender - (IBAction)stop:(id)sender
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
...@@ -559,6 +565,16 @@ ...@@ -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 - (IBAction)addSubtitleFile:(id)sender
{ {
NSInteger i_returnValue = 0; NSInteger i_returnValue = 0;
...@@ -591,7 +607,6 @@ ...@@ -591,7 +607,6 @@
if( input_AddSubtitle( p_input, [[[openPanel filenames] objectAtIndex: i] UTF8String], TRUE ) ) if( input_AddSubtitle( p_input, [[[openPanel filenames] objectAtIndex: i] UTF8String], TRUE ) )
msg_Warn( VLCIntf, "unable to load subtitles from '%s'", msg_Warn( VLCIntf, "unable to load subtitles from '%s'",
[[[openPanel filenames] objectAtIndex: i] UTF8String] ); [[[openPanel filenames] objectAtIndex: i] UTF8String] );
i++;
} }
} }
} }
...@@ -791,6 +806,18 @@ ...@@ -791,6 +806,18 @@
/* make (un)sensitive */ /* make (un)sensitive */
[o_parent setEnabled: ( val_list.p_list->i_count > 1 )]; [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 */ /* special case for the subtitles items */
if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES ) if( [[o_parent title] isEqualToString: _NS("Subtitles Track")] == YES )
{ {
......
...@@ -198,11 +198,14 @@ ...@@ -198,11 +198,14 @@
if( videoRatio.height == 0. || videoRatio.width == 0. ) if( videoRatio.height == 0. || videoRatio.width == 0. )
return proposedFrameSize; return proposedFrameSize;
if( [[[VLCMain sharedInstance] controls] aspectRatioIsLocked] )
{
NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil]; NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil];
NSRect contentRect = [self contentRectForFrameRect:[self frame]]; NSRect contentRect = [self contentRectForFrameRect:[self frame]];
float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height; float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height;
float marginx = contentRect.size.width - viewRect.size.width; float marginx = contentRect.size.width - viewRect.size.width;
proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy; proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy;
}
return proposedFrameSize; return proposedFrameSize;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment