Commit d34e5434 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/VLC_app: Nicely slide in/out the playlist.

parent 30ee7100
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
/* Split view that supports slider animation */ /* Split view that supports slider animation */
@interface VLCOneSplitView : NSSplitView @interface VLCOneSplitView : NSSplitView
{
BOOL fixedCursorDuringResize;
}
@property (assign) BOOL fixedCursorDuringResize;
- (float)sliderPosition; - (float)sliderPosition;
- (void)setSliderPosition:(float)newPosition; - (void)setSliderPosition:(float)newPosition;
@end @end
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
/* Split view that supports slider animation */ /* Split view that supports slider animation */
@implementation VLCOneSplitView @implementation VLCOneSplitView
@synthesize fixedCursorDuringResize;
- (float)sliderPosition - (float)sliderPosition
{ {
return [[[self subviews] objectAtIndex:0] frame].size.height; return [[[self subviews] objectAtIndex:0] frame].size.height;
...@@ -100,5 +101,25 @@ ...@@ -100,5 +101,25 @@
} }
return [super defaultAnimationForKey: key]; return [super defaultAnimationForKey: key];
} }
- (void)adjustSubviews
{
if( !fixedCursorDuringResize )
{
[super adjustSubviews];
return;
}
NSRect frame0 = [[[self subviews] objectAtIndex:0] frame];
NSRect frame1 = [[[self subviews] objectAtIndex:1] frame];
frame1.size.height = [self bounds].size.height - frame0.size.height - [self dividerThickness];
if( frame1.size.height < 0. )
{
float delta = -frame1.size.height;
frame1.size.height = 0.;
frame0.size.height -= delta;
frame1.origin.y = frame0.size.height + [self dividerThickness];
[[[self subviews] objectAtIndex:1] setFrame: frame0];
}
[[[self subviews] objectAtIndex:1] setFrame: frame1];
}
@end @end
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
#import "VLCBrowsableVideoView.h" #import "VLCBrowsableVideoView.h"
#import "VLCAppAdditions.h" #import "VLCAppAdditions.h"
@interface VLCMainWindow (NavigatorViewHidingShowing)
@property float contentHeight; /* animatable, keep the mainSplitView cursor at the same place, enabling playlist(navigator) togling */
@end
/****************************************************************************** /******************************************************************************
* VLCMainWindow (CategoriesListDelegate) * VLCMainWindow (CategoriesListDelegate)
*/ */
...@@ -280,28 +284,26 @@ ...@@ -280,28 +284,26 @@
if(visible) if(visible)
{ {
if( !navigatorHeight ) navigatorHeight = 100.f; /* Show the navigator view (playlist view) */
if( navigatorHeight < 100.f ) navigatorHeight = 100.f;
if( ![self videoViewVisible] && ![self navigatorViewVisible] ) if( ![self videoViewVisible] && ![self navigatorViewVisible] )
{ {
/* Nothing is visible, only our toolbar */
NSRect frame = [self frame]; NSRect frame = [self frame];
frame.origin.y -= navigatorHeight; frame.origin.y += navigatorHeight;
frame.size.height += navigatorHeight; frame.size.height += navigatorHeight;
[[self animator] setFrame:frame display:YES]; [[self animator] setFrame:frame display:YES];
} }
else else
[[mainSplitView animator] setSliderPosition:([mainSplitView bounds].size.height - navigatorHeight - [mainSplitView dividerThickness])]; [[self animator] setContentHeight:[mainSplitView bounds].size.height + navigatorHeight + [mainSplitView dividerThickness]];
/* Hack, because sliding cause some glitches */ /* Hack, because sliding cause some glitches */
[navigatorView moveSubviewsToVisible]; [navigatorView moveSubviewsToVisible];
} }
else else
{ {
/* Hide the navigator view (playlist view) */
navigatorHeight = [navigatorView bounds].size.height; navigatorHeight = [navigatorView bounds].size.height;
NSRect frame0 = [self frame]; [[self animator] setContentHeight:[mainSplitView bounds].size.height - navigatorHeight + [mainSplitView dividerThickness]];
NSRect frame1 = [[[mainSplitView subviews] objectAtIndex: 1] frame];
frame0.size.height -= frame1.size.height;
frame0.origin.y += frame1.size.height;
frame1.size.height = 0;
[[mainSplitView animator] setSliderPosition:([mainSplitView bounds].size.height)];
/* Hack, because sliding cause some glitches */ /* Hack, because sliding cause some glitches */
[navigatorView moveSubviewsToVisible]; [navigatorView moveSubviewsToVisible];
} }
...@@ -355,6 +357,36 @@ ...@@ -355,6 +357,36 @@
} }
@end @end
@implementation VLCMainWindow (NavigatorViewHidingShowing)
- (float)contentHeight
{
return [self contentRectForFrameRect:[self frame]].size.height;
}
- (void)setContentHeight:(float)height
{
/* Set the Height while keeping the mainSplitView at his current position */
[mainSplitView setFixedCursorDuringResize:YES];
NSRect contentRect = [self contentRectForFrameRect:[self frame]];
float delta = height - contentRect.size.height;
contentRect.size.height = height;
NSRect windowFrame = [self frameRectForContentRect:contentRect];
windowFrame.origin.y -= delta;
windowFrame = [self constrainFrameRect:windowFrame toScreen:[self screen]];
[self setFrame:windowFrame display:YES];
[mainSplitView setFixedCursorDuringResize:NO];
}
+ (id)defaultAnimationForKey:(NSString *)key
{
if([key isEqualToString:@"contentHeight"])
{
return [CABasicAnimation animation];
}
return [super defaultAnimationForKey: key];
}
@end
@implementation VLCMainWindow (NSToolbarDelegating) @implementation VLCMainWindow (NSToolbarDelegating)
/* Our item identifiers */ /* Our item identifiers */
static NSString * VLCToolbarMediaControl = @"VLCToolbarMediaControl"; static NSString * VLCToolbarMediaControl = @"VLCToolbarMediaControl";
......
...@@ -596,6 +596,7 @@ ...@@ -596,6 +596,7 @@
C01FCF4F08A954540054247B /* Debug */ = { C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(NATIVE_ARCH_32_BIT)";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO; PREBINDING = NO;
...@@ -605,6 +606,7 @@ ...@@ -605,6 +606,7 @@
C01FCF5008A954540054247B /* Release */ = { C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(NATIVE_ARCH_32_BIT)";
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO; PREBINDING = NO;
......
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