Commit c8044b72 authored by Benjamin Pracht's avatar Benjamin Pracht

* 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...
parent f991b085
......@@ -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;
......
......@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>230 -84 505 517 0 0 1024 746 </string>
<string>172 -174 505 517 0 0 1024 746 </string>
<key>IBEditorPositions</key>
<dict>
<key>1617</key>
......@@ -27,7 +27,7 @@
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
<integer>915</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>7R28</string>
......
......@@ -27,8 +27,11 @@
@interface VLCControllerWindow : NSWindow
{
NSSize o_size_with_playlist;
}
- (NSSize)getSizeWithPlaylist;
@end
/*****************************************************************************
......
......@@ -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
......
......@@ -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;
......
......@@ -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
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