Skip to content

Commit

Permalink
Convert the remainder of character format icons to ansi
Browse files Browse the repository at this point in the history
- Use common ColourBox control for Rip/Character colour selection
  • Loading branch information
cwensley committed Mar 11, 2023
1 parent 9da7484 commit 646e0de
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 100 deletions.
22 changes: 22 additions & 0 deletions Source/Pablo/Drawing/ColourBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Eto.Drawing;
using Eto.Forms;

namespace Pablo.Drawing
{
public abstract class ColourBox : Drawable
{
public abstract Color Color { get; set; }

protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
var rect = new Rectangle(Size);
pe.Graphics.FillRectangle(Color, rect);
pe.Graphics.DrawButtonOutline(rect);
}
}
}
3 changes: 2 additions & 1 deletion Source/Pablo/Formats/Character/Controls/ColourEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Eto.Forms;
using Eto.Drawing;
using Pablo.Controls;
using Pablo.Drawing;

namespace Pablo.Formats.Character.Controls
{
Expand All @@ -16,7 +17,7 @@ public class ColourEditor : Dialog<bool>

int SelectedIndex { get; set; }

class SelectColourBox : ColourPad.ColourBox
class SelectColourBox : ColourBox
{
public int Index { get; set; }

Expand Down
13 changes: 0 additions & 13 deletions Source/Pablo/Formats/Character/Controls/ColourPad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ public Palette Palette {

#region ColourBox

public abstract class ColourBox : Drawable
{
public abstract Color Color { get; set; }

protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
var rect = new Rectangle(Size);
pe.Graphics.FillRectangle(Color, rect);
pe.Graphics.DrawButtonOutline(rect);
}
}

class FBColourBox : ColourBox
{
public ColourPad Pad { get; set; }
Expand Down
Binary file not shown.
Binary file removed Source/Pablo/Formats/Character/Icons/ApplyColour.png
Binary file not shown.
Binary file not shown.
Binary file removed Source/Pablo/Formats/Character/Icons/ColourBrush.png
Binary file not shown.
Binary file not shown.
Binary file removed Source/Pablo/Formats/Character/Icons/DrawBackground.png
Binary file not shown.
Binary file not shown.
Binary file removed Source/Pablo/Formats/Character/Icons/DrawForeground.png
Binary file not shown.
Binary file added Source/Pablo/Formats/Character/Icons/Erase.ans
Binary file not shown.
Binary file removed Source/Pablo/Formats/Character/Icons/Erase.png
Binary file not shown.
Binary file added Source/Pablo/Formats/Character/Icons/Selection.ans
Binary file not shown.
8 changes: 4 additions & 4 deletions Source/Pablo/Formats/Character/Tools/BrushTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ protected override void Draw(Point location, MouseEventArgs e)

Control InvertButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.Erase.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.Erase.ans", false),
Toggle = true,
Pressed = Inverted,
ToolTip = "Erase mode (shift)"
Expand All @@ -104,9 +104,9 @@ Control InvertButton()

Control ColourButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.ApplyColour.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.ApplyColour.ans", false),
Toggle = true,
Pressed = ApplyColour,
ToolTip = "Draw with color (alt)"
Expand Down
35 changes: 8 additions & 27 deletions Source/Pablo/Formats/Character/Tools/ColourBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,13 @@ public override CharacterHandler Handler
}
}

public override Cursor MouseCursor
{
get { return new Cursor(CursorType.Crosshair); }
}
public override Cursor MouseCursor => new Cursor(CursorType.Crosshair);

public override Eto.Drawing.Image Image
{
get { return ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.ColourBrush.png"); }
}
public override CharacterDocument DocumentImage => ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.ColourBrush.ans", false);

public override string Description
{
get { return "Color Brush - paint only foreground and/or background colour"; }
}
public override string Description => "Color Brush - paint only foreground and/or background colour";

public override Keys Accelerator
{
get
{
return Keys.B | Keys.Shift | (Handler.Generator.IsMac ? Keys.Control : Keys.Alt);
}
}
public override Keys Accelerator => Keys.B | Keys.Shift | (Handler.Generator.IsMac ? Keys.Control : Keys.Alt);


public ColourBrush()
Expand Down Expand Up @@ -86,14 +71,12 @@ protected override void Draw(Point location, Eto.Forms.MouseEventArgs e)

Control FGButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.DrawForeground.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.DrawForeground.ans"),
Toggle = true,
Pressed = PaintForeground,
#if DESKTOP
ToolTip = "Paint foreground (shift)"
#endif
};

control.Click += delegate
Expand All @@ -105,14 +88,12 @@ Control FGButton()

Control BGButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.DrawBackground.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.DrawBackground.ans"),
Toggle = true,
Pressed = PaintBackground,
#if DESKTOP
ToolTip = "Paint background (alt)"
#endif
};

