Commit c8f0f3b4 authored by David Fuhrmann's avatar David Fuhrmann

macosx: deduplicate window accessibility code

and move detached_titlebar_view stuff to detached window
parent 721daa70
......@@ -8035,14 +8035,6 @@ LCAuLi4</string>
</object>
<int key="connectionID">5002</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_detached_titlebar_view</string>
<reference key="source" ref="498338108"/>
<reference key="destination" ref="117751361"/>
</object>
<int key="connectionID">5003</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_detached_resize_view</string>
......@@ -8579,6 +8571,14 @@ LCAuLi4</string>
</object>
<int key="connectionID">5334</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_titlebar_view</string>
<reference key="source" ref="429979276"/>
<reference key="destination" ref="117751361"/>
</object>
<int key="connectionID">5337</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
......@@ -13921,14 +13921,14 @@ LCAuLi4</string>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">5336</int>
<int key="maxID">5337</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">ITSlider</string>
<string key="superclassName">NSSlider</string>
<string key="superclassName">VLCVolumeSliderCommon</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="516086310">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../../modules/gui/macosx/misc.h</string>
......@@ -14279,18 +14279,7 @@ LCAuLi4</string>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCDetachedVideoWindow</string>
<string key="superclassName">NSWindow</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">customZoom:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">customZoom:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">customZoom:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<string key="superclassName">VLCVideoWindowCommon</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="348153990">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../../modules/gui/macosx/MainWindow.h</string>
......@@ -15861,7 +15850,7 @@ LCAuLi4</string>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCMainWindow</string>
<string key="superclassName">NSWindow</string>
<string key="superclassName">VLCVideoWindowCommon</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
......@@ -15870,7 +15859,6 @@ LCAuLi4</string>
<string>addPodcastWindowAction:</string>
<string>backward:</string>
<string>bwd:</string>
<string>customZoom:</string>
<string>dropzoneButtonAction:</string>
<string>effects:</string>
<string>forward:</string>
......@@ -15910,7 +15898,6 @@ LCAuLi4</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
......@@ -15921,7 +15908,6 @@ LCAuLi4</string>
<string>addPodcastWindowAction:</string>
<string>backward:</string>
<string>bwd:</string>
<string>customZoom:</string>
<string>dropzoneButtonAction:</string>
<string>effects:</string>
<string>forward:</string>
......@@ -15957,10 +15943,6 @@ LCAuLi4</string>
<string key="name">bwd:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">customZoom:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">dropzoneButtonAction:</string>
<string key="candidateClassName">id</string>
......@@ -16089,7 +16071,6 @@ LCAuLi4</string>
<string>o_time_sld</string>
<string>o_time_sld_background</string>
<string>o_time_sld_fancygradient_view</string>
<string>o_titlebar_view</string>
<string>o_topbar_view</string>
<string>o_video_view</string>
<string>o_volume_down_btn</string>
......@@ -16163,7 +16144,6 @@ LCAuLi4</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
......@@ -16228,7 +16208,6 @@ LCAuLi4</string>
<string>o_time_sld</string>
<string>o_time_sld_background</string>
<string>o_time_sld_fancygradient_view</string>
<string>o_titlebar_view</string>
<string>o_topbar_view</string>
<string>o_video_view</string>
<string>o_volume_down_btn</string>
......@@ -16470,10 +16449,6 @@ LCAuLi4</string>
<string key="name">o_time_sld_fancygradient_view</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_titlebar_view</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_topbar_view</string>
<string key="candidateClassName">id</string>
......@@ -16953,6 +16928,30 @@ LCAuLi4</string>
<string key="superclassName">NSTextField</string>
<reference key="sourceIdentifier" ref="516086310"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCVideoWindowCommon</string>
<string key="superclassName">VLCWindow</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">o_titlebar_view</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">o_titlebar_view</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">o_titlebar_view</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="615738430">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../../modules/gui/macosx/Windows.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCVolumeSliderCommon</string>
<string key="superclassName">NSSlider</string>
<reference key="sourceIdentifier" ref="516086310"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCVoutView</string>
<string key="superclassName">NSView</string>
......@@ -16961,6 +16960,11 @@ LCAuLi4</string>
<string key="minorKey">../../../modules/gui/macosx/VideoView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCWindow</string>
<string key="superclassName">NSWindow</string>
<reference key="sourceIdentifier" ref="615738430"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCWindowButtonCell</string>
<string key="superclassName">NSButtonCell</string>
......
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment