diff options
author | Larry Ewing <lewing@xamarin.com> | 2018-05-16 20:58:18 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2018-07-16 22:05:49 +0300 |
commit | e123b6b2ed14f6232bf6fc01f7d6c9ff56c3fe8f (patch) | |
tree | 52c887966f330b84a9ad592bb93cebe467c67923 /Xamarin.PropertyEditing.Mac | |
parent | 8d88963577cb32072ba4e039250aaf6da0f2afac (diff) |
Fix some appearance issues in popup mode
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs | 14 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs | 36 |
2 files changed, 25 insertions, 25 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index 3b3aaef..f89364f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -40,7 +40,6 @@ namespace Xamarin.PropertyEditing.Mac public BrushEditorControl () { TranslatesAutoresizingMaskIntoConstraints = false; - this.colorEditor = new BrushTabViewController (); this.popover = new NSPopover (); popover.Behavior = NSPopoverBehavior.Transient; @@ -48,8 +47,6 @@ namespace Xamarin.PropertyEditing.Mac PreferredContentSize = new CGSize (250, 300) }; - RowHeight = 230 + 28; - this.popUpButton = new ColorPopUpButton { TranslatesAutoresizingMaskIntoConstraints = false, ControlSize = NSControlSize.Small, @@ -58,19 +55,15 @@ namespace Xamarin.PropertyEditing.Mac popupButtonList = new NSMenu (); popUpButton.Menu = popupButtonList; - var view = this.colorEditor.View; this.DoConstraints (new[] { popUpButton.ConstraintTo (this, (pub, c) => pub.Width == c.Width - 34), popUpButton.ConstraintTo (this, (pub, c) => pub.Height == DefaultControlHeight + 1), popUpButton.ConstraintTo (this, (pub, c) => pub.Left == c.Left + 4), popUpButton.ConstraintTo (this, (pub, c) => pub.Top == c.Top + 0), - view.ConstraintTo (popUpButton, (v, pub) => v.Top == pub.Bottom), - view.ConstraintTo (popUpButton, (v, pub) => v.Left == pub.Left) }); AddSubview (this.popUpButton); - AddSubview (this.colorEditor.View); UpdateTheme (); } @@ -82,7 +75,7 @@ namespace Xamarin.PropertyEditing.Mac } readonly ColorPopUpButton popUpButton; - readonly BrushTabViewController colorEditor; + //readonly BrushTabViewController colorEditor; readonly NSPopover popover; readonly BrushTabViewController brushTabViewController; readonly NSMenu popupButtonList; @@ -99,6 +92,7 @@ namespace Xamarin.PropertyEditing.Mac protected override void SetEnabled () { + this.popUpButton.Enabled = this.ViewModel?.Property.CanWrite ?? false; } protected override void UpdateAccessibilityValues () @@ -131,9 +125,9 @@ namespace Xamarin.PropertyEditing.Mac protected override void UpdateValue () { - this.colorEditor.ViewModel = ViewModel; + SetEnabled (); this.brushTabViewController.ViewModel = ViewModel; - this.popUpButton.Popover = ViewModel.Property.CanWrite ? popover : null; + this.popUpButton.Popover = (ViewModel?.Property.CanWrite ?? false) ? popover : null; if (ViewModel.Solid != null) { var title = GetTitle (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs index 865c91f..aa4fb93 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs @@ -33,8 +33,8 @@ namespace Xamarin.PropertyEditing.Mac } ChannelGroup[] Editors { get; set; } - UnfocusableTextField StringLabel { get; set; } - NSTextField StringEditor { get; set; } + UnfocusableTextField hexLabel; + NSTextField hexEditor; class ChannelGroup { @@ -48,6 +48,7 @@ namespace Xamarin.PropertyEditing.Mac var ce = new ChannelGroup { Label = new UnfocusableTextField { StringValue = $"{editor.Name}:", + Alignment = NSTextAlignment.Right }, Editor = new ComponentSpinEditor (editor), Gradient = new CAGradientLayer { @@ -60,6 +61,7 @@ namespace Xamarin.PropertyEditing.Mac ce.Editor.TranslatesAutoresizingMaskIntoConstraints = true; ce.Editor.ValueChanged += UpdateComponent; ce.Editor.BackgroundColor = NSColor.Clear; + ce.Label.BackgroundColor = NSColor.Clear; AddSubview (ce.Label); AddSubview (ce.Editor); @@ -109,21 +111,25 @@ namespace Xamarin.PropertyEditing.Mac WantsLayer = true; Editors = CreateEditors (EditorType); - StringLabel = new UnfocusableTextField { + hexLabel = new UnfocusableTextField { StringValue = "#:", - Alignment = NSTextAlignment.Right + Alignment = NSTextAlignment.Right, + BackgroundColor = NSColor.Clear }; - AddSubview (StringLabel); - StringEditor = new NSTextField { - Alignment = NSTextAlignment.Right + AddSubview (hexLabel); + + hexEditor = new NSTextField { + Alignment = NSTextAlignment.Right, + BackgroundColor = NSColor.Clear }; - StringEditor.EditingEnded += (o, e) => { - if (CommonColor.TryParseRgbaHex (StringEditor.StringValue, out CommonColor c)) { + AddSubview (hexEditor); + + hexEditor.EditingEnded += (o, e) => { + if (CommonColor.TryParseArgbHex (hexEditor.StringValue, out CommonColor c)) { ViewModel.Color = c; - StringEditor.StringValue = c.ToRgbaHex (); + hexEditor.StringValue = c.ToString (); } }; - AddSubview (StringEditor); } void UpdateComponent (object sender, EventArgs args) @@ -148,7 +154,7 @@ namespace Xamarin.PropertyEditing.Mac editor.Value = editor.ComponentEditor.ValueFromColor (ViewModel.Color); editor.ComponentEditor.UpdateGradientLayer (channelGroup.Gradient, ViewModel.Color); } - StringEditor.StringValue = ViewModel.Color.ToString (); + hexEditor.StringValue = ViewModel.Color.ToString (); break; } } @@ -229,7 +235,7 @@ namespace Xamarin.PropertyEditing.Mac channelGroup.Editor.Frame = editorFrame; channelGroup.Gradient.Frame = new CGRect ( editorFrame.X, - editorFrame.Y - DefaultGradientHeight, + editorFrame.Y - DefaultGradientHeight + 1, editorFrame.Width - 16, DefaultGradientHeight); channelGroup.Gradient.BorderColor = NSColor.DisabledControlText.CGColor; @@ -238,8 +244,8 @@ namespace Xamarin.PropertyEditing.Mac editorFrame = editorFrame.Translate (0, -yOffset); } - StringLabel.Frame = new CGRect (frame.X, padding, 20, DefaultControlHeight); - StringEditor.Frame = new CGRect ( + hexLabel.Frame = new CGRect (frame.X, padding, 20, DefaultControlHeight); + hexEditor.Frame = new CGRect ( labelFrame.Right, padding, frame.Width - labelFrame.Right - 16, |