Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Abstracts IPropertyGrid and uses in Preferences to fix a11c issues #8937

Merged
merged 30 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5b5a83f
Adds an abstraction with IPropertyGrid
netonjm Oct 8, 2019
2055191
IPropertyPad based in IDisposable
netonjm Oct 8, 2019
5dfc17c
Sends the target instead the Object Editor
netonjm Oct 8, 2019
51da7ed
Includes more properties to configure in the abstraction
netonjm Oct 8, 2019
c029d80
Changes XmlFormattingPolicyPanelWidget to use wrapper instead gtk widget
netonjm Oct 8, 2019
cc26270
PropertyGridChanged is now correctly propagated in abstraction
netonjm Oct 15, 2019
119513a
Impoves current logic and adds some logic to handle better nullable e…
netonjm Oct 16, 2019
eb2a0cc
Uses default value sources
netonjm Oct 16, 2019
2f4ee83
Changes current PropertyPad to use PropertyGridWrapper in Preferences…
netonjm Oct 16, 2019
8261834
Adds IsEnabled hack to cover missing feature in proppy
netonjm Oct 16, 2019
a95249c
reordering property pad properties
netonjm Oct 16, 2019
01f38cd
Adds API to hide/show toolbar in proppy
netonjm Oct 16, 2019
447fa52
Sets Sensitive to true as value as default
netonjm Oct 17, 2019
534270f
Removes not used INameableObject
netonjm Oct 17, 2019
63e3805
Fixes background color in cases of header not visible
netonjm Oct 17, 2019
051bdc3
Merges Show/Hide methods into a single one
netonjm Oct 17, 2019
341366f
Registers as top window in MessageService every CustomRunDialog opened
netonjm Oct 23, 2019
93d42e9
Fixes current keydown hack to calculate nextkeyview
netonjm Oct 23, 2019
18307d4
Removes current internal keyloop hack in Toolbox to use new NextKeyVi…
netonjm Oct 23, 2019
7b034fe
Fixes call to KeyDown and sets corrects the selected view if was the …
netonjm Oct 24, 2019
95e8772
Renames ShowToolbar o ShowHeader for consistency with property
netonjm Oct 24, 2019
38f3276
Task.FromResult () to use generic
netonjm Oct 24, 2019
752a23f
Moves the logic handling keydown events to CommandManager instead Gtk…
netonjm Oct 25, 2019
d53aab0
Moves all the simulation in keydown into a method
netonjm Oct 26, 2019
fdf3b93
Adds a prototype simulation of default action behavior in basic types
netonjm Oct 26, 2019
1df6059
moves mac specific code to a mac compilation region code
netonjm Oct 26, 2019
a5ce42c
Removes some obsolete code in GtkNSViewHost
netonjm Oct 30, 2019
09febd9
Removes unnecessary allocation checking subviews
netonjm Oct 30, 2019
3904854
Fixes issue introduced in latest changes
netonjm Oct 30, 2019
a56b550
Don't saves values in cases where value doesn't change
netonjm Oct 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

open Gtk
open MonoDevelop.Core
open MonoDevelop.Components.PropertyGrid
open MonoDevelop.DesignerSupport

// Handwritten GUI, feel free to edit

Expand All @@ -21,7 +21,7 @@ type FSharpFormattingPolicyPanelWidget() =
let mutable hbox2 : Gtk.HBox = null
let mutable vbox4 : Gtk.VBox = null
let mutable tableScopes : Gtk.Table = null
let mutable propertyGrid : PropertyGrid = null
let mutable propertyGrid : PropertyGridWrapper = null

let getName format =
if format = policy.DefaultFormat then
Expand Down Expand Up @@ -125,12 +125,12 @@ type FSharpFormattingPolicyPanelWidget() =
w8.Expand <- false
w8.Fill <- false
// Container child vbox4.Gtk.Box+BoxChild
propertyGrid <- new PropertyGrid()
propertyGrid <- new PropertyGridWrapper ()
propertyGrid.Name <- "propertyGrid"
propertyGrid.ShowToolbar <- false
propertyGrid.ShowHelp <- false
vbox4.Add (propertyGrid)
let w9 = vbox4.[propertyGrid] :?> Gtk.Box.BoxChild
vbox4.Add (propertyGrid.Widget)
let w9 = vbox4.[propertyGrid.Widget] :?> Gtk.Box.BoxChild
w9.Position <- 2
hbox1.Add(vbox4)
let w10 = hbox1.[vbox4] :?> Gtk.Box.BoxChild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,13 @@ NSView GetNextFocusableViewForView (NSView view, int nextPositionInArray = 1)

public void AddViews (params NSView [] views) => viewsKeyLoopOrder.AddRange (views);

