diff options
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
3 files changed, 40 insertions, 23 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index c9f04d6..87242df 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -48,7 +48,7 @@ namespace Xamarin.PropertyEditing.Mac var material = new MaterialBrushEditorViewController (); material.ViewModel = ViewModel; item.ViewController = material; - item.Image = NSImage.ImageNamed ("property-brush-none-16"); + item.Image = NSImage.ImageNamed ("property-brush-palette-16"); break; case CommonBrushType.Resource: var resource = new ResourceBrushViewController (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs index 3526287..ca6a829 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs @@ -70,10 +70,6 @@ namespace Xamarin.PropertyEditing.Mac internal class UnderlinedTabViewController<TViewModel> : NotifyingTabViewController<TViewModel> where TViewModel : NotifyingObject { - private NSStackView tabStack = new NSStackView () { - Spacing = 4f, - }; - public override void NumberOfItemsChanged (NSTabView tabView) { base.NumberOfItemsChanged (tabView); @@ -85,7 +81,8 @@ namespace Xamarin.PropertyEditing.Mac foreach (var item in TabViewItems) { if (item.Image != null) { this.tabStack.AddView (new UnderlinedImageView (item.Image.Name) { - Selected = i == SelectedTabViewItemIndex + Selected = i == SelectedTabViewItemIndex, + ToolTip = item.Label, }, NSStackViewGravity.Leading); } else { this.tabStack.AddView (new UnderlinedTextField () { @@ -100,10 +97,28 @@ namespace Xamarin.PropertyEditing.Mac } } + private NSStackView outerStack; + private NSStackView innerStack; + private NSStackView tabStack = new NSStackView () { + Spacing = 4f, + }; + + private NSEdgeInsets edgeInsets = new NSEdgeInsets (0, 12, 12, 12); + public NSEdgeInsets EdgeInsets { + get => this.edgeInsets; + set { + this.edgeInsets = value; + if (this.outerStack != null) { + this.outerStack.EdgeInsets = value; + this.innerStack.EdgeInsets = value; + } + } + } + public override void MouseDown (NSEvent theEvent) { NSView hit = View.HitTest (View.Superview.ConvertPointFromView (theEvent.LocationInWindow, null)); - if (!(hit is ISelectable)) + if (!(hit is IUnderliningTabView)) return; int i = 0; @@ -120,7 +135,7 @@ namespace Xamarin.PropertyEditing.Mac { base.DidSelect (tabView, item); for (int i = 0; i < this.tabStack.Views.Length; i++) { - var tabItem = this.tabStack.Views[i] as ISelectable; + var tabItem = this.tabStack.Views[i] as IUnderliningTabView; if (tabItem != null) tabItem.Selected = SelectedTabViewItemIndex == i; } @@ -128,15 +143,22 @@ namespace Xamarin.PropertyEditing.Mac public override void LoadView () { - var stack = new NSStackView () { + this.outerStack = new NSStackView () { + Orientation = NSUserInterfaceLayoutOrientation.Horizontal, + EdgeInsets = EdgeInsets + }; + + this.innerStack = new NSStackView () { Spacing = 0, Alignment = NSLayoutAttribute.Left, - Orientation = NSUserInterfaceLayoutOrientation.Vertical + Orientation = NSUserInterfaceLayoutOrientation.Vertical, + EdgeInsets = EdgeInsets }; - stack.AddView (this.tabStack, NSStackViewGravity.Top); - stack.AddView (TabView, NSStackViewGravity.Bottom); - View = stack; + this.outerStack.AddView (this.innerStack, NSStackViewGravity.Leading); + this.innerStack.AddView (this.tabStack, NSStackViewGravity.Top); + this.innerStack.AddView (TabView, NSStackViewGravity.Bottom); + View = this.outerStack; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs index 39deb43..fcc4134 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs @@ -3,12 +3,11 @@ using CoreGraphics; namespace Xamarin.PropertyEditing.Mac { - - internal interface ISelectable { + internal interface IUnderliningTabView { bool Selected { get; set; } } - internal class UnderlinedImageView : NSImageView, ISelectable + internal class UnderlinedImageView : NSImageView, IUnderliningTabView { public UnderlinedImageView (string name) { @@ -22,14 +21,13 @@ namespace Xamarin.PropertyEditing.Mac { get => selected; set { - //if (selected == value) - // return; + if (selected == value && Image != null) + return; selected = value; var version = PropertyEditorPanel.ThemeManager.Theme == Themes.PropertyEditorTheme.Dark ? $"{name}~dark" : name; Image = NSImage.ImageNamed (selected ? $"{version}~sel" : version); - //Enabled = value; NeedsDisplay = true; } } @@ -55,7 +53,7 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class UnderlinedTextField : NSTextField, ISelectable + internal class UnderlinedTextField : NSTextField, IUnderliningTabView { public UnderlinedTextField () { @@ -70,12 +68,9 @@ namespace Xamarin.PropertyEditing.Mac get => selected; set { - //if (selected == value) - // return; selected = value; TextColor = selected ? NSColor.Text : NSColor.DisabledControlText; - //Enabled = value; NeedsDisplay = true; } } |