diff options
author | Larry Ewing <lewing@xamarin.com> | 2018-05-16 18:58:34 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2018-07-16 22:05:49 +0300 |
commit | 8d88963577cb32072ba4e039250aaf6da0f2afac (patch) | |
tree | 600149ff9707957ae7d33a8b6f0f480e39bdc2ce /Xamarin.PropertyEditing.Mac | |
parent | f5f245d7bbf156e87d117a158698533036e73331 (diff) |
Add hex string display
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
3 files changed, 21 insertions, 19 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index 33ead00..3b3aaef 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -45,7 +45,7 @@ namespace Xamarin.PropertyEditing.Mac this.popover = new NSPopover (); popover.Behavior = NSPopoverBehavior.Transient; popover.ContentViewController = brushTabViewController = new BrushTabViewController { - PreferredContentSize = new CGSize (300, 280) + PreferredContentSize = new CGSize (250, 300) }; RowHeight = 230 + 28; @@ -54,7 +54,6 @@ namespace Xamarin.PropertyEditing.Mac TranslatesAutoresizingMaskIntoConstraints = false, ControlSize = NSControlSize.Small, Font = NSFont.FromFontName (DefaultFontName, DefaultFontSize), - Popover = this.popover }; popupButtonList = new NSMenu (); @@ -82,7 +81,7 @@ namespace Xamarin.PropertyEditing.Mac set => base.ViewModel = value; } - readonly NSPopUpButton popUpButton; + readonly ColorPopUpButton popUpButton; readonly BrushTabViewController colorEditor; readonly NSPopover popover; readonly BrushTabViewController brushTabViewController; @@ -134,6 +133,7 @@ namespace Xamarin.PropertyEditing.Mac { this.colorEditor.ViewModel = ViewModel; this.brushTabViewController.ViewModel = ViewModel; + this.popUpButton.Popover = ViewModel.Property.CanWrite ? popover : null; if (ViewModel.Solid != null) { var title = GetTitle (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index 65b8562..078f7d7 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -120,7 +120,7 @@ namespace Xamarin.PropertyEditing.Mac inhibitSelection = false; old = View.Frame; - old.Height = 230; + //old.Height = 230; View.Frame = old; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs index 5fa9d2d..865c91f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs @@ -114,17 +114,19 @@ namespace Xamarin.PropertyEditing.Mac Alignment = NSTextAlignment.Right }; AddSubview (StringLabel); - StringEditor = new NSTextField (); + StringEditor = new NSTextField { + Alignment = NSTextAlignment.Right + }; StringEditor.EditingEnded += (o, e) => { - if (CommonColor.TryParse (StringEditor.StringValue, out CommonColor c)) { + if (CommonColor.TryParseRgbaHex (StringEditor.StringValue, out CommonColor c)) { ViewModel.Color = c; - StringEditor.StringValue = c.ToString (); + StringEditor.StringValue = c.ToRgbaHex (); } }; AddSubview (StringEditor); } - void UpdateComponent (object sender, EventArgs args) + void UpdateComponent (object sender, EventArgs args) { if (ViewModel == null) return; @@ -135,21 +137,21 @@ namespace Xamarin.PropertyEditing.Mac ViewModel.CommitLastColor (); } - protected override void OnPropertyChanged(object sender, PropertyChangedEventArgs e) - { - base.OnPropertyChanged(sender, e); + protected override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) + { + base.OnPropertyChanged (sender, e); switch (e.PropertyName) { case nameof (SolidBrushViewModel.Color): - foreach (var channelGroup in Editors) { - var editor = channelGroup.Editor; - editor.Value = editor.ComponentEditor.ValueFromColor(ViewModel.Color); - editor.ComponentEditor.UpdateGradientLayer (channelGroup.Gradient, ViewModel.Color); - } - StringEditor.StringValue = ViewModel.Color.ToString (); - break; + foreach (var channelGroup in Editors) { + var editor = channelGroup.Editor; + editor.Value = editor.ComponentEditor.ValueFromColor (ViewModel.Color); + editor.ComponentEditor.UpdateGradientLayer (channelGroup.Gradient, ViewModel.Color); + } + StringEditor.StringValue = ViewModel.Color.ToString (); + break; } - } + } public override void UpdateConstraints() { |