Skip to content

Commit

Permalink
Add symbolic icons for the color palette buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronwhite committed Nov 13, 2022
1 parent fed635e commit 97af453
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
17 changes: 12 additions & 5 deletions Pinta.Gui.Widgets/Widgets/StatusBarColorPaletteWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ public class StatusBarColorPaletteWidget : Gtk.DrawingArea
const int WIDGET_HEIGHT = 42;
const int PALETTE_MARGIN = 10;

private readonly Gdk.Pixbuf swap_icon;
private readonly Gdk.Pixbuf reset_icon;
private Gdk.Pixbuf swap_icon = new (Gdk.Colorspace.Rgb, false, 8, 0, 0); // overridden in OnShown()
private Gdk.Pixbuf reset_icon = new (Gdk.Colorspace.Rgb, false, 8, 0, 0);

public StatusBarColorPaletteWidget ()
{
AddEvents ((int) Gdk.EventMask.ButtonPressMask);

swap_icon = PintaCore.Resources.GetIcon ("ColorPalette.SwapIcon.png");
reset_icon = PintaCore.Resources.GetIcon ("ColorPalette.ResetIcon.png");

HasTooltip = true;
QueryTooltip += HandleQueryTooltip;

Expand All @@ -67,6 +64,16 @@ public StatusBarColorPaletteWidget ()
HeightRequest = WIDGET_HEIGHT;
}

protected override void OnShown ()
{
base.OnShown ();

// Load the symbolic icons when shown. In the constructor the StyleContext isn't ready,
// so symbolic icons might not be colored correctly.
swap_icon = PintaCore.Resources.GetIcon (Pinta.Resources.Icons.ColorPaletteSwap, StyleContext);
reset_icon = PintaCore.Resources.GetIcon (Pinta.Resources.Icons.ColorPaletteReset, StyleContext);
}

protected override bool OnButtonPressEvent (Gdk.EventButton ev)
{
var point = ev.GetPoint ();
Expand Down
3 changes: 3 additions & 0 deletions Pinta.Resources/Icons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public static class Icons
public const string ColorModeColor = "tool-gradient-colormode-color-symbolic";
public const string ColorModeTransparency = "tool-gradient-colormode-transparency-symbolic";

public const string ColorPaletteReset = "ui-colorpalette-reset-symbolic";
public const string ColorPaletteSwap = "ui-colorpalette-swap-symbolic";

public const string CursorPosition = "ui-cursor-location-symbolic";

public const string EditSelectionErase = "edit-selection-erase";
Expand Down
6 changes: 0 additions & 6 deletions Pinta.Resources/Pinta.Resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@
<EmbeddedResource Include="Resources\LayersWidget.Hidden.png">
<LogicalName>LayersWidget.Hidden.png</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\ColorPalette.SwapIcon.png">
<LogicalName>ColorPalette.SwapIcon.png</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\ColorPalette.ResetIcon.png">
<LogicalName>ColorPalette.ResetIcon.png</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Menu.Adjustments.AutoLevel.png">
<LogicalName>Menu.Adjustments.AutoLevel.png</LogicalName>
</EmbeddedResource>
Expand Down
Binary file removed Pinta.Resources/Resources/ColorPalette.ResetIcon.png
Binary file not shown.
Binary file removed Pinta.Resources/Resources/ColorPalette.SwapIcon.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 97af453

Please sign in to comment.