diff options
author | Dominique Louis <savagesoftware@gmail.com> | 2018-09-11 03:12:30 +0300 |
---|---|---|
committer | Dominique Louis <dominique@Dominiques-MacBook-Pro-2.local> | 2018-10-09 00:32:24 +0300 |
commit | b36e9d4abfdd6ceefd5d216559a0f49e604cc27d (patch) | |
tree | d46ce6ca8529011a157857a79eb8b0d8c8044ef1 /Xamarin.PropertyEditing.Mac/Controls/Custom | |
parent | b130ba7964cf71b166f5094250fc7874b0456101 (diff) |
[Mac] Add filtering capabilities to brush popUp controller.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
3 files changed, 41 insertions, 15 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index 588b4f6..b8f58fd 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -16,7 +16,22 @@ namespace Xamarin.PropertyEditing.Mac { PreferredContentSize = new CGSize (430, 230); TransitionOptions = NSViewControllerTransitionOptions.None; - EdgeInsets = new NSEdgeInsets (0, 12, 12, 12); + EdgeInsets = new NSEdgeInsets (0, 12, 12, 12);
+
+ this.filterResource = new NSSearchField {
+ ControlSize = NSControlSize.Mini,
+ Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
+ PlaceholderString = Properties.Resources.SearchResourcesTitle,
+ };
+
+ this.filterResource.Changed += (sender, e) => {
+ ViewModel.ResourceSelector.FilterText = this.filterResource.Cell.Title;
+ this.resource.ReloadData ();
+ };
+
+ this.filterResource.Hidden = true;
+
+ TabStack.AddView (this.filterResource, NSStackViewGravity.Leading); } public override void OnViewModelChanged (BrushPropertyViewModel oldModel) @@ -30,7 +45,7 @@ namespace Xamarin.PropertyEditing.Mac var removed = new HashSet<CommonBrushType> (this.brushTypeTable.Keys);
removed.ExceptWith (existing);
- foreach (var item in removed.Select (t => new { Type = t, Tab = TabView.Items[this.brushTypeTable[t]] }).ToArray()) {
+ foreach (var item in removed.Select (t => new { Type = t, Tab = TabView.Items[this.brushTypeTable[t]] }).ToArray ()) {
RemoveTabViewItem (item.Tab);
item.Tab.Dispose ();
this.brushTypeTable.Remove (item.Type);
@@ -67,9 +82,9 @@ namespace Xamarin.PropertyEditing.Mac item.Image = NSImage.ImageNamed ("property-brush-palette-16"); break; case CommonBrushType.Resource: - var resource = new ResourceBrushViewController (); - resource.ViewModel = ViewModel; - item.ViewController = resource; + this.resource = new ResourceBrushViewController (); + this.resource.ViewModel = ViewModel; + item.ViewController = this.resource; item.ToolTip = Properties.Resources.ResourceBrush; item.Image = NSImage.ImageNamed ("property-brush-resources-16"); break; @@ -79,7 +94,7 @@ namespace Xamarin.PropertyEditing.Mac item.ViewController = gradient; item.ToolTip = item.Label; item.Image = NSImage.ImageNamed ("property-brush-gradient-16"); - break;
+ break; default: case CommonBrushType.NoBrush: var none = new EmptyBrushEditorViewController (); @@ -114,10 +129,9 @@ namespace Xamarin.PropertyEditing.Mac public override void WillSelect (NSTabView tabView, NSTabViewItem item) { - var brushController = item.ViewController as NotifyingViewController<BrushPropertyViewModel>; - if (brushController != null) + if (item.ViewController is NotifyingViewController<BrushPropertyViewModel> brushController) brushController.ViewModel = ViewModel; - + if (this.inhibitSelection) return; @@ -129,13 +143,15 @@ namespace Xamarin.PropertyEditing.Mac if (this.inhibitSelection) return; + ViewModel.SelectedBrushType = ViewModel.BrushTypes[item.Label]; + this.filterResource.Hidden = ViewModel.SelectedBrushType != CommonBrushType.Resource; + base.DidSelect (tabView, item); - ViewModel.SelectedBrushType = ViewModel.BrushTypes [item.Label]; } public override void ViewDidLoad () { - View.Frame = new CGRect (0, 0, 430,230); + View.Frame = new CGRect (0, 0, 430, 230); this.inhibitSelection = true; base.ViewDidLoad (); @@ -143,6 +159,9 @@ namespace Xamarin.PropertyEditing.Mac }
private readonly Dictionary<CommonBrushType, int> brushTypeTable = new Dictionary<CommonBrushType, int> ();
- private bool inhibitSelection; + private bool inhibitSelection;
+
+ private NSSearchField filterResource;
+ private ResourceBrushViewController resource; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs index 94fb844..a212024 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs @@ -78,7 +78,7 @@ namespace Xamarin.PropertyEditing.Mac public override void LoadView () { viewDelegate.ViewModel = ViewModel; - resourceSelector = new ResourceOutlineView { + this.resourceSelector = new ResourceOutlineView { Delegate = viewDelegate, }; @@ -88,12 +88,17 @@ namespace Xamarin.PropertyEditing.Mac }; // add the panel to the window - tableContainer.DocumentView = resourceSelector; + tableContainer.DocumentView = this.resourceSelector; View = tableContainer; if (ViewModel != null) { resourceSelector.ViewModel = ViewModel?.ResourceSelector; } } + + public void ReloadData() + { + this.resourceSelector.ReloadData (); + } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs index b401833..b779ed4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs @@ -87,9 +87,11 @@ namespace Xamarin.PropertyEditing.Mac private NSStackView outerStack;
private NSStackView innerStack;
private NSStackView tabStack = new NSStackView () {
- Spacing = 2f,
+ Spacing = 10f,
};
+ protected NSStackView TabStack => this.tabStack;
+
private NSEdgeInsets edgeInsets = new NSEdgeInsets (0, 0, 0, 0);
private void SetSelected (int index)
|