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

David Fuhrmann git at videolan.org
Tue Jul 3 17:44:52 CEST 2012


vlc/vlc-2.0 | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Sat Jun 30 18:33:31 2012 +0200| [2e6b25b00a3fe5d980ba8d16b90b525bf6e4cd48] | 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.
(cherry picked from commit 73b270549bb441dd2f273f93d492239b459f1513)

Signed-off-by: David Fuhrmann <david.fuhrmann at googlemail.com>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=2e6b25b00a3fe5d980ba8d16b90b525bf6e4cd48
---

 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 fe531e6..71f34ca 100644
--- a/modules/gui/macosx/MainWindow.h
+++ b/modules/gui/macosx/MainWindow.h
@@ -200,6 +200,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 aa60731..c90a26f 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -2548,6 +2548,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
@@ -2758,4 +2811,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 7de275d..2e3a4d1 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