Clone in a terminal:
Commit 3c5f4b6
Johan Mattsson - 2015-06-04T11:32:02+00:00
3c5f4b6ec1290feff16798bcecc2601b31f2eef8johan.mattsson.m@gmail.com

Edit layer name

Changed files (8)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex 98b03a9..188fd34 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -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;diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 5e78ca6..9ad0d2d 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -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) {diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 449fd96..4aa3a54 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -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 (); 		}diff --git a/libbirdfont/Layer.vala b/libbirdfont/Layer.valaindex b2badb1..e722110 100644--- a/libbirdfont/Layer.vala+++ b/libbirdfont/Layer.vala@@ -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 ());diff --git a/libbirdfont/LayerLabel.vala b/libbirdfont/LayerLabel.valaindex dd67ab5..7468751 100644--- a/libbirdfont/LayerLabel.vala+++ b/libbirdfont/LayerLabel.vala@@ -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 () {diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex 2fb8d6b..b91e277 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -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) => {diff --git a/libbirdfont/Tool.vala b/libbirdfont/Tool.valaindex fed0573..ff94cff 100644--- a/libbirdfont/Tool.vala+++ b/libbirdfont/Tool.vala@@ -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);diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex 5b5f246..f551622 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -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; 		

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112