Skip to content

Commit

Permalink
Merge branch 'master' into add-flags-dock
Browse files Browse the repository at this point in the history
  • Loading branch information
gusmanb authored Dec 30, 2023
2 parents 5ac27e1 + da7ee2d commit d0f5ec9
Show file tree
Hide file tree
Showing 28 changed files with 1,563 additions and 303 deletions.
8 changes: 4 additions & 4 deletions ZXBStudio/BuildSystem/ZXProjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ZXProjectBuilder

if (ZXProjectManager.Current == null)
{
OutputLogWritter.WriteLine("No open projcet, aborting...");
OutputLogWritter.WriteLine("No open project, aborting...");
return null;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
{
if (ZXProjectManager.Current == null)
{
OutputLogWritter.WriteLine("No open projcet, aborting...");
OutputLogWritter.WriteLine("No open project, aborting...");
return null;
}

Expand Down Expand Up @@ -454,14 +454,14 @@ public static bool Export(ZXExportOptions Export, TextWriter OutputLogWritter)
{
if (ZXProjectManager.Current == null)
{
OutputLogWritter.WriteLine("No open projcet, aborting...");
OutputLogWritter.WriteLine("No open project, aborting...");
return false;
}

var project = ZXProjectManager.Current;

Cleanup(project.ProjectPath);
ZXBuildSettings? settings = null;
ZXBuildSettings? settings;
string? mainFile = null;

if (string.IsNullOrWhiteSpace(ZXOptions.Current.ZxbcPath) || string.IsNullOrWhiteSpace(ZXOptions.Current.ZxbasmPath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
x:Class="ZXBasicStudio.DocumentEditors.ZXGraphics.ColorPickerControl">
<Grid HorizontalAlignment="Center">
<Grid Name="grdMonochrome" IsVisible="False">
<TextBlock>Monochrome...</TextBlock>
</Grid>
<Grid Name="grdZXSpectrum" IsVisible="False">
<TextBlock>ZX Spectrum...</TextBlock>
<Canvas Name="cnvZXSpectrum" Width="160" Height="40" Margin="4"/>
</Grid>
<Grid Name="grdNext" IsVisible="False">
<TextBlock>Next...</TextBlock>
Expand Down
87 changes: 82 additions & 5 deletions ZXBStudio/DocumentEditors/ZXGraphics/ColorPickerControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ namespace ZXBasicStudio.DocumentEditors.ZXGraphics
public partial class ColorPickerControl : UserControl
{
private GraphicsModes graphicMode = GraphicsModes.Monochrome;

private Action<string, int> callBackCommand = null;
private PaletteColor[] palette = null;
private int selectedIndexColor = 0;

/// <summary>
/// Constructor
Expand All @@ -32,19 +34,23 @@ public ColorPickerControl()
}


public bool Inicialize(GraphicsModes graphicMode, PaletteColor[] palette, int primaryColor, int secondaryColor, bool bright, bool flash)
public bool Inicialize(GraphicsModes graphicMode, PaletteColor[] palette, int selectedIndexColor, Action<string, int> callBackCommand)
{
this.graphicMode = graphicMode;
this.palette = palette;
this.callBackCommand = callBackCommand;
this.selectedIndexColor = selectedIndexColor;

grdMonochrome.IsVisible = true;
grdZXSpectrum.IsVisible = true;
grdNext.IsVisible = true;
grdMonochrome.IsVisible = false;
grdZXSpectrum.IsVisible = false;
grdNext.IsVisible = false;
switch (graphicMode)
{
case GraphicsModes.Monochrome:
grdMonochrome.IsVisible = true;
break;
case GraphicsModes.ZXSpectrum:
DrawZXSpectrum();
grdZXSpectrum.IsVisible = true;
break;
case GraphicsModes.Next:
Expand All @@ -55,5 +61,76 @@ public bool Inicialize(GraphicsModes graphicMode, PaletteColor[] palette, int pr

return true;
}

/// <summary>
/// Draw colors for ZXSpectrum palette
/// </summary>
private void DrawZXSpectrum()
{
cnvZXSpectrum.Children.Clear();
// Draw all colors
int index = 0;
for (int y = 0; y < 2; y++)
{
for (int x = 0; x < 8; x++)
{
var p = palette[index];
var b = new SolidColorBrush(new Color(255, p.Red, p.Green, p.Blue));
DrawRectangle(cnvZXSpectrum, x * 20, y * 20, 18, 18, Brushes.White, b, index);
index++;

}
}

// Draw selected color (ink)
{
int y = selectedIndexColor / 8;
int x = selectedIndexColor % 8;
DrawRectangle(cnvZXSpectrum, (x * 20) - 2, (y * 20) - 2, 22, 22, Brushes.Red, null, -1);
}
}


private void DrawRectangle(Canvas canvas, int x, int y, int w, int h, IBrush? borderBrush, IBrush? colorBrush, int tag)
{
var r = new Rectangle();
r.Width = w;
r.Height = h;
r.Tag = tag.ToString();
if (borderBrush != null)
{
r.Stroke = borderBrush;
r.StrokeThickness = 1;
}
if (colorBrush != null)
{
r.Fill = colorBrush;
}
canvas.Children.Add(r);
Canvas.SetTop(r, y);
Canvas.SetLeft(r, x);

r.Tapped += R_Tapped;
}


private void R_Tapped(object? sender, TappedEventArgs e)
{
if (sender == null)
{
return;
}

Rectangle r = (Rectangle)sender;

int color = r.Tag.ToInteger();
if (color >= 0)
{
selectedIndexColor = color;
this.IsVisible = false;

callBackCommand?.Invoke("SELECT", selectedIndexColor);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,6 @@ private void ZoomOut()
{
sldZoom.Value = v - 1;
}

}

#endregion
Expand Down
15 changes: 15 additions & 0 deletions ZXBStudio/DocumentEditors/ZXGraphics/IZXBitmap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Avalonia;
using Avalonia.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZXBasicStudio.DocumentEditors.ZXGraphics
{
public interface IZXBitmap : IImage
{
public PixelSize PixelSize { get; }
}
}
81 changes: 29 additions & 52 deletions ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Focusable="True"
Background="#ff202020"
x:Class="ZXBasicStudio.DocumentEditors.ZXGraphics.SpriteEditor">
<UserControl.Styles>
<Style Selector="Button.toolbar_r90">
<Setter Property="Background" Value="#fff0f0f0" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Padding" Value="4" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="90"/>
</Setter.Value>
</Setter>
</Style>
<Style Selector="Button.toolbar_r270">
<Setter Property="Background" Value="#fff0f0f0" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Padding" Value="4" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="270"/>
</Setter.Value>
</Setter>
</Style>
<Style Selector="Button.toolbar_hMirror">
<Setter Property="Background" Value="#fff0f0f0" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Padding" Value="4" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="-1"/>
</Setter.Value>
</Setter>
</Style>
</UserControl.Styles>
x:Class="ZXBasicStudio.DocumentEditors.ZXGraphics.SpriteEditor">

<Grid Name="grdMain" RowDefinitions="*,Auto">
<Grid Name="grdEditor" Grid.RowSpan="2" ColumnDefinitions="180,4,*,4,200" Margin="0,8,0,0">
Expand Down Expand Up @@ -139,40 +101,55 @@
</WrapPanel>

<local:SpritePatternEditor Name="ctrlEditor" Grid.Row="1" Background="#303030"/>

<WrapPanel Orientation="Horizontal" Background="#ff202020" Grid.Row="2" Margin="10,5,10,5" Height="NaN">
<TextBlock Name="txtZoom" Classes="dialog" Width="54">Zoom 24x</TextBlock>
<Slider Name="sldZoom" Width="100" Minimum="1" Maximum="9" Value="6" VerticalAlignment="Center"/>
<TextBlock Name="txtFrame" Classes="dialog" Width="55" Margin="8,4,0,0">Frame</TextBlock>
<Slider Name="sldFrame" Width="100" Minimum="0" Maximum="0" Value="0" VerticalAlignment="Center"/>
<Button Name="btnPaper" Classes="toobar" Margin="8,0,0,0">Paper</Button>
<Button Name="btnInk" Classes="toobar" Margin="8,0,0,0">Ink</Button>

<Grid Name="btnPaper" Margin="8,0,0,0" ColumnDefinitions="*,16,Auto">
<TextBlock Margin="10,5,5,5">Paper</TextBlock>
<Border Grid.Column="1" BorderBrush="Red" BorderThickness="1" Width="20" Height="20">
<Grid Name="grdPaper">
<TextBlock Name="txtPaper" Grid.Column="2" HorizontalAlignment="Center">0</TextBlock>
</Grid>
</Border>
</Grid>

<Grid Name="btnInk" Margin="8,0,0,0" ColumnDefinitions="*,16,Auto">
<TextBlock Margin="10,5,5,5">Ink</TextBlock>
<Border Grid.Column="1" BorderBrush="Red" BorderThickness="1" Width="20" Height="20">
<Grid Name="grdInk">
<TextBlock Name="txtInk" Grid.Column="2" HorizontalAlignment="Center">1</TextBlock>
</Grid>
</Border>
</Grid>

<!--
<Button Name="btnBright" Classes="toobar" Margin="8,0,0,0">Bright</Button>
<Button Name="btnFlash" Classes="toobar" Margin="8,0,0,0">Flash</Button>
-->
</WrapPanel>

</Grid>

<GridSplitter ResizeDirection="Columns" Grid.Column="3" Classes="vertical"></GridSplitter>

<zxd:ZXDockingContainer Name="dockRight" DockingGroup="ZXGraphics" Grid.Column="4" RowDefinitions="*">
<Grid RowDefinitions="120,4,*">

<zxd:ZXDockingControl Grid.Row="0" Name="dockPreview" Title="Preview" DockingGroup="ZXGraphics2" DesiredFloatingSize="200,400">
<zxd:ZXDockingContainer Name="dockRight" DockingGroup="ZXGraphics" Grid.Column="4" RowDefinitions="*,4,4*" Background="Red">
<zxd:ZXDockingControl Grid.Row="0" Name="dockPreview" Title="Preview" DockingGroup="ZXGraphics" DesiredFloatingSize="200,400">
<zxd:ZXDockingControl.DockedControl>
<local:SpritePreviewControl Name="ctrlPreview"></local:SpritePreviewControl>
</zxd:ZXDockingControl.DockedControl>
</zxd:ZXDockingControl>

<GridSplitter ResizeDirection="Rows" Grid.Row="1" Classes="horizontal"></GridSplitter>

<zxd:ZXDockingControl Grid.Row="2" Name="dockProperties" Title="Properties" DockingGroup="ZXGraphics2" DesiredFloatingSize="200,400">
<zxd:ZXDockingControl.DockedControl>
<zxd:ZXDockingControl Grid.Row="2" Name="dockProperties" Title="Properties" DockingGroup="ZXGraphics" DesiredFloatingSize="200,400">
<zxd:ZXDockingControl.DockedControl>
<local:SpritePropertiesControl Name="ctrlProperties"/>
</zxd:ZXDockingControl.DockedControl>
</zxd:ZXDockingControl>
</Grid>

</zxd:ZXDockingControl.DockedControl>
</zxd:ZXDockingControl>
</zxd:ZXDockingContainer>

</Grid>
Expand Down
Loading

0 comments on commit d0f5ec9

Please sign in to comment.