[vlc-commits] macosx: improve accessibility support for black ui

David Fuhrmann git at videolan.org
Sat Jun 30 21:53:41 CEST 2012


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Sat Jun 30 18:33:31 2012 +0200| [73b270549bb441dd2f273f93d492239b459f1513] | committer: David Fuhrmann

macosx: improve accessibility support for black ui

The commit adds additional attributes to the black windows in order to correctly
link to the close / zoom / maximize buttons. This is needed to get some
tools using this api to work, in particular / e.g. jitouch.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73b270549bb441dd2f273f93d492239b459f1513
---

 modules/gui/macosx/MainWindow.h      |    1 +
 modules/gui/macosx/MainWindow.m      |   98 ++++++++++++++++++++++++++++++++++
 modules/gui/macosx/MainWindowTitle.h |    4 ++
 modules/gui/macosx/MainWindowTitle.m |   16 ++++++
 4 files changed, 119 insertions(+)

diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h
index b6e12ad..2cfe39a 100644
--- a/modules/gui/macosx/MainWindow.h
+++ b/modules/gui/macosx/MainWindow.h
@@ -206,6 +206,7 @@
 - (void)windowDidEnterFullScreen:(NSNotification *)notification;
 - (void)windowWillExitFullScreen:(NSNotification *)notification;
 
+- (id)detachedTitlebarView;
 @end
 
 @interface VLCDetachedVideoWindow : NSWindow
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 8411784..6615cd1 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -2750,6 +2750,59 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
     return 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
@@ -2960,4 +3013,49 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [self setFrame: maxRect display: YES animate: 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/MainWindowTitle.h b/modules/gui/macosx/MainWindowTitle.h
index 68e61c4..f3f8b11 100644
--- a/modules/gui/macosx/MainWindowTitle.h
+++ b/modules/gui/macosx/MainWindowTitle.h
@@ -56,6 +56,10 @@
 - (void)setWindowButtonOver:(BOOL)b_value;
 - (void)setWindowFullscreenButtonOver:(BOOL)b_value;
 
+- (NSButton*)closeButton;
+- (NSButton*)minimizeButton;
+- (NSButton*)zoomButton;
+
 @end
 
 @interface VLCWindowButtonCell : NSButtonCell
diff --git a/modules/gui/macosx/MainWindowTitle.m b/modules/gui/macosx/MainWindowTitle.m
index 39b44c9..a811c35 100644
--- a/modules/gui/macosx/MainWindowTitle.m
+++ b/modules/gui/macosx/MainWindowTitle.m
@@ -257,6 +257,22 @@
 
     [super mouseDown: event];
 }
+
+- (NSButton*)closeButton
+{
+    return o_red_btn;
+}
+
+- (NSButton*)minimizeButton
+{
+    return o_yellow_btn;
+}
+
+- (NSButton*)zoomButton
+{
+    return o_green_btn;
+}
+
 @end
 
 /*****************************************************************************



More information about the vlc-commits mailing list