Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCartBlanche <savagesoftware@gmail.com>2019-10-21 13:02:33 +0300
committerCartBlanche <savagesoftware@gmail.com>2019-10-24 13:57:25 +0300
commit97114ebcbde8c4668955d224946243ade502c239 (patch)
treec575b960ac72fc2fb1ef0fb99d7e9a89ff286197
parentdeefccfec69519207fac7e07e7b58341b96b20ca (diff)
[Mac] Initial Events implementation.dominique-Events
-rw-r--r--Xamarin.PropertyEditing.Mac/BaseOutlineList.cs84
-rw-r--r--Xamarin.PropertyEditing.Mac/BaseOutlineViewDataSource.cs43
-rw-r--r--Xamarin.PropertyEditing.Mac/BaseOutlineViewDelegate.cs23
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs3
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs85
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs20
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs30
-rw-r--r--Xamarin.PropertyEditing.Mac/EventList.cs44
-rw-r--r--Xamarin.PropertyEditing.Mac/EventTableDataSource.cs29
-rw-r--r--Xamarin.PropertyEditing.Mac/EventTableDelegate.cs53
-rw-r--r--Xamarin.PropertyEditing.Mac/FirstResponderOutlineView.cs40
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator.pngbin0 -> 135 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator@2x.pngbin0 -> 139 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark.pngbin0 -> 135 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark@2x.pngbin0 -> 139 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16.pngbin0 -> 462 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16@2x.pngbin0 -> 884 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark.pngbin0 -> 435 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark@2x.pngbin0 -> 795 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16.pngbin0 -> 264 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16@2x.pngbin0 -> 413 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark.pngbin0 -> 288 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark@2x.pngbin0 -> 481 bytes
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs130
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyList.cs125
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs51
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs39
27 files changed, 538 insertions, 261 deletions
diff --git a/Xamarin.PropertyEditing.Mac/BaseOutlineList.cs b/Xamarin.PropertyEditing.Mac/BaseOutlineList.cs
new file mode 100644
index 0000000..a1f9a34
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/BaseOutlineList.cs
@@ -0,0 +1,84 @@
+using System;
+using AppKit;
+using CoreGraphics;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal abstract class BaseOutlineList
+ : NSView
+ {
+ private IHostResourceProvider hostResources;
+ private readonly NSOutlineView outlineViewTable;
+ private readonly NSScrollView scrollView;
+ protected PanelViewModel viewModel;
+ public NSOutlineView OutlineViewTable => this.outlineViewTable;
+ protected BaseOutlineViewDataSource dataSource;
+
+ public IHostResourceProvider HostResourceProvider
+ {
+ get => this.hostResources;
+ set {
+ if (this.hostResources == value)
+ return;
+ if (value == null)
+ throw new ArgumentNullException (nameof (value), "Cannot set HostResourceProvider to null");
+
+ this.hostResources = value;
+ UpdateResourceProvider ();
+ }
+ }
+
+ public virtual PanelViewModel ViewModel {
+ get => this.viewModel;
+ set {
+ this.viewModel = value;
+ }
+ }
+
+ internal BaseOutlineList (IHostResourceProvider hostResources, string columnID)
+ {
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+
+ if (columnID == null)
+ throw new ArgumentNullException (nameof (columnID));
+
+ this.hostResources = hostResources;
+
+ this.outlineViewTable = new FirstResponderOutlineView {
+ IndentationPerLevel = 0,
+ SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.None,
+ HeaderView = null,
+ IntercellSpacing = new CGSize (0, 0)
+ };
+
+ var outlineViewColumn = new NSTableColumn (columnID);
+ this.outlineViewTable.AddColumn (outlineViewColumn);
+
+ this.scrollView = new NSScrollView {
+ AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable,
+ HasHorizontalScroller = false,
+ HasVerticalScroller = true,
+ };
+
+ this.scrollView.DocumentView = this.outlineViewTable;
+ AddSubview (this.scrollView);
+ }
+
+ public sealed override void ViewDidChangeEffectiveAppearance ()
+ {
+ base.ViewDidChangeEffectiveAppearance ();
+
+ UpdateResourceProvider ();
+ }
+
+ protected virtual void UpdateResourceProvider ()
+ {
+ if (this.outlineViewTable == null || this.hostResources == null)
+ return;
+
+ this.outlineViewTable.BackgroundColor = this.hostResources.GetNamedColor (NamedResources.PadBackgroundColor);
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac/BaseOutlineViewDataSource.cs b/Xamarin.PropertyEditing.Mac/BaseOutlineViewDataSource.cs
new file mode 100644
index 0000000..2657222
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/BaseOutlineViewDataSource.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using AppKit;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class BaseOutlineViewDataSource
+ : NSOutlineViewDataSource
+ {
+ internal bool Filtering => !string.IsNullOrEmpty (DataContext.FilterText);
+ internal PanelViewModel DataContext { get; }
+
+ internal Dictionary<object, NSObjectFacade> GroupFacades { get; }
+
+ internal BaseOutlineViewDataSource (PanelViewModel panelViewModel)
+ {
+ if (panelViewModel == null)
+ throw new ArgumentNullException (nameof (panelViewModel));
+
+ DataContext = panelViewModel;
+ GroupFacades = new Dictionary<object, NSObjectFacade> ();
+ }
+
+ internal bool TryGetFacade (object element, out NSObjectFacade facade)
+ {
+ return GroupFacades.TryGetValue (element, out facade);
+ }
+
+ internal NSObjectFacade GetFacade (object element)
+ {
+ NSObjectFacade facade;
+ if (element is PanelGroupViewModel) {
+ if (!GroupFacades.TryGetValue (element, out facade)) {
+ GroupFacades[element] = facade = new NSObjectFacade (element);
+ }
+ } else
+ facade = new NSObjectFacade (element);
+
+ return facade;
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/BaseOutlineViewDelegate.cs b/Xamarin.PropertyEditing.Mac/BaseOutlineViewDelegate.cs
new file mode 100644
index 0000000..63aef93
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/BaseOutlineViewDelegate.cs
@@ -0,0 +1,23 @@
+using System;
+using AppKit;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class BaseOutlineViewDelegate
+ : NSOutlineViewDelegate
+ {
+ internal IHostResourceProvider HostResources { get; }
+ internal BaseOutlineViewDataSource DataSource { get; }
+
+ public BaseOutlineViewDelegate (IHostResourceProvider hostResources, BaseOutlineViewDataSource dataSource)
+ {
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+ if (dataSource == null)
+ throw new ArgumentNullException (nameof (dataSource));
+
+ HostResources = hostResources;
+ DataSource = dataSource;
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs
index 27297e3..c464205 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs
@@ -108,8 +108,7 @@ namespace Xamarin.PropertyEditing.Mac
controlsBorder.AddSubview (addBorder);
controlsBorder.AddSubview (removeBorder);
- this.propertyList = new PropertyList {
- HostResourceProvider = hostResources,
+ this.propertyList = new PropertyList (hostResources, PropertyEditorPanel.PropertyEditorColId) {
ShowHeader = false,
};
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
index c621392..82acd29 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs
@@ -40,17 +40,11 @@ namespace Xamarin.PropertyEditing.Mac
}
}
- public PropertyButton (IHostResourceProvider hostResources)
+ public PropertyButton (IHostResourceProvider hostResources) : base (hostResources, "pe-property-button-default-mac-10")
{
- if (hostResources == null)
- throw new ArgumentNullException (nameof (hostResources));
-
- this.hostResources = hostResources;
-
AccessibilityTitle = Properties.Resources.AccessibilityPropertiesButton;
AccessibilityHelp = Properties.Resources.AccessibilityPropertiesButtonDescription;
Enabled = true;
- Image = this.hostResources.GetNamedImage ("pe-property-button-default-mac-10");
ImageScaling = NSImageScale.None;
ToolTip = Properties.Resources.Default;
@@ -69,20 +63,11 @@ namespace Xamarin.PropertyEditing.Mac
AppearanceChanged ();
}
- public sealed override void ViewDidChangeEffectiveAppearance ()
- {
- base.ViewDidChangeEffectiveAppearance ();
-
- AppearanceChanged ();
- }
-
- private void AppearanceChanged ()
+ protected override void AppearanceChanged ()
{
UpdateImage ();
}
- private readonly IHostResourceProvider hostResources;
-
private void PopUpContextMenu ()
{
if (this.popUpContextMenu == null) {
@@ -175,34 +160,34 @@ namespace Xamarin.PropertyEditing.Mac
if (this.viewModel != null) {
switch (this.viewModel.ValueSource) {
- case ValueSource.Binding:
- Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-bound-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-bound-mac-10");
- break;
-
- case ValueSource.Default:
- Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-default-mac-10");
- break;
-
- case ValueSource.Local:
- Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-local-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-local-mac-10");
- break;
-
- case ValueSource.Inherited:
- Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-10");
- break;
-
- case ValueSource.Resource:
- Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-10");
- break;
-
- case ValueSource.Unset:
- Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-default-mac-10");
- break;
-
- default:
- // To Handle ValueSource.DefaultStyle, ValueSource.Style etc.
- Image = null;
- break;
+ case ValueSource.Binding:
+ Image = focused ? HostResources.GetNamedImage ("pe-property-button-bound-mac-active-10") : HostResources.GetNamedImage ("pe-property-button-bound-mac-10");
+ break;
+
+ case ValueSource.Default:
+ Image = focused ? HostResources.GetNamedImage ("pe-property-button-default-mac-active-10") : HostResources.GetNamedImage ("pe-property-button-default-mac-10");
+ break;
+
+ case ValueSource.Local:
+ Image = focused ? HostResources.GetNamedImage ("pe-property-button-local-mac-active-10") : HostResources.GetNamedImage ("pe-property-button-local-mac-10");
+ break;
+
+ case ValueSource.Inherited:
+ Image = focused ? HostResources.GetNamedImage ("pe-property-button-inherited-mac-active-10") : HostResources.GetNamedImage ("pe-property-button-inherited-mac-10");
+ break;
+
+ case ValueSource.Resource:
+ Image = focused ? HostResources.GetNamedImage ("pe-property-button-inherited-mac-active-10") : HostResources.GetNamedImage ("pe-property-button-inherited-mac-10");
+ break;
+
+ case ValueSource.Unset:
+ Image = focused ? HostResources.GetNamedImage ("pe-property-button-default-mac-active-10") : HostResources.GetNamedImage ("pe-property-button-default-mac-10");
+ break;
+
+ default:
+ // To Handle ValueSource.DefaultStyle, ValueSource.Style etc.
+ Image = null;
+ break;
}
}
}
@@ -252,11 +237,11 @@ namespace Xamarin.PropertyEditing.Mac
private void OnCustomExpression (object sender, EventArgs e)
{
- var customExpressionView = new CustomExpressionView (this.hostResources, viewModel) {
+ var customExpressionView = new CustomExpressionView (this.HostResources, viewModel) {
Appearance = EffectiveAppearance
};
- var customExpressionPopOver = new AutoClosePopOver (this.hostResources, EffectiveAppearance) {
+ var customExpressionPopOver = new AutoClosePopOver (this.HostResources, EffectiveAppearance) {
CloseOnEnter = false,
ContentViewController = new NSViewController (null, null) { View = customExpressionView },
};
@@ -268,11 +253,11 @@ namespace Xamarin.PropertyEditing.Mac
private void OnResourceRequested (object sender, EventArgs e)
{
- var requestResourceView = new RequestResourceView (this.hostResources, this.viewModel) {
+ var requestResourceView = new RequestResourceView (this.HostResources, this.viewModel) {
Appearance = EffectiveAppearance
};
- var resourceSelectorPopOver = new AutoClosePopOver (this.hostResources, EffectiveAppearance) {
+ var resourceSelectorPopOver = new AutoClosePopOver (this.HostResources, EffectiveAppearance) {
ContentViewController = new NSViewController (null, null) { View = requestResourceView },
};
@@ -283,7 +268,7 @@ namespace Xamarin.PropertyEditing.Mac
private void OnBindingRequested (object sender, CreateBindingRequestedEventArgs e)
{
- var bindingEditorWindow = new BindingEditorWindow (this.hostResources, this.viewModel) {
+ var bindingEditorWindow = new BindingEditorWindow (this.HostResources, this.viewModel) {
Appearance = EffectiveAppearance,
};
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs
index 2b82a62..5a55498 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs
@@ -19,12 +19,8 @@ namespace Xamarin.PropertyEditing.Mac
return base.HitTest (aPoint);
}
- public SpinnerButton (IHostResourceProvider hostResource, bool isUp)
+ public SpinnerButton (IHostResourceProvider hostResource, bool isUp) : base (hostResource, "") // Blank because it is set up before AppearanceChanged is called
{
- if (hostResource == null)
- throw new ArgumentNullException (nameof (hostResource));
-
- this.hostResources = hostResource;
this.imageBase += (isUp) ? "up" : "down";
AppearanceChanged ();
@@ -42,22 +38,14 @@ namespace Xamarin.PropertyEditing.Mac
UpdateImage ();
}
- public sealed override void ViewDidChangeEffectiveAppearance ()
- {
- base.ViewDidChangeEffectiveAppearance ();
-
- AppearanceChanged ();
- }
-
- private void AppearanceChanged ()
+ protected override void AppearanceChanged ()
{
- this.image = this.hostResources.GetNamedImage (this.imageBase);
- this.mouseOverImage = this.hostResources.GetNamedImage (this.imageBase + "-focus-blue");
+ this.image = HostResources.GetNamedImage (this.imageBase);
+ this.mouseOverImage = HostResources.GetNamedImage (this.imageBase + "-focus-blue");
UpdateImage ();
}
- private readonly IHostResourceProvider hostResources;
private bool isMouseOver;
private string imageBase = "pe-stepper-";
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs
index e00482d..0316820 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs
@@ -3,17 +3,30 @@ using AppKit;
namespace Xamarin.PropertyEditing.Mac
{
- public abstract class UnfocusableButton : NSImageView
+ public class UnfocusableButton : NSImageView
{
public event EventHandler OnMouseEntered;
public event EventHandler OnMouseExited;
public event EventHandler OnMouseLeftDown;
public event EventHandler OnMouseRightDown;
- NSTrackingArea trackingArea;
+ private NSTrackingArea trackingArea;
- public UnfocusableButton ()
+ internal IHostResourceProvider HostResources { get; }
+
+ private readonly string imageName;
+
+ internal UnfocusableButton (IHostResourceProvider hostResources, string imageName)
{
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+
+ if (imageName == null)
+ throw new ArgumentNullException (nameof (imageName));
+
+ HostResources = hostResources;
+ this.imageName = imageName;
+
Enabled = true;
ImageScaling = NSImageScale.AxesIndependently;
}
@@ -62,6 +75,13 @@ namespace Xamarin.PropertyEditing.Mac
AddTrackingArea (trackingArea);
}
}
+
+ public sealed override void ViewDidChangeEffectiveAppearance ()
+ {
+ base.ViewDidChangeEffectiveAppearance ();
+
+ AppearanceChanged ();
+ }
#endregion
@@ -86,6 +106,10 @@ namespace Xamarin.PropertyEditing.Mac
OnMouseRightDown?.Invoke (this, EventArgs.Empty);
}
+ protected virtual void AppearanceChanged ()
+ {
+ Image = HostResources.GetNamedImage (this.imageName);
+ }
#endregion
}
}
diff --git a/Xamarin.PropertyEditing.Mac/EventList.cs b/Xamarin.PropertyEditing.Mac/EventList.cs
new file mode 100644
index 0000000..dae5a63
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/EventList.cs
@@ -0,0 +1,44 @@
+using System;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class EventList
+ : BaseOutlineList
+ {
+ public EventList (IHostResourceProvider hostResources, string columnID) : base (hostResources, columnID)
+ {
+ }
+
+ public override PanelViewModel ViewModel
+ {
+ set {
+ if (this.viewModel != null) {
+ OutlineViewTable.Delegate = null;
+ OutlineViewTable.DataSource = null;
+ }
+
+ this.viewModel = value;
+
+ if (this.viewModel != null) {
+ this.dataSource = new EventTableDataSource (this.viewModel);
+ OutlineViewTable.Delegate = new EventTableDelegate (HostResourceProvider, this.dataSource);
+ OutlineViewTable.DataSource = this.dataSource;
+ }
+ }
+ }
+
+ protected override void UpdateResourceProvider ()
+ {
+ base.UpdateResourceProvider ();
+
+ if (OutlineViewTable.Delegate == null)
+ OutlineViewTable.Delegate = new EventTableDelegate (HostResourceProvider, this.dataSource);
+ }
+
+ internal void ReloadDate ()
+ {
+ OutlineViewTable.ReloadData ();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac/EventTableDataSource.cs b/Xamarin.PropertyEditing.Mac/EventTableDataSource.cs
new file mode 100644
index 0000000..2255257
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/EventTableDataSource.cs
@@ -0,0 +1,29 @@
+using System;
+using AppKit;
+using Foundation;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class EventTableDataSource : BaseOutlineViewDataSource
+ {
+ public EventTableDataSource (PanelViewModel panelVm) : base (panelVm)
+ {
+ }
+
+ public override nint GetChildrenCount (NSOutlineView outlineView, NSObject item)
+ {
+ return DataContext.Events.Count;
+ }
+
+ public override NSObject GetChild (NSOutlineView outlineView, nint childIndex, NSObject item)
+ {
+ return GetFacade (DataContext.Events.ElementAt ((int)childIndex));
+ }
+
+ public override bool ItemExpandable (NSOutlineView outlineView, NSObject item)
+ {
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac/EventTableDelegate.cs b/Xamarin.PropertyEditing.Mac/EventTableDelegate.cs
new file mode 100644
index 0000000..15d080a
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/EventTableDelegate.cs
@@ -0,0 +1,53 @@
+using System;
+using AppKit;
+using Foundation;
+using Xamarin.PropertyEditing.ViewModels;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class EventTableDelegate : BaseOutlineViewDelegate
+ {
+ public const string EventIdentifier = "EventContainer";
+
+ public EventTableDelegate (IHostResourceProvider hostResources, BaseOutlineViewDataSource dataSource) : base (hostResources, dataSource)
+ {
+ }
+
+ public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
+ {
+ if (item is NSObjectFacade facade) {
+ if (facade.Target is EventViewModel eventViewModel) {
+ var viewContainer = (NSView)outlineView.MakeView (EventIdentifier, this);
+ if (viewContainer == null) {
+ viewContainer = new NSView {
+ Identifier = EventIdentifier,
+ };
+
+ var title = new UnfocusableTextField {
+ Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultDescriptionLabelFontSize),
+ TranslatesAutoresizingMaskIntoConstraints = false,
+ StringValue = eventViewModel.Name,
+ };
+ viewContainer.AddSubview (title);
+
+ viewContainer.AddConstraints (new[] {
+ NSLayoutConstraint.Create (title, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, viewContainer, NSLayoutAttribute.CenterY, 1, 0),
+ NSLayoutConstraint.Create (title, NSLayoutAttribute.Left, NSLayoutRelation.Equal, viewContainer, NSLayoutAttribute.Left, 1f, 0f),
+ NSLayoutConstraint.Create (title, NSLayoutAttribute.Right, NSLayoutRelation.Equal, viewContainer, NSLayoutAttribute.Right, 1f, -10f),
+ NSLayoutConstraint.Create (title, NSLayoutAttribute.Height, NSLayoutRelation.Equal, viewContainer, NSLayoutAttribute.Height, 1, 0),
+ });
+ }
+
+ return viewContainer;
+ }
+ }
+
+ return null;
+ }
+
+ public override nfloat GetRowHeight (NSOutlineView outlineView, NSObject item)
+ {
+ return 24f;
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac/FirstResponderOutlineView.cs b/Xamarin.PropertyEditing.Mac/FirstResponderOutlineView.cs
new file mode 100644
index 0000000..2dfe76a
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/FirstResponderOutlineView.cs
@@ -0,0 +1,40 @@
+using System;
+using AppKit;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ internal class FirstResponderOutlineView : NSOutlineView
+ {
+ private bool tabbedIn;
+ public override bool ValidateProposedFirstResponder (NSResponder responder, NSEvent forEvent)
+ {
+ return true;
+ }
+
+ public override bool BecomeFirstResponder ()
+ {
+ var willBecomeFirstResponder = base.BecomeFirstResponder ();
+ if (willBecomeFirstResponder) {
+ if (SelectedRows.Count == 0 && RowCount > 0) {
+ SelectRow (0, false);
+ this.tabbedIn = true;
+ var row = GetRowView ((nint)SelectedRows.FirstIndex, false);
+ return Window.MakeFirstResponder (row.NextValidKeyView);
+ }
+ }
+ this.tabbedIn = false;
+ return willBecomeFirstResponder;
+ }
+
+ public override bool ResignFirstResponder ()
+ {
+ var wilResignFirstResponder = base.ResignFirstResponder ();
+ if (wilResignFirstResponder) {
+ if (SelectedRows.Count > 0 && !this.tabbedIn) {
+ DeselectRow ((nint)SelectedRows.FirstIndex);
+ }
+ }
+ return wilResignFirstResponder;
+ }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator.png
new file mode 100644
index 0000000..438b639
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator@2x.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator@2x.png
new file mode 100644
index 0000000..31f56cc
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark.png
new file mode 100644
index 0000000..438b639
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark@2x.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark@2x.png
new file mode 100644
index 0000000..31f56cc
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-header-separator~dark@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16.png
new file mode 100644
index 0000000..13368d5
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16@2x.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16@2x.png
new file mode 100644
index 0000000..a992b32
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark.png
new file mode 100644
index 0000000..8a03423
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark@2x.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark@2x.png
new file mode 100644
index 0000000..ab9ddfc
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-events-16~dark@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16.png
new file mode 100644
index 0000000..894575e
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16@2x.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16@2x.png
new file mode 100644
index 0000000..fa4507f
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark.png
new file mode 100644
index 0000000..de6c960
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark@2x.png b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark@2x.png
new file mode 100644
index 0000000..fea871a
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditingResource/Contents/Resources/pe-show-properties-16~dark@2x.png
Binary files differ
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
index 1463c48..02871a8 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
@@ -87,11 +87,14 @@ namespace Xamarin.PropertyEditing.Mac
if (this.viewModel != null) {
this.viewModel.PropertyChanged -= OnVmPropertyChanged;
- var views = this.tabStack.Views;
- for (int i = 0; i < views.Length; i++) {
- var button = (TabButton)views[i];
- button.Clicked -= OnArrangeModeChanged;
- button.RemoveFromSuperview ();
+ var arrangeModeViews = this.arrangeModeTabStack.Views;
+ for (int i = 0; i < arrangeModeViews.Length; i++) {
+ ((TabButton)arrangeModeViews[i]).Clicked -= OnArrangeModeChanged;
+ }
+
+ var propertiesEventsViews = this.propertiesEventsTabStack.Views;
+ for (int i = 0; i < propertiesEventsViews.Length; i++) {
+ ((TabButton)propertiesEventsViews[i]).Clicked -= OnPropertiesEventsChanged;
}
}
@@ -114,12 +117,14 @@ namespace Xamarin.PropertyEditing.Mac
arrangeMode.Clicked += OnArrangeModeChanged;
- this.tabStack.AddView (arrangeMode, NSStackViewGravity.Top);
+ this.arrangeModeTabStack.AddView (arrangeMode, NSStackViewGravity.Top);
}
}
}
}
+
+
public ICollection<object> SelectedItems => this.viewModel.SelectedObjects;
public void Select (IEnumerable<object> selectedItems)
@@ -137,9 +142,14 @@ namespace Xamarin.PropertyEditing.Mac
private PanelViewModel viewModel;
private NSSearchField propertyFilter;
- private NSStackView tabStack;
+ private NSStackView arrangeModeTabStack;
+ private NSStackView propertiesEventsTabStack;
private DynamicBox header, border;
+ private EventList eventList;
+ internal const string PropertyEditorColId = "PropertyEditors";
+ internal const string EventEditorColId = "EventEditors";
+
private void Initialize ()
{
this.header = new DynamicBox (HostResourceProvider, NamedResources.PanelTabBackground) {
@@ -161,29 +171,41 @@ namespace Xamarin.PropertyEditing.Mac
this.propertyFilter.Changed += OnPropertyFilterChanged;
- this.tabStack = new NSStackView {
+ this.arrangeModeTabStack = new NSStackView {
Orientation = NSUserInterfaceLayoutOrientation.Horizontal,
TranslatesAutoresizingMaskIntoConstraints = false,
EdgeInsets = new NSEdgeInsets (0, 0, 0, 0)
};
- ((NSView)this.header.ContentView).AddSubview (this.tabStack);
+ ((NSView)this.header.ContentView).AddSubview (this.arrangeModeTabStack);
- this.propertyList = new PropertyList {
- HostResourceProvider = this.hostResources,
+ this.propertiesEventsTabStack = new NSStackView {
+ Orientation = NSUserInterfaceLayoutOrientation.Horizontal,
+ TranslatesAutoresizingMaskIntoConstraints = false,
+ EdgeInsets = new NSEdgeInsets (0, 0, 0, 0)
+ };
+
+ ((NSView)this.header.ContentView).AddSubview (this.propertiesEventsTabStack);
+
+ this.propertyList = new PropertyList (this.hostResources, PropertyEditorColId) {
TranslatesAutoresizingMaskIntoConstraints = false
};
AddSubview (this.propertyList);
- this.AddConstraints (new[] {
+ AddConstraints (new[] {
NSLayoutConstraint.Create (this.header, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0),
NSLayoutConstraint.Create (this.header, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1, 0),
NSLayoutConstraint.Create (this.header, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 30),
- NSLayoutConstraint.Create (this.tabStack, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Left, 1, 0),
- NSLayoutConstraint.Create (this.tabStack, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Top, 1, 0),
- NSLayoutConstraint.Create (this.tabStack, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Bottom, 1, 0),
- NSLayoutConstraint.Create (this.tabStack, NSLayoutAttribute.Right, NSLayoutRelation.LessThanOrEqual, this.propertyFilter, NSLayoutAttribute.Left, 1, 0),
+ NSLayoutConstraint.Create (this.arrangeModeTabStack, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Left, 1, 0),
+ NSLayoutConstraint.Create (this.arrangeModeTabStack, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Top, 1, 0),
+ NSLayoutConstraint.Create (this.arrangeModeTabStack, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Bottom, 1, 0),
+ NSLayoutConstraint.Create (this.arrangeModeTabStack, NSLayoutAttribute.Right, NSLayoutRelation.LessThanOrEqual, this.propertiesEventsTabStack, NSLayoutAttribute.Left, 1, 0),
+
+ NSLayoutConstraint.Create (this.propertiesEventsTabStack, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Top, 1, 0),
+ NSLayoutConstraint.Create (this.propertiesEventsTabStack, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Bottom, 1, 0),
+ NSLayoutConstraint.Create (this.propertiesEventsTabStack, NSLayoutAttribute.Left, NSLayoutRelation.GreaterThanOrEqual, this.arrangeModeTabStack, NSLayoutAttribute.Right, 1, 0),
+ NSLayoutConstraint.Create (this.propertiesEventsTabStack, NSLayoutAttribute.Right, NSLayoutRelation.LessThanOrEqual, this.propertyFilter, NSLayoutAttribute.Left, 1, 0),
NSLayoutConstraint.Create (this.propertyFilter, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this.header, NSLayoutAttribute.Right, 1, -15),
NSLayoutConstraint.Create (this.propertyFilter, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, 150),
@@ -232,12 +254,55 @@ namespace Xamarin.PropertyEditing.Mac
if (e.PropertyName == nameof (PanelViewModel.ArrangeMode) || String.IsNullOrEmpty (e.PropertyName)) {
if (this.viewModel != null) {
int selected = this.viewModel.ArrangeModes.Select (vm => vm.ArrangeMode).IndexOf (this.viewModel.ArrangeMode);
- var views = this.tabStack.Views;
+ var views = this.arrangeModeTabStack.Views;
for (int i = 0; i < views.Length; i++) {
- ((TabButton)views[i]).Selected = (i == selected);
+ ((TabButton)views[i]).Selected = i == selected;
}
}
}
+
+ if (e.PropertyName == nameof (PanelViewModel.EventsEnabled)) {
+ if (this.viewModel.EventsEnabled) {
+ var sepButton = new UnfocusableButton (this.hostResources, "pe-header-separator");
+
+ this.propertiesEventsTabStack.AddView (sepButton, NSStackViewGravity.Top);
+
+ var properties = new TabButton (this.hostResources, "pe-show-properties-16") {
+ Bounds = new CGRect (0, 0, 32, 30),
+ Selected = true,
+ Tag = 0,
+ ToolTip = Properties.Resources.PropertiesSelectedElement,
+ };
+
+ properties.Clicked += OnPropertiesEventsChanged;
+
+ this.propertiesEventsTabStack.AddView (properties, NSStackViewGravity.Top);
+
+ var events = new TabButton (this.hostResources, "pe-show-events-16") {
+ Bounds = new CGRect (0, 0, 32, 30),
+ Tag = 1,
+ ToolTip = Properties.Resources.EventHandlersSelectedElement,
+ };
+
+ events.Clicked += OnPropertiesEventsChanged;
+
+ this.propertiesEventsTabStack.AddView (events, NSStackViewGravity.Top);
+
+ this.eventList = new EventList (this.hostResources, EventEditorColId) {
+ Hidden = true,
+ TranslatesAutoresizingMaskIntoConstraints = false,
+ ViewModel = this.viewModel,
+ };
+ AddSubview (this.eventList);
+
+ AddConstraints (new[]{
+ NSLayoutConstraint.Create (this.propertiesEventsTabStack, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.arrangeModeTabStack, NSLayoutAttribute.Right, 1, 4),
+ NSLayoutConstraint.Create (this.eventList, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.border, NSLayoutAttribute.Bottom, 1, 0),
+ NSLayoutConstraint.Create (this.eventList, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, 0),
+ NSLayoutConstraint.Create (this.eventList, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1, 0),
+ });
+ }
+ }
}
private string GetIconName (PropertyArrangeMode mode)
@@ -251,5 +316,32 @@ namespace Xamarin.PropertyEditing.Mac
throw new ArgumentException();
}
}
+
+ private void OnPropertiesEventsChanged (object sender, EventArgs e)
+ {
+ if (sender is TabButton tabButton) {
+ // Reset them all
+ NSView[] views = this.propertiesEventsTabStack.Views;
+ for (int i = 0; i < views.Length; i++) {
+ if (views[i] is TabButton tb) {
+ tb.Selected = false;
+ }
+ }
+
+ switch (tabButton.Tag) {
+ case 0:
+ this.propertyList.Hidden = false;
+ this.eventList.Hidden = true;
+ break;
+ case 1:
+ this.propertyList.Hidden = true;
+ this.eventList.Hidden = false;
+ this.eventList.ReloadDate ();
+ break;
+ }
+
+ tabButton.Selected = true;
+ }
+ }
}
-}
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac/PropertyList.cs b/Xamarin.PropertyEditing.Mac/PropertyList.cs
index 06b76e5..40dae90 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyList.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyList.cs
@@ -9,30 +9,10 @@ using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal class PropertyList
- : NSView
+ : BaseOutlineList
{
- internal const string PropertyEditorColId = "PropertyEditors";
-
- public PropertyList ()
+ public PropertyList (IHostResourceProvider hostResources, string columnID) : base (hostResources, columnID)
{
- this.propertyTable = new FirstResponderOutlineView {
- IndentationPerLevel = 0,
- SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.None,
- HeaderView = null,
- IntercellSpacing = new CGSize (0, 0)
- };
-
- var propertyEditors = new NSTableColumn (PropertyEditorColId);
- this.propertyTable.AddColumn (propertyEditors);
-
- this.scrollView = new NSScrollView {
- AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable,
- HasHorizontalScroller = false,
- HasVerticalScroller = true,
- };
-
- this.scrollView.DocumentView = this.propertyTable;
- AddSubview (this.scrollView);
}
public bool ShowHeader
@@ -44,23 +24,21 @@ namespace Xamarin.PropertyEditing.Mac
return;
this.showHeader = value;
- if (this.dataSource != null) {
- this.dataSource.ShowHeader = value;
- this.propertyTable.ReloadData ();
+ if (this.dataSource != null && this.dataSource is PropertyTableDataSource propertyTableDataSource) {
+ propertyTableDataSource.ShowHeader = value;
+ OutlineViewTable.ReloadData ();
}
}
}
- public PanelViewModel ViewModel
+ public override PanelViewModel ViewModel
{
- get { return this.viewModel; }
- set
- {
+ set {
if (this.viewModel != null) {
this.viewModel.ArrangedPropertiesChanged -= OnPropertiesChanged;
- this.propertyTable.Delegate = null;
- this.propertyTable.DataSource = null;
+ OutlineViewTable.Delegate = null;
+ OutlineViewTable.DataSource = null;
}
this.viewModel = value;
@@ -69,97 +47,32 @@ namespace Xamarin.PropertyEditing.Mac
this.viewModel.ArrangedPropertiesChanged += OnPropertiesChanged;
this.dataSource = new PropertyTableDataSource (this.viewModel) { ShowHeader = ShowHeader };
- this.propertyTable.Delegate = new PropertyTableDelegate (HostResourceProvider, this.dataSource);
- this.propertyTable.DataSource = this.dataSource;
+ OutlineViewTable.Delegate = new PropertyTableDelegate (HostResourceProvider, this.dataSource);
+ OutlineViewTable.DataSource = this.dataSource;
}
}
}
- public IHostResourceProvider HostResourceProvider
- {
- get => this.hostResources;
- set
- {
- if (this.hostResources == value)
- return;
- if (value == null)
- throw new ArgumentNullException (nameof (value), "Cannot set HostResourceProvider to null");
-
- this.hostResources = value;
- UpdateResourceProvider ();
- }
- }
-
- public sealed override void ViewDidChangeEffectiveAppearance ()
- {
- base.ViewDidChangeEffectiveAppearance ();
-
- UpdateResourceProvider ();
- }
-
public void UpdateExpansions ()
{
- ((PropertyTableDelegate)this.propertyTable.Delegate).UpdateExpansions (this.propertyTable);
+ ((PropertyTableDelegate)OutlineViewTable.Delegate).UpdateExpansions (OutlineViewTable);
}
- private readonly NSOutlineView propertyTable;
- private readonly NSScrollView scrollView;
- private IHostResourceProvider hostResources;
- private PropertyTableDataSource dataSource;
- private PanelViewModel viewModel;
private bool showHeader = true;
- private class FirstResponderOutlineView : NSOutlineView
- {
- private bool tabbedIn;
- public override bool ValidateProposedFirstResponder (NSResponder responder, NSEvent forEvent)
- {
- return true;
- }
-
- public override bool BecomeFirstResponder ()
- {
- var willBecomeFirstResponder = base.BecomeFirstResponder ();
- if (willBecomeFirstResponder) {
- if (SelectedRows.Count == 0 && RowCount > 0) {
- SelectRow (0, false);
- this.tabbedIn = true;
- var row = GetRowView ((nint)SelectedRows.FirstIndex, false);
- return Window.MakeFirstResponder (row.NextValidKeyView);
- }
- }
- this.tabbedIn = false;
- return willBecomeFirstResponder;
- }
-
- public override bool ResignFirstResponder ()
- {
- var wilResignFirstResponder = base.ResignFirstResponder ();
- if (wilResignFirstResponder) {
- if (SelectedRows.Count > 0 && !this.tabbedIn) {
- DeselectRow ((nint)SelectedRows.FirstIndex);
- }
- }
- return wilResignFirstResponder;
- }
- }
-
private void OnPropertiesChanged (object sender, EventArgs e)
{
- this.propertyTable.ReloadData ();
+ OutlineViewTable.ReloadData ();
- ((PropertyTableDelegate)this.propertyTable.Delegate).UpdateExpansions (this.propertyTable);
+ ((PropertyTableDelegate)OutlineViewTable.Delegate).UpdateExpansions (OutlineViewTable);
}
- private void UpdateResourceProvider ()
+ protected override void UpdateResourceProvider ()
{
- if (this.propertyTable == null || this.hostResources == null)
- return;
-
- this.propertyTable.BackgroundColor = this.hostResources.GetNamedColor (NamedResources.PadBackgroundColor);
+ base.UpdateResourceProvider ();
- if (this.propertyTable.Delegate != null)
- this.propertyTable.Delegate = new PropertyTableDelegate (HostResourceProvider, this.dataSource);
+ if (OutlineViewTable.Delegate != null)
+ OutlineViewTable.Delegate = new PropertyTableDelegate (HostResourceProvider, this.dataSource);
}
}
-}
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs
index 1a312e0..3906508 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyTableDataSource.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq;
using AppKit;
using Foundation;
using Xamarin.PropertyEditing.ViewModels;
@@ -9,20 +7,12 @@ using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal class PropertyTableDataSource
- : NSOutlineViewDataSource
+ : BaseOutlineViewDataSource
{
- bool Filtering => !string.IsNullOrEmpty (this.vm.FilterText);
-
- internal PropertyTableDataSource (PanelViewModel panelVm)
+ internal PropertyTableDataSource (PanelViewModel panelVm) : base(panelVm)
{
- if (panelVm == null)
- throw new ArgumentNullException (nameof (panelVm));
-
- this.vm = panelVm;
}
- public PanelViewModel DataContext => this.vm;
-
public bool ShowHeader
{
get;
@@ -31,7 +21,7 @@ namespace Xamarin.PropertyEditing.Mac
public override nint GetChildrenCount (NSOutlineView outlineView, NSObject item)
{
- if (this.vm.ArrangedEditors.Count == 0)
+ if (DataContext.ArrangedEditors.Count == 0)
return 0;
var facade = (NSObjectFacade)item;
@@ -40,11 +30,11 @@ namespace Xamarin.PropertyEditing.Mac
int headerCount = (ShowHeader && !Filtering) ? 1 : 0;
- if (this.vm.ArrangeMode == PropertyArrangeMode.Name)
- return this.vm.ArrangedEditors[0].Editors.Count + headerCount;
+ if (DataContext.ArrangeMode == PropertyArrangeMode.Name)
+ return DataContext.ArrangedEditors[0].Editors.Count + headerCount;
else {
if (item == null)
- return this.vm.ArrangedEditors.Count + headerCount;
+ return DataContext.ArrangedEditors.Count + headerCount;
else {
var group = (PanelGroupViewModel)((NSObjectFacade)item).Target;
return group.Editors.Count + group.UncommonEditors.Count;
@@ -64,11 +54,11 @@ namespace Xamarin.PropertyEditing.Mac
element = ovm.ValueModel.Properties[(int)childIndex];
} else {
int headerCount = (ShowHeader && !Filtering) ? 1 : 0;
- if (this.vm.ArrangeMode == PropertyArrangeMode.Name)
- element = this.vm.ArrangedEditors[0].Editors[(int)childIndex - headerCount];
+ if (DataContext.ArrangeMode == PropertyArrangeMode.Name)
+ element = DataContext.ArrangedEditors[0].Editors[(int)childIndex - headerCount];
else {
if (item == null)
- element = this.vm.ArrangedEditors[(int)childIndex - headerCount];
+ element = DataContext.ArrangedEditors[(int)childIndex - headerCount];
else {
var group = (PanelGroupViewModel)f.Target;
var list = group.Editors;
@@ -102,31 +92,10 @@ namespace Xamarin.PropertyEditing.Mac
return ovm.CanDelve;
}
- if (this.vm.ArrangeMode == PropertyArrangeMode.Name)
+ if (DataContext.ArrangeMode == PropertyArrangeMode.Name)
return false;
return f.Target is PanelGroupViewModel;
}
-
- public NSObjectFacade GetFacade (object element)
- {
- NSObjectFacade facade;
- if (element is PanelGroupViewModel) {
- if (!this.groupFacades.TryGetValue (element, out facade)) {
- this.groupFacades[element] = facade = new NSObjectFacade (element);
- }
- } else
- facade = new NSObjectFacade (element);
-
- return facade;
- }
-
- public bool TryGetFacade (object element, out NSObjectFacade facade)
- {
- return this.groupFacades.TryGetValue (element, out facade);
- }
-
- private readonly PanelViewModel vm;
- private readonly Dictionary<object, NSObjectFacade> groupFacades = new Dictionary<object, NSObjectFacade> ();
}
}
diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
index 49f2665..80bd429 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
@@ -10,32 +10,25 @@ using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal class PropertyTableDelegate
- : NSOutlineViewDelegate
+ : BaseOutlineViewDelegate
{
- public PropertyTableDelegate (IHostResourceProvider hostResources, PropertyTableDataSource dataSource)
+ public PropertyTableDelegate (IHostResourceProvider hostResources, BaseOutlineViewDataSource dataSource) : base (hostResources, dataSource)
{
- if (hostResources == null)
- throw new ArgumentNullException (nameof (hostResources));
- if (dataSource == null)
- throw new ArgumentNullException (nameof (dataSource));
-
- this.hostResources = hostResources;
- this.dataSource = dataSource;
}
public void UpdateExpansions (NSOutlineView outlineView)
{
this.isUpdatingExpansions = true;
- if (!String.IsNullOrWhiteSpace (this.dataSource.DataContext.FilterText)) {
+ if (!String.IsNullOrWhiteSpace (DataSource.DataContext.FilterText)) {
outlineView.ExpandItem (null, true);
} else {
- foreach (PanelGroupViewModel g in this.dataSource.DataContext.ArrangedEditors) {
+ foreach (PanelGroupViewModel g in DataSource.DataContext.ArrangedEditors) {
NSObjectFacade item;
- if (!this.dataSource.TryGetFacade (g, out item))
+ if (!DataSource.TryGetFacade (g, out item))
continue;
- if (this.dataSource.DataContext.GetIsExpanded (g.Category))
+ if (DataSource.DataContext.GetIsExpanded (g.Category))
EnsureOpenOrClose (outlineView, item, open: true);
else
EnsureOpenOrClose (outlineView, item, open: false);
@@ -74,7 +67,7 @@ namespace Xamarin.PropertyEditing.Mac
((UnfocusableTextField)labelContainer.Subviews[1]).StringValue = group.Category;
- if (this.dataSource.DataContext.GetIsExpanded (group.Category)) {
+ if (DataSource.DataContext.GetIsExpanded (group.Category)) {
SynchronizationContext.Current.Post (s => {
outlineView.ExpandItem (item);
}, null);
@@ -86,7 +79,7 @@ namespace Xamarin.PropertyEditing.Mac
NSView editorOrContainer = null;
if (this.firstCache.TryGetValue (cellIdentifier, out IEditorView editor)) {
this.firstCache.Remove (cellIdentifier);
- editorOrContainer = (editor.NativeView is PropertyEditorControl) ? new EditorContainer (this.hostResources, editor) { Identifier = cellIdentifier } : editor.NativeView;
+ editorOrContainer = (editor.NativeView is PropertyEditorControl) ? new EditorContainer (HostResources, editor) { Identifier = cellIdentifier } : editor.NativeView;
} else {
editorOrContainer = GetEditor (cellIdentifier, evm, outlineView);
editor = ((editorOrContainer as EditorContainer)?.EditorView) ?? editorOrContainer as IEditorView;
@@ -129,7 +122,7 @@ namespace Xamarin.PropertyEditing.Mac
outlineView.NoteHeightOfRowsWithIndexesChanged (new NSIndexSet (index));
}
} else if (editorOrContainer is PanelHeaderEditorControl header) {
- header.ViewModel = this.dataSource.DataContext;
+ header.ViewModel = DataSource.DataContext;
}
return editorOrContainer;
@@ -155,7 +148,7 @@ namespace Xamarin.PropertyEditing.Mac
}
if (facade.Target is PanelGroupViewModel group)
- this.dataSource.DataContext.SetIsExpanded (group.Category, isExpanded: true);
+ DataSource.DataContext.SetIsExpanded (group.Category, isExpanded: true);
else if (facade.Target is ObjectPropertyViewModel ovm) {
NSView view = outline.GetView (0, row, makeIfNecessary: false);
SetRowValueBackground (view, valueBackground: true);
@@ -177,7 +170,7 @@ namespace Xamarin.PropertyEditing.Mac
}
if (facade.Target is PanelGroupViewModel group)
- this.dataSource.DataContext.SetIsExpanded (group.Category, isExpanded: false);
+ DataSource.DataContext.SetIsExpanded (group.Category, isExpanded: false);
else if (facade.Target is ObjectPropertyViewModel ovm) {
NSView view = outline.GetView (0, row, makeIfNecessary: false);
SetRowValueBackground (view, valueBackground: false);
@@ -238,11 +231,9 @@ namespace Xamarin.PropertyEditing.Mac
public const string CategoryIdentifier = "label";
- private PropertyTableDataSource dataSource;
private bool isUpdatingExpansions;
private readonly PropertyEditorSelector editorSelector = new PropertyEditorSelector ();
- private readonly IHostResourceProvider hostResources;
private readonly Dictionary<string, EditorRegistration> registrations = new Dictionary<string, EditorRegistration> ();
private readonly Dictionary<string, IEditorView> firstCache = new Dictionary<string, IEditorView> ();
@@ -270,7 +261,7 @@ namespace Xamarin.PropertyEditing.Mac
return;
if (valueBackground) {
- var c = this.hostResources.GetNamedColor (NamedResources.ValueBlockBackgroundColor);
+ var c = HostResources.GetNamedColor (NamedResources.ValueBlockBackgroundColor);
view.SetValueForKey (c, new NSString ("backgroundColor"));
} else {
view.SetValueForKey (NSColor.Clear, new NSString ("backgroundColor"));
@@ -284,7 +275,7 @@ namespace Xamarin.PropertyEditing.Mac
return view;
if (vm != null) {
- IEditorView editor = this.editorSelector.GetEditor (this.hostResources, vm);
+ IEditorView editor = this.editorSelector.GetEditor (HostResources, vm);
var editorControl = editor?.NativeView as PropertyEditorControl;
if (editorControl != null) {
@@ -294,9 +285,9 @@ namespace Xamarin.PropertyEditing.Mac
return editor.NativeView;
}
- return new EditorContainer (this.hostResources, editor) { Identifier = identifier };
+ return new EditorContainer (HostResources, editor) { Identifier = identifier };
} else
- return new PanelHeaderEditorControl (this.hostResources);
+ return new PanelHeaderEditorControl (HostResources);
}
private void GetVMGroupCellItendifiterFromFacade (NSObject item, out EditorViewModel vm, out PanelGroupViewModel group, out string cellIdentifier)