Commit bab18d1
new button
Changed files (8)
modifiedicons/tool_button_deselected.pngmodifiedicons/tool_button_selected.pngdeletedicons/toolbox_background.pngmodifiedlibbirdfont/CharDatabase.valamodifiedlibbirdfont/Tab.valamodifiedlibbirdfont/TabBar.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/Toolbox.vala
Diff
Binary files a/icons/tool_button_deselected.png and b/icons/tool_button_deselected.png differBinary files a/icons/tool_button_selected.png and b/icons/tool_button_selected.png differdeleted file mode 100644Binary files a/icons/toolbox_background.png and /dev/null differ@@ -41,7 +41,8 @@ public class CharDatabase { if (!database_is_loaded) { show_loading_message (); }- ++ return_val_if_fail (!is_null (index), result); return_val_if_fail (result.get_length () == 0, result); if (s.has_prefix ("U+") || s.has_prefix ("u+")) {@@ -56,7 +57,11 @@ public class CharDatabase { result.add_single (s.get_char ()); } + return_val_if_fail (!is_null (index.get (s)), result);+ for (var it = index.get (s).iterator (); it.has_next (); it.next ()) {+ return_val_if_fail (!is_null (it), result);+ iv = it.get (); if (iv != null) { i = (string) iv;@@ -38,10 +38,6 @@ public class Tab : GLib.Object { return display; } - public string get_label () {- return display.get_name ();- }- public double get_width () { return width; }@@ -124,7 +124,7 @@ public class TabBar : GLib.Object { public bool select_char (string s) { int i = 0; foreach (Tab t in tabs) {- if (t.get_label () == s) {+ if (t.get_display ().get_name () == s) { select_tab (i); return true; }@@ -233,7 +233,7 @@ public class TabBar : GLib.Object { int i = 0; foreach (var t in tabs) {- if (t.get_label () == name) {+ if (t.get_display ().get_name () == name) { return close_tab (i, background_tab); } @@ -272,7 +272,7 @@ public class TabBar : GLib.Object { public Tab? get_tab (string name) { foreach (var n in tabs) {- if (n.get_label () == name) {+ if (n.get_display ().get_name () == name) { return n; } }@@ -283,7 +283,7 @@ public class TabBar : GLib.Object { public bool selected_open_tab_by_name (string t) { int i = 0; foreach (var n in tabs) {- if (n.get_label () == t) {+ if (n.get_display ().get_name () == t) { select_tab (i); return true; }@@ -562,7 +562,7 @@ public class TabBar : GLib.Object { cr.set_source_rgba (0, 0, 0, 1); cr.set_font_size (14); cr.move_to (8, height - 6);- cr.show_text (t.get_label ());+ cr.show_text (t.get_display ().get_label ()); cr.stroke (); // edges@@ -241,7 +241,7 @@ public class Tool : GLib.Object { ImageSurface i = (!) icon; if (likely (i.status () == Cairo.Status.SUCCESS)) {- cr.set_source_surface (i, xt + (15 - i.get_width () / 2) - 5.7, yt + (15 - i.get_height ()) / 2.0);+ cr.set_source_surface (i, xt + (15.5 - i.get_width () / 2.0) - 5.7, yt + (15 - i.get_height ()) / 2.0); cr.paint (); } else { warning (@"Falied to load icon for $name");@@ -254,8 +254,10 @@ public class Tool : GLib.Object { /** Run pending events in main loop before continuing. */ public static void @yield () { int t = 0;- var time = new TimeoutSource (500);+ TimeoutSource time = new TimeoutSource (500); bool timeout;+ unowned MainContext context;+ bool acquired; if (TestBirdFont.is_slow_test ()) { timeout = false;@@ -270,29 +272,24 @@ public class Tool : GLib.Object { timeout = true; } - unowned MainContext c = MainContext.default ();- bool a = c.acquire ();+ context = MainContext.default ();+ acquired = context.acquire (); - while (unlikely (!a)) {+ while (unlikely (!acquired)) { warning ("Failed to acquire main loop.\n"); return; } - while (c.pending () || TestBirdFont.is_slow_test ()) {- c.iteration (true);+ while (context.pending () || TestBirdFont.is_slow_test ()) {+ context.iteration (true); t++; - if (!c.pending () && TestBirdFont.is_slow_test ()) {+ if (!context.pending () && TestBirdFont.is_slow_test ()) { if (timeout) break; }- - if (unlikely (t > 100000)) {- assert (false);- break;- } } - c.release ();+ context.release (); } public void set_persistent (bool p) {@@ -43,7 +43,7 @@ public class Toolbox : GLib.Object { toolbox_background = Icons.get_icon ("toolbox_background.png"); tab_bar.signal_tab_selected.connect ((tab) => {- if (tab.get_label () == "Kerning") {+ if (tab.get_display ().get_name () == "Kerning") { current_set = kerning_tools; } else { current_set = drawing_tools;@@ -72,6 +72,12 @@ public class Toolbox : GLib.Object { public void press (uint button, double x, double y) { foreach (Expander exp in current_set.get_expanders ()) {+ if (exp.is_over (x, y)) {+ exp.set_open (! exp.is_open ()); + update_expanders (); + redraw_tool_box ();+ }+ foreach (Tool t in exp.tool) { if (t.is_over (x, y)) { t.panel_press_action (t, button, x, y);@@ -82,13 +88,7 @@ public class Toolbox : GLib.Object { } public void release (uint button, double x, double y) {- foreach (Expander exp in current_set.get_expanders ()) {- if (exp.is_over (x, y)) {- exp.set_open (! exp.is_open ()); - update_expanders (); - redraw_tool_box ();- }- + foreach (Expander exp in current_set.get_expanders ()) { if (exp.is_open ()) { foreach (Tool t in exp.tool) { bool active = t.is_over (x, y);@@ -324,14 +324,9 @@ public class Toolbox : GLib.Object { cr.rectangle(0, 0, w, h); cr.set_line_width(0);- cr.set_source_rgba(255/255.0, 255/255.0, 255/255.0, 1);+ cr.set_source_rgba(242/255.0, 241/255.0, 240/255.0, 1); cr.fill();-- for (int i = 0; i < w; i++) {- cr.set_source_surface ((!) toolbox_background, i, 0);- cr.paint ();- }-+ cr.rectangle(0, 0, 1, h); cr.set_line_width(0); cr.set_source_rgba(0/255.0, 0/255.0, 0/255.0, 1);