]> git.sesse.net Git - vlc/commitdiff
macosx: implemented accessibility code for the custom window buttons used in the...
authorFelix Paul Kühne <fkuehne@videolan.org>
Sun, 19 Feb 2012 19:58:40 +0000 (20:58 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sun, 19 Feb 2012 20:10:27 +0000 (21:10 +0100)
based upon sample code by Peter Maurer - thanks so much!

extras/package/macosx/Resources/English.lproj/MainMenu.xib
modules/gui/macosx/CompatibilityFixes.h
modules/gui/macosx/MainWindowTitle.h
modules/gui/macosx/MainWindowTitle.m

index af1782166a948d916ac34a097d98fa1f1e62b23d..c9f9400d63f4caa0282eda79d4b7a2978aff5bf7 100644 (file)
     </object>
     <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
       <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="2770"/>
-      <integer value="4722"/>
+      <integer value="29"/>
+      <integer value="21"/>
       <integer value="2730"/>
       <integer value="4596"/>
+      <integer value="283"/>
+      <integer value="4850"/>
+      <integer value="915"/>
+      <integer value="4722"/>
     </object>
     <object class="NSArray" key="IBDocument.PluginDependencies">
       <bool key="EncodedWithXMLCoder">YES</bool>
@@ -4494,7 +4494,7 @@ LCAuLi4</string>
             <string key="NSReuseIdentifierKey">_NS:610</string>
             <bool key="NSEnabled">YES</bool>
             <object class="NSButtonCell" key="NSCell" id="113847949">
-              <int key="NSCellFlags">67239424</int>
+              <int key="NSCellFlags">-2080244224</int>
               <int key="NSCellFlags2">134217728</int>
               <string key="NSContents"/>
               <reference key="NSSupport" ref="841513812"/>
@@ -10934,12 +10934,16 @@ LCAuLi4</string>
           <string>4846.IBPluginDependency</string>
           <string>4850.IBEditorWindowLastContentRect</string>
           <string>4850.IBPluginDependency</string>
+          <string>4895.CustomClassName</string>
           <string>4895.IBPluginDependency</string>
           <string>4895.IBViewBoundsToFrameTransform</string>
+          <string>4896.CustomClassName</string>
           <string>4896.IBPluginDependency</string>
           <string>4896.IBViewBoundsToFrameTransform</string>
+          <string>4897.CustomClassName</string>
           <string>4897.IBPluginDependency</string>
           <string>4897.IBViewBoundsToFrameTransform</string>
+          <string>4898.CustomClassName</string>
           <string>4898.IBPluginDependency</string>
           <string>4898.IBViewBoundsToFrameTransform</string>
           <string>4899.IBPluginDependency</string>
@@ -11769,18 +11773,22 @@ LCAuLi4</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <string>{{363, 734}, {400, 22}}</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+          <string>VLCCustomWindowCloseButton</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <object class="NSAffineTransform">
             <bytes key="NSTransformStruct">P4AAAL+AAABBAAAAwXAAAA</bytes>
           </object>
+          <string>VLCCustomWindowMinimizeButton</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <object class="NSAffineTransform">
             <bytes key="NSTransformStruct">P4AAAL+AAABB4AAAwXAAAA</bytes>
           </object>
+          <string>VLCCustomWindowZoomButton</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <object class="NSAffineTransform">
             <bytes key="NSTransformStruct">P4AAAL+AAABCQAAAwXAAAA</bytes>
           </object>
+          <string>VLCCustomWindowFullscreenButton</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <object class="NSAffineTransform">
             <bytes key="NSTransformStruct">P4AAAL+AAABDv4AAwYAAAA</bytes>
@@ -14827,11 +14835,113 @@ LCAuLi4</string>
           <string key="superclassName">NSView</string>
           <reference key="sourceIdentifier" ref="386911354"/>
         </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">
           <string key="className">VLCMainWindowSplitView</string>
           <string key="superclassName">NSSplitView</string>
           <reference key="sourceIdentifier" ref="386911354"/>
         </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">
           <string key="className">VLCThreePartDropView</string>
           <string key="superclassName">VLCThreePartImageView</string>
@@ -14847,6 +14957,11 @@ LCAuLi4</string>
           <string key="superclassName">NSTextField</string>
           <reference key="sourceIdentifier" ref="386911354"/>
         </object>
+        <object class="IBPartialClassDescription">
+          <string key="className">VLCWindowButtonCell</string>
+          <string key="superclassName">NSButtonCell</string>
+          <reference key="sourceIdentifier" ref="672431580"/>
+        </object>
       </object>
       <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
         <bool key="EncodedWithXMLCoder">YES</bool>
index 8b7e5411b809e0f30d330e0b5b86480e6544cca3..a41ae61840bd198268ac497dfa6d64fa0b4bb15e 100644 (file)
@@ -79,6 +79,8 @@ extern OSErr UpdateSystemActivity(UInt8 activity);
 #pragma Fixes for OS X Snow Leopard (10.6)
 
 #ifndef MAC_OS_X_VERSION_10_7
+extern NSString *const NSAccessibilityFullScreenButtonSubrole;
+
 enum {
     NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
     NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
index 0a453604363806fac793a9d6f790a38f740533cc..fb85ff5c3bf04400207b9040342028a17b249b5f 100644 (file)
 {
 }
 @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
index b5bfa976daccd3de7db6ae69e852d63507e4ba3a..9b0e6a2292724a507b598c4bd6e27bfa96d91a23 100644 (file)
         [(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
+
+/*****************************************************************************
+ * 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