From: Benjamin Pracht Date: Wed, 15 Dec 2004 12:28:39 +0000 (+0000) Subject: * Implements playlist toggle button X-Git-Tag: 0.8.2~1481 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c8044b72f56b32c06fa282c4d180755d5cbab422;p=vlc * Implements playlist toggle button * Resizing is currently animated. I don't know if we should keep it like that * I don't know if this is implemented the proper way, but at least it's working... --- diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib index c98b5d757a..dfcdc839b8 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib @@ -397,11 +397,13 @@ selectAll = id; sortNodeByAuthor = id; sortNodeByName = id; + toggleWindow = id; }; CLASS = VLCPlaylist; LANGUAGE = ObjC; OUTLETS = { "o_btn_playlist" = id; + "o_controller" = id; "o_ctx_menu" = id; "o_loop_popup" = id; "o_mi_delete" = id; diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib index cb8865df03..6af1c0e3a9 100644 --- a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib +++ b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib @@ -3,7 +3,7 @@ IBDocumentLocation - 230 -84 505 517 0 0 1024 746 + 172 -174 505 517 0 0 1024 746 IBEditorPositions 1617 @@ -27,7 +27,7 @@ IBOpenObjects 29 - 915 + 21 IBSystem Version 7R28 diff --git a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib index 49cd0d9a39..86ea5cd798 100644 Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib differ diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h index 1434533f6a..fa8a70509d 100644 --- a/modules/gui/macosx/misc.h +++ b/modules/gui/macosx/misc.h @@ -27,8 +27,11 @@ @interface VLCControllerWindow : NSWindow { + NSSize o_size_with_playlist; } +- (NSSize)getSizeWithPlaylist; + @end /***************************************************************************** diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m index 7bcfbc4125..946495b0e0 100644 --- a/modules/gui/macosx/misc.m +++ b/modules/gui/macosx/misc.m @@ -39,6 +39,10 @@ self = [super initWithContentRect:contentRect styleMask:styleMask //& ~NSTitledWindowMask backing:backingType defer:flag]; + o_size_with_playlist = [self frame].size; + + [[[VLCMain sharedInstance] getPlaylist] updateTogglePlaylistState]; + return( self ); } @@ -47,6 +51,24 @@ return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event]; } +/*Stores the size the controller one resize, to be able to restore it when + toggling the playlist*/ + +- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize +{ + o_size_with_playlist = proposedFrameSize; + + /*Callback to update the state of Playlist Toggle Button*/ + [[[VLCMain sharedInstance] getPlaylist] updateTogglePlaylistState]; + + return proposedFrameSize; +} + +- (NSSize)getSizeWithPlaylist +{ + return o_size_with_playlist; +} + @end diff --git a/modules/gui/macosx/playlist.h b/modules/gui/macosx/playlist.h index fdb57545ca..0f56d6edc8 100644 --- a/modules/gui/macosx/playlist.h +++ b/modules/gui/macosx/playlist.h @@ -36,6 +36,8 @@ *****************************************************************************/ @interface VLCPlaylist : NSObject { + IBOutlet id o_controller; + IBOutlet id o_btn_playlist; IBOutlet id o_outline_view; IBOutlet id o_tc_name; @@ -71,6 +73,7 @@ - (void)initStrings; - (NSMenu *)menuForEvent:(NSEvent *)o_event; +- (void)updateTogglePlaylistState; - (void)playlistUpdated; - (void)sortNode:(int)i_mode; diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m index 904cd9d79f..95a84a98e9 100644 --- a/modules/gui/macosx/playlist.m +++ b/modules/gui/macosx/playlist.m @@ -50,6 +50,10 @@ #include "playlist.h" #include "controls.h" #include "osd.h" +#include "misc.h" + +#define REF_HEIGHT 500 +#define REF_WIDTH 500 /***************************************************************************** * VLCPlaylistView implementation @@ -167,6 +171,64 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ [[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")]; } +- (IBAction)toggleWindow:(id)sender +{ + NSRect o_rect; + /*First, check if the playlist is visible*/ + if ( [o_controller frame].size.height == [o_controller minSize].height ) + { + /*Check if the stored heigth of the controller is usable (!= minSize)*/ + if ([o_controller getSizeWithPlaylist].height != + [o_controller minSize].height) + { + o_rect.size.height = [o_controller getSizeWithPlaylist].height; + } + else + { + /*If the stored height is not usable, use a reference one*/ + o_rect.size.height = REF_HEIGHT; + } + + /*Check if the controller width is the minimum one*/ + if ( [o_controller frame].size.width == [o_controller minSize].width) + { + /*If the controller width is minimum, check if the stored height + of the playlist makes it visible*/ + if ([o_controller getSizeWithPlaylist].height != + [o_controller minSize].height) + { + o_rect.size.width = [o_controller getSizeWithPlaylist].width; + } + else + { + /*If not, use a reference width*/ + o_rect.size.width = REF_WIDTH; + } + } + else + { + o_rect.size.width = [o_controller frame].size.width; + } + o_rect.origin.x = [o_controller frame].origin.x; + o_rect.origin.y = [o_controller frame].origin.y - o_rect.size.height + + [o_controller minSize].height; + + [o_btn_playlist setState: YES]; + } + else + { + o_rect.size = [o_controller minSize]; + o_rect.origin.x = [o_controller frame].origin.x; + /*Calculate the position of the lower right corner after resize*/ + o_rect.origin.y = [o_controller frame].origin.y + + [o_controller frame].size.height - [o_controller minSize].height; + + [o_btn_playlist setState: NO]; + } + + [o_controller setFrame: o_rect display:YES animate: YES]; +} + - (void)playlistUpdated { unsigned int i; @@ -184,6 +246,19 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ [o_outline_view reloadData]; } +- (void)updateTogglePlaylistState +{ + if ([o_controller getSizeWithPlaylist].height == + [o_controller minSize].height) + { + [o_btn_playlist setState: NO]; + } + else + { + [o_btn_playlist setState: YES]; + } +} + - (bool)isItem:(playlist_item_t *)p_item inNode:(playlist_item_t *)p_node { playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, @@ -917,11 +992,11 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ } /* Delegate method of NSWindow */ -- (void)windowWillClose:(NSNotification *)aNotification +/*- (void)windowWillClose:(NSNotification *)aNotification { [o_btn_playlist setState: NSOffState]; } - +*/ @end