Commit 7c07687a authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Finally fixed the issue with resizing the controller and the broken playlist...

* Finally fixed the issue with resizing the controller and the broken playlist view that was the result of this resize. Estimated 60 hours spent to work around a stupid autoresize bug in the AppKit of Cocoa.
parent 214f206d
......@@ -112,6 +112,7 @@
openWebsite = id;
reportABug = id;
timesliderUpdate = id;
togglePlaylist = id;
viewAbout = id;
viewPreferences = id;
};
......@@ -122,10 +123,10 @@
"o_btn_fullscreen" = id;
"o_btn_next" = id;
"o_btn_play" = id;
"o_btn_playlist" = id;
"o_btn_prev" = id;
"o_btn_rewind" = id;
"o_btn_stop" = id;
"o_clip_view" = id;
"o_controls" = id;
"o_dmi_mute" = id;
"o_dmi_next" = id;
......@@ -229,6 +230,7 @@
"o_mu_visual" = id;
"o_mu_window" = id;
"o_playlist" = id;
"o_playlist_view" = id;
"o_scrollfield" = id;
"o_timefield" = id;
"o_timeslider" = id;
......@@ -248,12 +250,10 @@
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;
......@@ -267,6 +267,7 @@
"o_mi_sort_name" = id;
"o_mu_services" = id;
"o_outline_view" = id;
"o_playlist_view" = id;
"o_random_ckb" = id;
"o_search_field" = id;
"o_status_field" = id;
......
......@@ -3,13 +3,13 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>16 61 505 517 0 0 800 578 </string>
<string>78 314 505 517 0 0 1280 938 </string>
<key>IBEditorPositions</key>
<dict>
<key>1617</key>
<string>542 480 104 149 0 0 1024 746 </string>
<key>2197</key>
<string>195 211 596 367 0 0 1280 938 </string>
<string>342 573 596 143 0 0 1280 938 </string>
<key>29</key>
<string>132 749 419 44 0 0 1280 938 </string>
<key>915</key>
......@@ -18,12 +18,13 @@
<key>IBFramework Version</key>
<string>364.0</string>
<key>IBLockedObjects</key>
<array/>
<key>IBOpenObjects</key>
<array>
<integer>2203</integer>
<integer>2208</integer>
<integer>2206</integer>
<integer>2197</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>7S215</string>
<string>7U16</string>
</dict>
</plist>
/*****************************************************************************
* intf.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2004 VideoLAN
* Copyright (C) 2002-2005 VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -87,7 +87,7 @@ struct intf_sys_t
BOOL nib_open_loaded; /* reference to the open-nib */
IBOutlet id o_window; /* main window */
IBOutlet id o_clip_view; /* playlist clipview */
IBOutlet id o_playlist_view;/* playlist view */
IBOutlet id o_scrollfield; /* info field */
IBOutlet id o_timefield; /* time field */
IBOutlet id o_timeslider; /* time slider */
......@@ -102,6 +102,7 @@ struct intf_sys_t
IBOutlet id o_btn_ff; /* btn fast forward */
IBOutlet id o_btn_next; /* btn next */
IBOutlet id o_btn_fullscreen;/* btn fullscreen */
IBOutlet id o_btn_playlist; /* btn playlist */
NSImage * o_img_play; /* btn play img */
NSImage * o_img_pause; /* btn pause img */
......@@ -234,9 +235,8 @@ struct intf_sys_t
IBOutlet id o_dmi_previous;
IBOutlet id o_dmi_mute;
/* stupid outline views .... */
NSRect rect_remember;
NSView *o_document_view;
bool b_small_window;
}
+ (VLCMain *)sharedInstance;
......@@ -283,6 +283,9 @@ struct intf_sys_t
- (IBAction)openLicense:(id)sender;
- (IBAction)openCrashLog:(id)sender;
- (IBAction)togglePlaylist:(id)sender;
- (void)updateTogglePlaylistState;
- (void)windowDidBecomeKey:(NSNotification *)o_notification;
@end
......
/*****************************************************************************
* intf.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2004 VideoLAN
* Copyright (C) 2002-2005 VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -378,6 +378,22 @@ static VLCMain *_o_sharedMainInstance = nil;
[self setSubmenusEnabled: FALSE];
[self manageVolumeSlider];
[o_window setDelegate: self];
if( [o_window frame].size.height <= 200 )
{
b_small_window = YES;
[o_window setFrame: NSMakeRect( [o_window frame].origin.x, [o_window frame].origin.y, [o_window frame].size.width, 95 ) display: YES animate:YES];
[o_playlist_view setAutoresizesSubviews: NO];
}
else
{
b_small_window = NO;
[o_playlist_view setFrame: NSMakeRect( 10, 10, [o_window frame].size.width - 20, [o_window frame].size.height - 105 )];
[o_playlist_view setNeedsDisplay:YES];
[o_playlist_view setAutoresizesSubviews: YES];
[[o_window contentView] addSubview: o_playlist_view];
}
[self updateTogglePlaylistState];
p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
......@@ -413,6 +429,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_btn_fullscreen setToolTip: _NS("Fullscreen")];
[o_volumeslider setToolTip: _NS("Volume")];
[o_timeslider setToolTip: _NS("Position")];
[o_btn_playlist setToolTip: _NS("Playlist")];
/* messages panel */
[o_msgs_panel setTitle: _NS("Messages")];
......@@ -1438,31 +1455,80 @@ static VLCMain *_o_sharedMainInstance = nil;
}
}
- (IBAction)togglePlaylist:(id)sender
{
NSRect o_rect = [o_window frame];
/*First, check if the playlist is visible*/
if( o_rect.size.height <= 200 )
{
b_small_window = YES; /* we know we are small, make sure this is actually set (see case below) */
/* make large */
o_rect.size.height = 500;
o_rect.origin.x = [o_window frame].origin.x;
o_rect.origin.y = [o_window frame].origin.y - o_rect.size.height +
[o_window minSize].height;
[o_btn_playlist setState: YES];
}
else
{
/* make small */
o_rect.size.height = 95;
o_rect.origin.x = [o_window frame].origin.x;
/* Calculate the position of the lower right corner after resize */
o_rect.origin.y = [o_window frame].origin.y +
[o_window frame].size.height - [o_window minSize].height;
[o_playlist_view setAutoresizesSubviews: NO];
[o_playlist_view removeFromSuperview];
[o_btn_playlist setState: NO];
b_small_window = NO; /* we aren't small here just yet. we are doing an animated resize after this */
}
[o_window setFrame: o_rect display:YES animate: YES];
}
- (void)updateTogglePlaylistState
{
if( [o_window frame].size.height <= 200 )
{
[o_btn_playlist setState: NO];
}
else
{
[o_btn_playlist setState: YES];
}
}
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize
{
/* Not triggered on a window resize or maxification of the window. only by window mouse dragging resize */
if( proposedFrameSize.height <= 200 )
{
if( [sender frame].size.height > 200 )
if( b_small_window == NO )
{
//rect_remember = [[o_playlist playlistView] frame];
o_document_view = [o_clip_view documentView];
[o_document_view retain];
[o_clip_view setDocumentView: NULL];
/* if large and going to small then hide */
b_small_window = YES;
[o_playlist_view setAutoresizesSubviews: NO];
[o_playlist_view removeFromSuperview];
}
return NSMakeSize( proposedFrameSize.width, 95 );
}
else
return proposedFrameSize;
}
- (void)windowDidResize:(NSNotification *)notif
{
if( [o_window frame].size.height > 200 && b_small_window )
{
if( [sender frame].size.height <= 200 )
{
[o_clip_view setDocumentView: o_document_view];
[o_document_view release];
[o_document_view setFrameSize: NSMakeSize( proposedFrameSize.width - 22, proposedFrameSize.height - 120 )];
//[[o_playlist playlistView] setFrame: rect_remember];
}
return proposedFrameSize;
/* If large and coming from small then show */
[o_playlist_view setAutoresizesSubviews: YES];
[o_playlist_view setFrame: NSMakeRect( 10, 10, [o_window frame].size.width - 20, [o_window frame].size.height - 95 - 10 )];
[o_playlist_view setNeedsDisplay:YES];
[[o_window contentView] addSubview: o_playlist_view];
b_small_window = NO;
}
return proposedFrameSize;
[self updateTogglePlaylistState];
}
@end
......
/*****************************************************************************
* misc.m: code not specific to vlc
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* Copyright (C) 2003-2005 VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -41,7 +41,7 @@
o_size_with_playlist = [self frame].size;
[[[VLCMain sharedInstance] getPlaylist] updateTogglePlaylistState];
[[VLCMain sharedInstance] updateTogglePlaylistState];
return( self );
}
......@@ -59,7 +59,7 @@
o_size_with_playlist = proposedFrameSize;
/*Callback to update the state of Playlist Toggle Button*/
[[[VLCMain sharedInstance] getPlaylist] updateTogglePlaylistState];
[[VLCMain sharedInstance] updateTogglePlaylistState];
return proposedFrameSize;
}
......
/*****************************************************************************
* playlist.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2004 VideoLAN
* Copyright (C) 2002-2005 VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -39,6 +39,7 @@
IBOutlet id o_controller;
IBOutlet id o_btn_playlist;
IBOutlet id o_playlist_view;
IBOutlet id o_outline_view;
IBOutlet id o_tc_name;
IBOutlet id o_tc_author;
......@@ -73,12 +74,11 @@
- (void)initStrings;
- (NSMenu *)menuForEvent:(NSEvent *)o_event;
- (NSOutlineView *)playlistView;
- (NSOutlineView *)outlineView;
- (IBAction)handlePopUp:(id)sender;
- (IBAction)searchItem:(id)sender;
- (void)updateTogglePlaylistState;
- (void)playlistUpdated;
- (void)sortNode:(int)i_mode;
- (void)updateRowSelection;
......
/*****************************************************************************
* playlist.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2004 VideoLAN
* Copyright (C) 2002-2005 VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -25,7 +25,6 @@
/* TODO
* add 'icons' for different types of nodes? (http://www.cocoadev.com/index.pl?IconAndTextInTableCell)
* create a new 'playlist toggle' that hides the playlist and in effect give you the old controller
* create a new search field build with pictures from the 'regular' search field, so it can be emulated on 10.2
* create toggle buttons for the shuffle, repeat one, repeat all functions.
* implement drag and drop and item reordering.
......@@ -51,9 +50,6 @@
#include "osd.h"
#include "misc.h"
#define REF_HEIGHT 500
#define REF_WIDTH 500
/*****************************************************************************
* VLCPlaylistView implementation
*****************************************************************************/
......@@ -199,75 +195,16 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
#if 0
[o_search_button setTitle: _NS("Search")];
#endif
[o_btn_playlist setToolTip: _NS("Playlist")];
[[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
[[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
[[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
}
- (NSOutlineView *)playlistView
- (NSOutlineView *)outlineView
{
return o_outline_view;
}
- (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;
......@@ -286,20 +223,6 @@ 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];
}
}
- (void)updateRowSelection
{
int i,i_row;
......
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