Commit e93cace3 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: implemented accessibility code for the custom window buttons used in...

macosx: implemented accessibility code for the custom window buttons used in the black window style (close #6093)

based upon sample code by Peter Maurer - thanks so much!
parent f70cd93d
...@@ -21,16 +21,16 @@ ...@@ -21,16 +21,16 @@
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="21"/>
<integer value="4895"/>
<integer value="915"/>
<integer value="283"/>
<integer value="29"/>
<integer value="1617"/> <integer value="1617"/>
<integer value="2770"/> <integer value="2770"/>
<integer value="4722"/> <integer value="29"/>
<integer value="21"/>
<integer value="2730"/> <integer value="2730"/>
<integer value="4596"/> <integer value="4596"/>
<integer value="283"/>
<integer value="4850"/>
<integer value="915"/>
<integer value="4722"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
...@@ -4494,7 +4494,7 @@ LCAuLi4</string> ...@@ -4494,7 +4494,7 @@ LCAuLi4</string>
<string key="NSReuseIdentifierKey">_NS:610</string> <string key="NSReuseIdentifierKey">_NS:610</string>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="113847949"> <object class="NSButtonCell" key="NSCell" id="113847949">
<int key="NSCellFlags">67239424</int> <int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">134217728</int> <int key="NSCellFlags2">134217728</int>
<string key="NSContents"/> <string key="NSContents"/>
<reference key="NSSupport" ref="841513812"/> <reference key="NSSupport" ref="841513812"/>
...@@ -10934,12 +10934,16 @@ LCAuLi4</string> ...@@ -10934,12 +10934,16 @@ LCAuLi4</string>
<string>4846.IBPluginDependency</string> <string>4846.IBPluginDependency</string>
<string>4850.IBEditorWindowLastContentRect</string> <string>4850.IBEditorWindowLastContentRect</string>
<string>4850.IBPluginDependency</string> <string>4850.IBPluginDependency</string>
<string>4895.CustomClassName</string>
<string>4895.IBPluginDependency</string> <string>4895.IBPluginDependency</string>
<string>4895.IBViewBoundsToFrameTransform</string> <string>4895.IBViewBoundsToFrameTransform</string>
<string>4896.CustomClassName</string>
<string>4896.IBPluginDependency</string> <string>4896.IBPluginDependency</string>
<string>4896.IBViewBoundsToFrameTransform</string> <string>4896.IBViewBoundsToFrameTransform</string>
<string>4897.CustomClassName</string>
<string>4897.IBPluginDependency</string> <string>4897.IBPluginDependency</string>
<string>4897.IBViewBoundsToFrameTransform</string> <string>4897.IBViewBoundsToFrameTransform</string>
<string>4898.CustomClassName</string>
<string>4898.IBPluginDependency</string> <string>4898.IBPluginDependency</string>
<string>4898.IBViewBoundsToFrameTransform</string> <string>4898.IBViewBoundsToFrameTransform</string>
<string>4899.IBPluginDependency</string> <string>4899.IBPluginDependency</string>
...@@ -11769,18 +11773,22 @@ LCAuLi4</string> ...@@ -11769,18 +11773,22 @@ LCAuLi4</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{363, 734}, {400, 22}}</string> <string>{{363, 734}, {400, 22}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>VLCCustomWindowCloseButton</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABBAAAAwXAAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABBAAAAwXAAAA</bytes>
</object> </object>
<string>VLCCustomWindowMinimizeButton</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABB4AAAwXAAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABB4AAAwXAAAA</bytes>
</object> </object>
<string>VLCCustomWindowZoomButton</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABCQAAAwXAAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABCQAAAwXAAAA</bytes>
</object> </object>
<string>VLCCustomWindowFullscreenButton</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDv4AAwYAAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABDv4AAwYAAAA</bytes>
...@@ -14827,11 +14835,113 @@ LCAuLi4</string> ...@@ -14827,11 +14835,113 @@ LCAuLi4</string>
<string key="superclassName">NSView</string> <string key="superclassName">NSView</string>
<reference key="sourceIdentifier" ref="386911354"/> <reference key="sourceIdentifier" ref="386911354"/>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">VLCCustomWindowButtonPrototype</string>
<string key="superclassName">NSButton</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="672431580">
<string key="majorKey">IBDocumentRelativeSource</string>
<string key="minorKey">../../../../../modules/gui/macosx/MainWindowTitle.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCCustomWindowCloseButton</string>
<string key="superclassName">VLCCustomWindowButtonPrototype</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCCustomWindowFullscreenButton</string>
<string key="superclassName">VLCCustomWindowButtonPrototype</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCCustomWindowMinimizeButton</string>
<string key="superclassName">VLCCustomWindowButtonPrototype</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCCustomWindowZoomButton</string>
<string key="superclassName">VLCCustomWindowButtonPrototype</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">VLCMainWindowSplitView</string> <string key="className">VLCMainWindowSplitView</string>
<string key="superclassName">NSSplitView</string> <string key="superclassName">NSSplitView</string>
<reference key="sourceIdentifier" ref="386911354"/> <reference key="sourceIdentifier" ref="386911354"/>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">VLCMainWindowTitleView</string>
<string key="superclassName">VLCThreePartImageView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">buttonAction:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">buttonAction:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">buttonAction:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>o_fullscreen_btn</string>
<string>o_green_btn</string>
<string>o_red_btn</string>
<string>o_title_lbl</string>
<string>o_yellow_btn</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>o_fullscreen_btn</string>
<string>o_green_btn</string>
<string>o_red_btn</string>
<string>o_title_lbl</string>
<string>o_yellow_btn</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">o_fullscreen_btn</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_green_btn</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_red_btn</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_title_lbl</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_yellow_btn</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCResizeControl</string>
<string key="superclassName">NSImageView</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">VLCThreePartDropView</string> <string key="className">VLCThreePartDropView</string>
<string key="superclassName">VLCThreePartImageView</string> <string key="superclassName">VLCThreePartImageView</string>
...@@ -14847,6 +14957,11 @@ LCAuLi4</string> ...@@ -14847,6 +14957,11 @@ LCAuLi4</string>
<string key="superclassName">NSTextField</string> <string key="superclassName">NSTextField</string>
<reference key="sourceIdentifier" ref="386911354"/> <reference key="sourceIdentifier" ref="386911354"/>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">VLCWindowButtonCell</string>
<string key="superclassName">NSButtonCell</string>
<reference key="sourceIdentifier" ref="672431580"/>
</object>
</object> </object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
......
...@@ -79,6 +79,8 @@ extern OSErr UpdateSystemActivity(UInt8 activity); ...@@ -79,6 +79,8 @@ extern OSErr UpdateSystemActivity(UInt8 activity);
#pragma Fixes for OS X Snow Leopard (10.6) #pragma Fixes for OS X Snow Leopard (10.6)
#ifndef MAC_OS_X_VERSION_10_7 #ifndef MAC_OS_X_VERSION_10_7
extern NSString *const NSAccessibilityFullScreenButtonSubrole;
enum { enum {
NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7, NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8 NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
......
...@@ -72,3 +72,34 @@ ...@@ -72,3 +72,34 @@
{ {
} }
@end @end
@interface VLCCustomWindowButtonPrototype: NSButton
{
}
- (NSArray*)extendedAccessibilityAttributeNames: (NSArray*)theAttributeNames;
- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName;
- (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName;
@end
@interface VLCCustomWindowCloseButton: VLCCustomWindowButtonPrototype
{
}
@end
@interface VLCCustomWindowMinimizeButton: VLCCustomWindowButtonPrototype
{
}
@end
@interface VLCCustomWindowZoomButton: VLCCustomWindowButtonPrototype
{
}
@end
@interface VLCCustomWindowFullscreenButton : VLCCustomWindowButtonPrototype
{
}
@end
...@@ -258,6 +258,35 @@ ...@@ -258,6 +258,35 @@
[(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO]; [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO];
} }
/* accessibility stuff */
- (NSArray*)accessibilityAttributeNames {
NSArray *theAttributeNames = [super accessibilityAttributeNames];
id theControlView = [self controlView];
return ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeNames:)] ? [theControlView extendedAccessibilityAttributeNames: theAttributeNames] : theAttributeNames); // ask the cell's control view (i.e., the button) for additional attribute values
}
- (id)accessibilityAttributeValue: (NSString*)theAttributeName {
id theControlView = [self controlView];
if ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeValue:)]) {
id theValue = [theControlView extendedAccessibilityAttributeValue: theAttributeName];
if (theValue) {
return theValue; // if this is an extended attribute value we added, return that -- otherwise, fall back to super's implementation
}
}
return [super accessibilityAttributeValue: theAttributeName];
}
- (BOOL)accessibilityIsAttributeSettable: (NSString*)theAttributeName {
id theControlView = [self controlView];
if ([theControlView respondsToSelector: @selector(extendedAccessibilityIsAttributeSettable:)]) {
NSNumber *theValue = [theControlView extendedAccessibilityIsAttributeSettable: theAttributeName];
if (theValue) {
return [theValue boolValue]; // same basic strategy we use in -accessibilityAttributeValue:
}
}
return [super accessibilityIsAttributeSettable: theAttributeName];
}
@end @end
...@@ -335,3 +364,66 @@ ...@@ -335,3 +364,66 @@
} }
@end @end
/*****************************************************************************
* custom window buttons to support the accessibility stuff
*****************************************************************************/
@implementation VLCCustomWindowButtonPrototype
+ (Class)cellClass {
return [VLCWindowButtonCell class];
}
- (NSArray*)extendedAccessibilityAttributeNames: (NSArray*)theAttributeNames {
return ([theAttributeNames containsObject: NSAccessibilitySubroleAttribute] ? theAttributeNames : [theAttributeNames arrayByAddingObject: NSAccessibilitySubroleAttribute]); // run-of-the-mill button cells don't usually have a Subrole attribute, so we add that attribute
}
- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
return nil;
}
- (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName {
return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool: NO] : nil); // make the Subrole attribute we added non-settable
}
- (void)accessibilityPerformAction: (NSString*)theActionName {
if ([theActionName isEqualToString: NSAccessibilityPressAction]) {
if ([self isEnabled]) {
[self performClick: nil];
}
} else {
[super accessibilityPerformAction: theActionName];
}
}
@end
@implementation VLCCustomWindowCloseButton
- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityCloseButtonAttribute : nil);
}
@end
@implementation VLCCustomWindowMinimizeButton
- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityMinimizeButtonAttribute : nil);
}
@end
@implementation VLCCustomWindowZoomButton
- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityZoomButtonAttribute : nil);
}
@end
@implementation VLCCustomWindowFullscreenButton
- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityFullScreenButtonAttribute : nil);
}
@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