Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Ewing <lewing@xamarin.com>2018-05-16 06:24:44 +0300
committerLarry Ewing <lewing@microsoft.com>2018-07-16 22:05:49 +0300
commitf5f245d7bbf156e87d117a158698533036e73331 (patch)
treef510494915a6e4ba6b9cb20c0e5149a501633b45 /Xamarin.PropertyEditing.Mac/Controls
parenta7fb38a78a5af820c8f41c8e6db676b30df43cfb (diff)
Add color parsing logic
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs4
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs4
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs58
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs2
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs16
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs4
6 files changed, 60 insertions, 28 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs
index ab60a7d..33ead00 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs
@@ -45,10 +45,10 @@ namespace Xamarin.PropertyEditing.Mac
this.popover = new NSPopover ();
popover.Behavior = NSPopoverBehavior.Transient;
popover.ContentViewController = brushTabViewController = new BrushTabViewController {
- PreferredContentSize = new CGSize (300, 250)
+ PreferredContentSize = new CGSize (300, 280)
};
- RowHeight = 200 + 28;
+ RowHeight = 230 + 28;
this.popUpButton = new ColorPopUpButton {
TranslatesAutoresizingMaskIntoConstraints = false,
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs
index 786e509..65b8562 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs
@@ -112,7 +112,7 @@ namespace Xamarin.PropertyEditing.Mac
public override void ViewDidLoad()
{
var old = View.Frame;
- old.Height = 200;
+ old.Height = 230;
View.Frame = old;
inhibitSelection = true;
@@ -120,7 +120,7 @@ namespace Xamarin.PropertyEditing.Mac
inhibitSelection = false;
old = View.Frame;
- old.Height = 200;
+ 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 eb06942..5fa9d2d 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs
@@ -4,6 +4,7 @@ using System.Linq;
using AppKit;
using CoreAnimation;
using CoreGraphics;
+using Xamarin.PropertyEditing.Drawing;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
@@ -31,6 +32,10 @@ namespace Xamarin.PropertyEditing.Mac
Initialize ();
}
+ ChannelGroup[] Editors { get; set; }
+ UnfocusableTextField StringLabel { get; set; }
+ NSTextField StringEditor { get; set; }
+
class ChannelGroup
{
public UnfocusableTextField Label { get; set; }
@@ -62,10 +67,9 @@ namespace Xamarin.PropertyEditing.Mac
return ce;
}
- ChannelGroup[] Editors { get; set; }
-
ChannelGroup[] CreateEditors (ChannelEditorType type)
{
+
switch (type) {
case ChannelEditorType.HSB:
return new[] {
@@ -104,6 +108,20 @@ namespace Xamarin.PropertyEditing.Mac
{
WantsLayer = true;
Editors = CreateEditors (EditorType);
+
+ StringLabel = new UnfocusableTextField {
+ StringValue = "#:",
+ Alignment = NSTextAlignment.Right
+ };
+ AddSubview (StringLabel);
+ StringEditor = new NSTextField ();
+ StringEditor.EditingEnded += (o, e) => {
+ if (CommonColor.TryParse (StringEditor.StringValue, out CommonColor c)) {
+ ViewModel.Color = c;
+ StringEditor.StringValue = c.ToString ();
+ }
+ };
+ AddSubview (StringEditor);
}
void UpdateComponent (object sender, EventArgs args)
@@ -123,11 +141,12 @@ namespace Xamarin.PropertyEditing.Mac
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);
- }
+ 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;
}
}
@@ -206,26 +225,23 @@ namespace Xamarin.PropertyEditing.Mac
foreach (var channelGroup in Editors) {
channelGroup.Label.Frame = labelFrame;
channelGroup.Editor.Frame = editorFrame;
- channelGroup.Gradient.Frame = new CGRect (editorFrame.X, editorFrame.Y - DefaultGradientHeight, editorFrame.Width - 16, DefaultGradientHeight);
+ channelGroup.Gradient.Frame = new CGRect (
+ editorFrame.X,
+ editorFrame.Y - DefaultGradientHeight,
+ editorFrame.Width - 16, DefaultGradientHeight);
+
channelGroup.Gradient.BorderColor = NSColor.DisabledControlText.CGColor;
channelGroup.Gradient.ContentsScale = Window?.Screen?.BackingScaleFactor ?? NSScreen.MainScreen.BackingScaleFactor;
labelFrame = labelFrame.Translate (0, -yOffset);
editorFrame = editorFrame.Translate (0, -yOffset);
}
- }
- }
- class ComponentSpinEditor : NumericSpinEditor
- {
- public ComponentSpinEditor (ChannelEditor component)
- {
- ComponentEditor = component;
- MinimumValue = component.MinimumValue;
- MaximumValue = component.MaximumValue;
- IncrementValue = component.IncrementValue;
- Digits = 2;
+ StringLabel.Frame = new CGRect (frame.X, padding, 20, DefaultControlHeight);
+ StringEditor.Frame = new CGRect (
+ labelFrame.Right,
+ padding,
+ frame.Width - labelFrame.Right - 16,
+ DefaultControlHeight);
}
-
- public ChannelEditor ComponentEditor { get; }
}
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs
index 65f3246..03e7241 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs
@@ -12,7 +12,7 @@ namespace Xamarin.PropertyEditing.Mac
public ColorComponentViewController (ChannelEditorType type) : base ()
{
- PreferredContentSize = new CGSize (200, 200);
+ PreferredContentSize = new CGSize (200, 220);
this.EditorType = type;
}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs
new file mode 100644
index 0000000..0f05b29
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs
@@ -0,0 +1,16 @@
+namespace Xamarin.PropertyEditing.Mac
+{
+ class ComponentSpinEditor : NumericSpinEditor
+ {
+ public ComponentSpinEditor (ChannelEditor component)
+ {
+ ComponentEditor = component;
+ MinimumValue = component.MinimumValue;
+ MaximumValue = component.MaximumValue;
+ IncrementValue = component.IncrementValue;
+ Digits = 2;
+ }
+
+ public ChannelEditor ComponentEditor { get; }
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs
index 118f3e6..fbd5e33 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs
@@ -178,8 +178,6 @@ namespace Xamarin.PropertyEditing.Mac
public override void Layout ()
{
- base.Layout ();
-
if (modelChanged) {
var interx = interaction ?? new EditorInteraction (ViewModel, null);
foreach (var editor in Layer.Sublayers.OfType<ColorEditorLayer> ()) {
@@ -188,6 +186,8 @@ namespace Xamarin.PropertyEditing.Mac
modelChanged = false;
}
+ base.Layout ();
+
if (Frame.IsEmpty || Frame.IsInfinite () || double.IsNaN (Frame.X) || double.IsInfinity (Frame.X))
return;