Skip to content

Commit 3e0de1c

Browse files
author
Juan Segura
committed
Added color picker button
1 parent 1e2a406 commit 3e0de1c

5 files changed

Lines changed: 35 additions & 3 deletions

File tree

ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
<ToggleButton Classes="toolbar" Name="btnViewAttributes" ToolTip.Tip="Hide or view attributes" IsChecked="True">
107107
<svg:Svg Path="/Svg/hide.svg"></svg:Svg>
108108
</ToggleButton>
109-
<ToggleButton Classes="toolbar" Name="btnSelectPixelsCell" ToolTip.Tip="Select cell" IsChecked="True" IsVisible="False">
110-
<svg:Svg Path="/Svg/select.svg"></svg:Svg>
109+
<ToggleButton Classes="toolbar" Name="btnColorPicker" ToolTip.Tip="Select cell" IsChecked="True">
110+
<svg:Svg Path="/Svg/picker.svg"></svg:Svg>
111111
</ToggleButton>
112112
<ToggleButton Classes="toolbar" Name="btnInvertPixelsCell" ToolTip.Tip="Invert pixels on selected cell" IsChecked="True">
113113
<svg:Svg Path="/Svg/invert-mode-svgrepo-com.svg"></svg:Svg>

ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ private void _Initialize(string fileName)
327327
btnRedo.Tapped += BtnRedo_Tapped;
328328

329329
btnViewAttributes.Tapped += BtnViewAttributes_Tapped;
330+
btnColorPicker.Tapped += BtnColorPicker_Tapped;
330331
btnInvertColorsCell.Tapped += BtnInvertColorsCell_Tapped;
331332
btnInvertPixelsCell.Tapped += BtnInvertPixelsCell_Tapped;
332333

@@ -711,6 +712,9 @@ private void Editor_Command(SpritePatternEditor sender, string command)
711712
ctrlProperties.PrimaryColor = sender.PrimaryColorIndex;
712713
ctrlProperties.SecondaryColor = sender.SecondaryColorIndex;
713714
ctrlPreview.SpriteData = sender.SpriteData;
715+
716+
btnColorPicker.IsChecked = !ctrlEditor.ColorPicker;
717+
UpdateColorPanel();
714718
}
715719
}
716720
break;
@@ -1026,6 +1030,11 @@ private void BtnViewAttributes_Tapped(object? sender, TappedEventArgs e)
10261030
ctrlEditor.ViewAttributes = btnViewAttributes.IsChecked==true;
10271031
}
10281032

1033+
private void BtnColorPicker_Tapped(object? sender, TappedEventArgs e)
1034+
{
1035+
ctrlEditor.ColorPicker = btnColorPicker.IsChecked == false;
1036+
}
1037+
10291038

10301039
private void BtnInvertPixelsCell_Tapped(object? sender, TappedEventArgs e)
10311040
{

ZXBStudio/DocumentEditors/ZXGraphics/SpritePatternEditor.axaml.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public bool ViewAttributes
103103

104104
public bool InvertColorsCell { get; set; } = false;
105105

106+
public bool ColorPicker { get; set; } = false;
107+
106108
#endregion
107109

108110

@@ -300,7 +302,19 @@ private void GrdEditor_PointerPressed(object? sender, Avalonia.Input.PointerPres
300302
{
301303
var p = e.GetCurrentPoint(grdEditor);
302304

303-
if (InvertPixelsCell)
305+
if (ColorPicker)
306+
{
307+
int x = (int)p.Position.X;
308+
int y = (int)p.Position.Y;
309+
x = x / (_Zoom + 1);
310+
y = y / (_Zoom + 1);
311+
var atr=GetAttribute(SpriteData.Patterns[SpriteData.CurrentFrame], x,y);
312+
PrimaryColorIndex = atr.Ink;
313+
SecondaryColorIndex = atr.Paper;
314+
ColorPicker = false;
315+
Refresh(true);
316+
}
317+
else if (InvertPixelsCell)
304318
{
305319
GrdEditor_InvertPixelsCell(p.Position.X, p.Position.Y);
306320
}

ZXBStudio/Svg/picker.svg

Lines changed: 7 additions & 0 deletions
Loading

ZXBStudio/ZXBasicStudio.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
<None Remove="Svg\minus-solid.svg" />
190190
<None Remove="Svg\paste-solid.svg" />
191191
<None Remove="Svg\pause-solid.svg" />
192+
<None Remove="Svg\picker.svg" />
192193
<None Remove="Svg\play-solid.svg" />
193194
<None Remove="Svg\power-off-solid.svg" />
194195
<None Remove="Svg\rectangle-list-solid.svg" />
@@ -362,6 +363,7 @@
362363
<AvaloniaResource Include="Svg\Documents\file-zxramdisk.svg" />
363364
<AvaloniaResource Include="Svg\github.svg" />
364365
<AvaloniaResource Include="Svg\hide.svg" />
366+
<AvaloniaResource Include="Svg\picker.svg" />
365367
<AvaloniaResource Include="Svg\select.svg" />
366368
<AvaloniaResource Include="Svg\White\book.svg" />
367369
<AvaloniaResource Include="Svg\White\chat.svg" />

0 commit comments

Comments
 (0)