Commit 3923ab2
propagate events for some tools
Changed files (5)
modifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/Expander.valamodifiedlibbirdfont/Preferences.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/Toolbox.vala
Diff
@@ -411,33 +411,6 @@ public class DrawingTools : ToolCollection { Tool rectangle = new RectangleTool ("rectangle"); shape_tools.add_tool (rectangle);-- // adjust precision- string precision_value = Preferences.get ("precision");- - precision = new SpinButton ("precision", _("Set precision"));- - if (precision_value != "") {- precision.set_value (precision_value);- } else {- precision.set_value_round (1);- }- - precision.new_value_action.connect ((self) => {- MainWindow.get_toolbox ().select_tool (precision);- - Preferences.set ("precision", self.get_display_value ());- MainWindow.get_toolbox ().redraw ((int) precision.x, (int) precision.y, 70, 70);- });-- precision.select_action.connect((self) => {- pen_tool.set_precision (((SpinButton)self).get_value ());- });- - precision.set_min (0.001);- precision.set_max (1);- - shape_tools.add_tool (precision); // background tools background_scale = new SpinButton ("scale_background", _("Set size for background image"));@@ -580,7 +553,34 @@ public class DrawingTools : ToolCollection { handle_color.set_b (double.parse (Preferences.get ("handle_color_b"))); handle_color.set_a (double.parse (Preferences.get ("handle_color_a"))); style_tools.add_tool (handle_color);++ // adjust precision+ string precision_value = Preferences.get ("precision"); + precision = new SpinButton ("precision", _("Set precision"));+ + if (precision_value != "") {+ precision.set_value (precision_value);+ } else {+ precision.set_value_round (1);+ }+ + precision.new_value_action.connect ((self) => {+ MainWindow.get_toolbox ().select_tool (precision);+ + Preferences.set ("precision", self.get_display_value ());+ MainWindow.get_toolbox ().redraw ((int) precision.x, (int) precision.y, 70, 70);+ });++ precision.select_action.connect((self) => {+ pen_tool.set_precision (((SpinButton)self).get_value ());+ });+ + precision.set_min (0.001);+ precision.set_max (1);+ + style_tools.add_tool (precision);+ draw_tools.set_open (true); draw_tool_modifiers.set_open (true); edit_point_modifiers.set_open (true);@@ -640,18 +640,27 @@ public class DrawingTools : ToolCollection { background_tools.set_persistent (true); background_tools.set_unique (true);+ + style_tools.set_persistent (true);+ style_tools.set_unique (true); MainWindow.get_toolbox ().update_expanders (); MainWindow.get_toolbox ().reset_active_tool (); - // let these tools progagate events even when other tools are selectes + // let these tools progagate events even when other tools are selected foreach (Tool t in draw_tools.tool) {- t.persistent = true;+ t.editor_events = true; }- ++ move_background.editor_events = true;+ cut_background.editor_events = true;+ move_background.persistent = true; cut_background.persistent = true; + precision.persistent = true;+ stroke_width.persistent = true;+ foreach (Tool t in shape_tools.tool) { t.persistent = true; }@@ -78,26 +78,6 @@ public class Expander : GLib.Object { yt += t.h + 2; } }- - /*- foreach (Tool t in tool) {- // FIXME: delete- //t.set_properties (xt, yt, w, h);- t.x = xt;- t.y = yt;- - print (@"$(xt), $yt\n");- if (xt + t.w + 10 > 160) {- yt += t.h;- i = 0;- xt = x + 10;- print (@"NEW LINE\n");- } else {- i++;- print (@"t.w: $(t.w)\n");- xt += t.w + 5;- }- } */ } public void set_offset (double ty) {@@ -113,14 +93,6 @@ public class Expander : GLib.Object { update_tool_position (); t.select_action.connect ((selected) => {- if (!selected.new_selection && selected.persistent) {- if (is_persistent ()) {- selected.set_selected (true);- } else {- selected.set_selected (false);- }- }- MainWindow.get_toolbox ().redraw ((int) x, (int) y, (int) w + 300, (int) (h + margin)); if (is_unique ()) {@@ -131,7 +103,15 @@ public class Expander : GLib.Object { } } - if (!is_persistent ()) {+ if (!selected.new_selection && selected.persistent) {+ if (is_persistent ()) {+ selected.set_selected (true);+ } else {+ selected.set_selected (false);+ }+ }+ + if (!is_persistent () && !selected.persistent) { var time = new TimeoutSource(200); time.set_callback(() => { selected.set_selected (false);@@ -13,12 +13,14 @@ */ namespace BirdFont { +using Gee;+ public class Preferences { - static HashTable<string, string> data;+ static Gee.HashMap<string, string> data; public Preferences () {- data = new HashTable<string, string> (str_hash, str_equal);+ data = new HashMap<string, string> (); } public static void set_last_file (string fn) {@@ -27,19 +29,14 @@ public class Preferences { public static string @get (string k) { string? s;- - lock (data) {- s = data.lookup (k);- }+ s = data.get (k); return (s != null) ? (!) s : ""; } public static void @set (string k, string v) {- lock (data) {- data.replace (k, v);- save ();- }+ data.set (k, v);+ save (); } public static string[] get_recent_files () {@@ -84,7 +81,7 @@ public class Preferences { File app_dir = BirdFont.get_settings_directory (); File settings = app_dir.get_child ("settings"); - data = new HashTable<string, string> (str_hash, str_equal);+ data = new HashMap<string, string> (); if (!settings.query_exists ()) { return;@@ -124,7 +121,7 @@ public class Preferences { i = line.index_of_char('"', s); string val = line.substring (s, i - s); - data.insert (key, val);+ data.set (key, val); } } @@ -148,10 +145,10 @@ public class Preferences { sb.append ("# BirdFont settings\n"); sb.append ("# Version: 1.0\n"); - foreach (var k in data.get_keys ()) {+ foreach (var k in data.keys) { sb.append (k); sb.append (" \"");- sb.append (data.lookup (k));+ sb.append (data.get (k)); sb.append ("\"\n"); } @@ -84,6 +84,7 @@ public class Tool : GLib.Object { private static ImageSurface? active_deselected_button = null; public bool persistent = false;+ public bool editor_events = false; /** Create tool with a certain name and load icon "name".png */ public Tool (string? name = null, string tip = "", unichar key = '\0', uint modifier_flag = 0) {@@ -204,8 +204,7 @@ public class Toolbox : GLib.Object { redraw ((int) exp.x - 10, (int) exp.y - 10, allocation_width, (int) (allocation_height - exp.y + 10)); } - if (tool.persistent) {- print ("PERSIS\n");+ if (tool.editor_events) { current_tool = tool; } }