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>
40 #import <vlc_strings.h>
41 #import <vlc_services_discovery.h>
43 #import "ControlsBar.h"
45 #import "VLCVoutWindowController.h"
48 @interface VLCMainWindow (Internal)
49 - (void)resizePlaylistAfterCollapse;
50 - (void)makeSplitViewVisible;
51 - (void)makeSplitViewHidden;
52 - (void)showPodcastControls;
53 - (void)hidePodcastControls;
57 @implementation VLCMainWindow
59 @synthesize nativeFullscreenMode=b_nativeFullscreenMode;
60 @synthesize nonembedded=b_nonembedded;
61 @synthesize fsPanel=o_fspanel;
63 static VLCMainWindow *_o_sharedInstance = nil;
65 + (VLCMainWindow *)sharedInstance
67 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
71 #pragma mark Initialization
75 if (_o_sharedInstance) {
77 return _o_sharedInstance;
79 _o_sharedInstance = [super init];
81 return _o_sharedInstance;
84 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
85 backing:(NSBackingStoreType)backingType defer:(BOOL)flag
87 self = [super initWithContentRect:contentRect styleMask:styleMask
88 backing:backingType defer:flag];
89 _o_sharedInstance = self;
91 [[VLCMain sharedInstance] updateTogglePlaylistState];
96 - (BOOL)isEvent:(NSEvent *)o_event forKey:(const char *)keyString
101 key = config_GetPsz(VLCIntf, keyString);
102 o_key = [NSString stringWithFormat:@"%s", key];
105 unsigned int i_keyModifiers = [[VLCStringUtility sharedInstance] VLCModifiersToCocoa:o_key];
107 NSString * characters = [o_event charactersIgnoringModifiers];
108 if ([characters length] > 0) {
109 return [[characters lowercaseString] isEqualToString: [[VLCStringUtility sharedInstance] VLCKeyToString: o_key]] &&
110 (i_keyModifiers & NSShiftKeyMask) == ([o_event modifierFlags] & NSShiftKeyMask) &&
111 (i_keyModifiers & NSControlKeyMask) == ([o_event modifierFlags] & NSControlKeyMask) &&
112 (i_keyModifiers & NSAlternateKeyMask) == ([o_event modifierFlags] & NSAlternateKeyMask) &&
113 (i_keyModifiers & NSCommandKeyMask) == ([o_event modifierFlags] & NSCommandKeyMask);
118 - (BOOL)performKeyEquivalent:(NSEvent *)o_event
121 // these are key events which should be handled by vlc core, but are attached to a main menu item
122 if (![self isEvent: o_event forKey: "key-vol-up"] &&
123 ![self isEvent: o_event forKey: "key-vol-down"] &&
124 ![self isEvent: o_event forKey: "key-vol-mute"]) {
125 /* We indeed want to prioritize some Cocoa key equivalent against libvlc,
126 so we perform the menu equivalent now. */
127 if ([[NSApp mainMenu] performKeyEquivalent:o_event])
133 return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event force:b_force] ||
134 [(VLCControls *)[[VLCMain sharedInstance] controls] keyEvent:o_event];
139 if (b_dark_interface)
140 [o_color_backdrop release];
142 [[NSNotificationCenter defaultCenter] removeObserver: self];
143 [o_sidebaritems release];
150 // sets lion fullscreen behaviour
151 [super awakeFromNib];
153 BOOL b_splitviewShouldBeHidden = NO;
155 /* setup the styled interface */
156 b_nativeFullscreenMode = NO;
157 #ifdef MAC_OS_X_VERSION_10_7
158 if (!OSX_SNOW_LEOPARD)
159 b_nativeFullscreenMode = var_InheritBool(VLCIntf, "macosx-nativefullscreenmode");
161 t_hide_mouse_timer = nil;
162 [self useOptimizedDrawing: YES];
164 [[o_search_fld cell] setPlaceholderString: _NS("Search")];
165 [[o_search_fld cell] accessibilitySetOverrideValue:_NS("Enter a term to search the playlist. Results will be selected in the table.") forAttribute:NSAccessibilityDescriptionAttribute];
167 [o_dropzone_btn setTitle: _NS("Open media...")];
168 [[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];
169 [o_dropzone_lbl setStringValue: _NS("Drop media here")];
171 [o_podcast_add_btn setTitle: _NS("Subscribe")];
172 [o_podcast_remove_btn setTitle: _NS("Unsubscribe")];
173 [o_podcast_subscribe_title_lbl setStringValue: _NS("Subscribe to a podcast")];
174 [o_podcast_subscribe_subtitle_lbl setStringValue: _NS("Enter URL of the podcast to subscribe to:")];
175 [o_podcast_subscribe_cancel_btn setTitle: _NS("Cancel")];
176 [o_podcast_subscribe_ok_btn setTitle: _NS("Subscribe")];
177 [o_podcast_unsubscribe_title_lbl setStringValue: _NS("Unsubscribe from a podcast")];
178 [o_podcast_unsubscribe_subtitle_lbl setStringValue: _NS("Select the podcast you would like to unsubscribe from:")];
179 [o_podcast_unsubscribe_ok_btn setTitle: _NS("Unsubscribe")];
180 [o_podcast_unsubscribe_cancel_btn setTitle: _NS("Cancel")];
182 /* interface builder action */
183 float f_threshold_height = f_min_video_height + [[o_controls_bar bottomBarView] frame].size.height;
184 if (b_dark_interface)
185 f_threshold_height += [o_titlebar_view frame].size.height;
186 if ([[self contentView] frame].size.height < f_threshold_height)
187 b_splitviewShouldBeHidden = YES;
189 [self setDelegate: self];
190 [self setExcludedFromWindowsMenu: YES];
191 [self setAcceptsMouseMovedEvents: YES];
192 // Set that here as IB seems to be buggy
193 if (b_dark_interface) {
194 [self setContentMinSize:NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
196 [self setContentMinSize:NSMakeSize(604., 288.)];
199 [self setTitle: _NS("VLC media player")];
201 b_dropzone_active = YES;
202 [o_dropzone_view setFrame: [o_playlist_table frame]];
203 [o_left_split_view setFrame: [o_sidebar_view frame]];
205 if (!OSX_SNOW_LEOPARD) {
206 /* the default small size of the search field is slightly different on Lion, let's work-around that */
208 frame = [o_search_fld frame];
209 frame.origin.y = frame.origin.y + 2.0;
210 frame.size.height = frame.size.height - 1.0;
211 [o_search_fld setFrame: frame];
214 /* create the sidebar */
215 o_sidebaritems = [[NSMutableArray alloc] init];
216 SideBarItem *libraryItem = [SideBarItem itemWithTitle:_NS("LIBRARY") identifier:@"library"];
217 SideBarItem *playlistItem = [SideBarItem itemWithTitle:_NS("Playlist") identifier:@"playlist"];
218 [playlistItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
219 SideBarItem *medialibraryItem = [SideBarItem itemWithTitle:_NS("Media Library") identifier:@"medialibrary"];
220 [medialibraryItem setIcon: [NSImage imageNamed:@"sidebar-playlist"]];
221 SideBarItem *mycompItem = [SideBarItem itemWithTitle:_NS("MY COMPUTER") identifier:@"mycomputer"];
222 SideBarItem *devicesItem = [SideBarItem itemWithTitle:_NS("DEVICES") identifier:@"devices"];
223 SideBarItem *lanItem = [SideBarItem itemWithTitle:_NS("LOCAL NETWORK") identifier:@"localnetwork"];
224 SideBarItem *internetItem = [SideBarItem itemWithTitle:_NS("INTERNET") identifier:@"internet"];
226 /* SD subnodes, inspired by the Qt4 intf */
227 char **ppsz_longnames;
229 char **ppsz_names = vlc_sd_GetNames(pl_Get(VLCIntf), &ppsz_longnames, &p_categories);
231 msg_Err(VLCIntf, "no sd item found"); //TODO
232 char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
233 int *p_category = p_categories;
234 NSMutableArray *internetItems = [[NSMutableArray alloc] init];
235 NSMutableArray *devicesItems = [[NSMutableArray alloc] init];
236 NSMutableArray *lanItems = [[NSMutableArray alloc] init];
237 NSMutableArray *mycompItems = [[NSMutableArray alloc] init];
238 NSString *o_identifier;
239 for (; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++) {
240 o_identifier = [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding];
241 switch (*p_category) {
242 case SD_CAT_INTERNET:
243 [internetItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
244 if (!strncmp(*ppsz_name, "podcast", 7))
245 [[internetItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-podcast"]];
247 [[internetItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
248 [[internetItems lastObject] setSdtype: SD_CAT_INTERNET];
249 [[internetItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
252 [devicesItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
253 [[devicesItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
254 [[devicesItems lastObject] setSdtype: SD_CAT_DEVICES];
255 [[devicesItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
258 [lanItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
259 [[lanItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-local"]];
260 [[lanItems lastObject] setSdtype: SD_CAT_LAN];
261 [[lanItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
263 case SD_CAT_MYCOMPUTER:
264 [mycompItems addObject: [SideBarItem itemWithTitle: _NS(*ppsz_longname) identifier: o_identifier]];
265 if (!strncmp(*ppsz_name, "video_dir", 9))
266 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-movie"]];
267 else if (!strncmp(*ppsz_name, "audio_dir", 9))
268 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-music"]];
269 else if (!strncmp(*ppsz_name, "picture_dir", 11))
270 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-pictures"]];
272 [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
273 [[mycompItems lastObject] setUntranslatedTitle: [NSString stringWithUTF8String: *ppsz_longname]];
274 [[mycompItems lastObject] setSdtype: SD_CAT_MYCOMPUTER];
277 msg_Warn(VLCIntf, "unknown SD type found, skipping (%s)", *ppsz_name);
282 free(*ppsz_longname);
284 [mycompItem setChildren: [NSArray arrayWithArray: mycompItems]];
285 [devicesItem setChildren: [NSArray arrayWithArray: devicesItems]];
286 [lanItem setChildren: [NSArray arrayWithArray: lanItems]];
287 [internetItem setChildren: [NSArray arrayWithArray: internetItems]];
288 [mycompItems release];
289 [devicesItems release];
291 [internetItems release];
293 free(ppsz_longnames);
296 [libraryItem setChildren: [NSArray arrayWithObjects: playlistItem, medialibraryItem, nil]];
297 [o_sidebaritems addObject: libraryItem];
298 if ([mycompItem hasChildren])
299 [o_sidebaritems addObject: mycompItem];
300 if ([devicesItem hasChildren])
301 [o_sidebaritems addObject: devicesItem];
302 if ([lanItem hasChildren])
303 [o_sidebaritems addObject: lanItem];
304 if ([internetItem hasChildren])
305 [o_sidebaritems addObject: internetItem];
307 [o_sidebar_view reloadData];
308 [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
309 [o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex];
310 [o_sidebar_view registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
312 [o_sidebar_view setAutosaveName:@"mainwindow-sidebar"];
313 [(PXSourceList *)o_sidebar_view setDataSource:self];
314 [o_sidebar_view setDelegate:self];
315 [o_sidebar_view setAutosaveExpandedItems:YES];
317 [o_sidebar_view expandItem: libraryItem expandChildren: YES];
319 /* make sure we display the desired default appearance when VLC launches for the first time */
320 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
321 if (![defaults objectForKey:@"VLCFirstRun"]) {
322 [defaults setObject:[NSDate date] forKey:@"VLCFirstRun"];
324 NSUInteger i_sidebaritem_count = [o_sidebaritems count];
325 for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
326 [o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
329 if (b_dark_interface) {
330 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidResizeNotification object: nil];
331 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidMoveNotification object: nil];
333 [self setBackgroundColor: [NSColor clearColor]];
334 [self setOpaque: NO];
336 [self setHasShadow:NO];
337 [self setHasShadow:YES];
339 NSRect winrect = [self frame];
340 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
342 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
343 winrect.size.width, f_titleBarHeight)];
344 [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: o_split_view];
346 if (winrect.size.height > 100) {
347 [self setFrame: winrect display:YES animate:YES];
348 previousSavedFrame = winrect;
351 winrect = [o_split_view frame];
352 winrect.size.height = winrect.size.height - f_titleBarHeight;
353 [o_split_view setFrame: winrect];
354 [o_video_view setFrame: winrect];
356 o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_split_view frame]];
357 [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_split_view];
358 [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
361 [o_video_view setFrame: [o_split_view frame]];
362 [o_playlist_table setBorderType: NSNoBorder];
363 [o_sidebar_scrollview setBorderType: NSNoBorder];
366 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
367 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
368 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
369 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainSplitViewWillResizeSubviews:) name:NSSplitViewWillResizeSubviewsNotification object:o_split_view];
371 if (b_splitviewShouldBeHidden) {
372 [self hideSplitView];
373 i_lastSplitViewHeight = 300;
376 /* sanity check for the window size */
377 NSRect frame = [self frame];
378 NSSize screenSize = [[self screen] frame].size;
379 if (screenSize.width <= frame.size.width || screenSize.height <= frame.size.height) {
380 nativeVideoSize = screenSize;
384 /* update fs button to reflect state for next startup */
385 if (var_InheritBool(pl_Get(VLCIntf), "fullscreen"))
386 [o_controls_bar setFullscreenState:YES];
388 /* restore split view */
389 i_lastLeftSplitViewWidth = 200;
390 /* trick NSSplitView implementation, which pretends to know better than us */
391 if (!config_GetInt(VLCIntf, "macosx-show-sidebar"))
392 [self performSelector:@selector(toggleLeftSubSplitView) withObject:nil afterDelay:0.05];
396 #pragma mark appearance management
398 - (VLCMainWindowControlsBar *)controlsBar;
400 return (VLCMainWindowControlsBar *)o_controls_bar;
403 - (void)resizePlaylistAfterCollapse
406 plrect = [o_playlist_table frame];
407 plrect.size.height = i_lastSplitViewHeight - 20.0; // actual pl top bar height, which differs from its frame
408 [[o_playlist_table animator] setFrame: plrect];
410 NSRect rightSplitRect;
411 rightSplitRect = [o_right_split_view frame];
412 plrect = [o_dropzone_box frame];
413 plrect.origin.x = (rightSplitRect.size.width - plrect.size.width) / 2;
414 plrect.origin.y = (rightSplitRect.size.height - plrect.size.height) / 2;
415 [[o_dropzone_box animator] setFrame: plrect];
418 - (void)makeSplitViewVisible
420 if (b_dark_interface)
421 [self setContentMinSize: NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
423 [self setContentMinSize: NSMakeSize(604., 288.)];
425 NSRect old_frame = [self frame];
426 float newHeight = [self minSize].height;
427 if (old_frame.size.height < newHeight) {
428 NSRect new_frame = old_frame;
429 new_frame.origin.y = old_frame.origin.y + old_frame.size.height - newHeight;
430 new_frame.size.height = newHeight;
432 [[self animator] setFrame: new_frame display: YES animate: YES];
435 [o_video_view setHidden: YES];
436 [o_split_view setHidden: NO];
437 [self makeFirstResponder: nil];
441 - (void)makeSplitViewHidden
443 if (b_dark_interface)
444 [self setContentMinSize: NSMakeSize(604., f_min_video_height + [o_titlebar_view frame].size.height)];
446 [self setContentMinSize: NSMakeSize(604., f_min_video_height)];
448 [o_split_view setHidden: YES];
449 [o_video_view setHidden: NO];
451 if ([[o_video_view subviews] count] > 0)
452 [self makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
455 // only exception for an controls bar button action
456 - (IBAction)togglePlaylist:(id)sender
458 if (![self isVisible] && sender != nil) {
459 [self makeKeyAndOrderFront: sender];
463 BOOL b_activeVideo = [[VLCMain sharedInstance] activeVideoPlayback];
464 BOOL b_restored = NO;
466 // TODO: implement toggle playlist in this situation (triggerd via menu item).
467 // but for now we block this case, to avoid displaying only the half
468 if (b_nativeFullscreenMode && b_fullscreen && b_activeVideo && sender != nil)
471 if (b_dropzone_active && ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0) {
476 if (!(b_nativeFullscreenMode && b_fullscreen) && !b_splitview_removed && ((([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0 && b_activeVideo)
477 || (b_nonembedded && sender != nil)
478 || (!b_activeVideo && sender != nil)
479 || b_minimized_view))
480 [self hideSplitView];
482 if (b_splitview_removed) {
483 if (!b_nonembedded || (sender != nil && b_nonembedded))
484 [self showSplitView];
487 b_minimized_view = YES;
489 b_minimized_view = NO;
495 if (!b_nonembedded) {
496 if (([o_video_view isHidden] && b_activeVideo) || b_restored || (b_activeVideo && sender == nil))
497 [self makeSplitViewHidden];
499 [self makeSplitViewVisible];
501 [o_split_view setHidden: NO];
502 [o_playlist_table setHidden: NO];
503 [o_video_view setHidden: YES];
508 - (IBAction)dropzoneButtonAction:(id)sender
510 [[[VLCMain sharedInstance] open] openFileGeneric];
514 #pragma mark overwritten default functionality
516 - (void)windowResizedOrMoved:(NSNotification *)notification
518 [self saveFrameUsingName: [self frameAutosaveName]];
521 - (void)applicationWillTerminate:(NSNotification *)notification
523 config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
525 [self saveFrameUsingName: [self frameAutosaveName]];
529 - (void)someWindowWillClose:(NSNotification *)notification
531 id obj = [notification object];
533 if ([obj class] == [VLCVideoWindowCommon class] || [obj class] == [VLCDetachedVideoWindow class] || ([obj class] == [VLCMainWindow class] && !b_nonembedded)) {
534 if ([[VLCMain sharedInstance] activeVideoPlayback])
535 [[VLCCoreInteraction sharedInstance] stop];
539 - (void)someWindowWillMiniaturize:(NSNotification *)notification
541 if (config_GetInt(VLCIntf, "macosx-pause-minimized")) {
542 id obj = [notification object];
544 if ([obj class] == [VLCVideoWindowCommon class] || [obj class] == [VLCDetachedVideoWindow class] || ([obj class] == [VLCMainWindow class] && !b_nonembedded)) {
545 if ([[VLCMain sharedInstance] activeVideoPlayback])
546 [[VLCCoreInteraction sharedInstance] pause];
552 #pragma mark Update interface and respond to foreign events
555 b_dropzone_active = YES;
556 [o_right_split_view addSubview: o_dropzone_view positioned:NSWindowAbove relativeTo:o_playlist_table];
557 [o_dropzone_view setFrame: [o_playlist_table frame]];
558 [[o_playlist_table animator] setHidden:YES];
563 b_dropzone_active = NO;
564 [o_dropzone_view removeFromSuperview];
565 [[o_playlist_table animator] setHidden: NO];
568 - (void)hideSplitView
570 NSRect winrect = [self frame];
571 i_lastSplitViewHeight = [o_split_view frame].size.height;
572 winrect.size.height = winrect.size.height - i_lastSplitViewHeight;
573 winrect.origin.y = winrect.origin.y + i_lastSplitViewHeight;
574 [self setFrame: winrect display: YES animate: YES];
575 [self performSelector:@selector(hideDropZone) withObject:nil afterDelay:0.1];
576 if (b_dark_interface) {
577 [self setContentMinSize: NSMakeSize(604., [[o_controls_bar bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
578 [self setContentMaxSize: NSMakeSize(FLT_MAX, [[o_controls_bar bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
580 [self setContentMinSize: NSMakeSize(604., [[o_controls_bar bottomBarView] frame].size.height)];
581 [self setContentMaxSize: NSMakeSize(FLT_MAX, [[o_controls_bar bottomBarView] frame].size.height)];
584 b_splitview_removed = YES;
587 - (void)showSplitView
590 if (b_dark_interface)
591 [self setContentMinSize:NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)];
593 [self setContentMinSize:NSMakeSize(604., 288.)];
594 [self setContentMaxSize: NSMakeSize(FLT_MAX, FLT_MAX)];
597 winrect = [self frame];
598 winrect.size.height = winrect.size.height + i_lastSplitViewHeight;
599 winrect.origin.y = winrect.origin.y - i_lastSplitViewHeight;
600 [self setFrame: winrect display: YES animate: YES];
602 [self performSelector:@selector(resizePlaylistAfterCollapse) withObject: nil afterDelay:0.75];
604 b_splitview_removed = NO;
607 - (void)updateTimeSlider
609 [o_controls_bar updateTimeSlider];
610 [[self controlsBar] updatePosAndTimeInFSPanel:o_fspanel];
612 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateTimeSlider)];
617 input_thread_t * p_input;
618 p_input = pl_CurrentInput(VLCIntf);
621 char *format = var_InheritString(VLCIntf, "input-title-format");
622 char *formated = str_format_meta(pl_Get(VLCIntf), format);
624 aString = [NSString stringWithUTF8String:formated];
627 char *uri = input_item_GetURI(input_GetItem(p_input));
629 NSURL * o_url = [NSURL URLWithString: [NSString stringWithUTF8String: uri]];
630 if ([o_url isFileURL]) {
631 [self setRepresentedURL: o_url];
632 [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
633 [o_window setRepresentedURL:o_url];
636 [self setRepresentedURL: nil];
637 [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
638 [o_window setRepresentedURL:nil];
643 if ([aString isEqualToString:@""]) {
644 if ([o_url isFileURL])
645 aString = [[NSFileManager defaultManager] displayNameAtPath: [o_url path]];
647 aString = [o_url absoluteString];
650 if ([aString length] > 0) {
651 [self setTitle: aString];
652 [[[VLCMain sharedInstance] voutController] updateWindowsUsingBlock:^(VLCVideoWindowCommon *o_window) {
653 [o_window setTitle:aString];
656 [o_fspanel setStreamTitle: aString];
658 [self setTitle: _NS("VLC media player")];
659 [self setRepresentedURL: nil];
662 vlc_object_release(p_input);
664 [self setTitle: _NS("VLC media player")];
665 [self setRepresentedURL: nil];
671 [o_controls_bar updateControls];
672 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateControls)];
674 bool b_seekable = false;
676 playlist_t * p_playlist = pl_Get(VLCIntf);
677 input_thread_t * p_input = playlist_CurrentInput(p_playlist);
679 /* seekable streams */
680 b_seekable = var_GetBool(p_input, "can-seek");
682 vlc_object_release(p_input);
685 [self updateTimeSlider];
686 if ([o_fspanel respondsToSelector:@selector(setSeekable:)])
687 [o_fspanel setSeekable: b_seekable];
690 if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
695 [o_sidebar_view setNeedsDisplay:YES];
700 [o_controls_bar setPause];
701 [o_fspanel setPause];
703 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPause)];
708 [o_controls_bar setPlay];
711 [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPlay)];
715 - (void)updateVolumeSlider
717 [[self controlsBar] updateVolumeSlider];
718 [o_fspanel setVolumeLevel: [[VLCCoreInteraction sharedInstance] volume]];
722 #pragma mark Video Output handling
724 - (void)setVideoplayEnabled
726 BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback];
728 if (b_videoPlayback) {
730 frameBeforePlayback = [self frame];
732 if (!b_nonembedded && !b_fullscreen && frameBeforePlayback.size.width > 0 && frameBeforePlayback.size.height > 0)
733 [[self animator] setFrame:frameBeforePlayback display:YES];
735 // update fs button to reflect state for next startup
736 if (var_InheritBool(pl_Get(VLCIntf), "fullscreen")) {
737 [o_controls_bar setFullscreenState:YES];
740 [self makeFirstResponder: nil];
741 [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
743 // restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
744 [self setAlphaValue:1.0];
747 if (b_nativeFullscreenMode) {
748 if ([NSApp presentationOptions] & NSApplicationPresentationFullScreen)
749 [[o_controls_bar bottomBarView] setHidden: b_videoPlayback];
751 [[o_controls_bar bottomBarView] setHidden: NO];
752 if (b_videoPlayback && b_fullscreen)
753 [o_fspanel setActive: nil];
754 if (!b_videoPlayback)
755 [o_fspanel setNonActive: nil];
759 // Called automatically if window's acceptsMouseMovedEvents property is true
760 - (void)mouseMoved:(NSEvent *)theEvent
763 [self recreateHideMouseTimer];
765 [super mouseMoved: theEvent];
768 - (void)recreateHideMouseTimer
770 if (t_hide_mouse_timer != nil) {
771 [t_hide_mouse_timer invalidate];
772 [t_hide_mouse_timer release];
775 t_hide_mouse_timer = [NSTimer scheduledTimerWithTimeInterval:2
777 selector:@selector(hideMouseCursor:)
780 [t_hide_mouse_timer retain];
783 // NSTimer selectors require this function signature as per Apple's docs
784 - (void)hideMouseCursor:(NSTimer *)timer
786 [NSCursor setHiddenUntilMouseMoves: YES];
790 #pragma mark Lion native fullscreen handling
791 - (void)windowWillEnterFullScreen:(NSNotification *)notification
793 [super windowWillEnterFullScreen:notification];
795 // update split view frame after removing title bar
796 [o_split_view setFrame: [o_video_view frame]];
799 - (void)windowWillExitFullScreen:(NSNotification *)notification
801 [super windowWillExitFullScreen: notification];
803 // update split view frame after readding title bar
804 [o_split_view setFrame: [o_video_view frame]];
807 #pragma mark Fullscreen support
809 - (void)showFullscreenController
812 id currentWindow = [NSApp keyWindow];
813 if ([currentWindow respondsToSelector:@selector(hasActiveVideo)] && [currentWindow hasActiveVideo]) {
814 if ([currentWindow respondsToSelector:@selector(fullscreen)] && [currentWindow fullscreen]) {
816 if ([[VLCMain sharedInstance] activeVideoPlayback])
825 - (void)makeKeyAndOrderFront: (id)sender
828 * when we exit fullscreen and fade out, we may endup in
829 * having a window that is faded. We can't have it fade in unless we
832 if (!b_window_is_invisible) {
833 /* Make sure we don't do it too much */
834 [super makeKeyAndOrderFront: sender];
838 [super setAlphaValue:0.0f];
839 [super makeKeyAndOrderFront: sender];
841 NSMutableDictionary * dict = [[NSMutableDictionary alloc] initWithCapacity:2];
842 [dict setObject:self forKey:NSViewAnimationTargetKey];
843 [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
845 o_makekey_anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
848 [o_makekey_anim setAnimationBlockingMode: NSAnimationNonblocking];
849 [o_makekey_anim setDuration: 0.1];
850 [o_makekey_anim setFrameRate: 30];
851 [o_makekey_anim setDelegate: self];
853 [o_makekey_anim startAnimation];
854 b_window_is_invisible = NO;
856 /* fullscreenAnimation will be unlocked when animation ends */
860 #pragma mark split view delegate
861 - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
863 if (dividerIndex == 0)
869 - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex
871 if (dividerIndex == 0)
877 - (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview
879 return ([subview isEqual:o_left_split_view]);
882 - (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)subview
884 if ([subview isEqual:o_left_split_view])
889 - (void)mainSplitViewWillResizeSubviews:(id)object
891 i_lastLeftSplitViewWidth = [o_left_split_view frame].size.width;
892 config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
893 [[[VLCMain sharedInstance] mainMenu] updateSidebarMenuItem];
896 - (void)toggleLeftSubSplitView
898 [o_split_view adjustSubviews];
899 if ([o_split_view isSubviewCollapsed:o_left_split_view])
900 [o_split_view setPosition:i_lastLeftSplitViewWidth ofDividerAtIndex:0];
902 [o_split_view setPosition:[o_split_view minPossiblePositionOfDividerAtIndex:0] ofDividerAtIndex:0];
906 #pragma mark Side Bar Data handling
907 /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
908 - (NSUInteger)sourceList:(PXSourceList*)sourceList numberOfChildrenOfItem:(id)item
910 //Works the same way as the NSOutlineView data source: `nil` means a parent item
912 return [o_sidebaritems count];
914 return [[item children] count];
918 - (id)sourceList:(PXSourceList*)aSourceList child:(NSUInteger)index ofItem:(id)item
920 //Works the same way as the NSOutlineView data source: `nil` means a parent item
922 return [o_sidebaritems objectAtIndex:index];
924 return [[item children] objectAtIndex:index];
928 - (id)sourceList:(PXSourceList*)aSourceList objectValueForItem:(id)item
933 - (void)sourceList:(PXSourceList*)aSourceList setObjectValue:(id)object forItem:(id)item
935 [item setTitle:object];
938 - (BOOL)sourceList:(PXSourceList*)aSourceList isItemExpandable:(id)item
940 return [item hasChildren];
944 - (BOOL)sourceList:(PXSourceList*)aSourceList itemHasBadge:(id)item
946 if ([[item identifier] isEqualToString: @"playlist"] || [[item identifier] isEqualToString: @"medialibrary"])
949 return [item hasBadge];
953 - (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item
955 playlist_t * p_playlist = pl_Get(VLCIntf);
956 NSInteger i_playlist_size;
958 if ([[item identifier] isEqualToString: @"playlist"]) {
960 i_playlist_size = p_playlist->p_local_category->i_children;
963 return i_playlist_size;
965 if ([[item identifier] isEqualToString: @"medialibrary"]) {
967 i_playlist_size = p_playlist->p_ml_category->i_children;
970 return i_playlist_size;
973 return [item badgeValue];
977 - (BOOL)sourceList:(PXSourceList*)aSourceList itemHasIcon:(id)item
979 return [item hasIcon];
983 - (NSImage*)sourceList:(PXSourceList*)aSourceList iconForItem:(id)item
988 - (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
990 if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
993 if ([item sdtype] > 0)
995 m = [[NSMenu alloc] init];
996 playlist_t * p_playlist = pl_Get(VLCIntf);
997 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [[item identifier] UTF8String]);
999 [m addItemWithTitle:_NS("Enable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
1001 [m addItemWithTitle:_NS("Disable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
1002 [[m itemAtIndex:0] setRepresentedObject: [item identifier]];
1004 return [m autorelease];
1011 - (IBAction)sdmenuhandler:(id)sender
1013 NSString * identifier = [sender representedObject];
1014 if ([identifier length] > 0 && ![identifier isEqualToString:@"lua{sd='freebox',longname='Freebox TV'}"]) {
1015 playlist_t * p_playlist = pl_Get(VLCIntf);
1016 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [identifier UTF8String]);
1019 playlist_ServicesDiscoveryAdd(p_playlist, [identifier UTF8String]);
1021 playlist_ServicesDiscoveryRemove(p_playlist, [identifier UTF8String]);
1026 #pragma mark Side Bar Delegate Methods
1027 /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
1028 - (BOOL)sourceList:(PXSourceList*)aSourceList isGroupAlwaysExpanded:(id)group
1030 if ([[group identifier] isEqualToString:@"library"])
1036 - (void)sourceListSelectionDidChange:(NSNotification *)notification
1038 playlist_t * p_playlist = pl_Get(VLCIntf);
1040 NSIndexSet *selectedIndexes = [o_sidebar_view selectedRowIndexes];
1041 id item = [o_sidebar_view itemAtRow:[selectedIndexes firstIndex]];
1044 //Set the label text to represent the new selection
1045 if ([item sdtype] > -1 && [[item identifier] length] > 0) {
1046 BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded(p_playlist, [[item identifier] UTF8String]);
1048 playlist_ServicesDiscoveryAdd(p_playlist, [[item identifier] UTF8String]);
1051 [o_chosen_category_lbl setStringValue:[item title]];
1053 if ([[item identifier] isEqualToString:@"playlist"]) {
1054 [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_local_category];
1055 } else if ([[item identifier] isEqualToString:@"medialibrary"]) {
1056 [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_ml_category];
1058 playlist_item_t * pl_item;
1060 pl_item = playlist_ChildSearchName(p_playlist->p_root, [[item untranslatedTitle] UTF8String]);
1062 [[[VLCMain sharedInstance] playlist] setPlaylistRoot: pl_item];
1066 if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
1067 [self hideDropZone];
1069 [self showDropZone];
1072 if ([[item identifier] isEqualToString:@"podcast{longname=\"Podcasts\"}"])
1073 [self showPodcastControls];
1075 [self hidePodcastControls];
1078 - (NSDragOperation)sourceList:(PXSourceList *)aSourceList validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
1080 if ([[item identifier] isEqualToString:@"playlist"] || [[item identifier] isEqualToString:@"medialibrary"]) {
1081 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1082 if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] || [[o_pasteboard types] containsObject: NSFilenamesPboardType])
1083 return NSDragOperationGeneric;
1085 return NSDragOperationNone;
1088 - (BOOL)sourceList:(PXSourceList *)aSourceList acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
1090 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1092 playlist_t * p_playlist = pl_Get(VLCIntf);
1093 playlist_item_t *p_node;
1095 if ([[item identifier] isEqualToString:@"playlist"])
1096 p_node = p_playlist->p_local_category;
1098 p_node = p_playlist->p_ml_category;
1100 if ([[o_pasteboard types] containsObject: NSFilenamesPboardType]) {
1101 NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
1102 NSUInteger count = [o_values count];
1103 NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
1105 for(NSUInteger i = 0; i < count; i++) {
1106 NSDictionary *o_dic;
1107 char *psz_uri = vlc_path2uri([[o_values objectAtIndex:i] UTF8String], NULL);
1111 o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
1115 [o_array addObject: o_dic];
1118 [[[VLCMain sharedInstance] playlist] appendNodeArray:o_array inNode: p_node atPos:-1 enqueue:YES];
1121 else if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"]) {
1122 NSArray * array = [[[VLCMain sharedInstance] playlist] draggedItems];
1124 NSUInteger count = [array count];
1125 playlist_item_t * p_item = NULL;
1128 for(NSUInteger i = 0; i < count; i++) {
1129 p_item = [[array objectAtIndex:i] pointerValue];
1130 if (!p_item) continue;
1131 playlist_NodeAddCopy(p_playlist, p_item, p_node, PLAYLIST_END);
1140 - (id)sourceList:(PXSourceList *)aSourceList persistentObjectForItem:(id)item
1142 return [item identifier];
1145 - (id)sourceList:(PXSourceList *)aSourceList itemForPersistentObject:(id)object
1147 /* the following code assumes for sakes of simplicity that only the top level
1148 * items are allowed to have children */
1150 NSArray * array = [NSArray arrayWithArray: o_sidebaritems]; // read-only arrays are noticebly faster
1151 NSUInteger count = [array count];
1155 for (NSUInteger x = 0; x < count; x++) {
1156 id item = [array objectAtIndex: x]; // save one objc selector call
1157 if ([[item identifier] isEqualToString:object])
1165 #pragma mark Podcast
1167 - (IBAction)addPodcast:(id)sender
1169 [NSApp beginSheet:o_podcast_subscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil];
1172 - (IBAction)addPodcastWindowAction:(id)sender
1174 [o_podcast_subscribe_window orderOut:sender];
1175 [NSApp endSheet: o_podcast_subscribe_window];
1177 if (sender == o_podcast_subscribe_ok_btn && [[o_podcast_subscribe_url_fld stringValue] length] > 0) {
1178 NSMutableString * podcastConf = [[NSMutableString alloc] init];
1179 if (config_GetPsz(VLCIntf, "podcast-urls") != NULL)
1180 [podcastConf appendFormat:@"%s|", config_GetPsz(VLCIntf, "podcast-urls")];
1182 [podcastConf appendString: [o_podcast_subscribe_url_fld stringValue]];
1183 config_PutPsz(VLCIntf, "podcast-urls", [podcastConf UTF8String]);
1185 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name(VLCIntf->p_libvlc, "podcast");
1187 var_SetString(p_obj, "podcast-urls", [podcastConf UTF8String]);
1188 vlc_object_release(p_obj);
1190 [podcastConf release];
1194 - (IBAction)removePodcast:(id)sender
1196 if (config_GetPsz(VLCIntf, "podcast-urls") != NULL) {
1197 [o_podcast_unsubscribe_pop removeAllItems];
1198 [o_podcast_unsubscribe_pop addItemsWithTitles:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
1199 [NSApp beginSheet:o_podcast_unsubscribe_window modalForWindow:self modalDelegate:self didEndSelector:NULL contextInfo:nil];
1203 - (IBAction)removePodcastWindowAction:(id)sender
1205 [o_podcast_unsubscribe_window orderOut:sender];
1206 [NSApp endSheet: o_podcast_unsubscribe_window];
1208 if (sender == o_podcast_unsubscribe_ok_btn) {
1209 NSMutableArray * urls = [[NSMutableArray alloc] initWithArray:[[NSString stringWithUTF8String:config_GetPsz(VLCIntf, "podcast-urls")] componentsSeparatedByString:@"|"]];
1210 [urls removeObjectAtIndex: [o_podcast_unsubscribe_pop indexOfSelectedItem]];
1211 config_PutPsz(VLCIntf, "podcast-urls", [[urls componentsJoinedByString:@"|"] UTF8String]);
1214 vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name(VLCIntf->p_libvlc, "podcast");
1216 var_SetString(p_obj, "podcast-urls", config_GetPsz(VLCIntf, "podcast-urls"));
1217 vlc_object_release(p_obj);
1220 /* reload the podcast module, since it won't update its list when removing podcasts */
1221 playlist_t * p_playlist = pl_Get(VLCIntf);
1222 if (playlist_IsServicesDiscoveryLoaded(p_playlist, "podcast{longname=\"Podcasts\"}")) {
1223 playlist_ServicesDiscoveryRemove(p_playlist, "podcast{longname=\"Podcasts\"}");
1224 playlist_ServicesDiscoveryAdd(p_playlist, "podcast{longname=\"Podcasts\"}");
1225 [o_playlist_table reloadData];
1231 - (void)showPodcastControls
1233 NSRect podcastViewDimensions = [o_podcast_view frame];
1234 NSRect rightSplitRect = [o_right_split_view frame];
1235 NSRect playlistTableRect = [o_playlist_table frame];
1237 podcastViewDimensions.size.width = rightSplitRect.size.width;
1238 podcastViewDimensions.origin.x = podcastViewDimensions.origin.y = .0;
1239 [o_podcast_view setFrame:podcastViewDimensions];
1241 playlistTableRect.origin.y = playlistTableRect.origin.y + podcastViewDimensions.size.height;
1242 playlistTableRect.size.height = playlistTableRect.size.height - podcastViewDimensions.size.height;
1243 [o_playlist_table setFrame:playlistTableRect];
1244 [o_playlist_table setNeedsDisplay:YES];
1246 [o_right_split_view addSubview: o_podcast_view positioned: NSWindowAbove relativeTo: o_right_split_view];
1247 b_podcastView_displayed = YES;
1250 - (void)hidePodcastControls
1252 if (b_podcastView_displayed) {
1253 NSRect podcastViewDimensions = [o_podcast_view frame];
1254 NSRect playlistTableRect = [o_playlist_table frame];
1256 playlistTableRect.origin.y = playlistTableRect.origin.y - podcastViewDimensions.size.height;
1257 playlistTableRect.size.height = playlistTableRect.size.height + podcastViewDimensions.size.height;
1259 [o_podcast_view removeFromSuperviewWithoutNeedingDisplay];
1260 [o_playlist_table setFrame: playlistTableRect];
1261 b_podcastView_displayed = NO;
1267 @implementation VLCDetachedVideoWindow
1269 - (void)awakeFromNib
1271 // sets lion fullscreen behaviour
1272 [super awakeFromNib];
1273 [self setAcceptsMouseMovedEvents: YES];
1275 if (b_dark_interface) {
1276 [self setBackgroundColor: [NSColor clearColor]];
1278 [self setOpaque: NO];
1280 [self setHasShadow:NO];
1281 [self setHasShadow:YES];
1283 NSRect winrect = [self frame];
1284 CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
1286 [self setTitle: _NS("VLC media player")];
1287 [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)];
1288 [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: nil];
1291 [self setBackgroundColor: [NSColor blackColor]];
1294 NSRect videoViewRect = [[self contentView] bounds];
1295 if (b_dark_interface)
1296 videoViewRect.size.height -= [o_titlebar_view frame].size.height;
1297 CGFloat f_bottomBarHeight = [[[self controlsBar] bottomBarView] frame].size.height;
1298 videoViewRect.size.height -= f_bottomBarHeight;
1299 videoViewRect.origin.y = f_bottomBarHeight;
1300 [o_video_view setFrame: videoViewRect];
1302 if (b_dark_interface) {
1303 o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_video_view frame]];
1304 [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_video_view];
1305 [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
1307 [self setContentMinSize: NSMakeSize(363., f_min_video_height + [[[self controlsBar] bottomBarView] frame].size.height + [o_titlebar_view frame].size.height)];
1309 [self setContentMinSize: NSMakeSize(363., f_min_video_height + [[[self controlsBar] bottomBarView] frame].size.height)];
1315 if (b_dark_interface)
1316 [o_color_backdrop release];