Clone in a terminal:
Commit e9686fb
Johan Mattsson - 2015-04-11T22:00:37+00:00
e9686fbc95569ca1b59df4dcabc93e2fc765bd65johan.mattsson.m@gmail.com

Fade out orientation arrow

Changed files (7)

Diff

diff --git a/libbirdfont/CheckBox.vala b/libbirdfont/CheckBox.valaindex c5fa520..e7a6546 100644--- a/libbirdfont/CheckBox.vala+++ b/libbirdfont/CheckBox.vala@@ -56,7 +56,7 @@ public class CheckBox : Widget { 		double center_y = (get_height () - (h + 2 * padding)) / 2.0 + padding;  		cr.save ();-		Theme.color (cr, "Background 2");	+		Theme.color (cr, "Checkbox Background"); 		draw_rounded_rectangle (cr, widget_x, widget_y + center_y, w, h - padding, padding); 		cr.fill (); 		cr.restore ();diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex e8603f5..44d215f 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -106,8 +106,9 @@ public class Glyph : FontDisplay { 	public const double CANVAS_MIN = -10000; 	public const double CANVAS_MAX = 10000; -	public bool show_orientation_arrow = false;-+	public static bool show_orientation_arrow = false;+	public static double orientation_arrow_opacity = 1;+	 	public Glyph (string name, unichar unichar_code = 0) { 		this.name = name; 		this.unichar_code = unichar_code;@@ -129,6 +130,7 @@ public class Glyph : FontDisplay {  	public GlyfData get_ttf_data () { 		if (ttf_data == null) {+			 			ttf_data =  new GlyfData (this); 		} 		@@ -1523,10 +1525,10 @@ public class Glyph : FontDisplay { 				if (p.stroke > 0) { 					stroke = StrokeTool.get_stroke (p, p.stroke); 					foreach (Path ps in stroke.paths) {-						ps.draw_orientation_arrow (cr);+						ps.draw_orientation_arrow (cr, orientation_arrow_opacity); 					}	 				} else {-					p.draw_orientation_arrow (cr);+					p.draw_orientation_arrow (cr, orientation_arrow_opacity); 				} 			} 		}diff --git a/libbirdfont/OrientationTool.vala b/libbirdfont/OrientationTool.valaindex 8729b97..77278e5 100644--- a/libbirdfont/OrientationTool.vala+++ b/libbirdfont/OrientationTool.vala@@ -19,6 +19,9 @@ namespace BirdFont {  public class OrientationTool : Tool { +	double time = 0;+	bool count_down = false;+	 	public OrientationTool (string n, string tip) { 		base (n, tip); @@ -33,10 +36,10 @@ public class OrientationTool : Tool { 		});  		panel_move_action.connect ((t, x, y) => {-			Glyph g = MainWindow.get_current_glyph ();-			-			if (!g.show_orientation_arrow && is_active ()) {-				g.show_orientation_arrow = true;+			if (!Glyph.show_orientation_arrow && is_active ()) {+				count_down = false;+				Glyph.show_orientation_arrow = true;+				Glyph.orientation_arrow_opacity = 1; 				GlyphCanvas.redraw (); 			} 			@@ -44,21 +47,37 @@ public class OrientationTool : Tool { 		}); 		 		move_out_action.connect ((t) => {-			Glyph g = MainWindow.get_current_glyph ();-			-			if (g.show_orientation_arrow) {-				g.show_orientation_arrow = false;+			if (Glyph.show_orientation_arrow) {+				count_down = true;+				time = 6;+				fade_out (); 				GlyphCanvas.redraw (); 			} 		});-						-		draw_action.connect ((self, cr, glyph) => {-			draw_actions (cr);-		}); 	} 	-	public static void draw_actions (Context cr) {-+	public void fade_out () {+			TimeoutSource timer = new TimeoutSource (100);+			timer.set_callback (() => {+				if (count_down) {+					if (time <= 0) {+						Glyph.show_orientation_arrow = false;+						count_down = false;+					}+					+					if (time < 1) {+						Glyph.orientation_arrow_opacity = time;+						GlyphCanvas.redraw ();+					}+					+					time -= 0.1;+				} else {+					Glyph.show_orientation_arrow = false;+				}+				+				return count_down;+			});+			timer.attach (null); 	} } diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex a043f12..5839de2 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -280,17 +280,17 @@ public class Path { 			c = (!) color; 			cr.set_source_rgba (c.r, c.g, c.b, c.a); 		} else {-			Theme.color (cr, "Selected Objects");+			Theme.color_opacity (cr, "Selected Objects", 0.5); 		} 	} -	public void draw_orientation_arrow (Context cr) {+	public void draw_orientation_arrow (Context cr, double opacity) { 		EditPoint top = new EditPoint (); 		double max = Glyph.CANVAS_MIN; 		Text arrow; 		double x, y, angle; 		double size = 50 * Glyph.ivz ();-				+		 		foreach (EditPoint e in points) { 			if (e.y > max) { 				max = e.y;@@ -302,20 +302,22 @@ public class Path { 		arrow.load_font ("icons.bf"); 		arrow.use_cache (false); 		-		Theme.text_color (arrow, "Highlighted 1");+		Theme.text_color_opacity (arrow, "Highlighted 1", opacity);  		angle = top.get_right_handle ().angle; 		x = Glyph.xc () + top.x + cos (angle + PI / 2) * 10 * Glyph.ivz ();	 		y = Glyph.yc () - top.y - sin (angle + PI / 2) * 10 * Glyph.ivz (); 		-		cr.save ();-		cr.translate (x, y);-		cr.rotate (-angle);-		cr.translate (-x, -y); -		-		arrow.draw_at_baseline (cr, x, y);-		-		cr.restore ();+		if (points.size > 0) {+			cr.save ();+			cr.translate (x, y);+			cr.rotate (-angle);+			cr.translate (-x, -y); +			+			arrow.draw_at_baseline (cr, x, y);+			+			cr.restore ();+		} 	}  	private void draw_next (EditPoint e, EditPoint en, Context cr, bool highlighted = false) {diff --git a/libbirdfont/Theme.vala b/libbirdfont/Theme.valaindex 973c3cd..aacf540 100644--- a/libbirdfont/Theme.vala+++ b/libbirdfont/Theme.vala@@ -113,6 +113,8 @@ public class Theme : GLib.Object { 		Theme.set_default_color ("Background 9", 72/255.0, 72/255.0, 72/255.0, 1); 		Theme.set_default_color ("Background 10", 223/255.0, 223/255.0, 223/255.0, 1); 		+		Theme.set_default_color ("Checkbox Background", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1);+		 		Theme.set_default_color ("Foreground 1", 0, 0, 0, 1); 		Theme.set_default_color ("Foreground 2", 101 / 255.0, 108 / 255.0, 116 / 255.0, 1); 		Theme.set_default_color ("Foreground 3", 26 / 255.0, 30 / 255.0, 32 / 255.0, 1);@@ -194,6 +196,7 @@ public class Theme : GLib.Object { 			t_("Stroke Color"); 			t_("Handle Color"); 			t_("Fill Color");+			t_("Selected Objects"); 			 			t_("Background 1"); 			t_("Background 2");@@ -205,6 +208,8 @@ public class Theme : GLib.Object { 			t_("Background 8"); 			t_("Background 9"); 			+			t_("Checkbox Background");+			 			t_("Foreground 1"); 			t_("Foreground 2"); 			t_("Foreground 3");diff --git a/resources/default.theme b/resources/default.themeindex 1ee5b89..bf9b6e0 100644--- a/resources/default.theme+++ b/resources/default.theme@@ -50,8 +50,10 @@ 	<color name="Selected Button Foreground" red="1" green="1" blue="1" alpha="1"/> 	<color name="Menu Foreground" red="0.396078431372549" green="0.42352941176470588" blue="0.45490196078431372" alpha="1"/> 	<color name="Overview Foreground" red="0.17647058823529413" green="0.17647058823529413" blue="0.17647058823529413" alpha="1"/>+	<color name="Selected Objects" red="0.5" green="0.5" blue="0.5" alpha="1"/> 	<color name="Tool Foreground" red="0.396078431372549" green="0.42352941176470588" blue="0.45490196078431372" alpha="1"/> 	<color name="Selected Quadratic Control Point" red="0" green="0" blue="0" alpha="1"/>+	<color name="Checkbox Background" red="0.396078431372549" green="0.42352941176470588" blue="0.45490196078431372" alpha="1"/> 	<color name="Active Cubic Control Point" red="0.27450980392156865" green="0.27450980392156865" blue="0.27450980392156865" alpha="1"/> 	<color name="Foreground 1" red="0" green="0" blue="0" alpha="1"/> 	<color name="Active Control Point Handle" red="0.31764705882352939" green="0.57647058823529407" blue="0.35294117647058826" alpha="1"/>diff --git a/resources/high_contrast.theme b/resources/high_contrast.themeindex 091f815..f9c94cc 100644--- a/resources/high_contrast.theme+++ b/resources/high_contrast.theme@@ -6,14 +6,14 @@ 	<color name="Active Quadratic Control Point" red="0" green="0" blue="0" alpha="1"/> 	<color name="Background 1" red="1" green="1" blue="1" alpha="1"/> 	<color name="Guide 2" red="0" green="0" blue="0" alpha="1"/>-	<color name="Foreground 7" red="1" green="1" blue="1" alpha="1"/>+	<color name="Foreground 7" red="0" green="0" blue="0" alpha="1"/> 	<color name="Background 2" red="0" green="0" blue="0" alpha="1"/> 	<color name="Guide 3" red="0" green="0" blue="0" alpha="1"/> 	<color name="Selected Overview Item 1" red="0" green="0" blue="0" alpha="1"/> 	<color name="Background 3" red="0" green="0" blue="0" alpha="1"/> 	<color name="Selected Overview Item 2" red="0" green="0" blue="0" alpha="1"/> 	<color name="Background 4" red="1" green="1" blue="1" alpha="1"/>-	<color name="Dialog Shadow" red="0" green="0" blue="0" alpha="1"/>+	<color name="Dialog Shadow" red="0" green="0" blue="0" alpha="0.29999999999999999"/> 	<color name="Background 5" red="1" green="1" blue="1" alpha="1"/> 	<color name="Glyph Count Background" red="1" green="1" blue="1" alpha="1"/> 	<color name="Background 6" red="1" green="1" blue="1" alpha="1"/>@@ -23,7 +23,7 @@ 	<color name="Control Point Handle" red="0" green="0" blue="0" alpha="1"/> 	<color name="Background 8" red="1" green="1" blue="1" alpha="1"/> 	<color name="Fill Color" red="0" green="0" blue="0" alpha="1"/>-	<color name="Foreground Inverted Table" red="0" green="0" blue="0" alpha="1"/>+	<color name="Foreground Inverted Table" red="1" green="1" blue="1" alpha="1"/> 	<color name="Background 9" red="1" green="1" blue="1" alpha="1"/> 	<color name="Stroke Color" red="0" green="0" blue="0" alpha="1"/> 	<color name="Selected Tool Foreground" red="1" green="1" blue="1" alpha="1"/>@@ -50,8 +50,10 @@ 	<color name="Selected Button Foreground" red="1" green="1" blue="1" alpha="1"/> 	<color name="Menu Foreground" red="1" green="1" blue="1" alpha="1"/> 	<color name="Overview Foreground" red="0" green="0" blue="0" alpha="1"/>+	<color name="Selected Objects" red="0" green="0" blue="0" alpha="1"/> 	<color name="Tool Foreground" red="0" green="0" blue="0" alpha="1"/> 	<color name="Selected Quadratic Control Point" red="0" green="0" blue="0" alpha="1"/>+	<color name="Checkbox Background" red="1" green="1" blue="1" alpha="1"/> 	<color name="Active Cubic Control Point" red="0" green="0" blue="0" alpha="1"/> 	<color name="Foreground 1" red="0" green="0" blue="0" alpha="1"/> 	<color name="Active Control Point Handle" red="0" green="0" blue="0" alpha="1"/>

Contact

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