1 /*****************************************************************************
2 * MainWindow.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2012 VLC authors and VideoLAN
7 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
8 * Jon Lech Johansen <jon-vl@nanocrew.net>
9 * Christophe Massiot <massiot@via.ecp.fr>
10 * Derk-Jan Hartman <hartman at videolan.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #import "CompatibilityFixes.h"
28 #import "MainWindow.h"
30 #import "CoreInteraction.h"
31 #import "AudioEffects.h"
34 #import "controls.h" // TODO: remove me
36 #import "SideBarItem.h"
38 #import <vlc_playlist.h>
39 #import <vlc_aout_intf.h>
41 #import <vlc_strings.h>
42 #import <vlc_services_discovery.h>
43 #import <vlc_aout_intf.h>
45 #import "ControlsBar.h"
47 #import "VLCVoutWindowController.h"
50 @interface VLCMainWindow ()
51 - (void)resizePlaylistAfterCollapse;
52 - (void)makeSplitViewVisible;
53 - (void)makeSplitViewHidden;
58 @implementation VLCMainWindow
60 @synthesize fullscreen=b_fullscreen;
61 @synthesize nativeFullscreenMode=b_nativeFullscreenMode;
62 @synthesize nonembedded=b_nonembedded;
63 @synthesize fsPanel=o_fspanel;
65 static VLCMainWindow *_o_sharedInstance = nil;
67 + (VLCMainWindow *)sharedInstance
69 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
73 #pragma mark Initialization
77 if (_o_sharedInstance) {
79 return _o_sharedInstance;
81 _o_sharedInstance = [super init];
83 return _o_sharedInstance;
86 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
87 backing:(NSBackingStoreType)backingType defer:(BOOL)flag
89 self = [super initWithContentRect:contentRect styleMask:styleMask
90 backing:backingType defer:flag];
91 _o_sharedInstance = self;
93 [[VLCMain sharedInstance] updateTogglePlaylistState];
98 - (BOOL)isEvent:(NSEvent *)o_event forKey:(const char *)keyString
103 key = config_GetPsz(VLCIntf, keyString);
104 o_key = [NSString stringWithFormat:@"%s", key];
107 unsigned int i_keyModifiers = [[VLCStringUtility sharedInstance] VLCModifiersToCocoa:o_key];
109 NSString * characters = [o_event charactersIgnoringModifiers];
110 if ([characters length] > 0) {
111 return [[characters lowercaseString] isEqualToString: [[VLCStringUtility sharedInstance] VLCKeyToString: o_key]] &&
112 (i_keyModifiers & NSShiftKeyMask) == ([o_event modifierFlags] & NSShiftKeyMask) &&
113 (i_keyModifiers & NSControlKeyMask) == ([o_event modifierFlags] & NSControlKeyMask) &&
114 (i_keyModifiers & NSAlternateKeyMask) == ([o_event modifierFlags] & NSAlternateKeyMask) &&
115 (i_keyModifiers & NSCommandKeyMask) == ([o_event modifierFlags] & NSCommandKeyMask);
120 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
123 // these are key events which should be handled by vlc core, but are attached to a main menu item
124 if (![self isEvent: o_event forKey: "key-vol-up"] &&
125 ![self isEvent: o_event forKey: "key-vol-down"] &&
126 ![self isEvent: o_event forKey: "key-vol-mute"]) {
127 /* We indeed want to prioritize some Cocoa key equivalent against libvlc,
128 so we perform the menu equivalent now. */
129 if ([[NSApp mainMenu] performKeyEquivalent:o_event])
135 return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event force:b_force] ||
136 [(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event];
141 if (b_dark_interface)
142 [o_color_backdrop release];
144 [[NSNotificationCenter defaultCenter] removeObserver: self];
145 [o_sidebaritems release];
152 BOOL b_splitviewShouldBeHidden = NO;
154 /* setup the styled interface */
155 b_nativeFullscreenMode = NO;
156 #ifdef MAC_OS_X_VERSION_10_7
157 if (!OSX_SNOW_LEOPARD)
158 b_nativeFullscreenMode = var_InheritBool(VLCIntf, "macosx-nativefullscreenmode");
160 t_hide_mouse_timer = nil;
161 [self useOptimizedDrawing: YES];
163 [[o_search_fld cell] setPlaceholderString: _NS("Search")];
164 [[o_search_fld cell] accessibilitySetOverrideValue:_NS("Enter a term to search the playlist. Results will be selected in the table.") forAttribute:NSAccessibilityDescriptionAttribute];
166 [o_dropzone_btn setTitle: _NS("Open media...")];
167 [[o_dropzone_btn cell] accessibilitySetOverrideValue:_NS("Click to open an advanced dialog to select the media to play. You can also drop files here to play.") forAttribute:NSAccessibilityDescriptionAttribute];
168 [o_dropzone_lbl setStringValue: _NS("Drop media here")];
170 [o_podcast_add_btn setTitle: _NS("Subscribe")];
171 [o_podcast_remove_btn setTitle: _NS("Unsubscribe")];
172 [o_podcast_subscribe_title_lbl setStringValue: _NS("Subscribe to a podcast")];
173 [o_podcast_subscribe_subtitle_lbl setStringValue: _NS("Enter URL of the podcast to subscribe to:")];
174 [o_podcast_subscribe_cancel_btn setTitle: _NS("Cancel")];
175 [o_podcast_subscribe_ok_btn setTitle: _NS("Subscribe")];
176 [o_podcast_unsubscribe_title_lbl setStringValue: _NS("Unsubscribe from a podcast")];
177 [o_podcast_unsubscribe_subtitle_lbl setStringValue: _NS("Select the podcast you would like to unsubscribe from:")];
178 [o_podcast_unsubscribe_ok_btn setTitle: _NS("Unsubscribe")];
179 [o_podcast_unsubscribe_cancel_btn setTitle: _NS("Cancel")];
181 /* interface builder action */
182 float f_threshold_height = f_min_video_height + [[o_controls_bar bottomBarView] frame].size.height;
183 if (b_dark_interface)
184 f_threshold_height += [o_titlebar_view frame].size.height;
185 if ([[self contentView] frame].size.height < f_threshold_height)
186 b_splitviewShouldBeHidden = YES;
188 [self setDelegate: self];
189 [self setExcludedFromWindowsMenu: YES];
190 [self setAcceptsMouseMovedEvents: YES];
191 // Set that here as IB seems to be buggy
192 if (b_dark_interface) {
193 [self setContentMinSize:NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
195 [self setContentMinSize:NSMakeSize(604., 288.)];
198 [self setTitle: _NS("VLC media player")];
200 b_dropzone_active = YES;
201 [o_dropzone_view setFrame: [o_playlist_table frame]];
202 [o_left_split_view setFrame: [o_sidebar_view frame]];
204 if (b_nativeFullscreenMode) {
205 [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
207 [o_titlebar_view setFullscreenButtonHidden: YES];
210 if (!OSX_SNOW_LEOPARD) {
211 /* the default small size of the search field is slightly different on Lion, let's work-around that */
213 frame = [o_search_fld frame];
214 frame.origin.y = frame.origin.y + 2.0;
215 frame.size.height = frame.size.height - 1.0;
216 [o_search_fld setFrame: frame];
219 /* create the sidebar */
220 o_sidebaritems = [[NSMutableArray alloc] init];
221 SideBarItem *libraryItem = [SideBarItem itemWithTitle:_NS("LIBRARY") identifier:@"library"];
222 SideBarItem *playlistItem = [SideBarItem itemWithTitle:_NS("Playlist") identifier:@"playlist"];
223 [playlistItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
224 SideBarItem *medialibraryItem = [SideBarItem itemWithTitle:_NS("Media Library") identifier:@"medialibrary"];
225 [medialibraryItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
226 SideBarItem *mycompItem = [SideBarItem itemWithTitle:_NS("MY COMPUTER") identifier:@"mycomputer"];
227 SideBarItem *devicesItem = [SideBarItem itemWithTitle:_NS("DEVICES") identifier:@"devices"];
228 SideBarItem *lanItem = [SideBarItem itemWithTitle:_NS("LOCAL NETWORK") identifier:@"localnetwork"];
229 SideBarItem *internetItem = [SideBarItem itemWithTitle:_NS("INTERNET") identifier:@"internet"];
231 /* SD subnodes, inspired by the Qt4 intf */
232 char **ppsz_longnames;
234 char **ppsz_names = vlc_sd_GetNames(pl_Get(VLCIntf), &ppsz_longnames, &p_categories);
236 msg_Err(VLCIntf, "no sd item found"); //TODO
237 char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
238 int *p_category = p_categories;
239 NSMutableArray *internetItems = [[NSMutableArray alloc] init];
240 NSMutableArray *devicesItems = [[NSMutableArray alloc] init];
241 NSMutableArray *lanItems = [[NSMutableArray alloc] init];
242 NSMutableArray *mycompItems = [[NSMutableArray alloc] init];
243 NSString *o_identifier;
244 for (; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++) {
245 o_identifier = [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding];
246 switch (*p_category) {
247 case SD_CAT_INTERNET:
248 [internetItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
249 if (!strncmp(*ppsz_name, "podcast", 7))
250 [[internetItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-podcast"]];
252 [[internetItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
253 [[internetItems lastObject] setSdtype: SD_CAT_INTERNET];
254 [[internetItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
257 [devicesItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
258 [[devicesItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
259 [[devicesItems lastObject] setSdtype: SD_CAT_DEVICES];
260 [[devicesItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
263 [lanItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
264 [[lanItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-local"]];
265 [[lanItems lastObject] setSdtype: SD_CAT_LAN];
266 [[lanItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
268 case SD_CAT_MYCOMPUTER:
269 [mycompItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
270 if (!strncmp(*ppsz_name, "video_dir", 9))
271 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-movie"]];
272 else if (!strncmp(*ppsz_name, "audio_dir", 9))
273 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-music"]];
274 else if (!strncmp(*ppsz_name, "picture_dir", 11))
275 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-pictures"]];
277 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
278 [[mycompItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
279 [[mycompItems lastObject] setSdtype: SD_CAT_MYCOMPUTER];
282 msg_Warn(VLCIntf, "unknown SD type found, skipping (%s)", *ppsz_name);
287 free(*ppsz_longname);
289 [mycompItem setChildren: [NSArray arrayWithArray: mycompItems]];
290 [devicesItem setChildren: [NSArray arrayWithArray: devicesItems]];
291 [lanItem setChildren: [NSArray arrayWithArray: lanItems]];
292 [internetItem setChildren: [NSArray arrayWithArray: internetItems]];
293 [mycompItems release];
294 [devicesItems release];
296 [internetItems release];
298 free(ppsz_longnames);
301 [libraryItem setChildren: [NSArray arrayWithObjects: playlistItem, medialibraryItem, nil]];
302 [o_sidebaritems addObject: libraryItem];
303 if ([mycompItem hasChildren])
304 [o_sidebaritems addObject: mycompItem];
305 if ([devicesItem hasChildren])
306 [o_sidebaritems addObject: devicesItem];
307 if ([lanItem hasChildren])
308 [o_sidebaritems addObject: lanItem];
309 if ([internetItem hasChildren])
310 [o_sidebaritems addObject: internetItem];
312 [o_sidebar_view reloadData];
313 [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
314 [o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex];
315 [o_sidebar_view registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
317 [o_sidebar_view setAutosaveName:@"mainwindow-sidebar"];
318 [(PXSourceList *)o_sidebar_view setDataSource:self];
319 [o_sidebar_view setDelegate:self];
320 [o_sidebar_view setAutosaveExpandedItems:YES];
322 [o_sidebar_view expandItem: libraryItem expandChildren: YES];
324 /* make sure we display the desired default appearance when VLC launches for the first time */
325 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
326 if (![defaults objectForKey:@"VLCFirstRun"]) {
327 [defaults setObject:[NSDate date] forKey:@"VLCFirstRun"];
329 NSUInteger i_sidebaritem_count = [o_sidebaritems count];
330 for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
331 [o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
334 if (b_dark_interface) {
335 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidResizeNotification object: nil];
336 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidMoveNotification object: nil];
338 [self setBackgroundColor: [NSColor clearColor]];
339 [self setOpaque: NO];
341 [self setHasShadow:NO];
342 [self setHasShadow:YES];
344 NSRect winrect = [self frame];
345 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
347 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
348 winrect.size.width, f_titleBarHeight)];
349 [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: o_split_view];
351 if (winrect.size.height > 100) {
352 [self setFrame: winrect display:YES animate:YES];
353 previousSavedFrame = winrect;
356 winrect = [o_split_view frame];
357 winrect.size.height = winrect.size.height - f_titleBarHeight;
358 [o_split_view setFrame: winrect];
359 [o_video_view setFrame: winrect];
361 o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_split_view frame]];
362 [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_split_view];
363 [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
366 [o_video_view setFrame: [o_split_view frame]];
367 [o_playlist_table setBorderType: NSNoBorder];
368 [o_sidebar_scrollview setBorderType: NSNoBorder];
371 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
372 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
373 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
375 [o_split_view setAutosaveName:@"10thanniversary-splitview"];
376 if (b_splitviewShouldBeHidden) {
377 [self hideSplitView];
378 i_lastSplitViewHeight = 300;
381 /* sanity check for the window size */
382 NSRect frame = [self frame];
383 NSSize screenSize = [[self screen] frame].size;
384 if (screenSize.width <= frame.size.width || screenSize.height <= frame.size.height) {
385 nativeVideoSize = screenSize;
392 - (VLCMainWindowControlsBar *)controlsBar;
394 return (VLCMainWindowControlsBar *)o_controls_bar;
397 - (void)resizePlaylistAfterCollapse
400 plrect = [o_playlist_table frame];
401 plrect.size.height = i_lastSplitViewHeight - 20.0; // actual pl top bar height, which differs from its frame
402 [[o_playlist_table animator] setFrame: plrect];
404 NSRect rightSplitRect;
405 rightSplitRect = [o_right_split_view frame];
406 plrect = [o_dropzone_box frame];
407 plrect.origin.x = (rightSplitRect.size.width - plrect.size.width) / 2;
408 plrect.origin.y = (rightSplitRect.size.height - plrect.size.height) / 2;
409 [[o_dropzone_box animator] setFrame: plrect];
412 - (void)makeSplitViewVisible
414 if (b_dark_interface)
415 [self setContentMinSize: NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
417 [self setContentMinSize: NSMakeSize(604., 288.)];
419 NSRect old_frame = [self frame];
420 float newHeight = [self minSize].height;
421 if (old_frame.size.height < newHeight) {
422 NSRect new_frame = old_frame;
423 new_frame.origin.y = old_frame.origin.y + old_frame.size.height - newHeight;
424 new_frame.size.height = newHeight;
426 [[self animator] setFrame: new_frame display: YES animate: YES];
429 [o_video_view setHidden: YES];
430 [o_split_view setHidden: NO];
431 [self makeFirstResponder: nil];
435 - (void)makeSplitViewHidden
437 if (b_dark_interface)
438 [self setContentMinSize: NSMakeSize(604., f_min_video_height + [o_titlebar_view frame].size.height)];
440 [self setContentMinSize: NSMakeSize(604., f_min_video_height)];
442 [o_split_view setHidden: YES];
443 [o_video_view setHidden: NO];
445 if ([[o_video_view subviews] count] > 0)
446 [self makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
449 // only exception for an controls bar button action
450 - (IBAction)togglePlaylist:(id)sender
452 if (![self isVisible] && sender != nil) {
453 [self makeKeyAndOrderFront: sender];
457 BOOL b_activeVideo = [[VLCMain sharedInstance] activeVideoPlayback];
458 BOOL b_restored = NO;
460 // TODO: implement toggle playlist in this situation (triggerd via menu item).
461 // but for now we block this case, to avoid displaying only the half
462 if (b_nativeFullscreenMode && b_fullscreen && b_activeVideo && sender != nil)
465 if (b_dropzone_active && ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0) {
470 if (!(b_nativeFullscreenMode && b_fullscreen) && !b_splitview_removed && ((([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0 && b_activeVideo)
471 || (b_nonembedded && sender != nil)
472 || (!b_activeVideo && sender != nil)
473 || b_minimized_view))
474 [self hideSplitView];
476 if (b_splitview_removed) {
477 if (!b_nonembedded || (sender != nil && b_nonembedded))
478 [self showSplitView];
481 b_minimized_view = YES;
483 b_minimized_view = NO;
489 if (!b_nonembedded) {
490 if (([o_video_view isHidden] && b_activeVideo) || b_restored || (b_activeVideo && sender == nil))
491 [self makeSplitViewHidden];
493 [self makeSplitViewVisible];
495 [o_split_view setHidden: NO];
496 [o_playlist_table setHidden: NO];
497 [o_video_view setHidden: !b_activeVideo];
498 if (b_activeVideo && [[o_video_view subviews] count] > 0)
499 [[o_video_view window] makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
504 - (IBAction)dropzoneButtonAction:(id)sender
506 [[[VLCMain sharedInstance] open] openFileGeneric];
510 #pragma mark overwritten default functionality
512 - (void)windowResizedOrMoved:(NSNotification *)notification
514 [self saveFrameUsingName: [self frameAutosaveName]];
517 - (void)applicationWillTerminate:(NSNotification *)notification
519 [self saveFrameUsingName: [self frameAutosaveName]];
523 - (void)someWindowWillClose:(NSNotification *)notification
525 id obj = [notification object];
527 if ([obj class] == [VLCVideoWindowCommon class] || [obj class] == [VLCDetachedVideoWindow class] || ([obj class] == [VLCMainWindow class] && !b_nonembedded)) {
528 if ([[VLCMain sharedInstance] activeVideoPlayback])
529 [[VLCCoreInteraction sharedInstance] stop];
533 - (void)someWindowWillMiniaturize:(NSNotification *)notification
535 if (config_GetInt(VLCIntf, "macosx-pause-minimized")) {
536 id obj = [notification object];
538 if ([obj class] == [VLCVideoWindowCommon class] || [obj class] == [VLCDetachedVideoWindow class] || ([obj class] == [VLCMainWindow class] && !b_nonembedded)) {
539 if ([[VLCMain sharedInstance] activeVideoPlayback])
540 [[VLCCoreInteraction sharedInstance] pause];
546 #pragma mark Update interface and respond to foreign events
549 b_dropzone_active = YES;
550 [o_right_split_view addSubview: o_dropzone_view positioned:NSWindowAbove relativeTo:o_playlist_table];
551 [o_dropzone_view setFrame: [o_playlist_table frame]];
552 [[o_playlist_table animator] setHidden:YES];
557 b_dropzone_active = NO;
558 [o_dropzone_view removeFromSuperview];
559 [[o_playlist_table animator] setHidden: NO];
562 - (void)hideSplitView
564 NSRect winrect = [self frame];
565 i_lastSplitViewHeight = [o_split_view frame].size.height;
566 winrect.size.height = winrect.size.height - i_lastSplitViewHeight;
567 winrect.origin.y = winrect.origin.y + i_lastSplitViewHeight;
568 [self setFrame: winrect display: YES animate: YES];
569 [self performSelector:@selector(hideDropZone) withObject:nil afterDelay:0.1];
570 if (b_dark_interface) {
571 [self setContentMinSize: NSMakeSize(604., [[o_controls_bar bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
572 [self setContentMaxSize: NSMakeSize(FLT_MAX, [[o_controls_bar bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
574 [self setContentMinSize: NSMakeSize(604., [[o_controls_bar bottomBarView] frame].size.height)];
575 [self setContentMaxSize: NSMakeSize(FLT_MAX, [[o_controls_bar bottomBarView] frame].size.height)];
578 b_splitview_removed = YES;
581 - (void)showSplitView
584 if (b_dark_interface)
585 [self setContentMinSize:NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
587 [self setContentMinSize:NSMakeSize(604., 288.)];
588 [self setContentMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)];
591 winrect = [self frame];
592 winrect.size.height = winrect.size.height + i_lastSplitViewHeight;
593 winrect.origin.y = winrect.origin.y - i_lastSplitViewHeight;
594 [self setFrame: winrect display: YES animate: YES];
596 [self performSelector:@selector(resizePlaylistAfterCollapse) withObject: nil afterDelay:0.75];
598 b_splitview_removed = NO;
601 - (void)updateTimeSlider
603 [o_controls_bar updateTimeSlider];
604 [[self controlsBar] updatePosAndTimeInFSPanel:o_fspanel];
606 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateTimeSlider)];
611 input_thread_t * p_input;
612 p_input = pl_CurrentInput(VLCIntf);
615 char *format = var_InheritString(VLCIntf, "input-title-format");
616 char *formated = str_format_meta(pl_Get(VLCIntf), format);
618 aString = [NSString stringWithUTF8String:formated];
621 char *uri = input_item_GetURI(input_GetItem(p_input));
623 NSURL * o_url = [NSURL URLWithString: [NSString stringWithUTF8String: uri]];
624 if ([o_url isFileURL]) {
625 [self setRepresentedURL: o_url];
626 [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
627 [o_window setRepresentedURL:o_url];
630 [self setRepresentedURL: nil];
631 [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
632 [o_window setRepresentedURL:nil];
637 if ([aString isEqualToString:@""]) {
638 if ([o_url isFileURL])
639 aString = [[NSFileManager defaultManager] displayNameAtPath: [o_url path]];
641 aString = [o_url absoluteString];
644 [self setTitle: aString];
645 [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
646 [o_window setTitle:aString];
649 [o_fspanel setStreamTitle: aString];
650 vlc_object_release(p_input);
652 [self setTitle: _NS("VLC media player")];
653 [self setRepresentedURL: nil];
659 [o_controls_bar updateControls];
660 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateControls)];
662 bool b_seekable = false;
664 playlist_t * p_playlist = pl_Get(VLCIntf);
665 input_thread_t * p_input = playlist_CurrentInput(p_playlist);
667 /* seekable streams */
668 b_seekable = var_GetBool(p_input, "can-seek");
670 vlc_object_release(p_input);
673 [self updateTimeSlider];
674 if ([o_fspanel respondsToSelector:@selector(setSeekable:)])
675 [o_fspanel setSeekable: b_seekable];
678 if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
683 [o_sidebar_view setNeedsDisplay:YES];
688 [o_controls_bar setPause];
689 [o_fspanel setPause];
691 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPause)];
696 [o_controls_bar setPlay];
699 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPlay)];
703 - (void)updateVolumeSlider
705 [[self controlsBar] updateVolumeSlider];
706 [o_fspanel setVolumeLevel: [[VLCCoreInteraction sharedInstance] volume]];
710 #pragma mark Video Output handling
712 - (void)setVideoplayEnabled
714 BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback];
716 if (b_videoPlayback) {
718 frameBeforePlayback = [self frame];
720 if (!b_nonembedded && !b_fullscreen && frameBeforePlayback.size.width > 0 && frameBeforePlayback.size.height > 0)
721 [[self animator] setFrame:frameBeforePlayback display:YES];
723 [self makeFirstResponder: nil];
725 if ([self level] != NSNormalWindowLevel)
726 [self setLevel: NSNormalWindowLevel];
728 // restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
729 [self setAlphaValue:1.0];
732 if (b_nativeFullscreenMode) {
733 if ([NSApp presentationOptions] & NSApplicationPresentationFullScreen)
734 [[o_controls_bar bottomBarView] setHidden: b_videoPlayback];
736 [[o_controls_bar bottomBarView] setHidden: NO];
737 if (b_videoPlayback && b_fullscreen)
738 [o_fspanel setActive: nil];
739 if (!b_videoPlayback)
740 [o_fspanel setNonActive: nil];
744 // Called automatically if window's acceptsMouseMovedEvents property is true
745 - (void)mouseMoved:(NSEvent *)theEvent
748 [self recreateHideMouseTimer];
750 [super mouseMoved: theEvent];
753 - (void)recreateHideMouseTimer
755 if (t_hide_mouse_timer != nil) {
756 [t_hide_mouse_timer invalidate];
757 [t_hide_mouse_timer release];
760 t_hide_mouse_timer = [NSTimer scheduledTimerWithTimeInterval:2
762 selector:@selector(hideMouseCursor:)
765 [t_hide_mouse_timer retain];
768 // NSTimer selectors require this function signature as per Apple's docs
769 - (void)hideMouseCursor:(NSTimer *)timer
771 [NSCursor setHiddenUntilMouseMoves: YES];
776 #pragma mark Fullscreen support
778 - (void)showFullscreenController
780 if (b_fullscreen && [[VLCMain sharedInstance] activeVideoPlayback])
784 - (void)makeKeyAndOrderFront: (id)sender
787 * when we exit fullscreen and fade out, we may endup in
788 * having a window that is faded. We can't have it fade in unless we
791 if (!b_window_is_invisible) {
792 /* Make sure we don't do it too much */
793 [super makeKeyAndOrderFront: sender];
797 [super setAlphaValue:0.0f];
798 [super makeKeyAndOrderFront: sender];
800 NSMutableDictionary * dict = [[NSMutableDictionary alloc] initWithCapacity:2];
801 [dict setObject:self forKey:NSViewAnimationTargetKey];
802 [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
804 o_makekey_anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
807 [o_makekey_anim setAnimationBlockingMode: NSAnimationNonblocking];
808 [o_makekey_anim setDuration: 0.1];
809 [o_makekey_anim setFrameRate: 30];
810 [o_makekey_anim setDelegate: self];
812 [o_makekey_anim startAnimation];
813 b_window_is_invisible = NO;
815 /* fullscreenAnimation will be unlocked when animation ends */
819 #pragma mark Lion native fullscreen handling
820 - (void)windowWillEnterFullScreen:(NSNotification *)notification
822 // workaround, see #6668
823 [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
825 var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
827 vout_thread_t *p_vout = getVout();
829 var_SetBool(p_vout, "fullscreen", true);
830 vlc_object_release(p_vout);
833 [o_video_view setFrame: [[self contentView] frame]];
836 [self recreateHideMouseTimer];
837 i_originalLevel = [self level];
838 [self setLevel:NSNormalWindowLevel];
840 if (b_dark_interface) {
841 [o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
844 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
845 winrect = [self frame];
847 winrect.size.height = winrect.size.height - f_titleBarHeight;
848 [self setFrame: winrect display:NO animate:NO];
849 winrect = [o_split_view frame];
850 winrect.size.height = winrect.size.height + f_titleBarHeight;
851 [o_split_view setFrame: winrect];
854 if ([[VLCMain sharedInstance] activeVideoPlayback])
855 [[o_controls_bar bottomBarView] setHidden: YES];
857 [self setMovableByWindowBackground: NO];
860 - (void)windowDidEnterFullScreen:(NSNotification *)notification
862 // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
863 // But this creates some problems when leaving fs over remote intfs, so activate app here.
864 [NSApp activateIgnoringOtherApps:YES];
866 [o_fspanel setVoutWasUpdated: self];
867 [o_fspanel setActive: nil];
870 - (void)windowWillExitFullScreen:(NSNotification *)notification
873 var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
875 vout_thread_t *p_vout = getVout();
877 var_SetBool(p_vout, "fullscreen", false);
878 vlc_object_release(p_vout);
881 [o_video_view setFrame: [o_split_view frame]];
882 [NSCursor setHiddenUntilMouseMoves: NO];
883 [o_fspanel setNonActive: nil];
884 [self setLevel:i_originalLevel];
887 if (b_dark_interface) {
889 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
890 winrect = [self frame];
892 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
893 winrect.size.width, f_titleBarHeight)];
894 [[self contentView] addSubview: o_titlebar_view];
896 winrect.size.height = winrect.size.height + f_titleBarHeight;
897 [self setFrame: winrect display:NO animate:NO];
898 winrect = [o_split_view frame];
899 winrect.size.height = winrect.size.height - f_titleBarHeight;
900 [o_split_view setFrame: winrect];
901 [o_video_view setFrame: winrect];
904 if ([[VLCMain sharedInstance] activeVideoPlayback])
905 [[o_controls_bar bottomBarView] setHidden: NO];
907 [self setMovableByWindowBackground: YES];
911 #pragma mark split view delegate
912 - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
914 if (dividerIndex == 0)
920 - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex
922 if (dividerIndex == 0)
928 - (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview
930 return ([subview isEqual:o_left_split_view]);
933 - (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)subview
935 if ([subview isEqual:o_left_split_view])
941 #pragma mark Side Bar Data handling
942 /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
943 - (NSUInteger)sourceList:(PXSourceList*)sourceList numberOfChildrenOfItem:(id)item
945 //Works the same way as the NSOutlineView data source: `nil` means a parent item
947 return [o_sidebaritems count];
949 return [[item children] count];
953 - (id)sourceList:(PXSourceList*)aSourceList child:(NSUInteger)index ofItem:(id)item
955 //Works the same way as the NSOutlineView data source: `nil` means a parent item
957 return [o_sidebaritems objectAtIndex:index];
959 return [[item children] objectAtIndex:index];
963 - (id)sourceList:(PXSourceList*)aSourceList objectValueForItem:(id)item
968 - (void)sourceList:(PXSourceList*)aSourceList setObjectValue:(id)object forItem:(id)item
970 [item setTitle:object];
973 - (BOOL)sourceList:(PXSourceList*)aSourceList isItemExpandable:(id)item
975 return [item hasChildren];
979 - (BOOL)sourceList:(PXSourceList*)aSourceList itemHasBadge:(id)item
981 if ([[item identifier] isEqualToString: @"playlist"] || [[item identifier] isEqualToString: @"medialibrary"])
984 return [item hasBadge];
988 - (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item
990 playlist_t * p_playlist = pl_Get(VLCIntf);
991 NSInteger i_playlist_size;
993 if ([[item identifier] isEqualToString: @"playlist"]) {
995 i_playlist_size = p_playlist->p_local_category->i_children;
998 return i_playlist_size;
1000 if ([[item identifier] isEqualToString: @"medialibrary"]) {
1002 i_playlist_size = p_playlist->p_ml_category->i_children;
1005 return i_playlist_size;
1008 return [item badgeValue];
1012 - (BOOL)sourceList:(PXSourceList*)aSourceList itemHasIcon:(id)item
1014 return [item hasIcon];
1018 - (NSImage*)sourceList:(PXSourceList*)aSourceList iconForItem:(id)item
1023 - (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
1025 if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
1028 if ([item sdtype] > 0)
1030 m = [[NSMenu alloc] init];
1031 playlist_t * p_playlist = pl_Get(VLCIntf);
1032 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [[item identifier] UTF8String]);
1034 [m addItemWithTitle:_NS("Enable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
1036 [m addItemWithTitle:_NS("Disable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
1037 [[m itemAtIndex:0] setRepresentedObject: [item identifier]];
1039 return [m autorelease];
1046 - (IBAction)sdmenuhandler:(id)sender
1048 NSString * identifier = [sender representedObject];
1049 if ([identifier length] > 0 && ![identifier isEqualToString:@"lua{sd='freebox',longname='Freebox TV'}"]) {
1050 playlist_t * p_playlist = pl_Get(VLCIntf);
1051 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [identifier UTF8String]);
1054 playlist_ServicesDiscoveryAdd(p_playlist, [identifier UTF8String]);
1056 playlist_ServicesDiscoveryRemove(p_playlist, [identifier UTF8String]);
1061 #pragma mark Side Bar Delegate Methods
1062 /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
1063 - (BOOL)sourceList:(PXSourceList*)aSourceList isGroupAlwaysExpanded:(id)group
1065 if ([[group identifier] isEqualToString:@"library"])
1071 - (void)sourceListSelectionDidChange:(NSNotification *)notification
1073 playlist_t * p_playlist = pl_Get(VLCIntf);
1075 NSIndexSet *selectedIndexes = [o_sidebar_view selectedRowIndexes];
1076 id item = [o_sidebar_view itemAtRow:[selectedIndexes firstIndex]];
1079 //Set the label text to represent the new selection
1080 if ([item sdtype] > -1 && [[item identifier] length] > 0) {
1081 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [[item identifier] UTF8String]);
1083 playlist_ServicesDiscoveryAdd(p_playlist, [[item identifier] UTF8String]);
1086 [o_chosen_category_lbl setStringValue:[item title]];
1088 if ([[item identifier] isEqualToString:@"playlist"]) {
1089 [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_local_category];
1090 } else if ([[item identifier] isEqualToString:@"medialibrary"]) {
1091 [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_ml_category];
1093 playlist_item_t * pl_item;
1095 pl_item = playlist_ChildSearchName(p_playlist->p_root, [[item untranslatedTitle] UTF8String]);
1097 [[[VLCMain sharedInstance] playlist] setPlaylistRoot: pl_item];
1101 if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
1102 [self hideDropZone];
1104 [self showDropZone];
1107 if ([[item identifier] isEqualToString:@"podcast{longname=\"Podcasts\"}"])
1108 [self showPodcastControls];
1110 [self hidePodcastControls];
1113 - (NSDragOperation)sourceList:(PXSourceList *)aSourceList validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
1115 if ([[item identifier] isEqualToString:@"playlist"] || [[item identifier] isEqualToString:@"medialibrary"]) {
1116 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1117 if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] || [[o_pasteboard types] containsObject: NSFilenamesPboardType])
1118 return NSDragOperationGeneric;
1120 return NSDragOperationNone;
1123 - (BOOL)sourceList:(PXSourceList *)aSourceList acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
1125 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1127 playlist_t * p_playlist = pl_Get(VLCIntf);
1128 playlist_item_t *p_node;
1130 if ([[item identifier] isEqualToString:@"playlist"])
1131 p_node = p_playlist->p_local_category;
1133 p_node = p_playlist->p_ml_category;
1135 if ([[o_pasteboard types] containsObject: NSFilenamesPboardType]) {
1136 NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
1137 NSUInteger count = [o_values count];
1138 NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
1140 for(NSUInteger i = 0; i < count; i++) {
1141 NSDictionary *o_dic;
1142 char *psz_uri = vlc_path2uri([[o_values objectAtIndex:i] UTF8String], NULL);
1146 o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
1150 [o_array addObject: o_dic];
1153 [[[VLCMain sharedInstance] playlist] appendNodeArray:o_array inNode: p_node atPos:-1 enqueue:YES];
1156 else if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"]) {
1157 NSArray * array = [[[VLCMain sharedInstance] playlist] draggedItems];
1159 NSUInteger count = [array count];
1160 playlist_item_t * p_item = NULL;
1163 for(NSUInteger i = 0; i < count; i++) {
1164 p_item = [[array objectAtIndex:i] pointerValue];
1165 if (!p_item) continue;
1166 playlist_NodeAddCopy(p_playlist, p_item, p_node, PLAYLIST_END);
1175 - (id)sourceList:(PXSourceList *)aSourceList persistentObjectForItem:(id)item
1177 return [item identifier];
1180 - (id)sourceList:(PXSourceList *)aSourceList itemForPersistentObject:(id)object
1182 /* the following code assumes for sakes of simplicity that only the top level
1183 * items are allowed to have children */
1185 NSArray * array = [NSArray arrayWithArray: o_sidebaritems]; // read-only arrays are noticebly faster
1186 NSUInteger count = [array count];
1190 for (NSUInteger x = 0; x < count; x++) {
1191 id item = [array objectAtIndex: x]; // save one objc selector call
1192 if ([[item identifier] isEqualToString:object])
1200 #pragma mark Podcast
1202 - (IBAction)addPodcast:(id)sender
1204 [NSApp beginSheet:o_podcast_subscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil];
1207 - (IBAction)addPodcastWindowAction:(id)sender
1209 [o_podcast_subscribe_window orderOut:sender];
1210 [NSApp endSheet: o_podcast_subscribe_window];
1212 if (sender == o_podcast_subscribe_ok_btn && [[o_podcast_subscribe_url_fld stringValue] length] > 0) {
1213 NSMutableString * podcastConf = [[NSMutableString alloc] init];
1214 if (config_GetPsz(VLCIntf, "podcast-urls") != NULL)
1215 [podcastConf appendFormat:@"%s|", config_GetPsz(VLCIntf, "podcast-urls")];
1217 [podcastConf appendString: [o_podcast_subscribe_url_fld stringValue]];
1218 config_PutPsz(VLCIntf, "podcast-urls", [podcastConf UTF8String]);
1220 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name(VLCIntf->p_libvlc, "podcast");
1222 var_SetString(p_obj, "podcast-urls", [podcastConf UTF8String]);
1223 vlc_object_release(p_obj);
1225 [podcastConf release];
1229 - (IBAction)removePodcast:(id)sender
1231 if (config_GetPsz(VLCIntf, "podcast-urls") != NULL) {
1232 [o_podcast_unsubscribe_pop removeAllItems];
1233 [o_podcast_unsubscribe_pop addItemsWithTitles:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
1234 [NSApp beginSheet:o_podcast_unsubscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil];
1238 - (IBAction)removePodcastWindowAction:(id)sender
1240 [o_podcast_unsubscribe_window orderOut:sender];
1241 [NSApp endSheet: o_podcast_unsubscribe_window];
1243 if (sender == o_podcast_unsubscribe_ok_btn) {
1244 NSMutableArray * urls = [[NSMutableArray alloc] initWithArray:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
1245 [urls removeObjectAtIndex: [o_podcast_unsubscribe_pop indexOfSelectedItem]];
1246 config_PutPsz(VLCIntf, "podcast-urls", [[urls componentsJoinedByString:@"|"] UTF8String]);
1249 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name(VLCIntf->p_libvlc, "podcast");
1251 var_SetString(p_obj, "podcast-urls", config_GetPsz(VLCIntf, "podcast-urls"));
1252 vlc_object_release(p_obj);
1255 /* reload the podcast module, since it won't update its list when removing podcasts */
1256 playlist_t * p_playlist = pl_Get(VLCIntf);
1257 if (playlist_IsServicesDiscoveryLoaded(p_playlist, "podcast{longname=\"Podcasts\"}")) {
1258 playlist_ServicesDiscoveryRemove(p_playlist, "podcast{longname=\"Podcasts\"}");
1259 playlist_ServicesDiscoveryAdd(p_playlist, "podcast{longname=\"Podcasts\"}");
1260 [o_playlist_table reloadData];
1266 - (void)showPodcastControls
1268 NSRect podcastViewDimensions = [o_podcast_view frame];
1269 NSRect rightSplitRect = [o_right_split_view frame];
1270 NSRect playlistTableRect = [o_playlist_table frame];
1272 podcastViewDimensions.size.width = rightSplitRect.size.width;
1273 podcastViewDimensions.origin.x = podcastViewDimensions.origin.y = .0;
1274 [o_podcast_view setFrame:podcastViewDimensions];
1276 playlistTableRect.origin.y = playlistTableRect.origin.y + podcastViewDimensions.size.height;
1277 playlistTableRect.size.height = playlistTableRect.size.height - podcastViewDimensions.size.height;
1278 [o_playlist_table setFrame:playlistTableRect];
1279 [o_playlist_table setNeedsDisplay:YES];
1281 [o_right_split_view addSubview: o_podcast_view positioned: NSWindowAbove relativeTo: o_right_split_view];
1282 b_podcastView_displayed = YES;
1285 - (void)hidePodcastControls
1287 if (b_podcastView_displayed) {
1288 NSRect podcastViewDimensions = [o_podcast_view frame];
1289 NSRect playlistTableRect = [o_playlist_table frame];
1291 playlistTableRect.origin.y = playlistTableRect.origin.y - podcastViewDimensions.size.height;
1292 playlistTableRect.size.height = playlistTableRect.size.height + podcastViewDimensions.size.height;
1294 [o_podcast_view removeFromSuperviewWithoutNeedingDisplay];
1295 [o_playlist_table setFrame: playlistTableRect];
1296 b_podcastView_displayed = NO;
1302 @implementation VLCDetachedVideoWindow
1304 - (void)awakeFromNib
1306 [self setAcceptsMouseMovedEvents: YES];
1308 if (b_dark_interface) {
1309 [self setBackgroundColor: [NSColor clearColor]];
1311 [self setOpaque: NO];
1313 [self setHasShadow:NO];
1314 [self setHasShadow:YES];
1316 NSRect winrect = [self frame];
1317 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
1319 [self setTitle: _NS("VLC media player")];
1320 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)];
1321 [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: nil];
1323 // native fs not supported with detached view yet
1324 [o_titlebar_view setFullscreenButtonHidden: YES];
1326 [self setBackgroundColor: [NSColor blackColor]];
1329 NSRect videoViewRect = [[self contentView] bounds];
1330 if (b_dark_interface)
1331 videoViewRect.size.height -= [o_titlebar_view frame].size.height;
1332 CGFloat f_bottomBarHeight = [[[self controlsBar] bottomBarView] frame].size.height;
1333 videoViewRect.size.height -= f_bottomBarHeight;
1334 videoViewRect.origin.y = f_bottomBarHeight;
1335 [o_video_view setFrame: videoViewRect];
1337 if (b_dark_interface) {
1338 o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_video_view frame]];
1339 [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_video_view];
1340 [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
1342 [self setContentMinSize: NSMakeSize(363., f_min_video_height + [[[self controlsBar] bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
1344 [self setContentMinSize: NSMakeSize(363., f_min_video_height + [[[self controlsBar] bottomBarView] frame].size.height)];
1350 if (b_dark_interface)
1351 [o_color_backdrop release];