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 @@
/* Split view that supports slider animation */
@interface VLCOneSplitView : NSSplitView
{
BOOL fixedCursorDuringResize;
}
@property (assign) BOOL fixedCursorDuringResize;
- (float)sliderPosition;
- (void)setSliderPosition:(float)newPosition;
@end
\ No newline at end of file
@end
......@@ -84,6 +84,7 @@
/* Split view that supports slider animation */
@implementation VLCOneSplitView
@synthesize fixedCursorDuringResize;
- (float)sliderPosition
{
return [[[self subviews] objectAtIndex:0] frame].size.height;
......@@ -100,5 +101,25 @@
}
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
......@@ -28,6 +28,10 @@
#import "VLCBrowsableVideoView.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)
*/
......@@ -280,28 +284,26 @@
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] )
{
/* Nothing is visible, only our toolbar */
NSRect frame = [self frame];
frame.origin.y -= navigatorHeight;
frame.origin.y += navigatorHeight;
frame.size.height += navigatorHeight;
[[self animator] setFrame:frame display:YES];
}
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 */
[navigatorView moveSubviewsToVisible];
}
else
{
/* Hide the navigator view (playlist view) */
navigatorHeight = [navigatorView bounds].size.height;
NSRect frame0 = [self frame];
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)];
[[self animator] setContentHeight:[mainSplitView bounds].size.height - navigatorHeight + [mainSplitView dividerThickness]];
/* Hack, because sliding cause some glitches */
[navigatorView moveSubviewsToVisible];
}
......@@ -355,6 +357,36 @@
}
@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)
/* Our item identifiers */
static NSString * VLCToolbarMediaControl = @"VLCToolbarMediaControl";
......
......@@ -596,6 +596,7 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_32_BIT)";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
......@@ -605,6 +606,7 @@
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_32_BIT)";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
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