Commit ca941cc
Replace pixly tool button with cairo drawing
Changed files (6)
deletedicons/tool_button_deselected.pngdeletedicons/tool_button_deselected_active.pngdeletedicons/tool_button_selected.pngdeletedicons/tool_button_selected_active.pngmodifiedlibbirdfont/BirdFont.valamodifiedlibbirdfont/Tool.vala
Diff
deleted file mode 100644Binary files a/icons/tool_button_deselected.png and /dev/null differdeleted file mode 100644Binary files a/icons/tool_button_deselected_active.png and /dev/null differdeleted file mode 100644Binary files a/icons/tool_button_selected.png and /dev/null differdeleted file mode 100644Binary files a/icons/tool_button_selected_active.png and /dev/null differ@@ -523,6 +523,18 @@ public class BirdFont { Theme.save_color ("Background Glyph", 0.2, 0.2, 0.2, 0.5); + Theme.save_color ("Tool Border 1", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+ Theme.save_color ("Tool Background 1", 14 / 255.0, 16 / 255.0, 17 / 255.0, 1);++ Theme.save_color ("Tool Border 2", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+ Theme.save_color ("Tool Background 2", 26 / 255.0, 30 / 255.0, 32 / 255.0, 1);++ Theme.save_color ("Tool Border 3", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+ Theme.save_color ("Tool Background 3", 44 / 255.0, 47 / 255.0, 51 / 255.0, 1);++ Theme.save_color ("Tool Border 4", 38 / 255.0, 39 / 255.0, 43 / 255.0, 1);+ Theme.save_color ("Tool Background 4", 33 / 255.0, 36 / 255.0, 39 / 255.0, 1);+ N_("Background 1"); N_("Background 2"); N_("Background 3");@@ -536,8 +548,26 @@ public class BirdFont { N_("Foreground 1"); N_("Foreground 2"); N_("Foreground 3");+ N_("Foreground 4");+ N_("Foreground 5"); N_("Highlighted 1");+ N_("Highlighted Guide");+ + N_("Grid");+ + N_("Guide 1");+ N_("Guide 2");+ N_("Guide 3");+ + N_("Tool Border 1");+ N_("Tool Background 1");+ N_("Tool Border 2");+ N_("Tool Background 2");+ N_("Tool Border 3");+ N_("Tool Background 3");+ N_("Tool Border 4");+ N_("Tool Background 4"); } public static void set_bundle_path (string path) {@@ -16,13 +16,15 @@ using Cairo; namespace BirdFont { -public class Tool : GLib.Object {+public class Tool : Widget { public double x = 0; public double y = 0; public double w = 33 * Toolbox.get_scale (); public double h = (33 / 1.11) * Toolbox.get_scale ();- ++ double scale;+ public bool active = false; public bool selected = false; @@ -86,6 +88,8 @@ public class Tool : GLib.Object { public Tool (string? name = null, string tip = "", unichar key = '\0', uint modifier_flag = 0) { this.tip = tip; + scale = w / 111.0; // scale to 320 dpi+ if (selected_button == null) { selected_button = Icons.get_icon ("tool_button_selected.png"); active_selected_button = Icons.get_icon ("tool_button_selected_active.png");@@ -120,6 +124,14 @@ public class Tool : GLib.Object { }); } + public override double get_height () {+ return 33 * scale;+ }++ public override double get_width () {+ return 33 * scale;+ }+ public void set_tool_visibility (bool v) { visible = v; }@@ -232,18 +244,17 @@ public class Tool : GLib.Object { return ret; } - public virtual void draw (Context cr) {+ public override void draw (Context cr) { double xt = x; double yt = y; double bgx, bgy; double iconx, icony; - double scale;-- cr.save ();+ string border = "Foreground 1";+ string background = "Background 1"; - scale = w / 111.0; // scale to 320 dpi+ cr.save (); if (unlikely (scale == 0)) { warning ("Scale is zero.");@@ -257,25 +268,34 @@ public class Tool : GLib.Object { // Button in four states if (selected && selected_button != null) {- cr.set_source_surface ((!) selected_button, bgx, bgy);- cr.paint ();+ border = "Tool Border 1";+ background = "Tool Background 1"; } if (selected && active && active_selected_button != null) {- cr.set_source_surface ((!) active_selected_button, bgx, bgy);- cr.paint ();+ border = "Tool Border 2";+ background = "Tool Background 2"; } if (!selected && deselected_button != null) {- cr.set_source_surface ((!) deselected_button, bgx, bgy);- cr.paint ();+ border = "Tool Border 3";+ background = "Tool Background 3"; } if (!selected && active && active_deselected_button != null) {- cr.set_source_surface ((!) active_deselected_button, bgx, bgy);- cr.paint ();+ border = "Tool Border 4";+ background = "Tool Background 4"; }++ Theme.color (cr, background);+ draw_rounded_rectangle (cr, bgx, bgy, 34 / scale, 28 / scale, 4 / scale);+ cr.fill (); + cr.set_line_width (1 / scale);+ Theme.color (cr, border);+ draw_rounded_rectangle (cr, bgx, bgy, 34 / scale, 28 / scale, 4 / scale);+ cr.stroke ();+ if (icon != null) { ImageSurface i = (!) icon;