Skip to content

Commit 88fb43e

Browse files
committed
ux: new style for ColorPicker
1 parent e5c2c81 commit 88fb43e

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/Views/ColorPicker.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ public override void Render(DrawingContext context)
112112

113113
// Palette picker
114114
{
115-
var y = 6 * 32 + 8;
116-
var x = 0;
117-
118-
context.DrawRectangle(new SolidColorBrush(_darkestColor), null, new RoundedRect(new Rect(x, y, 32, 32), new CornerRadius(4, 0, 0, 4))); x += 32;
119-
context.FillRectangle(new SolidColorBrush(_darkerColor), new Rect(x, y, 32, 32)); x += 32;
120-
context.FillRectangle(new SolidColorBrush(_darkColor), new Rect(x, y, 32, 32)); x += 32;
121-
context.FillRectangle(new SolidColorBrush(_color), new Rect(x, y - 4, 64, 40), 4); x += 64;
122-
context.FillRectangle(new SolidColorBrush(_lightColor), new Rect(x, y, 32, 32)); x += 32;
123-
context.FillRectangle(new SolidColorBrush(_lighterColor), new Rect(x, y, 32, 32)); x += 32;
124-
context.DrawRectangle(new SolidColorBrush(_lightestColor), null, new RoundedRect(new Rect(x, y, 32, 32), new CornerRadius(0, 4, 4, 0)));
115+
context.DrawRectangle(Brushes.Transparent, null, new Rect(0, 200, 256, 32), 4, 4, _shadow);
116+
117+
context.DrawRectangle(new SolidColorBrush(_darkestColor), null, _darkestRect);
118+
context.FillRectangle(new SolidColorBrush(_darkerColor), _darkerRect);
119+
context.FillRectangle(new SolidColorBrush(_darkColor), _darkRect);
120+
context.FillRectangle(new SolidColorBrush(_lightColor), _lightRect);
121+
context.FillRectangle(new SolidColorBrush(_lighterColor), _lighterRect);
122+
context.DrawRectangle(new SolidColorBrush(_lightestColor), null, _lightestRect);
123+
124+
context.DrawRectangle(new SolidColorBrush(_color), null, new Rect(96, 200 - 4, 64, 40), 4, 4, _shadow);
125125
}
126126
}
127127

@@ -138,9 +138,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
138138

139139
protected override Size MeasureOverride(Size availableSize)
140140
{
141-
var w = 32 * 8;
142-
var h = 32 * 6 + 16 + 36;
143-
return new Size(w, h);
141+
return new Size(256, 256);
144142
}
145143

146144
protected override void OnPointerPressed(PointerPressedEventArgs e)
@@ -162,7 +160,7 @@ protected override void OnPointerPressed(PointerPressedEventArgs e)
162160
return;
163161
}
164162

165-
if (_darkestRect.Contains(p))
163+
if (_darkestRect.Rect.Contains(p))
166164
{
167165
_hightlightedTableElement = -1;
168166
SetCurrentValue(ValueProperty, _darkestColor.ToUInt32());
@@ -187,7 +185,7 @@ protected override void OnPointerPressed(PointerPressedEventArgs e)
187185
_hightlightedTableElement = -1;
188186
SetCurrentValue(ValueProperty, _lighterColor.ToUInt32());
189187
}
190-
else if (_lightestRect.Contains(p))
188+
else if (_lightestRect.Rect.Contains(p))
191189
{
192190
_hightlightedTableElement = -1;
193191
SetCurrentValue(ValueProperty, _lightestColor.ToUInt32());
@@ -217,13 +215,15 @@ private Color GetNextColor(HsvColor c, double step)
217215
return newColor.ToRgb();
218216
}
219217

218+
private BoxShadows _shadow = BoxShadows.Parse("0 0 6 0 #A9000000");
219+
220220
private Rect _colorTableRect = new Rect(0, 0, 32 * 8, 32 * 6);
221-
private Rect _darkestRect = new Rect(0, 200, 32, 32);
221+
private RoundedRect _darkestRect = new RoundedRect(new Rect(0, 200, 32, 32), new CornerRadius(4, 0, 0, 4));
222222
private Rect _darkerRect = new Rect(32, 200, 32, 32);
223223
private Rect _darkRect = new Rect(64, 200, 32, 32);
224224
private Rect _lightRect = new Rect(160, 200, 32, 32);
225225
private Rect _lighterRect = new Rect(192, 200, 32, 32);
226-
private Rect _lightestRect = new Rect(224, 200, 32, 32);
226+
private RoundedRect _lightestRect = new RoundedRect(new Rect(224, 200, 32, 32), new CornerRadius(0, 4, 4, 0));
227227

228228
private int _hightlightedTableElement = -1;
229229

src/Views/ConfigureWorkspace.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</Grid>
4747

4848
<!-- BODY -->
49-
<Grid Grid.Row="1" ColumnDefinitions="200,*" Height="320" Margin="8">
49+
<Grid Grid.Row="1" ColumnDefinitions="200,*" Height="324" Margin="8">
5050
<Border Grid.Column="0"
5151
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
5252
Background="{DynamicResource Brush.Contents}">

0 commit comments

Comments
 (0)