From c8f0f3b423b92d212d3b66510454d6c63105260d Mon Sep 17 00:00:00 2001 From: David Fuhrmann Date: Fri, 14 Sep 2012 19:55:13 +0200 Subject: [PATCH] macosx: deduplicate window accessibility code and move detached_titlebar_view stuff to detached window --- .../Resources/English.lproj/MainMenu.xib | 78 ++++++----- modules/gui/macosx/MainWindow.h | 4 - modules/gui/macosx/MainWindow.m | 128 +++--------------- modules/gui/macosx/Windows.h | 4 + modules/gui/macosx/Windows.m | 58 ++++++++ 5 files changed, 119 insertions(+), 153 deletions(-) diff --git a/extras/package/macosx/Resources/English.lproj/MainMenu.xib b/extras/package/macosx/Resources/English.lproj/MainMenu.xib index 3e2f002452..b9ddfa273b 100644 --- a/extras/package/macosx/Resources/English.lproj/MainMenu.xib +++ b/extras/package/macosx/Resources/English.lproj/MainMenu.xib @@ -8035,14 +8035,6 @@ LCAuLi4 5002 - - - o_detached_titlebar_view - - - - 5003 - o_detached_resize_view @@ -8579,6 +8571,14 @@ LCAuLi4 5334 + + + o_titlebar_view + + + + 5337 + @@ -13921,14 +13921,14 @@ LCAuLi4 - 5336 + 5337 YES ITSlider - NSSlider + VLCVolumeSliderCommon IBProjectSource ../../../modules/gui/macosx/misc.h @@ -14279,18 +14279,7 @@ LCAuLi4 VLCDetachedVideoWindow - NSWindow - - customZoom: - id - - - customZoom: - - customZoom: - id - - + VLCVideoWindowCommon IBProjectSource ../../../modules/gui/macosx/MainWindow.h @@ -15861,7 +15850,7 @@ LCAuLi4 VLCMainWindow - NSWindow + VLCVideoWindowCommon YES @@ -15870,7 +15859,6 @@ LCAuLi4 addPodcastWindowAction: backward: bwd: - customZoom: dropzoneButtonAction: effects: forward: @@ -15910,7 +15898,6 @@ LCAuLi4 id id id - id @@ -15921,7 +15908,6 @@ LCAuLi4 addPodcastWindowAction: backward: bwd: - customZoom: dropzoneButtonAction: effects: forward: @@ -15957,10 +15943,6 @@ LCAuLi4 bwd: id - - customZoom: - id - dropzoneButtonAction: id @@ -16089,7 +16071,6 @@ LCAuLi4 o_time_sld o_time_sld_background o_time_sld_fancygradient_view - o_titlebar_view o_topbar_view o_video_view o_volume_down_btn @@ -16163,7 +16144,6 @@ LCAuLi4 id id id - id @@ -16228,7 +16208,6 @@ LCAuLi4 o_time_sld o_time_sld_background o_time_sld_fancygradient_view - o_titlebar_view o_topbar_view o_video_view o_volume_down_btn @@ -16470,10 +16449,6 @@ LCAuLi4 o_time_sld_fancygradient_view id - - o_titlebar_view - id - o_topbar_view id @@ -16953,6 +16928,30 @@ LCAuLi4 NSTextField + + VLCVideoWindowCommon + VLCWindow + + o_titlebar_view + id + + + o_titlebar_view + + o_titlebar_view + id + + + + IBProjectSource + ../../../modules/gui/macosx/Windows.h + + + + VLCVolumeSliderCommon + NSSlider + + VLCVoutView NSView @@ -16961,6 +16960,11 @@ LCAuLi4 ../../../modules/gui/macosx/VideoView.h + + VLCWindow + NSWindow + + VLCWindowButtonCell NSButtonCell diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h index f34dc59167..82f5c63a4a 100644 --- a/modules/gui/macosx/MainWindow.h +++ b/modules/gui/macosx/MainWindow.h @@ -71,7 +71,6 @@ IBOutlet id o_dropzone_box; IBOutlet VLCFSPanel *o_fspanel; - IBOutlet id o_titlebar_view; IBOutlet id o_resize_view; IBOutlet id o_detached_resize_view; @@ -85,7 +84,6 @@ IBOutlet id o_detached_progress_bar; IBOutlet id o_detached_time_sld_fancygradient_view; IBOutlet id o_detached_bottombar_view; - IBOutlet id o_detached_titlebar_view; IBOutlet id o_detached_video_window; IBOutlet id o_podcast_view; @@ -187,7 +185,6 @@ - (IBAction)removePodcast:(id)sender; - (IBAction)removePodcastWindowAction:(id)sender; -- (void)setTitle:(NSString *)title; - (void)windowResizedOrMoved:(NSNotification *)notification; - (void)showDropZone; @@ -233,7 +230,6 @@ - (void)windowDidEnterFullScreen:(NSNotification *)notification; - (void)windowWillExitFullScreen:(NSNotification *)notification; -- (id)detachedTitlebarView; @end @interface VLCDetachedVideoWindow : VLCVideoWindowCommon diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m index a92877f15d..5c145a6c76 100644 --- a/modules/gui/macosx/MainWindow.m +++ b/modules/gui/macosx/MainWindow.m @@ -364,7 +364,7 @@ static VLCMainWindow *_o_sharedInstance = nil; // Set that here as IB seems to be buggy if (b_dark_interface) { [self setContentMinSize:NSMakeSize(604., 288. + [o_titlebar_view frame].size.height)]; - [o_detached_video_window setContentMinSize: NSMakeSize(363., f_min_video_height + [o_detached_bottombar_view frame].size.height + [o_detached_titlebar_view frame].size.height)]; + [o_detached_video_window setContentMinSize: NSMakeSize(363., f_min_video_height + [o_detached_bottombar_view frame].size.height + [o_titlebar_view frame].size.height)]; } else { [self setContentMinSize:NSMakeSize(604., 288.)]; [o_detached_video_window setContentMinSize: NSMakeSize(363., f_min_video_height + [o_detached_bottombar_view frame].size.height)]; @@ -410,7 +410,6 @@ static VLCMainWindow *_o_sharedInstance = nil; [o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay]; } else { [o_titlebar_view setFullscreenButtonHidden: YES]; - [o_detached_titlebar_view setFullscreenButtonHidden: YES]; } if (!OSX_SNOW_LEOPARD) { @@ -564,11 +563,6 @@ static VLCMainWindow *_o_sharedInstance = nil; [o_split_view setFrame: winrect]; [o_video_view setFrame: winrect]; - /* detached video window */ - winrect = [o_detached_video_window frame]; - [o_detached_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)]; - [[o_detached_video_window contentView] addSubview: o_detached_titlebar_view positioned: NSWindowAbove relativeTo: nil]; - o_color_backdrop = [[VLCColorView alloc] initWithFrame: [o_split_view frame]]; [[self contentView] addSubview: o_color_backdrop positioned: NSWindowBelow relativeTo: o_split_view]; [o_color_backdrop setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable]; @@ -1256,17 +1250,6 @@ static VLCMainWindow *_o_sharedInstance = nil; return YES; } -- (void)setTitle:(NSString *)title -{ - if (b_dark_interface) { - [o_titlebar_view setWindowTitle: title]; - [o_detached_titlebar_view setWindowTitle: title]; - } - if (b_nonembedded && [[VLCMain sharedInstance] activeVideoPlayback]) - [o_detached_video_window setTitle: title]; - [super setTitle: title]; -} - - (void)windowResizedOrMoved:(NSNotification *)notification { [self saveFrameUsingName: [self frameAutosaveName]]; @@ -1472,6 +1455,9 @@ static VLCMainWindow *_o_sharedInstance = nil; } [self setTitle: aString]; + if (b_nonembedded && [[VLCMain sharedInstance] activeVideoPlayback]) + [o_detached_video_window setTitle: aString]; + [o_fspanel setStreamTitle: aString]; vlc_object_release(p_input); } else { @@ -1692,7 +1678,7 @@ static VLCMainWindow *_o_sharedInstance = nil; videoFrame.size = [[o_detached_video_window contentView] frame].size; videoFrame.size.height -= [o_detached_bottombar_view frame].size.height; if (b_dark_interface) - videoFrame.size.height -= [o_detached_titlebar_view frame].size.height; + videoFrame.size.height -= [o_titlebar_view frame].size.height; videoFrame.origin.x = .0; videoFrame.origin.y = [o_detached_bottombar_view frame].size.height; @@ -2726,56 +2712,6 @@ static VLCMainWindow *_o_sharedInstance = nil; } } -#pragma mark - -#pragma mark Accessibility stuff - -- (NSArray *)accessibilityAttributeNames -{ - if (!b_dark_interface) - return [super accessibilityAttributeNames]; - - static NSMutableArray *attributes = nil; - if (attributes == nil) { - attributes = [[super accessibilityAttributeNames] mutableCopy]; - NSArray *appendAttributes = [NSArray arrayWithObjects: NSAccessibilitySubroleAttribute, - NSAccessibilityCloseButtonAttribute, - NSAccessibilityMinimizeButtonAttribute, - NSAccessibilityZoomButtonAttribute, - nil]; - - for(NSString *attribute in appendAttributes) { - if (![attributes containsObject:attribute]) - [attributes addObject:attribute]; - } - } - return attributes; -} - -- (id)accessibilityAttributeValue: (NSString*)o_attribute_name -{ - if (b_dark_interface) { - VLCMainWindowTitleView *o_tbv = o_titlebar_view; - - if ([o_attribute_name isEqualTo: NSAccessibilitySubroleAttribute]) - return NSAccessibilityStandardWindowSubrole; - - if ([o_attribute_name isEqualTo: NSAccessibilityCloseButtonAttribute]) - return [[o_tbv closeButton] cell]; - - if ([o_attribute_name isEqualTo: NSAccessibilityMinimizeButtonAttribute]) - return [[o_tbv minimizeButton] cell]; - - if ([o_attribute_name isEqualTo: NSAccessibilityZoomButtonAttribute]) - return [[o_tbv zoomButton] cell]; - } - - return [super accessibilityAttributeValue: o_attribute_name]; -} - -- (id)detachedTitlebarView -{ - return o_detached_titlebar_view; -} @end @implementation VLCDetachedVideoWindow @@ -2790,6 +2726,17 @@ static VLCMainWindow *_o_sharedInstance = nil; [self display]; [self setHasShadow:NO]; [self setHasShadow:YES]; + + NSRect winrect = [self frame]; + CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height; + + [self setTitle: _NS("VLC media player")]; + [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)]; + [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: nil]; + + // native fs not supported with detached view yet + [o_titlebar_view setFullscreenButtonHidden: YES]; + } } @@ -2803,47 +2750,4 @@ static VLCMainWindow *_o_sharedInstance = nil; return YES; } -- (NSArray *)accessibilityAttributeNames -{ - if (!b_dark_interface) - return [super accessibilityAttributeNames]; - - static NSMutableArray *attributes = nil; - if (attributes == nil) { - attributes = [[super accessibilityAttributeNames] mutableCopy]; - NSArray *appendAttributes = [NSArray arrayWithObjects: NSAccessibilitySubroleAttribute, - NSAccessibilityCloseButtonAttribute, - NSAccessibilityMinimizeButtonAttribute, - NSAccessibilityZoomButtonAttribute, - nil]; - - for(NSString *attribute in appendAttributes) { - if (![attributes containsObject:attribute]) - [attributes addObject:attribute]; - } - } - return attributes; -} - -- (id)accessibilityAttributeValue: (NSString*)o_attribute_name -{ - if (b_dark_interface) { - VLCMainWindowTitleView *o_tbv = [[VLCMainWindow sharedInstance] detachedTitlebarView]; - - if ([o_attribute_name isEqualTo: NSAccessibilitySubroleAttribute]) - return NSAccessibilityStandardWindowSubrole; - - if ([o_attribute_name isEqualTo: NSAccessibilityCloseButtonAttribute]) - return [[o_tbv closeButton] cell]; - - if ([o_attribute_name isEqualTo: NSAccessibilityMinimizeButtonAttribute]) - return [[o_tbv minimizeButton] cell]; - - if ([o_attribute_name isEqualTo: NSAccessibilityZoomButtonAttribute]) - return [[o_tbv zoomButton] cell]; - } - - return [super accessibilityAttributeValue: o_attribute_name]; -} - @end diff --git a/modules/gui/macosx/Windows.h b/modules/gui/macosx/Windows.h index 655658c7ae..2c5273fa3f 100644 --- a/modules/gui/macosx/Windows.h +++ b/modules/gui/macosx/Windows.h @@ -67,6 +67,10 @@ { NSRect previousSavedFrame; BOOL b_dark_interface; + + IBOutlet id o_titlebar_view; // only set in main or detached window } +- (void)setTitle:(NSString *)title; + @end \ No newline at end of file diff --git a/modules/gui/macosx/Windows.m b/modules/gui/macosx/Windows.m index 79e4b851d7..d3c81123f9 100644 --- a/modules/gui/macosx/Windows.m +++ b/modules/gui/macosx/Windows.m @@ -219,6 +219,9 @@ @implementation VLCVideoWindowCommon +#pragma mark - +#pragma mark Init + - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag { @@ -241,6 +244,17 @@ return self; } +- (void)setTitle:(NSString *)title +{ + if (b_dark_interface && o_titlebar_view) + [o_titlebar_view setWindowTitle: title]; + + [super setTitle: title]; +} + +#pragma mark - +#pragma mark zoom / minimize / close + - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { SEL s_menuAction = [menuItem action]; @@ -381,6 +395,50 @@ [self setFrame: maxRect display: YES animate: YES]; } +#pragma mark - +#pragma mark Accessibility stuff +- (NSArray *)accessibilityAttributeNames +{ + if (!b_dark_interface || !o_titlebar_view) + return [super accessibilityAttributeNames]; + + static NSMutableArray *attributes = nil; + if (attributes == nil) { + attributes = [[super accessibilityAttributeNames] mutableCopy]; + NSArray *appendAttributes = [NSArray arrayWithObjects: NSAccessibilitySubroleAttribute, + NSAccessibilityCloseButtonAttribute, + NSAccessibilityMinimizeButtonAttribute, + NSAccessibilityZoomButtonAttribute, + nil]; + + for(NSString *attribute in appendAttributes) { + if (![attributes containsObject:attribute]) + [attributes addObject:attribute]; + } + } + return attributes; +} + +- (id)accessibilityAttributeValue: (NSString*)o_attribute_name +{ + if (b_dark_interface && o_titlebar_view) { + VLCMainWindowTitleView *o_tbv = o_titlebar_view; + + if ([o_attribute_name isEqualTo: NSAccessibilitySubroleAttribute]) + return NSAccessibilityStandardWindowSubrole; + + if ([o_attribute_name isEqualTo: NSAccessibilityCloseButtonAttribute]) + return [[o_tbv closeButton] cell]; + + if ([o_attribute_name isEqualTo: NSAccessibilityMinimizeButtonAttribute]) + return [[o_tbv minimizeButton] cell]; + + if ([o_attribute_name isEqualTo: NSAccessibilityZoomButtonAttribute]) + return [[o_tbv zoomButton] cell]; + } + + return [super accessibilityAttributeValue: o_attribute_name]; +} @end -- 2.39.2