Clone in a terminal:
Commit e8781cb
Johan Mattsson - 2014-07-20T08:29:08+00:00
e8781cba7f20ff77dee809776a06843c1717aa8bjohan.mattsson.m@gmail.com

Remove response delay

Changed files (4)

Diff

diff --git a/icons/delay_circle.png b/icons/delay_circle.pngdeleted file mode 100644index 9ac6702..0000000Binary files a/icons/delay_circle.png and /dev/null differdiff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 5615d57..f1d2ddc 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -779,34 +779,6 @@ public class DrawingTools : ToolCollection  { 			track_tool.set_samples_per_point (freehand_samples.get_value ()); 		}); -		-#if ANDROID-		string delayed_response_value = Preferences.get ("response_delay");-		SpinButton delayed_response = new SpinButton ("response_delay", t_("Delay response for editing tools"));--		delayed_response.set_min (0);-		delayed_response.set_max (9);-				-		if (delayed_response_value != "") {-			delayed_response.set_value (delayed_response_value);-		} else {-			delayed_response.set_value_round (4);-		}-		-		delayed_response.new_value_action.connect ((self) => {-			MainWindow.get_toolbox ().select_tool (delayed_response);-			Preferences.set ("response_delay", self.get_display_value ());-			MainWindow.get_toolbox ().redraw ((int) delayed_response.x, (int) delayed_response.y, 70, 70);-		});--		delayed_response.select_action.connect((self) => {-			pen_tool.set_response_delay (((SpinButton)self).get_value ());-		});-		-		pen_tool.set_response_delay (delayed_response.get_value ());-		style_tools.add_tool (delayed_response);-#endif- 		// selection policy 		draw_tools.set_open (true); 		key_tools.set_open (true);diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex af0665b..74476a5 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -52,21 +52,21 @@ public class Path { 	 	public delegate bool SegmentIterator (EditPoint start, EditPoint stop); 	-	private static ImageSurface? edit_point_image = null;-	private static ImageSurface? active_edit_point_image = null;+	public static ImageSurface? edit_point_image = null;+	public static ImageSurface? active_edit_point_image = null; 	-	private static ImageSurface? edit_point_handle_image = null;-	private static ImageSurface? active_edit_point_handle_image = null;-	private static ImageSurface? selected_edit_point_handle_image = null;+	public static ImageSurface? edit_point_handle_image = null;+	public static ImageSurface? active_edit_point_handle_image = null;+	public static ImageSurface? selected_edit_point_handle_image = null; -	private static ImageSurface? selected_edit_point_image = null;-	private static ImageSurface? active_selected_edit_point_image = null;+	public static ImageSurface? selected_edit_point_image = null;+	public static ImageSurface? active_selected_edit_point_image = null; -	private static ImageSurface? cubic_edit_point_image = null;-	private static ImageSurface? cubic_active_edit_point_image = null;+	public static ImageSurface? cubic_edit_point_image = null;+	public static ImageSurface? cubic_active_edit_point_image = null; -	private static ImageSurface? cubic_selected_edit_point_image = null;-	private static ImageSurface? cubic_active_selected_edit_point_image = null;+	public static ImageSurface? cubic_selected_edit_point_image = null;+	public static ImageSurface? cubic_active_selected_edit_point_image = null; 	 	public static double line_color_r = 0; 	public static double line_color_g = 0;diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex a53360e..aec7fcf 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -55,16 +55,11 @@ public class PenTool : Tool {  	public static double precision = 1; 	-	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,7 +89,6 @@ public class PenTool : Tool { 		counter_clockwise = new List<Path> (); 		 		tie_icon = Icons.get_icon ("tie_is_active.png");-		delay_circle = Icons.get_icon ("delay_circle.png"); 		 		select_action.connect ((self) => { 		});@@ -113,8 +107,6 @@ public class PenTool : Tool { 			begin_action_x = x; 			begin_action_y = y; -			do_respond = false; // if the response is delayed- 			foreach (Path p in glyph.path_list) { 				if (p.is_clockwise ()) { 					clockwise.append (p);@@ -152,9 +144,7 @@ public class PenTool : Tool { 			 			x = ix; 			y = iy;-			-			do_respond = true;-			+						 			if (has_join_icon ()) { 				join_paths (x, y); 			}@@ -190,12 +180,7 @@ public class PenTool : Tool { 			selection_box_last_x = x; 			selection_box_last_y = y; 			-			if (isResponding (x, y)) {-				move (x, y);-			} else {-				last_point_x = x;-				last_point_y = y;-			}+			move (x, y); 		}); 		 		key_press_action.connect ((self, keyval) => {@@ -238,23 +223,7 @@ public class PenTool : Tool { 	private bool has_join_icon () { 		double mx, my; 		get_tie_position (out mx, out my);-		return (mx > -10 && my > - 10);-	}-	-	/** @return true after the initial delay.*/-	public static bool isResponding (int px, int py) {-		double d;-		-		if (!move_selected && !move_selected_handle) {-			do_respond = true;-		}-		-		if (!do_respond) {-			d = Math.sqrt (Math.pow (px - begin_action_x, 2) + Math.pow (py - begin_action_y, 2));-			do_respond = d > RESPONSE_PIXELS * response_delay;-		}-		-		return do_respond;+		return (mx > -10 * MainWindow.units && my > -10 * MainWindow.units); 	}  	public static void select_points_in_box () {@@ -338,10 +307,6 @@ public class PenTool : Tool { 		g.redraw_area (0, 0, g.allocation.width, g.allocation.height); 	} 	-	public void set_response_delay (double d) {-		response_delay = d;-	}-	 	public void set_precision (double p) { 		precision = p; 		DrawingTools.precision.set_value_round (p, false, false);@@ -857,24 +822,21 @@ 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) {+	/** Higlight the selected point on Android. */+	void draw_point_select_circle (Context cr) { 		ImageSurface img; 		double x, y; 		double ratio; 		-		return_if_fail (delay_circle != null);+		return_if_fail (Path.edit_point_image != null); 		-		img = (!) delay_circle;	+		img = (!) Path.edit_point_image;	 			 		cr.save ();-		ratio = 2 * RESPONSE_PIXELS * response_delay / img.get_width ();+		ratio = 40 * MainWindow.units / img.get_width (); 		cr.scale (ratio, ratio); 		x = begin_action_x - ratio * img.get_width () / 2; 		x /= ratio;

Contact

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