diff options
author | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-12-09 21:10:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-09 21:10:18 +0300 |
commit | 0e3a84d98c8ffe24ff29a3c4ac83d24b824ab176 (patch) | |
tree | 9a36b5a47f73f4ad6fc9e9d271ecad4fa1c2951a /main/src | |
parent | 97d54a4e8fd4bbeb066be8d7b3ae905894e35a7f (diff) | |
parent | 79c8b1011379595dabbe9ee9b468d6bb2a7517e3 (diff) |
Merge pull request #9410 from mono/jstedfast-debugger-a11y-improvements
[Debugger] Various fixes to improve a11y
Diffstat (limited to 'main/src')
19 files changed, 72 insertions, 54 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs index 87683dd53f..8158421700 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs @@ -54,7 +54,7 @@ namespace MonoDevelop.Debugger.Viewers visualizers.Sort ((v1, v2) => string.Compare (v1.Name, v2.Name, StringComparison.CurrentCultureIgnoreCase)); buttons = new List<ToggleButton> (); - Gtk.Button defaultVis = null; + ToggleButton defaultVis = null; for (int i = 0; i < visualizers.Count; i++) { var button = new ToggleButton (); @@ -64,14 +64,15 @@ namespace MonoDevelop.Debugger.Viewers defaultVis = button; hbox1.PackStart (button, false, false, 0); buttons.Add (button); - button.CanFocus = false; button.Show (); } - if (defaultVis != null) - defaultVis.Click (); - else if (buttons.Count > 0) - buttons [0].Click (); + if (defaultVis == null) + defaultVis = buttons [0]; + + defaultVis.GrabFocus (); + SetToggleState (defaultVis, true); + UpdateVisualizer (defaultVis); if (val.IsReadOnly || !visualizers.Any (v => v.CanEdit (val))) { buttonCancel.Label = Gtk.Stock.Close; @@ -89,24 +90,23 @@ namespace MonoDevelop.Debugger.Viewers return base.OnKeyPressEvent (evnt); } - protected virtual void OnComboVisualizersChanged (object sender, EventArgs e) + void SetToggleState (ToggleButton button, bool value) + { + button.Toggled -= OnComboVisualizersChanged; + button.Active = value; + button.Toggled += OnComboVisualizersChanged; + } + + void UpdateVisualizer (ToggleButton button) { - var button = (ToggleButton)sender; - if (!button.Active) {//Prevent un-toggling - button.Toggled -= OnComboVisualizersChanged; - button.Active = true; - button.Toggled += OnComboVisualizersChanged; - return; - } if (currentWidget != null) mainBox.Remove (currentWidget); + foreach (var b in buttons) { - if (b != button && b.Active) { - b.Toggled -= OnComboVisualizersChanged; - b.Active = false; - b.Toggled += OnComboVisualizersChanged; - } + if (b != button && b.Active) + SetToggleState (b, false); } + currentVisualizer = visualizers [buttons.IndexOf (button)]; currentWidget = currentVisualizer.GetVisualizerWidget (value); buttonSave.Sensitive = currentVisualizer.CanEdit (value); @@ -114,6 +114,18 @@ namespace MonoDevelop.Debugger.Viewers currentWidget.Show (); } + protected virtual void OnComboVisualizersChanged (object sender, EventArgs e) + { + var button = (ToggleButton) sender; + + if (!button.Active) {//Prevent un-toggling + SetToggleState (button, true); + return; + } + + UpdateVisualizer (button); + } + protected virtual void OnSaveClicked (object sender, EventArgs e) { bool saved = false; diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs index b179e894b9..d3d2aacf06 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectCellViewBase.cs @@ -42,6 +42,7 @@ namespace MonoDevelop.Debugger { abstract class MacDebuggerObjectCellViewBase : NSTableCellView { + protected static readonly string[] SelectedStyle = { "sel" }; protected const int CompactImageSize = 12; protected const int RowCellSpacing = 2; protected const int ImageSize = 16; @@ -103,12 +104,12 @@ namespace MonoDevelop.Debugger get { return Node is LoadingObjectValueNode; } } - protected static NSImage GetImage (string name, Gtk.IconSize size, bool selected = false) + protected static NSImage GetImage (string name, Gtk.IconSize size, params string[] styles) { var icon = ImageService.GetIcon (name, size); - if (selected) - icon = icon.WithStyles ("sel"); + if (styles != null && styles.Length > 0) + icon = icon.WithStyles (styles); try { return icon.ToNSImage (); @@ -118,19 +119,9 @@ namespace MonoDevelop.Debugger } } - protected static NSImage GetImage (string name, Gtk.IconSize size, double alpha, bool selected = false) + protected static NSImage GetImage (string name, Gtk.IconSize size, bool selected = false) { - var icon = ImageService.GetIcon (name, size).WithAlpha (alpha); - - if (selected) - icon = icon.WithStyles ("sel"); - - try { - return icon.ToNSImage (); - } catch (Exception ex) { - Core.LoggingService.LogError ($"Failed to load '{name}' as an NSImage", ex); - return icon.ToBitmap (NSScreen.MainScreen.BackingScaleFactor).ToNSImage (); - } + return GetImage (name, size, selected ? SelectedStyle : null); } protected static NSImage GetImage (string name, int width, int height, bool selected = false) diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs index 21d85d89f5..63b1c60e32 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectNameView.cs @@ -380,6 +380,13 @@ namespace MonoDevelop.Debugger public void SetPreviewButtonIcon (PreviewButtonIcon icon) { + // When a11y is in use, always show an icon. + if (IdeServices.DesktopService.AccessibilityInUse && icon == PreviewButtonIcon.Hidden) { + var selected = Superview is NSTableRowView rowView && rowView.Selected; + + icon = selected ? PreviewButtonIcon.Selected : PreviewButtonIcon.Hover; + } + if (!previewIconVisible || icon == currentIcon) return; diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectPinView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectPinView.cs index 82209926a5..011162b647 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectPinView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValue/Mac/MacDebuggerObjectPinView.cs @@ -30,21 +30,19 @@ using AppKit; using MonoDevelop.Core; using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; namespace MonoDevelop.Debugger { class MacDebuggerObjectPinView : MacDebuggerObjectCellViewBase { - static readonly NSImage selectedUnpinnedImage = GetImage ("md-pin-up", Gtk.IconSize.Menu, true); - static readonly NSImage selectedPinnedImage = GetImage ("md-pin-down", Gtk.IconSize.Menu, true); - static readonly NSImage unpinnedImage = GetImage ("md-pin-up", Gtk.IconSize.Menu); - static readonly NSImage pinnedImage = GetImage ("md-pin-down", Gtk.IconSize.Menu); - - static readonly NSImage liveUpdateOnImage = GetImage ("md-live", Gtk.IconSize.Menu); - static readonly NSImage liveUpdateOffImage = GetImage ("md-live", Gtk.IconSize.Menu, 0.5); - static readonly NSImage none = GetImage ("md-empty", Gtk.IconSize.Menu); + static readonly NSImage EmptyImage = GetImage (Stock.Empty, Gtk.IconSize.Menu); + static readonly string [] ActiveSelectedStyle = { "active", "sel" }; + static readonly string [] ActiveStyle = { "active" }; + public const int MinWidth = MarginSize + 16 + MarginSize; public const int MaxWidth = MarginSize + 16 + RowCellSpacing + 16 + MarginSize; + bool disposed; bool pinned; @@ -53,7 +51,7 @@ namespace MonoDevelop.Debugger PinButton = new NSButton { TranslatesAutoresizingMaskIntoConstraints = false, BezelStyle = NSBezelStyle.Inline, - Image = none, + Image = EmptyImage, Bordered = false, }; PinButton.AccessibilityTitle = GettextCatalog.GetString ("Pin to the editor"); @@ -62,8 +60,8 @@ namespace MonoDevelop.Debugger LiveUpdateButton = new NSButton { TranslatesAutoresizingMaskIntoConstraints = false, + Image = GetImage ("md-live", Gtk.IconSize.Menu), BezelStyle = NSBezelStyle.Inline, - Image = liveUpdateOffImage, Bordered = false }; LiveUpdateButton.AccessibilityTitle = GettextCatalog.GetString ("Refresh value"); @@ -103,20 +101,28 @@ namespace MonoDevelop.Debugger var selected = Superview is NSTableRowView rowView && rowView.Selected; if (TreeView.PinnedWatch != null && Node.Parent == TreeView.Controller.Root) { - PinButton.Image = selected ? selectedPinnedImage : pinnedImage; + PinButton.Image = GetImage (Stock.PinDown, Gtk.IconSize.Menu, selected); pinned = true; } else { - PinButton.Image = none; + // When a11y is in use, always show an icon. + if (IdeServices.DesktopService.AccessibilityInUse) + PinButton.Image = GetImage (Stock.PinUp, Gtk.IconSize.Menu, selected); + else + PinButton.Image = EmptyImage; pinned = false; } if (pinned) { + string[] styles; + if (TreeView.PinnedWatch.LiveUpdate) - LiveUpdateButton.Image = liveUpdateOnImage; + styles = selected ? ActiveSelectedStyle : ActiveStyle; else - LiveUpdateButton.Image = liveUpdateOffImage; + styles = selected ? SelectedStyle : null; + + LiveUpdateButton.Image = GetImage ("md-live", Gtk.IconSize.Menu, styles); } else { - LiveUpdateButton.Image = none; + LiveUpdateButton.Image = EmptyImage; } } @@ -144,10 +150,11 @@ namespace MonoDevelop.Debugger var selected = Superview is NSTableRowView rowView && rowView.Selected; + // When a11y is in use, always show an icon. if (hover || IdeServices.DesktopService.AccessibilityInUse) { - PinButton.Image = selected ? selectedUnpinnedImage : unpinnedImage; + PinButton.Image = GetImage (Stock.PinUp, Gtk.IconSize.Menu, selected); } else { - PinButton.Image = none; + PinButton.Image = EmptyImage; } SetNeedsDisplayInRect (PinButton.Frame); diff --git a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs index 0d9e6c2395..f5f29f6b08 100644 --- a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs +++ b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs @@ -65,8 +65,6 @@ namespace MonoDevelop.HexEditor window = new ScrollView (hexEditor); await LoadContent (); - hexEditor.SetFocus (); - return new XwtControl (window); } diff --git a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs index 40c0f444db..74087bbc2a 100644 --- a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs +++ b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs @@ -135,7 +135,6 @@ namespace MonoDevelop.HexEditor var xwtScrollView = new Xwt.ScrollView (hexEditor); var scrollWidget = (Widget) Xwt.Toolkit.CurrentEngine.GetNativeWidget (xwtScrollView); SetHexEditorOptions (); - hexEditor.SetFocus (); return scrollWidget; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index ea344d65b9..9d85bab7a4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -2326,6 +2326,10 @@ <EmbeddedResource Include="icons\live-16~dark~sel%402x.png" /> <EmbeddedResource Include="icons\live-16~sel.png" /> <EmbeddedResource Include="icons\live-16~sel%402x.png" /> + <EmbeddedResource Include="icons\live-16~active.png" /> + <EmbeddedResource Include="icons\live-16~active%402x.png" /> + <EmbeddedResource Include="icons\live-16~active~dark.png" /> + <EmbeddedResource Include="icons\live-16~active~dark%402x.png" /> <EmbeddedResource Include="icons\status-instrumentation-16.png" /> <EmbeddedResource Include="icons\status-instrumentation-16%402x.png" /> <EmbeddedResource Include="icons\status-instrumentation-16~dark.png" /> diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16.png b/main/src/core/MonoDevelop.Ide/icons/live-16.png Binary files differindex 5062b7b0ef..4de5bb4cbe 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16@2x.png b/main/src/core/MonoDevelop.Ide/icons/live-16@2x.png Binary files differindex 5981bd69a5..40c90b8f4f 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~active.png b/main/src/core/MonoDevelop.Ide/icons/live-16~active.png Binary files differnew file mode 100644 index 0000000000..1bdf1ea3e9 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~active.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~active@2x.png b/main/src/core/MonoDevelop.Ide/icons/live-16~active@2x.png Binary files differnew file mode 100644 index 0000000000..b21098ea94 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~active@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~active~dark.png b/main/src/core/MonoDevelop.Ide/icons/live-16~active~dark.png Binary files differnew file mode 100644 index 0000000000..57eb64fe8c --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~active~dark.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~active~dark@2x.png b/main/src/core/MonoDevelop.Ide/icons/live-16~active~dark@2x.png Binary files differnew file mode 100644 index 0000000000..ff956acf21 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~active~dark@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~dark.png b/main/src/core/MonoDevelop.Ide/icons/live-16~dark.png Binary files differindex b2dcbca9cf..87e1169432 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16~dark.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~dark.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~dark@2x.png b/main/src/core/MonoDevelop.Ide/icons/live-16~dark@2x.png Binary files differindex d7b5fb0f53..8e6641dc49 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16~dark@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~dark@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel.png b/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel.png Binary files differindex 5ca6600be9..3ae97552ce 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel@2x.png Binary files differindex cf2965cf4d..f3c6340a68 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~dark~sel@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~sel.png b/main/src/core/MonoDevelop.Ide/icons/live-16~sel.png Binary files differindex 5ca6600be9..3ae97552ce 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16~sel.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/live-16~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/live-16~sel@2x.png Binary files differindex cf2965cf4d..f3c6340a68 100644 --- a/main/src/core/MonoDevelop.Ide/icons/live-16~sel@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/live-16~sel@2x.png |