Clone in a terminal:
Commit 7bbf034
Johan Mattsson - 2014-02-14T08:35:01+00:00
7bbf0344354d2ba47f59c0f0c72863e02a5748a5johan.mattsson.m@gmail.com

Delay visualization

Changed files (3)

Diff

diff --git a/graphics/tools_and_buttons.svg b/graphics/tools_and_buttons.svgindex 69b3b70..b0d2031 100644--- a/graphics/tools_and_buttons.svg+++ b/graphics/tools_and_buttons.svg@@ -23,6 +23,18 @@      id="defs3788">     <linearGradient        inkscape:collect="always"+       id="linearGradient3575">+      <stop+         style="stop-color:#d5e5ff;stop-opacity:1;"+         offset="0"+         id="stop3577" />+      <stop+         style="stop-color:#d5e5ff;stop-opacity:0;"+         offset="1"+         id="stop3579" />+    </linearGradient>+    <linearGradient+       inkscape:collect="always"        id="linearGradient4635">       <stop          style="stop-color:#e7e6e6;stop-opacity:1;"@@ -382,6 +394,17 @@        y2="743"        gradientUnits="userSpaceOnUse"        gradientTransform="matrix(1.2890276,0,0,1,-73.718994,-5)" />+    <radialGradient+       inkscape:collect="always"+       xlink:href="#linearGradient3575"+       id="radialGradient3581"+       cx="199.80905"+       cy="24.502512"+       fx="199.80905"+       fy="24.502512"+       r="30.703518"+       gradientUnits="userSpaceOnUse"+       gradientTransform="matrix(1.696811,-0.06964229,0.06038833,1.4713414,-140.70881,2.3661124)" />   </defs>   <sodipodi:namedview      id="base"@@ -391,8 +414,8 @@      inkscape:pageopacity="0.0"      inkscape:pageshadow="2"      inkscape:zoom="1"-     inkscape:cx="204.06067"-     inkscape:cy="568.36736"+     inkscape:cx="-152"+     inkscape:cy="796.5"      inkscape:current-layer="layer1"      inkscape:document-units="px"      showgrid="false"@@ -1811,5 +1834,18 @@          id="tspan4601"          x="11.868663"          y="389.10025">AV</tspan></text>+    <path+       sodipodi:type="arc"+       style="opacity:0.72016458000000005;fill:url(#radialGradient3581);fill-opacity:1"+       id="path3573"+       sodipodi:cx="200.75377"+       sodipodi:cy="25.919598"+       sodipodi:rx="30.703518"+       sodipodi:ry="30.703518"+       d="m 231.45729,25.919598 a 30.703518,30.703518 0 1 1 -61.40704,0 30.703518,30.703518 0 1 1 61.40704,0 z"+       transform="translate(13.934673,8.0301508)"+       inkscape:export-filename="/home/johan/birdfont/icons/delay_circle.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824" />   </g> </svg>diff --git a/icons/delay_circle.png b/icons/delay_circle.pngnew file mode 100644index 0000000..6103d43Binary files /dev/null and b/icons/delay_circle.png differdiff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex f498d30..583b46e 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -53,12 +53,14 @@ public class PenTool : Tool { 	 	public static double response_delay = 0; 	public static bool do_respond = false;-+	private static const double RESPONSE_PIXELS = 20;+	 	// The pixel where the user pressed the mouse button 	public static int begin_action_x = 0;  	public static int begin_action_y = 0; 	 	private static ImageSurface? tie_icon = null;+	private static ImageSurface? delay_circle = null; 	 	/** First move action must move the current point in to the grid. */ 	bool first_move_action = false;@@ -94,6 +96,7 @@ public class PenTool : Tool { 		base (name, click_to_add_points + " " + t_("and double click to add new point on path."), ',', CTRL); 		 		tie_icon = Icons.get_icon ("tie_is_active.png");+		delay_circle = Icons.get_icon ("delay_circle.png"); 		 		select_action.connect ((self) => { 		});@@ -240,7 +243,7 @@ public class PenTool : Tool { 		 		if (!do_respond) { 			d = Math.sqrt (Math.pow (px - begin_action_x, 2) + Math.pow (py - begin_action_y, 2));-			do_respond = d > 20 * response_delay;+			do_respond = d > RESPONSE_PIXELS * response_delay; 		} 		 		return do_respond;@@ -819,9 +822,34 @@ public class PenTool : Tool { 			draw_selection_box (cr); 		} 		+		if (!do_respond) {+			draw_delay_circle (cr);+		}+		 		draw_merge_icon (cr); 	} 	+	void draw_delay_circle (Context cr) {+		ImageSurface img;+		double x, y;+		double ratio;+		+		return_if_fail (delay_circle != null);+		+		img = (!) delay_circle;	+			+		cr.save ();+		ratio = 2 * RESPONSE_PIXELS * response_delay / img.get_width ();+		cr.scale (ratio, ratio);+		x = begin_action_x - ratio * img.get_width () / 2;+		x /= ratio;+		y = begin_action_y - ratio * img.get_height () / 2;+		y /= ratio;+		cr.set_source_surface (img, x, y);+		cr.paint ();+		cr.restore ();+	}+	 	void draw_selection_box (Context cr) { 		double x, y, w, h; 

Contact

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