Skip to content

Commit 7fbf5bb

Browse files
committed
Sprite editor:
- Extended sprite size limit from 32 to 256 sprites - Added ScrollViewer container in sprite preview area - Frame slide control changed to numeric up down
1 parent 6e0bf0d commit 7fbf5bb

6 files changed

Lines changed: 51 additions & 21 deletions

File tree

ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@
105105
<WrapPanel Orientation="Horizontal" Background="#ff202020" Grid.Row="2" Margin="10,5,10,5" Height="NaN">
106106
<TextBlock Name="txtZoom" Classes="dialog" Width="54">Zoom 24x</TextBlock>
107107
<Slider Name="sldZoom" Width="100" Minimum="1" Maximum="9" Value="6" VerticalAlignment="Center"/>
108-
<TextBlock Name="txtFrame" Classes="dialog" Width="55" Margin="8,4,0,0">Frame</TextBlock>
109-
<Slider Name="sldFrame" Width="100" Minimum="0" Maximum="0" Value="0" VerticalAlignment="Center"/>
108+
<TextBlock Name="lblFrame" Classes="dialog" Width="55" Margin="16,8,0,0">Frame</TextBlock>
109+
<Border Classes="numericborder" Margin="-10,0,0,0">
110+
<NumericUpDown Classes="dialog" Name="txtFrame" Minimum="0" Increment="1" Maximum="255" Value="0" VerticalAlignment="Center"/>
111+
</Border>
110112

111113
<Grid Name="btnPaper" Margin="8,0,0,0" ColumnDefinitions="*,16,Auto">
112114
<TextBlock Margin="10,5,5,5">Paper</TextBlock>

ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml.cs

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ private void _Initialize(string fileName)
313313
}
314314

315315
sldZoom.PropertyChanged += SldZoom_PropertyChanged;
316-
sldFrame.PropertyChanged += SldFrame_PropertyChanged;
316+
txtFrame.PropertyChanged += TxtFrame_PropertyChanged;
317317

318318
btnClear.Tapped += BtnClear_Tapped;
319319
btnCut.Tapped += BtnCut_Tapped;
@@ -351,7 +351,6 @@ private void _Initialize(string fileName)
351351
this.Focus();
352352
}
353353

354-
355354
#region Color
356355

357356
private void BtnPaper_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
@@ -498,17 +497,34 @@ private void SpriteProperties_Command(SpritePropertiesControl sender, string com
498497
SpriteList_Clone(sender.SpriteData);
499498
SpriteList_Modified(sender.SpriteData);
500499
break;
500+
case "FRAMEUPDATE":
501+
{
502+
int f = sender.SpriteData.Frames - 1;
503+
if (f < 0)
504+
{
505+
f = 0;
506+
}
507+
else if (f > 255)
508+
{
509+
f = 255;
510+
}
511+
txtFrame.Maximum = f;
512+
txtFrame.Text = f.ToString();
513+
txtFrame.UpdateLayout();
514+
SpriteProperties_Command(sender, "REFRESH");
515+
}
516+
break;
501517
case "REFRESH":
502518
ctrlEditor.SpriteData = sender.SpriteData;
503519
SpriteList_Modified(sender.SpriteData);
504520
if (ctrlEditor.SpriteData.CurrentFrame != actualFrame)
505521
{
506-
actualFrame = ctrlEditor.SpriteData.CurrentFrame;
507-
if (sldFrame.Maximum < actualFrame)
522+
txtFrame.Value = actualFrame;
523+
if (txtFrame.Maximum < actualFrame)
508524
{
509-
sldFrame.Maximum = actualFrame;
525+
txtFrame.Maximum = actualFrame;
510526
}
511-
sldFrame.Value = actualFrame;
527+
txtFrame.Value = actualFrame;
512528
Refresh();
513529
}
514530
UpdateColorPanel();
@@ -607,7 +623,7 @@ private void SpriteList_Insert(Sprite spriteData)
607623
spriteData.Frames++;
608624
ctrlProperties.Refresh();
609625
ctrlEditor.Refresh();
610-
sldFrame.Maximum = spriteData.Frames;
626+
txtFrame.MaxHeight = spriteData.Frames - 1;
611627
}
612628

613629

@@ -688,16 +704,16 @@ private void Editor_Command(SpritePatternEditor sender, string command)
688704

689705
private void Refresh()
690706
{
691-
txtFrame.Text = "Frame " + actualFrame.ToString();
707+
txtFrame.Text = actualFrame.ToString();
692708
if (ctrlProperties.SpriteData != null)
693709
{
694-
sldFrame.Maximum = ctrlProperties.SpriteData.Frames;
710+
txtFrame.Maximum = ctrlProperties.SpriteData.Frames - 1;
695711
}
696712
else
697713
{
698-
sldFrame.Maximum = 0;
714+
txtFrame.Maximum = 0;
699715
}
700-
sldFrame.UpdateLayout();
716+
txtFrame.UpdateLayout();
701717
}
702718

