Commit 3c5f4b6
Edit layer name
Changed files (8)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/DrawingTools.valamodifiedlibbirdfont/Layer.valamodifiedlibbirdfont/LayerLabel.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/Tool.valamodifiedlibbirdfont/Toolbox.vala
Diff
@@ -762,7 +762,9 @@ class ToolboxCanvas : DrawingArea { }); button_press_event.connect ((se, e)=> {- if (e.type != EventType.2BUTTON_PRESS) {+ if (e.type == EventType.2BUTTON_PRESS) {+ tb.double_click (e.button, e.x, e.y);+ } else { tb.press (e.button, e.x, e.y); } return true;@@ -403,7 +403,7 @@ class BirdFontFile : GLib.Object { string data; // FIXME: name etc.- os.put_string (@"\t\t<layer visible=\"$(layer.visible)\">\n");+ os.put_string (@"\t\t<layer name= \"$(layer.name)\" visible=\"$(layer.visible)\">\n"); foreach (Path p in layer.get_all_paths ().paths) { data = get_point_data (p);@@ -1277,6 +1277,10 @@ class BirdFontFile : GLib.Object { if (a.get_name () == "visible") { layer.visible = bool.parse (a.get_content ()); }+ + if (a.get_name () == "name") {+ layer.name = a.get_content ();+ } } foreach (Tag t in tag) {@@ -1256,7 +1256,6 @@ public class DrawingTools : ToolCollection { add_stroke.selected = stroke; StrokeTool.add_stroke = stroke; set_stroke_tool_visibility ();- // FIXME: This is slow: Toolbox.redraw_tool_box (); } void auto_trace_background () {@@ -1587,7 +1586,7 @@ public class DrawingTools : ToolCollection { layer_tools.tool.clear (); foreach (Layer layer in g.layers.subgroups) { - LayerLabel label = new LayerLabel ("Layer", layer);+ LayerLabel label = new LayerLabel (layer); layer_tools.add_tool (label, 0); label.select_layer (); }@@ -18,6 +18,7 @@ public class Layer : GLib.Object { public PathList paths; public Gee.ArrayList<Layer> subgroups; public bool visible = true;+ public string name = "Layer"; public Layer () { paths = new PathList ();@@ -75,6 +76,7 @@ public class Layer : GLib.Object { public Layer copy () { Layer layer = new Layer (); + layer.name = name; layer.paths = paths.copy (); foreach (Layer l in subgroups) { layer.subgroups.add (l.copy ());@@ -24,20 +24,15 @@ public class LayerLabel : Tool { public Layer layer; Text label_text; - public LayerLabel (string label, Layer layer) {- double text_height;- + public LayerLabel (Layer layer) { base (); this.layer = layer;- this.label = label;+ this.label = layer.name; selected_layer = false; - label_text = new Text ();- label_text.set_text (label);- text_height = 17 * Toolbox.get_scale ();- label_text.set_font_size (text_height);+ set_text (); panel_press_action.connect ((selected, button, tx, ty) => { if (y <= ty <= y + h) {@@ -56,6 +51,43 @@ public class LayerLabel : Tool { selected_layer = false; } });+ + panel_double_click_action.connect ((selected, button, tx, ty) => {+ print ("double_click_action\n"); + if (y <= ty <= y + h) {+ if (25 * Toolbox.get_scale () <= tx <= w - 30 * Toolbox.get_scale ()) {+ set_layer_name ();+ }+ }+ });+ }+ + void set_text () {+ double text_height;+ + label_text = new Text ();+ label_text.set_text (label);+ text_height = 17 * Toolbox.get_scale ();+ label_text.set_font_size (text_height); + }+ + void set_layer_name () {+ TextListener listener;+ + listener = new TextListener (t_("Layer"), layer.name, t_("Set"));+ + listener.signal_text_input.connect ((text) => {+ layer.name = text;+ label = text;+ set_text ();+ redraw ();+ });+ + listener.signal_submit.connect (() => {+ TabContent.hide_text_input ();+ });+ + TabContent.show_text_input (listener); } public void select_layer () {@@ -146,7 +146,7 @@ public class PenTool : Tool { last_point_x = Glyph.path_coordinate_x (x); last_point_y = Glyph.path_coordinate_y (y); - press (b, x, y, true);+ press (b, (int) x, (int) y, true); }); release_action.connect ((self, b, ix, iy) => {@@ -48,6 +48,7 @@ public class Tool : Widget { public signal void panel_press_action (Tool selected, uint button, double x, double y); public signal void panel_release_action (Tool selected, uint button, double x, double y);+ public signal void panel_double_click_action (Tool selected, uint button, double x, double y); /** @return true is event is consumed. */ public signal bool panel_move_action (Tool selected, double x, double y);@@ -175,6 +175,23 @@ public class Toolbox : GLib.Object { scrolling_touch = false; } + public void double_click (uint button, double x, double y) {+ if (MenuTab.suppress_event) {+ warn_if_test ("Event suppressed");+ return;+ }+ + y -= current_set.scroll;+ + foreach (Expander e in current_set.get_expanders ()) {+ if (e.visible) {+ foreach (Tool t in e.tool) {+ t.panel_double_click_action (t, button, x, y);+ }+ }+ }+ }+ public void scroll_up (double x, double y) { bool action = false;