|
1 | 1 | using System; |
2 | 2 | using System.ComponentModel; |
3 | 3 | using System.Linq; |
4 | | -using System.Runtime.CompilerServices; |
| 4 | + |
5 | 5 | using AppKit; |
6 | 6 | using CoreAnimation; |
7 | 7 | using CoreGraphics; |
8 | | -using CoreImage; |
9 | | -using Foundation; |
| 8 | + |
10 | 9 | using Xamarin.PropertyEditing.Drawing; |
11 | 10 | using Xamarin.PropertyEditing.ViewModels; |
12 | 11 |
|
@@ -79,12 +78,14 @@ private void Initialize (IHostResourceProvider hostResources) |
79 | 78 |
|
80 | 79 | private readonly CALayer background = new CALayer { |
81 | 80 | CornerRadius = 3, |
82 | | - BorderWidth = 1 |
| 81 | + BorderWidth = 1, |
| 82 | + BorderColor = new CGColor (.5f, .5f, .5f, .5f), |
83 | 83 | }; |
84 | 84 |
|
85 | 85 | private readonly CALayer componentBackground = new CALayer { |
86 | 86 | CornerRadius = 3, |
87 | | - BorderWidth = 1 |
| 87 | + BorderWidth = 1, |
| 88 | + BorderColor = new CGColor (.5f, .5f, .5f, .5f) |
88 | 89 | }; |
89 | 90 |
|
90 | 91 | private EditorInteraction interaction; |
@@ -176,36 +177,36 @@ public override void Layout () |
176 | 177 | if (Frame.IsEmpty || Frame.IsInfinite () || double.IsNaN (Frame.X) || double.IsInfinity (Frame.X)) |
177 | 178 | return; |
178 | 179 |
|
179 | | - var secondarySpan = 20; |
180 | | - var primarySpan = Frame.Height - 2 * padding - secondarySpan; |
181 | | - var firstBase = padding; |
182 | | - var secondBase = padding + secondarySpan; |
183 | | - var firstStop = firstBase + primarySpan; |
184 | | - |
185 | | - this.background.BorderColor = new CGColor (.5f, .5f, .5f, .5f); |
186 | 180 | this.background.BackgroundColor = NSColor.ControlBackground.CGColor; |
187 | | - this.background.Frame = new CGRect (0, 0, Frame.Height, Frame.Height); |
188 | | - |
189 | | - this.componentBackground.BorderColor = new CGColor (.5f, .5f, .5f, .5f); |
190 | 181 | this.componentBackground.BackgroundColor = NSColor.ControlBackground.CGColor; |
191 | | - this.componentBackground.Frame = new CGRect (0, 0, Frame.Height, Frame.Height); |
| 182 | + this.hueLayer.GripColor = NSColor.Text.CGColor; |
192 | 183 |
|
193 | | - var x = firstStop + secondarySpan + 4 * padding; |
194 | | - var backgroundFrame = new CGRect (x, 0, Math.Max(Frame.Width - x, 180), Frame.Height); |
195 | | - this.componentBackground.Frame = backgroundFrame; |
| 184 | + const float spacing = 8, hueWidth = 20, historyHeight = 20; |
| 185 | + const float leftMinWidth = hueWidth + (Padding * 2) + 50; |
| 186 | + const float rightMinWidth = 125; |
| 187 | + const float rightRatio = 0.85f; |
196 | 188 |
|
197 | | - this.hueLayer.Frame = new CGRect (firstStop, secondBase, secondarySpan, primarySpan); |
198 | | - this.hueLayer.GripColor = NSColor.Text.CGColor; |
| 189 | + nfloat hspace = Frame.Width - spacing; |
| 190 | + float leftWidth = Math.Max ((float)(hspace / 2) * (1 + (1 - rightRatio)), leftMinWidth); |
| 191 | + float rightWidth = Math.Max ((float)(hspace - leftWidth), rightMinWidth); |
| 192 | + nfloat vspace = Frame.Height - (Padding * 2); |
| 193 | + |
| 194 | + this.background.Frame = new CGRect (0, 0, leftWidth, Frame.Height); |
| 195 | + |
| 196 | + var shadeFrame = new CGRect (Padding, Padding + historyHeight + Padding, leftWidth - (Padding * 3) - hueWidth, vspace - historyHeight - Padding); |
| 197 | + this.shadeLayer.Frame = shadeFrame; |
| 198 | + this.historyLayer.Frame = new CGRect (Padding, Padding, shadeFrame.Width, historyHeight); |
| 199 | + this.hueLayer.Frame = new CGRect (this.shadeLayer.Frame.Right + Padding, this.historyLayer.Frame.Bottom + Padding, hueWidth, shadeFrame.Height); |
| 200 | + |
| 201 | + var backgroundFrame = new CGRect (this.hueLayer.Frame.Right + spacing, 0, rightWidth, Frame.Height); |
| 202 | + this.componentBackground.Frame = backgroundFrame; |
| 203 | + var inset = backgroundFrame.Inset (4 * Padding, 2 * Padding); |
| 204 | + this.componentTabs.View.Frame = inset; |
199 | 205 |
|
200 | | - this.shadeLayer.Frame = new CGRect (firstBase, secondBase, primarySpan, primarySpan); |
201 | | - this.historyLayer.Frame = new CGRect (firstBase, firstBase, primarySpan, secondarySpan); |
202 | 206 | var inter = interaction ?? new EditorInteraction (ViewModel, null); |
203 | 207 | foreach (var editor in Layer.Sublayers.OfType<ColorEditorLayer> ()) { |
204 | 208 | editor.UpdateFromModel (inter); |
205 | 209 | } |
206 | | - |
207 | | - var inset = backgroundFrame.Inset (4 * padding, 2 * padding); |
208 | | - this.componentTabs.View.Frame = inset; |
209 | 210 | } |
210 | 211 | } |
211 | 212 | } |
0 commit comments