703719

@@ -742,13 +758,20 @@ private void ZoomOut()
742758
}
743759

744760

745-
private void SldFrame_PropertyChanged(object? sender, Avalonia.AvaloniaPropertyChangedEventArgs e)
761+
private void TxtFrame_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
746762
{
747-
byte v = (byte)sldFrame.Value;
748-
if (actualFrame == v || ctrlProperties.SpriteData == null || v < 0 || v >= (ctrlProperties.SpriteData.Frames))
763+
byte v = txtFrame.Text.ToByte();
764+
if (actualFrame == v ||
765+
ctrlProperties.SpriteData == null ||
766+
v < 0 ||
767+
v >= (ctrlProperties.SpriteData.Frames))
749768
{
750769
return;
751770
}
771+
if (v > 255)
772+
{
773+
v = 255;
774+
}
752775
actualFrame = v;
753776
if (ctrlEditor.SpriteData != null)
754777
{

ZXBStudio/DocumentEditors/ZXGraphics/SpritePreviewControl.axaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<ComboBoxItem>20 fps (50ms)</ComboBoxItem>
2020
<ComboBoxItem>50 fps (20ms)</ComboBoxItem>
2121
</ComboBox>
22-
<Image Name="imgPreview" Grid.ColumnSpan="2" Grid.Row="1" Width="32" Height="32" RenderOptions.BitmapInterpolationMode="None"></Image>
22+
<ScrollViewer Grid.ColumnSpan="2" Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto">
23+
<Image Name="imgPreview" Grid.ColumnSpan="2" Grid.Row="1" Width="32" Height="32" RenderOptions.BitmapInterpolationMode="None" HorizontalAlignment="Center" VerticalAlignment="Center"></Image>
24+
</ScrollViewer>
2325
</Grid>
2426
</UserControl>

ZXBStudio/DocumentEditors/ZXGraphics/SpritePreviewControl.axaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public SpritePreviewControl()
5050
aspect.Clear(emptyColor);
5151
InitializeComponent();
5252
imgPreview.Source = aspect;
53+
imgPreview.Width = aspect.Size.Width;
54+
imgPreview.Height = aspect.Size.Height;
5355
}
5456

5557
/// <summary>
@@ -99,6 +101,8 @@ public void Refresh(object? sender = null, EventArgs? e = null)
99101
return;
100102

101103
aspect.Clear(emptyColor);
104+
imgPreview.Width = aspect.Size.Width;
105+
imgPreview.Height = aspect.Size.Height;
102106
imgPreview.InvalidateVisual();
103107
return;
104108
}

ZXBStudio/DocumentEditors/ZXGraphics/SpritePropertiesControl.axaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@
1818
<ComboBox Name="cmbMode" Classes="dialog" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" MaxWidth="Infinity" Margin="4,0,0,2">
1919
<ComboBoxItem>Monochrome</ComboBoxItem>
2020
<ComboBoxItem>ZX Spectrum</ComboBoxItem>
21-
<!--<ComboBoxItem>Next (256 colors)</ComboBoxItem>-->
2221
</ComboBox>
2322

2423
<TextBlock Grid.Row="3" Classes="dialog" VerticalAlignment="Center" HorizontalAlignment="Right">Width:</TextBlock>
2524
<Border Grid.Row="3" Grid.Column="1" Classes="numericborder">
26-
<NumericUpDown Classes="dialog" Name="txtWidth" Minimum="8" Increment="8" Maximum="32" Value="8" VerticalAlignment="Center"/>
25+
<NumericUpDown Classes="dialog" Name="txtWidth" Minimum="8" Increment="8" Maximum="256" Value="8" VerticalAlignment="Center"/>
2726
</Border>
2827

2928
<TextBlock Grid.Row="4" Classes="dialog" VerticalAlignment="Center" HorizontalAlignment="Right">Height:</TextBlock>
3029
<Border Grid.Row="4" Grid.Column="1" Classes="numericborder">
31-
<NumericUpDown Classes="dialog" Name="txtHeight" Minimum="1" Increment="8" Maximum="32" Value="8" VerticalAlignment="Center"/>
30+
<NumericUpDown Classes="dialog" Name="txtHeight" Minimum="1" Increment="8" Maximum="256" Value="8" VerticalAlignment="Center"/>
3231
</Border>
3332

3433
<TextBlock Grid.Row="5" Classes="dialog" VerticalAlignment="Center" HorizontalAlignment="Right">Frames:</TextBlock>

ZXBStudio/DocumentEditors/ZXGraphics/SpritePropertiesControl.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ private void TxtFrames_ValueChanged(object? sender, NumericUpDownValueChangedEve
413413
}
414414
SpriteData.CurrentFrame = (byte)(SpriteData.Frames - 1);
415415
Refresh();
416-
CallBackCommand(this, "REFRESH");
416+
CallBackCommand(this, "FRAMEUPDATE");
417417
}
418418
}
419419

0 commit comments

Comments
 (0)