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:
authorEric Maupin <ermaup@microsoft.com>2019-02-01 20:46:10 +0300
committerEric Maupin <ermaup@microsoft.com>2019-02-15 21:00:44 +0300
commit0ff7c089e4ff137dbf535445df8da88ece02a0ec (patch)
tree4eae1ec8e351422318cac4a8f6fc52a720ab85fe /Xamarin.PropertyEditing.Mac
parent5fc4290bc2563e032281da7e1eb02260f117c6d1 (diff)
[mac] Object editor backgrounds
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs1
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs47
2 files changed, 44 insertions, 4 deletions
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
index 51051be..a42d166 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
@@ -178,6 +178,7 @@ namespace Xamarin.PropertyEditing.Mac
RefusesFirstResponder = true,
SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.None,
HeaderView = null,
+ IntercellSpacing = new CGSize (0, 0)
};
var propertyEditors = new NSTableColumn (PropertyEditorColId);
diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
index e25efbb..b9ef018 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
@@ -92,6 +92,14 @@ namespace Xamarin.PropertyEditing.Mac
if (editor != null) {
editor.ViewModel = evm;
+ bool openObjectRow = evm is ObjectPropertyViewModel && outlineView.IsItemExpanded (item);
+ if (!openObjectRow) {
+ var parent = outlineView.GetParent (item);
+ openObjectRow = (parent != null && ((NSObjectFacade)parent).Target is ObjectPropertyViewModel);
+ }
+
+ SetRowValueBackground (editorOrContainer, openObjectRow);
+
// Force a row update due to new height, but only when we are non-default
if (editor.IsDynamicallySized) {
nint index = outlineView.RowForItem (item);
@@ -115,9 +123,15 @@ namespace Xamarin.PropertyEditing.Mac
return;
NSObjectFacade facade = notification.UserInfo.Values[0] as NSObjectFacade;
- var group = facade.Target as PanelGroupViewModel;
- if (group != null)
+ var outline = (NSOutlineView)notification.Object;
+ nint row = outline.RowForItem (facade);
+
+ if (facade.Target is PanelGroupViewModel group)
this.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);
+ }
}
public override void ItemDidCollapse (NSNotification notification)
@@ -126,9 +140,15 @@ namespace Xamarin.PropertyEditing.Mac
return;
NSObjectFacade facade = notification.UserInfo.Values[0] as NSObjectFacade;
- var group = facade.Target as PanelGroupViewModel;
- if (group != null)
+ var outline = (NSOutlineView)notification.Object;
+ nint row = outline.RowForItem (facade);
+
+ if (facade.Target is PanelGroupViewModel group)
this.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);
+ }
}
public override nfloat GetRowHeight (NSOutlineView outlineView, NSObject item)
@@ -193,6 +213,25 @@ namespace Xamarin.PropertyEditing.Mac
private readonly Dictionary<string, EditorRegistration> registrations = new Dictionary<string, EditorRegistration> ();
private readonly Dictionary<string, IEditorView> firstCache = new Dictionary<string, IEditorView> ();
+ private NSView GetViewForItem (NSOutlineView outline, NSObjectFacade facade)
+ {
+ nint row = outline.RowForItem (facade);
+ return outline.GetView (0, row, false);
+ }
+
+ private void SetRowValueBackground (NSView view, bool valueBackground)
+ {
+ if (view == null)
+ return;
+
+ if (valueBackground) {
+ var c = this.hostResources.GetNamedColor (NamedResources.ValueBlockBackgroundColor);
+ view.SetValueForKey (c, new NSString ("backgroundColor"));
+ } else {
+ view.SetValueForKey (NSColor.Clear, new NSString ("backgroundColor"));
+ }
+ }
+
private NSView GetEditor (string identifier, EditorViewModel vm, NSOutlineView outlineView)
{
var view = outlineView.MakeView (identifier, this);