The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Store tool selection state in tool collection

These changes was commited to the Birdfont repository Thu, 10 Dec 2015 11:31:50 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 10 Dec 2015 11:31:50 +0000 (12:31 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 10 Dec 2015 11:31:50 +0000 (12:31 +0100)
commit 4f64c1e76e8d25fdb10e4e383b311172af1e91ba
tree 880e3008a327d3f3c53e5b1fe49754d55dfaa6e2
parent 846483567d2db14066e070902a0c5db597a712b6
Store tool selection state in tool collection

libbirdfont/BackgroundTools.vala
libbirdfont/DrawingTools.vala
libbirdfont/ToolCollection.vala
libbirdfont/Toolbox.vala
--- a/libbirdfont/BackgroundTools.vala +++ b/libbirdfont/BackgroundTools.vala @@ -65,11 +65,15 @@ expanders.add (parts); } - public void update_tool_selection (Tool selected) { + public override void reset_selection (Tool selected) { select_background.set_selected (false); DrawingTools.move_background.set_selected (false); DrawingTools.move_canvas.set_selected (false); DrawingTools.background_scale.set_selected (false); + } + + public void update_tool_selection (Tool selected) { + reset_selection (selected); selected.set_selected (true); } @@ -97,6 +101,8 @@ return false; }); idle.attach (null); + + base.selected (); } public void update_parts_list (BackgroundImage current_image) {
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -1369,6 +1369,14 @@ flip_horizontal.set_tool_visibility (true); full_height_tool.set_tool_visibility (true); + } + + public override void reset_selection (Tool current_tool) { + foreach (Tool t in draw_tools.tool) { + if (t != current_tool) { + t.set_selected (false); + } + } } public void update_drawing_and_background_tools (Tool current_tool) { @@ -1377,12 +1385,7 @@ idle.set_callback (() => { Glyph g = MainWindow.get_current_glyph (); - foreach (Tool t in draw_tools.tool) { - if (t != current_tool) { - t.set_selected (false); - } - } - + reset_selection (current_tool); FontDisplay display = MainWindow.get_current_display (); if (display.get_name () == "Backgrounds") {
--- a/libbirdfont/ToolCollection.vala +++ b/libbirdfont/ToolCollection.vala @@ -20,11 +20,20 @@ public abstract class ToolCollection : GLib.Object { public double scroll = 0; public double content_height = 0; + private Tool current_tool = new Tool ("no_icon"); public abstract Gee.ArrayList<Expander> get_expanders (); public virtual Gee.ArrayList<string> get_displays () { return new Gee.ArrayList<string> (); + } + + public void set_current_tool (Tool tool) { + current_tool = tool; + } + + public Tool get_current_tool () { + return current_tool; } public void redraw () { @@ -33,9 +42,14 @@ } } - public virtual void selected () { + public virtual void selected () { + reset_selection (current_tool); + current_tool.set_selected (true); + } + + public virtual void reset_selection (Tool current_tool) { } } }
--- a/libbirdfont/Toolbox.vala +++ b/libbirdfont/Toolbox.vala @@ -29,8 +29,6 @@ public static SpacingTools spacing_tools; public static FileTools file_tools; public static ThemeTools theme_tools; - - Tool current_tool; public Tool press_tool; @@ -57,7 +55,6 @@ public Toolbox (GlyphCanvas glyph_canvas, TabBar tab_bar) { tool_sets = new Gee.ArrayList<ToolCollection> (); - current_tool = new Tool ("no_icon"); press_tool = new Tool (null); hidden_tools = new HiddenTools (); @@ -369,12 +366,12 @@ public void set_current_tool (Tool tool) { if (tool.editor_events) { - current_tool = tool; + current_set.set_current_tool (tool); } } public Tool get_current_tool () { - return current_tool; + return current_set.get_current_tool (); } public void select_tool (Tool tool) {