[vlc-devel] Proposal + patch (for MacOSX) to give the User back control over the playback window size
philipp
videolan.org at biermann.org
Fri May 22 12:18:29 CEST 2009
Since 0.9, the Window of the embedded player is locked to the aspect
of the movie. Helpful to stop black borders. Makes window resizing
easier.
This is ok, as long as the aspect is ok, or, if you watch fullscreen.
But, If the aspect is wrong, and you correct it with the acpect-ratio
menu, you get black borders - which normally nobody will like.
In 0.8.6 (and before) you could adjust the window, so that no black
borders are visible.
in 0.9 and 1.0 this option is disabled, the Canvas aspect will stay at
the original aspect ratio.
Even worse, when you decide to use the crop filter, it will render its
useless ( the video might be clipped, but the black bars stay).
I made a patch, which defaults to lock the canvas aspect (current
behaviour), but, you can unlock it with a toggle in the aspect ratio
menu.
This is a useful addition, and, if you look in the videolan forum,
there are some complains already written by users.
I even think, not only mac Users will enjoy the revival of this good
previous feature, but the way I implemented it, it must be done for
each platform differently.
Philipp
patch_canvas-resize.diff:
diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/
controls.m
index 084c7f1..ef7dfcd 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -37,6 +37,7 @@
#import "open.h"
#import "controls.h"
#import "playlist.h"
+
#include <vlc_osd.h>
#include <vlc_keys.h>
@@ -559,6 +560,18 @@
}
}
+
+- (IBAction)CanvasLock:(id)sender
+{
+
+ id o_vout_view = [self voutView];
+ if( o_vout_view )
+ {
+ [o_vout_view VoutlockCanvasRatio];
+ }
+}
+
+
- (IBAction)addSubtitleFile:(id)sender
{
NSInteger i_returnValue = 0;
@@ -791,6 +804,20 @@
/* make (un)sensitive */
[o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
+
+ /* case Aspect Ratio */
+ if( [[o_parent title] isEqualToString: _NS("Aspect-ratio")] ==
YES )
+ {
+
+ NSMenuItem * o_lmi_tmp1;
+ o_lmi_tmp1 = [o_menu addItemWithTitle: _NS("toggle Canvas resize
lock") action: @selector(CanvasLock:) keyEquivalent: @""];
+ [o_lmi_tmp1 setTarget: self];
+ [o_lmi_tmp1 setEnabled: YES];
+ [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.h b/modules/gui/macosx/
embeddedwindow.h
index ead8618..c5c5e3b 100644
--- a/modules/gui/macosx/embeddedwindow.h
+++ b/modules/gui/macosx/embeddedwindow.h
@@ -54,6 +54,7 @@
NSSize videoRatio;
int originalLevel;
+ int keepCanvasAspect;
}
- (void)controlTintChanged;
@@ -62,15 +63,13 @@
- (void)playStatusUpdated: (int)i_status;
- (void)setSeekable: (BOOL)b_seekable;
-- (void)setVideoRatio:(NSSize)ratio;
-
+- (void) resizeWithAspect: (int) flag;
- (NSView *)mainView;
- (BOOL)isFullscreen;
-
+- (void)setVideoRatio:(NSSize)ratio;
- (void)lockFullscreenAnimation;
- (void)unlockFullscreenAnimation;
-
- (void)enterFullscreen;
- (void)leaveFullscreen;
/* Allows to leave fullscreen by simply fading out the display */
diff --git a/modules/gui/macosx/embeddedwindow.m b/modules/gui/macosx/
embeddedwindow.m
index adcec67..dbc4be7 100644
--- a/modules/gui/macosx/embeddedwindow.m
+++ b/modules/gui/macosx/embeddedwindow.m
@@ -73,6 +73,7 @@
object: nil];
/* Useful to save o_view frame in fullscreen mode */
+ keepCanvasAspect = 1;
o_temp_view = [[NSView alloc] init];
[o_temp_view setAutoresizingMask:NSViewHeightSizable |
NSViewWidthSizable];
@@ -190,17 +191,40 @@
videoRatio = ratio;
}
+
+- (void) resizeWithAspect: (int) flag
+{
+ switch (flag)
+ {
+ case -1: keepCanvasAspect = 0;
+ break;
+ case 1: keepCanvasAspect = 1;
+ break;
+ case 0:
+ if (keepCanvasAspect)
+ keepCanvasAspect = 0;
+ else
+ keepCanvasAspect = 1;
+ break;
+ default:
+ break;
+ }
+
+}
+
+
- (NSSize)windowWillResize:(NSWindow *)window toSize:
(NSSize)proposedFrameSize
{
if( videoRatio.height == 0. || videoRatio.width == 0. )
return proposedFrameSize;
+if (keepCanvasAspect ) {
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;
}
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index d411dc0..9d4daf6 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1830,7 +1830,6 @@ end:
[o_controls setupVarMenuItem: o_mi_aspect_ratio target:
(vlc_object_t *)p_vout
var: "aspect-ratio" selector: @selector(toggleVar:)];
-
[o_controls setupVarMenuItem: o_mi_crop target:
(vlc_object_t *) p_vout
var: "crop" selector: @selector(toggleVar:)];
diff --git a/modules/gui/macosx/vout.h b/modules/gui/macosx/vout.h
index 6b57f7a..fb783e7 100644
--- a/modules/gui/macosx/vout.h
+++ b/modules/gui/macosx/vout.h
@@ -105,6 +105,7 @@
- (void)setUsed: (BOOL)b_new_used;
- (BOOL)isUsed;
+- (void)VoutlockCanvasRatio;
@end
diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m
index 224ed25..87f8f8a 100644
--- a/modules/gui/macosx/vout.m
+++ b/modules/gui/macosx/vout.m
@@ -367,7 +367,6 @@ int DeviceCallback( vlc_object_t *p_this, const
char *psz_variable,
newsize.width = (int) ( p_vout->render.i_width * factor );
newsize.height = (int) ( i_corrected_height * factor );
}
-
return newsize;
}
@@ -894,6 +893,9 @@ int DeviceCallback( vlc_object_t *p_this, const
char *psz_variable,
[super scaleWindowWithFactor: factor animate: animate];
[o_window setMovableByWindowBackground: YES];
}
+
+
+
@end
/
*****************************************************************************
@@ -923,6 +925,14 @@ int DeviceCallback( vlc_object_t *p_this, const
char *psz_variable,
return self;
}
+
+- (void)VoutlockCanvasRatio
+{
+ [o_embeddedwindow resizeWithAspect : 0];
+
+}
+
+
- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
frame: (NSRect *)s_arg_frame
{
@@ -964,7 +974,6 @@ int DeviceCallback( vlc_object_t *p_this, const
char *psz_variable,
[o_window makeKeyAndOrderFront: self];
[self scaleWindowWithFactor: 1.0 animate: [o_window
isVisible] && (![o_window isFullscreen])];
-
[o_embeddedwindow setVideoRatio:[self voutSizeForFactor:1.0]];
/* Make sure our window is visible, if we are not in
fullscreen */
More information about the vlc-devel
mailing list