diff options
author | Larry Ewing <lewing@microsoft.com> | 2018-07-16 02:50:14 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2018-07-16 23:23:36 +0300 |
commit | 9ada82b7f67227912bfff17555b9b1536645e142 (patch) | |
tree | 23067de17b5a24241f98fb327bc205be08290177 | |
parent | 17f46bfd8a4572382a2efd04d155efbcc093104b (diff) |
[mac] expose group editor in the property treelewing-mac-group-editing
10 files changed, 75 insertions, 26 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs index 3a4ebc9..1b975e9 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs @@ -29,7 +29,7 @@ namespace Xamarin.PropertyEditing.Mac public override bool TriggerRowChange => true; - public override nint GetHeight (PropertyViewModel vm) + public override nint GetHeight (EditorViewModel vm) { var realVm = (CombinablePropertyViewModel<T>)vm; return checkHeight * realVm.Choices.Count; @@ -57,7 +57,7 @@ namespace Xamarin.PropertyEditing.Mac } } - protected override void OnViewModelChanged (PropertyViewModel oldModel) + protected override void OnViewModelChanged (EditorViewModel oldModel) { nint rowHeight = GetHeight (ViewModel); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index 5e4bf48..9b065bb 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -20,6 +20,9 @@ namespace Xamarin.PropertyEditing.Mac } viewModel = value; + if (viewModel == null) + return; + viewModel.PropertyChanged += OnPropertyChanged; // No point showing myself if you can't do anything with me. diff --git a/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs new file mode 100644 index 0000000..d00fd98 --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections; +using AppKit; + +namespace Xamarin.PropertyEditing.Mac +{ + class GroupEditorControl : PropertyEditorControl + { + public override NSView FirstKeyView => null; + public override NSView LastKeyView => null; + public GroupEditorControl () + { + + } + protected override void UpdateValue () + { + + } + + protected override void HandleErrorsChanged (object sender, System.ComponentModel.DataErrorsChangedEventArgs e) + { + + } + + + + protected override void UpdateErrorsDisplayed (IEnumerable errors) + { + + } + + + protected override void SetEnabled () + { + + } + + protected override void UpdateAccessibilityValues () + { + } + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs index 881e34f..963eb08 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs @@ -25,7 +25,7 @@ namespace Xamarin.PropertyEditing.Mac YEditor.Frame = new CGRect (132, 13, 90, 20); } - public override nint GetHeight (PropertyViewModel vm) + public override nint GetHeight (EditorViewModel vm) { return 33; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs index 6ae54db..81c923a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs @@ -84,7 +84,7 @@ namespace Xamarin.PropertyEditing.Mac } } - protected override void OnViewModelChanged (PropertyViewModel oldModel) + protected override void OnViewModelChanged (EditorViewModel oldModel) { if (!dataPopulated) { if (ViewModel.IsConstrainedToPredefined) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs index 04c7c48..396ac2c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs @@ -24,17 +24,18 @@ namespace Xamarin.PropertyEditing.Mac public const string DefaultFontName = ".AppleSystemUIFont"; public virtual bool TriggerRowChange => false; - PropertyViewModel viewModel; - public PropertyViewModel ViewModel { + EditorViewModel viewModel; + public EditorViewModel ViewModel { get { return viewModel; } set { if (viewModel == value) return; - PropertyViewModel oldModel = this.viewModel; + EditorViewModel oldModel = this.viewModel; if (oldModel != null) { oldModel.PropertyChanged -= OnPropertyChanged; - oldModel.ErrorsChanged -= HandleErrorsChanged; + if (viewModel is PropertyViewModel) + ((PropertyViewModel)oldModel).ErrorsChanged -= HandleErrorsChanged; } this.viewModel = value; @@ -42,7 +43,8 @@ namespace Xamarin.PropertyEditing.Mac viewModel.PropertyChanged += OnPropertyChanged; // FIXME: figure out what we want errors to display as (tooltip, etc.) - viewModel.ErrorsChanged += HandleErrorsChanged; + if (viewModel is PropertyViewModel) + ((PropertyViewModel)viewModel).ErrorsChanged += HandleErrorsChanged; } } @@ -75,21 +77,21 @@ namespace Xamarin.PropertyEditing.Mac } /// <remarks>You should treat the implementation of this as static.</remarks> - public virtual nint GetHeight (PropertyViewModel vm) + public virtual nint GetHeight (EditorViewModel vm) { return DefaultControlHeight; } - + protected abstract void UpdateValue (); - protected virtual void OnViewModelChanged (PropertyViewModel oldModel) + protected virtual void OnViewModelChanged (EditorViewModel oldModel) { SetEnabled (); UpdateValue (); UpdateAccessibilityValues (); // Hook this up so we know when to reset values - PropertyButton.ViewModel = viewModel; + PropertyButton.ViewModel = viewModel as PropertyViewModel; } protected virtual void OnPropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -113,7 +115,7 @@ namespace Xamarin.PropertyEditing.Mac } internal abstract class PropertyEditorControl<TViewModel> : PropertyEditorControl - where TViewModel : PropertyViewModel + where TViewModel : EditorViewModel { internal new TViewModel ViewModel { diff --git a/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs index 3853314..efcefbc 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs @@ -37,7 +37,7 @@ namespace Xamarin.PropertyEditing.Mac HeightEditor.Frame = new CGRect (132, 13, 90, 20); } - public override nint GetHeight (PropertyViewModel vm) + public override nint GetHeight (EditorViewModel vm) { return 66; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs index a514bc2..0152f05 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs @@ -26,7 +26,7 @@ namespace Xamarin.PropertyEditing.Mac YEditor.Frame = new CGRect (132, 13, 90, 20); } - public override nint GetHeight (PropertyViewModel vm) + public override nint GetHeight (EditorViewModel vm) { return 33; } diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs index db257b7..d240c86 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs @@ -41,7 +41,7 @@ namespace Xamarin.PropertyEditing.Mac // the table is looking for this method, picks it up automagically public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { - PropertyViewModel vm; + EditorViewModel vm; IGroupingList<string, EditorViewModel> group; string cellIdentifier; GetVMGroupCellItendifiterFromFacade (item, out vm, out group, out cellIdentifier); @@ -67,12 +67,12 @@ namespace Xamarin.PropertyEditing.Mac }; } - view.StringValue = ((group == null) ? vm.Property.Name + ":" : group.Key) ?? String.Empty; + view.StringValue = ((group == null) ? vm.Name + ":" : group.Key) ?? String.Empty; // Set tooltips only for truncated strings var stringWidth = view.AttributedStringValue.Size.Width + 30; if (stringWidth > tableColumn.Width) { - view.ToolTip = vm.Property.Name; + view.ToolTip = vm.Name; } return view; @@ -91,7 +91,7 @@ namespace Xamarin.PropertyEditing.Mac return new NSView (); // we must reset these every time, as the view may have been reused - editor.TableRow = outlineView.RowForItem (item); + editor.TableRow = outlineView.RowForItem (item); editor.ViewModel = vm; // Force a row update due to new height, but only when we are non-default @@ -133,7 +133,7 @@ namespace Xamarin.PropertyEditing.Mac public override nfloat GetRowHeight (NSOutlineView outlineView, NSObject item) { - PropertyViewModel vm; + EditorViewModel vm; IGroupingList<string, EditorViewModel> group; string cellIdentifier; GetVMGroupCellItendifiterFromFacade (item, out vm, out group, out cellIdentifier); @@ -172,7 +172,7 @@ namespace Xamarin.PropertyEditing.Mac public nint RowSize; public PropertyEditorControl SizingInstance; - public nint GetHeight (PropertyViewModel vm) + public nint GetHeight (EditorViewModel vm) { if (SizingInstance != null) return SizingInstance.GetHeight (vm); @@ -224,10 +224,10 @@ namespace Xamarin.PropertyEditing.Mac return view; } - private void GetVMGroupCellItendifiterFromFacade (NSObject item, out PropertyViewModel vm, out IGroupingList<string, EditorViewModel> group, out string cellIdentifier) + private void GetVMGroupCellItendifiterFromFacade (NSObject item, out EditorViewModel vm, out IGroupingList<string, EditorViewModel> group, out string cellIdentifier) { var facade = (NSObjectFacade)item; - vm = facade.Target as PropertyViewModel; + vm = facade.Target as EditorViewModel; group = facade.Target as IGroupingList<string, EditorViewModel>; cellIdentifier = (group == null) ? vm.GetType ().FullName : group.Key; } @@ -247,6 +247,7 @@ namespace Xamarin.PropertyEditing.Mac {typeof (PropertyViewModel<Point>), typeof (SystemPointEditorControl)}, {typeof (PropertyViewModel<Size>), typeof (SystemSizeEditorControl)}, {typeof (PropertyViewModel<Rectangle>), typeof (SystemRectangleEditorControl)}, - {typeof (BrushPropertyViewModel), typeof (BrushEditorControl) }}; + {typeof (BrushPropertyViewModel), typeof (BrushEditorControl)}, + {typeof (PropertyGroupViewModel), typeof (GroupEditorControl)}}; } } diff --git a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj index c2f7a98..8790189 100644 --- a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj +++ b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj @@ -71,6 +71,7 @@ <Compile Include="Controls\BaseRectangleEditorControl.cs" /> <Compile Include="Controls\CGRectEditorControl.cs" /> <Compile Include="Controls\CGPointEditorControl.cs" /> + <Compile Include="Controls\GroupEditorControl.cs" /> <Compile Include="NSObjectFacade.cs" /> <Compile Include="Controls\PredefinedValuesEditor.cs" /> <Compile Include="Controls\BasePointEditorControl.cs" /> @@ -250,4 +251,4 @@ <BundleResource Include="Resources\property-brush-palette-16~dark~sel%402x.png" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" /> -</Project>
\ No newline at end of file +</Project> |