control.Click += delegate
Expand Down
6 changes: 2 additions & 4 deletions Source/Pablo/Formats/Character/Tools/EllipseTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,12 @@ protected override void UpdateWithLocation(Rectangle rect, Keys modifiers, Point

Control ApplyColourButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.ApplyColour.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.ApplyColour.ans", false),
Toggle = true,
Pressed = ApplyColour,
#if DESKTOP
ToolTip = "Draw with color"
#endif
};

control.Click += delegate
Expand Down
6 changes: 2 additions & 4 deletions Source/Pablo/Formats/Character/Tools/LineTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,12 @@ protected override void UpdateWithLocation(Rectangle rect, Keys modifiers, Point

Control ApplyColourButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.ApplyColour.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.ApplyColour.ans", false),
Toggle = true,
Pressed = ApplyColour,
#if DESKTOP
ToolTip = "Draw with color"
#endif
};

control.Click += delegate
Expand Down
12 changes: 4 additions & 8 deletions Source/Pablo/Formats/Character/Tools/PencilTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,12 @@ protected override void Draw(Point location, Eto.Forms.MouseEventArgs e)

Control InvertButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.Erase.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.Erase.ans", false),
Toggle = true,
Pressed = Inverted,
#if DESKTOP
ToolTip = "Erase mode (shift)"
#endif
};

control.Click += delegate
Expand All @@ -117,14 +115,12 @@ Control InvertButton()

Control ColourButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.ApplyColour.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.ApplyColour.ans", false),
Toggle = true,
Pressed = ApplyColour,
#if DESKTOP
ToolTip = "Draw with color (alt)"
#endif
};

control.Click += delegate
Expand Down
4 changes: 2 additions & 2 deletions Source/Pablo/Formats/Character/Tools/RectangleTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public override void Cancel()

Control ApplyColourButton()
{
var control = new ImageButton
var control = new AnsiButton
{
Image = ImageCache.BitmapFromResource("Pablo.Formats.Character.Icons.ApplyColour.png"),
Document = ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.ApplyColour.ans", false),
Toggle = true,
Pressed = ApplyColour,
ToolTip = "Draw with color"
Expand Down
28 changes: 5 additions & 23 deletions Source/Pablo/Formats/Character/Tools/Selection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,15 @@ public class Selection : CenterAspectTool
Rectangle? selectedRegion;
Canvas pasteCanvas;

public override Eto.Drawing.Image Image
{
get { return ImageCache.BitmapFromResource("Pablo.Formats.Rip.Icons.Copy.png"); }
}
public override CharacterDocument DocumentImage => ImageCache.CharacterFromResource("Pablo.Formats.Character.Icons.Selection.ans");

public override string Description
{
get { return "Selection - Select text and position the cursor with the mouse"; }
}
public override string Description => "Selection - Select text and position the cursor with the mouse";

public override Keys Accelerator
{
get
{
return Keys.E | (Handler.Generator.IsMac ? Keys.Control : Keys.Alt);
}
}
public override Keys Accelerator => Keys.E | (Handler.Generator.IsMac ? Keys.Control : Keys.Alt);

public override Cursor MouseCursor
{
get { return new Cursor(CursorType.IBeam); }
}
public override Cursor MouseCursor => new Cursor(CursorType.IBeam);

public override bool AllowKeyboard
{
get { return drawMode == DrawMode.Normal; }
}
public override bool AllowKeyboard => drawMode == DrawMode.Normal;

public override void Unselected()
{
Expand Down
15 changes: 1 addition & 14 deletions Source/Pablo/Formats/Rip/Controls/ColourPad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Eto;
using System.Collections.Generic;
using Pablo.Controls;
using Pablo.Drawing;

namespace Pablo.Formats.Rip.Controls
{
Expand All @@ -23,20 +24,6 @@ public Palette Palette {

#region ColourBox

public abstract class ColourBox : Drawable
{
public abstract Color Color { get; set; }

protected override void OnPaint (PaintEventArgs pe)
{
base.OnPaint (pe);
var rect = new Rectangle (Point.Empty, this.Size);
pe.Graphics.DrawInsetRectangle (Colors.Gray, Colors.White, rect);
rect.Inflate (-1, -1);
pe.Graphics.FillRectangle (Color, rect);
}
}

class FBColourBox : ColourBox
{
public ColourPad Pad { get; set; }
Expand Down

0 comments on commit 646e0de

Please sign in to comment.