]> git.sesse.net Git - vlc/commitdiff
* Implements playlist toggle button
authorBenjamin Pracht <bigben@videolan.org>
Wed, 15 Dec 2004 12:28:39 +0000 (12:28 +0000)
committerBenjamin Pracht <bigben@videolan.org>
Wed, 15 Dec 2004 12:28:39 +0000 (12:28 +0000)
* 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...

extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib
modules/gui/macosx/misc.h
modules/gui/macosx/misc.m
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index c98b5d757ad5d9530915743ab9e236c675665bb6..dfcdc839b8858d8cb51f1eb28d2109cd743a49f3 100644 (file)
                 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; 
index cb8865df03981f23c1908163c367c9a804880162..6af1c0e3a99e8a15f71f76d1b1e6d767959ca09f 100644 (file)
@@ -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>
index 49cd0d9a39fb6c61a6f3f8ca2a8837d4dba9687f..86ea5cd798acbfcf36d67aa5c677742c6afe30ad 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib differ
index 1434533f6a2917a0f9cf51aca1fbc8f9e8495698..fa8a70509dd9ecbf6c00441667a2ead1237a4cae 100644 (file)
 
 @interface VLCControllerWindow : NSWindow
 {
+    NSSize o_size_with_playlist;
 }
 
+- (NSSize)getSizeWithPlaylist;
+
 @end
 
 /*****************************************************************************
index 7bcfbc4125ecfb9b9163a0f47a908fcffd92c0fe..946495b0e009cfed866a84b57c6d77ec91f146f9 100644 (file)
     self = [super initWithContentRect:contentRect styleMask:styleMask //& ~NSTitledWindowMask
     backing:backingType defer:flag];
 
+    o_size_with_playlist = [self frame].size;
+
+    [[[VLCMain sharedInstance] getPlaylist] updateTogglePlaylistState];
+
     return( self );
 }
 
     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
 
 
index fdb57545ca9a61f223e3bee99302445e94a1e254..0f56d6edc81e8f59aad60e8b6b2bb20e4872769c 100644 (file)
@@ -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;
 
index 904cd9d79f1919ef532035ebc65162ad2bf1b64a..95a84a98e9cf33d8debdab6f09c078970cc4a28e 100644 (file)
 #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