public void FocusNextView (NSView view, int nextPositionInArray = 1)
public void RecalculeNextResponderChain ()
{
var window = view?.Window;
if (window == null) {
return;
}
var nextView = GetNextFocusableViewForView (view, nextPositionInArray);
if (nextView != null) {
window.MakeFirstResponder (nextView);
} else {
//in case of no view found we follow the next logical view
window.MakeFirstResponder (nextPositionInArray >= 0 ? view.NextKeyView : view.PreviousKeyView);
NSView currentView = viewsKeyLoopOrder.FirstOrDefault ();
while (currentView != null) {
var nextView = GetNextFocusableViewForView (currentView, 1);
currentView.NextKeyView = nextView;
currentView = nextView;
}
}
}
Expand Down Expand Up @@ -125,15 +120,15 @@ class MacToolbox : NSView, IPropertyPadProvider, IToolboxConfiguration

NSTextField messageTextField;

KeyViewLoopDelegate keyViewLoopDelegate;

readonly KeyViewLoopDelegate keyViewLoopDelegate;
public MacToolbox (ToolboxService toolboxService, IPadWindow container)
{
WantsLayer = true;

keyViewLoopDelegate = new KeyViewLoopDelegate ();

verticalStackView = new NSStackView () {
verticalStackView = new UnfocusableStackView () {
Orientation = NSUserInterfaceLayoutOrientation.Vertical,
Alignment = NSLayoutAttribute.Leading,
Spacing = 0,
Expand Down Expand Up @@ -165,7 +160,6 @@ public MacToolbox (ToolboxService toolboxService, IPadWindow container)
filterEntry.AccessibilityTitle = GettextCatalog.GetString ("Search Toolbox");
filterEntry.AccessibilityHelp = GettextCatalog.GetString ("Enter a term to search for it in the toolbox");
filterEntry.Activated += FilterTextChanged;
filterEntry.CommandRaised += FilterEntry_CommandRaised;

horizontalStackView.AddArrangedSubview (filterEntry);

Expand All @@ -178,8 +172,7 @@ public MacToolbox (ToolboxService toolboxService, IPadWindow container)
catToggleButton.ToolTip = GettextCatalog.GetString ("Show categories");
catToggleButton.AccessibilityHelp = GettextCatalog.GetString ("Toggle to show categories");
catToggleButton.Activated += ToggleCategorisation;
catToggleButton.KeyDownPressed += OnKeyDownKeyLoop;


horizontalStackView.AddArrangedSubview (catToggleButton);

catToggleButton.SetContentCompressionResistancePriority ((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
Expand All @@ -191,8 +184,6 @@ public MacToolbox (ToolboxService toolboxService, IPadWindow container)
compactModeToggleButton.AccessibilityTitle = GettextCatalog.GetString ("Compact Layout");
compactModeToggleButton.AccessibilityHelp = GettextCatalog.GetString ("Toggle for toolbox to use compact layout");
compactModeToggleButton.Activated += ToggleCompactMode;
compactModeToggleButton.KeyDownPressed += OnKeyDownKeyLoop;


horizontalStackView.AddArrangedSubview (compactModeToggleButton);

Expand All @@ -205,7 +196,6 @@ public MacToolbox (ToolboxService toolboxService, IPadWindow container)
toolboxAddButton.AccessibilityHelp = GettextCatalog.GetString ("Add toolbox items");
toolboxAddButton.ToolTip = GettextCatalog.GetString ("Add toolbox items");
toolboxAddButton.Activated += ToolboxAddButton_Clicked;
toolboxAddButton.KeyDownPressed += OnKeyDownKeyLoop;

horizontalStackView.AddArrangedSubview (toolboxAddButton);

Expand All @@ -218,7 +208,7 @@ public MacToolbox (ToolboxService toolboxService, IPadWindow container)
AccessibilityTitle = GettextCatalog.GetString ("Toolbox Toolbar"),
};

var scrollView = new NSScrollView () {
var scrollView = new UnfocusableScrollview () {
HasVerticalScroller = true,
HasHorizontalScroller = false,
DocumentView = toolboxWidget
Expand Down Expand Up @@ -261,43 +251,9 @@ public MacToolbox (ToolboxService toolboxService, IPadWindow container)
AddSubview (messageTextField);

keyViewLoopDelegate.AddViews (filterEntry, catToggleButton, compactModeToggleButton, toolboxAddButton, toolboxWidget);
keyViewLoopDelegate.RecalculeNextResponderChain ();
}

#region InternalKeyLoop

private void FilterEntry_CommandRaised (object sender, NativeViews.SearchTextFieldCommand e)
{
switch (e) {
case NativeViews.SearchTextFieldCommand.InsertBacktab:
keyViewLoopDelegate.FocusNextView ((NSView)sender, -1);
break;
case NativeViews.SearchTextFieldCommand.InsertTab:
keyViewLoopDelegate.FocusNextView ((NSView)sender, 1);
break;
}
}

private void OnKeyDownKeyLoop (object sender, NativeViews.NSEventArgs args)
{
if (sender is NSView view && keyViewLoopDelegate.Contains (view)) {
if (args.Event.KeyCode == (int)KeyCodes.Tab) {

if ((int)args.Event.ModifierFlags == (int)KeyModifierFlag.None) {
keyViewLoopDelegate.FocusNextView (view, 1);
args.Handled = true;
return;
}
if ((int)args.Event.ModifierFlags == (int)KeyModifierFlag.Shift) {
keyViewLoopDelegate.FocusNextView (view, -1);
args.Handled = true;
return;
}
}
}
}

#endregion

NSIndexPath GetFirstVisibleItemIndexPath ()
{
for (int i = 0; i < toolboxWidget.CategoryVisibilities.Count; i++) {
Expand All @@ -323,7 +279,6 @@ private void ToolboxWidget_KeyDownPressed (object sender, NativeViews.NSEventArg
return;
}
}
OnKeyDownKeyLoop (sender, args);
}

void SetCustomMessage (string value)
Expand Down Expand Up @@ -482,7 +437,6 @@ internal void OnUpdateDeleteItem (CommandInfo info)

#region GUI population

readonly List<ToolboxWidgetCategory> items = new List<ToolboxWidgetCategory> ();
Dictionary<string, ToolboxWidgetCategory> categories = new Dictionary<string, ToolboxWidgetCategory> ();

void AddItems (IEnumerable<ItemToolboxNode> nodes)
Expand Down Expand Up @@ -534,6 +488,7 @@ public void Refresh ()

compactModeToggleButton.Hidden = !toolboxWidget.CanIconizeToolboxCategories;
compactModeToggleButton.InvalidateIntrinsicContentSize ();
keyViewLoopDelegate.RecalculeNextResponderChain ();

if (categories.Count == 0) {
SetCustomMessage (GettextCatalog.GetString ("There are no tools available for the current document."));
Expand All @@ -553,22 +508,13 @@ protected override void Dispose (bool disposing)
if (disposing) {
filterEntry.Activated -= FilterTextChanged;

filterEntry.CommandRaised -= FilterEntry_CommandRaised;

catToggleButton.Activated -= ToggleCategorisation;
catToggleButton.KeyDownPressed -= OnKeyDownKeyLoop;

compactModeToggleButton.Activated -= ToggleCompactMode;
compactModeToggleButton.KeyDownPressed -= OnKeyDownKeyLoop;

toolboxAddButton.Activated -= ToolboxAddButton_Clicked;
toolboxAddButton.KeyDownPressed -= OnKeyDownKeyLoop;

toolboxWidget.ActivateSelectedItem -= ToolboxWidget_ActivateSelectedItem;
toolboxWidget.MenuOpened -= ToolboxWidget_MenuOpened;
toolboxWidget.DragBegin -= ToolboxWidget_DragBegin;
toolboxWidget.RegionCollapsed -= FilterTextChanged;
toolboxWidget.KeyDownPressed -= OnKeyDownKeyLoop;

toolboxService.ToolboxContentsChanged -= ToolboxService_ToolboxContentsChanged;
toolboxService.ToolboxConsumerChanged -= ToolboxService_ToolboxConsumerChanged;
Expand Down Expand Up @@ -614,6 +560,7 @@ public bool AllowEditingComponents {
}
set {
toolboxAddButton.Hidden = !value;
keyViewLoopDelegate.RecalculeNextResponderChain ();
toolboxAddButton.InvalidateIntrinsicContentSize ();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,20 @@

namespace MonoDevelop.DesignerSupport.Toolbox.NativeViews
{
enum SearchTextFieldCommand
{
InsertTab,
InsertBacktab
}

class SearchTextField : NSSearchField, INSSearchFieldDelegate
class SearchTextField : NSSearchField
{
public event EventHandler Focused;
public event EventHandler<SearchTextFieldCommand> CommandRaised;

public SearchTextField ()
{
Delegate = this;

}

public override bool BecomeFirstResponder ()
{
Focused?.Invoke (this, EventArgs.Empty);
return base.BecomeFirstResponder ();
}

[Export ("control:textView:doCommandBySelector:")]
bool CommandBySelector (NSControl control, NSTextField field, ObjCRuntime.Selector sel)
{
switch (sel.Name) {
case "insertTab:": // down arrow
CommandRaised?.Invoke (this, SearchTextFieldCommand.InsertTab);
return true;

case "insertBacktab:": // up arrow
CommandRaised?.Invoke (this, SearchTextFieldCommand.InsertBacktab);
return true;
}
return false;
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public NSEventArgs (NSEvent nsEvent)

class ToggleButton : NSButton
{
public event EventHandler<NSEventArgs> KeyDownPressed;
public event EventHandler Focused;

public override CGSize IntrinsicContentSize => Hidden ? CGSize.Empty : new CGSize (25, 25);
Expand Down Expand Up @@ -78,12 +77,6 @@ public override void KeyDown (NSEvent theEvent)
if ((int)theEvent.ModifierFlags == (int) KeyModifierFlag.None && (theEvent.KeyCode == (int)KeyCodes.Enter || theEvent.KeyCode == (int)KeyCodes.Space)) {
PerformClick (this);
}

var args = new NSEventArgs (theEvent);
KeyDownPressed?.Invoke (this, args);

if (!args.Handled)
base.KeyDown (theEvent);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MonoDevelop.DesignerSupport
{
public interface IPropertyPad
public interface IPropertyPad : IDisposable
{
bool IsGridEditing { get; }

Expand Down
Loading