Clone in a terminal:
Commit c37a2c6
Johan Mattsson - 2012-10-01T19:33:46+00:00
c37a2c65b3940cc51bf9bc00127feb1f19dccd44johan.mattsson.m@gmail.com

remove some GTK functions from FontDisplay

Changed files (10)

Diff

diff --git a/src/BackgroundSelection.vala b/src/BackgroundSelection.valaindex 068e53d..61f7507 100644--- a/src/BackgroundSelection.vala+++ b/src/BackgroundSelection.vala@@ -143,8 +143,8 @@ class BackgroundSelection : FontDisplay { 		cr.restore ();		 	} 	-	public override void button_release (EventButton e) {-		motion (e.x, e.y);+	public override void button_release (int button, double ex, double ey) {+		motion (ex, ey); 		 		if (active_box == 0) { 			add_image ();@@ -263,8 +263,8 @@ class BackgroundSelection : FontDisplay { 	public override void key_release (uint e) { 	} 	-	public override void motion_notify (EventMotion e) {-		motion (e.x, e.y);+	public override void motion_notify (double x, double y) {+		motion (x, y); 	} 	 	public void motion (double x, double y) {@@ -279,8 +279,8 @@ class BackgroundSelection : FontDisplay { 		} 	} -	public override void button_press (EventButton e) {-		motion (e.x, e.y);+	public override void button_press (uint button, double ex, double ey) {+		motion (ex, ey); 	}  	public override void store_current_view () {@@ -292,10 +292,10 @@ class BackgroundSelection : FontDisplay { 	public override void next_view () { 	} 	-	public override void scroll_wheel_up (Gdk.EventScroll e) {+	public override void scroll_wheel_up (double x, double y) { 	} -	public override void scroll_wheel_down (Gdk.EventScroll e) {+	public override void scroll_wheel_down (double x, double y) { 	}  }diff --git a/src/Context.vala b/src/Context.valaindex 918a614..a1b6523 100644--- a/src/Context.vala+++ b/src/Context.vala@@ -231,24 +231,24 @@ class ContextDisplay : FontDisplay { 		MainWindow.get_glyph_canvas ().redraw (); 	} 	-	public override void motion_notify (EventMotion e) {+	public override void motion_notify (double ex, double ey) { 		double k, y; 		 		if (selected_handle == -1) {-			set_active_handle (e.x, e.y);+			set_active_handle (ex, ey); 		} else { 			y = 1; 			-			if (Math.fabs (e.y - begin_handle_y) > 20) {-				y = ((Math.fabs (e.y - begin_handle_y) / 100) + 1);+			if (Math.fabs (ey - begin_handle_y) > 20) {+				y = ((Math.fabs (ey - begin_handle_y) / 100) + 1); 			} 			-			k = (e.x - last_handle_x) / y; // y-axis is variable precision+			k = (ex - last_handle_x) / y; // y-axis is variable precision 			set_kerning (selected_handle, k); 			MainWindow.get_glyph_canvas ().redraw (); 		} 		-		last_handle_x = e.x;+		last_handle_x = ex; 	} 	 	public void set_active_handle (double ex, double ey) {@@ -310,17 +310,17 @@ class ContextDisplay : FontDisplay { 		} 	} 	-	public override void button_release (EventButton e) {-		set_active_handle (e.x, e.y);+	public override void button_release (int button, double ex, double ey) {+		set_active_handle (ex, ey); 		selected_handle = -1; 	} 	-	public override void button_press (EventButton e) {-		set_active_handle (e.x, e.y);+	public override void button_press (uint button, double ex, double ey) {+		set_active_handle (ex, ey); 		selected_handle = active_handle;-		begin_handle_x = e.x;-		begin_handle_y = e.y;-		last_handle_x = e.x;+		begin_handle_x = ex;+		begin_handle_y = ey;+		last_handle_x = ex; 	}  }diff --git a/src/FontDisplay.vala b/src/FontDisplay.valaindex faa96af..9275a57 100644--- a/src/FontDisplay.vala+++ b/src/FontDisplay.vala@@ -95,18 +95,18 @@ internal abstract class FontDisplay : GLib.Object { 	public virtual void key_release (uint keyval) { 	} 	-	public virtual void motion_notify (EventMotion e) {+	public virtual void motion_notify (double x, double y) { 	} 	-	public virtual void button_release (EventButton event) {+	public virtual void button_release (int button, double x, double y) { 	} 	-	public virtual void leave_notify (EventCrossing e) {-	}-	-	public virtual void button_press (EventButton e) {+	public virtual void button_press (uint button, double x, double y) { 	} +	public virtual void double_click (uint button, double ex, double ey) {+	}	+ 	public virtual void zoom_in () { 	} 	@@ -134,10 +134,10 @@ internal abstract class FontDisplay : GLib.Object { 		warning ("next_view not implemented for this class."); 	} 	-	public virtual void scroll_wheel_up (Gdk.EventScroll e) {+	public virtual void scroll_wheel_up (double x, double y) { 	} 	-	public virtual void scroll_wheel_down (Gdk.EventScroll e) {+	public virtual void scroll_wheel_down (double x, double y) { 	}  	public virtual void undo () {diff --git a/src/Glyph.vala b/src/Glyph.valaindex 2a073a4..a27edc3 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -250,9 +250,9 @@ class Glyph : FontDisplay { 		return (!) background_image; 	} 		-	public override void scroll_wheel_up (Gdk.EventScroll e) {+	public override void scroll_wheel_up (double x, double y) { 		if (KeyBindings.has_ctrl ()) {-			zoom_in_at_point (e.x, e.y);+			zoom_in_at_point (x, y); 		} else if (KeyBindings.has_alt ()) {  			view_offset_x -= 10 / view_zoom; 		} else {@@ -262,9 +262,9 @@ class Glyph : FontDisplay { 		redraw_area (0, 0, allocation.width, allocation.height); 	} 	-	public override void scroll_wheel_down (Gdk.EventScroll e) {+	public override void scroll_wheel_down (double x, double y) { 		if (KeyBindings.has_ctrl ()) {-			zoom_out_at_point (e.x, e.y);+			zoom_out_at_point (x, y); 		} else	if (KeyBindings.has_alt ()) {  			view_offset_x += 10 / view_zoom; 		} else {@@ -480,16 +480,16 @@ class Glyph : FontDisplay { 		return name; 	} 			-	private void help_line_event (EventMotion e) {-		double mx = e.x;-		double my = e.y;+	private void help_line_event (double x, double y) {+		double mx = x;+		double my = y; 		 		if (GridTool.is_visible ()) { 			GridTool.tie (ref mx, ref my); 		} 		 		foreach (Line line in get_all_help_lines ()) {-			line.event_move_to (mx, my, e.x, e.y, allocation);+			line.event_move_to (mx, my, x, y, allocation); 		} 	} @@ -515,26 +515,26 @@ class Glyph : FontDisplay { 		} 	} 	-	public override void motion_notify (EventMotion e) {+	public override void motion_notify (double x, double y) { 		Tool t; 		t = MainWindow.get_toolbox ().get_current_tool (); 		 		if (move_view && KeyBindings.has_ctrl ()) {-			move_view_offset  (e.x, e.y);+			move_view_offset  (x, y); 			return; 		} -		t.move_action (t, (int) e.x, (int) e.y);+		t.move_action (t, (int) x, (int) y);  		if (Supplement.show_coordinates) {-			motion_x = e.x * ivz () - xc () + view_offset_x;-			motion_y = yc () - e.y * ivz () - view_offset_y;+			motion_x = x * ivz () - xc () + view_offset_x;+			motion_y = yc () - y * ivz () - view_offset_y; 		} 	-		help_line_event (e);	+		help_line_event (x, y);	 	} 	-	public override void button_release (EventButton event) {+	public override void button_release (int button, double ex, double ey) { 		bool line_moving = false; 		 		if (KeyBindings.has_ctrl ()) {@@ -550,7 +550,7 @@ class Glyph : FontDisplay {  		if (!line_moving) { 			Tool t = MainWindow.get_toolbox ().get_current_tool ();-			t.release_action (t, (int) event.button, (int) event.x, (int) event.y);+			t.release_action (t, (int) button, (int) ex, (int) ey); 		} 		 		update_view ();@@ -574,15 +574,17 @@ class Glyph : FontDisplay { 		MainWindow.get_glyph_canvas ().redraw (); 	} 	-	public override void leave_notify (EventCrossing e) {+	public override void double_click (uint button, double ex, double ey) {	+		Tool t = MainWindow.get_toolbox ().get_current_tool ();+		t.double_click_action (t, (int) button, (int) ex, (int) ey); 	} 	-	public override void button_press (EventButton e) {				-		pointer_begin_x = e.x;-		pointer_begin_y = e.y;+	public override void button_press (uint button, double ex, double ey) {				+		pointer_begin_x = ex;+		pointer_begin_y = ey; 		 		foreach (Line line in get_all_help_lines ()) {-			if (line.button_press (e, allocation)) {+			if (line.button_press ()) { 				return; 			} 		}@@ -593,12 +595,7 @@ class Glyph : FontDisplay { 			move_offset_y = view_offset_y; 		} else { 			Tool t = MainWindow.get_toolbox ().get_current_tool ();-			-			if (e.type == EventType.BUTTON_PRESS) {-				t.press_action (t, (int) e.button, (int) e.x, (int) e.y);-			} else if (e.type == EventType.2BUTTON_PRESS) {-				t.double_click_action (t, (int) e.button, (int) e.x, (int) e.y);-			}+			t.press_action (t, (int) button, (int) ex, (int) ey); 		} 	} diff --git a/src/GlyphCanvas.vala b/src/GlyphCanvas.valaindex 61c720e..8d0ed0d 100644--- a/src/GlyphCanvas.vala+++ b/src/GlyphCanvas.vala@@ -84,32 +84,32 @@ class GlyphCanvas : DrawingArea  { 			});
 
 		add_events (EventMask.BUTTON_PRESS_MASK | EventMask.BUTTON_RELEASE_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK | EventMask.SCROLL_MASK);
-		
-		leave_notify_event.connect ((t, e)=> {
-			current_display.leave_notify (e);
-			return true;
-		});
 				           
 		button_press_event.connect ((t, e)=> {
-			current_display.button_press (e);		
+			if (e.type == EventType.BUTTON_PRESS) {
+				current_display.button_press (e.button, e.x, e.y);	
+			} else if (e.type == EventType.2BUTTON_PRESS) {
+				current_display.double_click (e.button, e.x, e.y);
+			}
+				
 			return true;
 		});
 
 		button_release_event.connect ((t, e)=> {
-			current_display.button_release (e);
+			current_display.button_release ((int) e.button, e.x, e.y);
 			return true;
 		});
 		
 		motion_notify_event.connect ((t, e)=> {
-			current_display.motion_notify (e);		
+			current_display.motion_notify (e.x, e.y);		
 			return true;
 		});
 		
 		scroll_event.connect ((t, e)=> {
 			if (e.direction == Gdk.ScrollDirection.UP) {
-				current_display.scroll_wheel_up (e);
+				current_display.scroll_wheel_up (e.x, e.y);
 			} else if (e.direction == Gdk.ScrollDirection.DOWN) {
-				current_display.scroll_wheel_down (e);
+				current_display.scroll_wheel_down (e.x, e.y);
 			}
 			
 			return true;
diff --git a/src/Line.vala b/src/Line.valaindex 1d0d279..dfd5034 100644--- a/src/Line.vala+++ b/src/Line.vala@@ -103,7 +103,7 @@ class Line : GLib.Object { 		return (r == moving); 	} 	-	public bool button_press (EventButton e, Allocation allocation) {+	public bool button_press () { 		Glyph g; 		if (get_active ()) { 			move = true;diff --git a/src/OverView.vala b/src/OverView.valaindex c172f7a..6427d89 100644--- a/src/OverView.vala+++ b/src/OverView.vala@@ -146,13 +146,13 @@ class OverView : FontDisplay { 		return first_visible <= selected <= first_visible + items_per_row * rows; 	} -	public override void scroll_wheel_up (Gdk.EventScroll e) {+	public override void scroll_wheel_up (double x, double y) { 		key_up (); 		close_menus (); 		redraw_area (0, 0, allocation.width, allocation.height); 	} 	-	public override void scroll_wheel_down (Gdk.EventScroll e) {+	public override void scroll_wheel_down (double x, double y) { 		key_down (); 		close_menus (); 		redraw_area (0, 0, allocation.width, allocation.height);@@ -850,22 +850,19 @@ class OverView : FontDisplay { 		set_glyph_range (gr); 	} 		-	public override void motion_notify (EventMotion e) {-		if (e.x > allocation.x - 10) {-			scrollbar.motion_notify (e);+	public override void motion_notify (double x, double y) {+		if (x > allocation.x - 10) {+			scrollbar.motion_notify ((int) x, (int) y); 		} 	} 	-	public override void button_release (EventButton e) {-		if (e.x > allocation.x - 10) {-			scrollbar.button_release (e);+	public override void button_release (int button, double ex, double ey) {+		if (ex > allocation.x - 10) {+			scrollbar.button_release (button, ex, ey); 		} 	} 	-	public override void leave_notify (EventCrossing e) {-	}-	-	private void selection_click (EventButton e) {+	private void selection_click (uint button, double ex, double ey) { 		double x = view_offset_x; 		double y = view_offset_y; @@ -892,33 +889,33 @@ class OverView : FontDisplay { 		foreach (GlyphCollection g in get_visible_glyphs ()) { 			bool a; -			a = g.get_version_list ().menu_item_action (e.x - view_offset_x, e.y - view_offset_y); // select one item on the menu+			a = g.get_version_list ().menu_item_action (ex - view_offset_x, ey - view_offset_y); // select one item on the menu 			 			if (a) { 				return; 			} 						-			a = g.get_version_list ().menu_icon_action (e.x - view_offset_x, e.y - view_offset_y); // open menu+			a = g.get_version_list ().menu_icon_action (ex - view_offset_x, ey - view_offset_y); // open menu 			 			if (a) { 				menu_action = true; 			} 		} 		-		if (e.x < m) {-			e.x = m + 1;+		if (ex < m) {+			ex = m + 1; 		} 		-		if (e.x > allocation.width - m) {-			e.x = allocation.width - m - 1;+		if (ex > allocation.width - m) {+			ex = allocation.width - m - 1; 		} 		-		if (e.y < 5) {-			e.y = 5;+		if (ey < 5) {+			ey = 5; 		} 		-		if (e.y > allocation.height - 5) {-			e.y = allocation.height - 5;+		if (ey > allocation.height - 5) {+			ey = allocation.height - 5; 		} 			 		// empty set@@ -927,13 +924,13 @@ class OverView : FontDisplay { 		// scroll to the selected glyph 		selected = (uint32) first_visible; -		while (y < e.y < allocation.height) {+		while (y < ey < allocation.height) { 			selected += items_per_row; 			y += nail_height; 		} 		selected -= items_per_row; -		while (x < e.x < allocation.width) {+		while (x < ex < allocation.width) { 			selected++; 			x += nail_width; 		}@@ -954,13 +951,13 @@ class OverView : FontDisplay { 		adjust_scroll (); 	} 	-	public override void button_press (EventButton e) {-		if (e.x > allocation.width - 10) {+	public override void button_press (uint button, double x, double y) {+		if (x > allocation.width - 10) { 			if (Supplement.experimental) {-				scrollbar.button_press (e);+				scrollbar.button_press (button, x, y); 			} 		} else {-			selection_click (e);+			selection_click (button, x, y); 		} 	} diff --git a/src/PenTool.vala b/src/PenTool.valaindex 2cc07be..2a53748 100644--- a/src/PenTool.vala+++ b/src/PenTool.vala@@ -194,7 +194,7 @@ class PenTool : Tool { 			return; 		} -		if (double_click || insert_new_point_on_path_selected ()) {+		if (double_click) { 			glyph.insert_new_point_on_path (x, y); 			return; 		}@@ -227,10 +227,6 @@ class PenTool : Tool { 			select_active_point (x, y); 		} -		if (is_erase_selected () && active_edit_point != null) {-			glyph.delete_edit_point ((!) active_edit_point);-		}- 		glyph.store_undo_state (); 	} 	diff --git a/src/Scrollbar.vala b/src/Scrollbar.valaindex 7f62dd2..802e662 100644--- a/src/Scrollbar.vala+++ b/src/Scrollbar.vala@@ -21,7 +21,7 @@ using Gtk;  namespace Supplement { -class Scrollbar : DrawingArea {+class Scrollbar : GLib.Object { 	Allocation alloc;  	double pos = 0;@@ -38,33 +38,6 @@ class Scrollbar : DrawingArea { 	public signal void signal_scroll (double delta, double delta_last, double absolute);  	public Scrollbar () {-		add_events (EventMask.BUTTON_PRESS_MASK | EventMask.BUTTON_RELEASE_MASK | EventMask.POINTER_MOTION_MASK);-		-		expose_event.connect ((t, e)=> {-			Context cr = cairo_create (get_window ());-			-			get_allocation (out alloc);-			allocation = alloc;-			-			draw (cr, alloc);-			-			return true;-		});-		-		button_press_event.connect ((t, e)=> {-			button_press (e);			-			return true;-		});--		button_release_event.connect ((t, e)=> {-			button_release (e);-			return true;-		});-		-		motion_notify_event.connect ((t, e)=> {-			motion_notify (e);		-			return true;-		}); 	} 	 	public void set_handle_size (double s) {@@ -82,17 +55,17 @@ class Scrollbar : DrawingArea { 		y = pos * alloc.height; 	} 	-	public void button_press (EventButton e) {+	public void button_press (uint button, double x, double y) { 		move = true;-		y_begin = e.y;-		y_last = e.y;+		y_begin = y;+		y_last = y; 	} 	-	public void button_release (EventButton event) {+	public void button_release (int button, double ex, double ey) { 		move = false; 	} 	-	public void motion_notify (EventMotion e) {+	public void motion_notify (double ex, double ey) { 		double d = 0; 		double dl = 0; 		double m;@@ -100,11 +73,11 @@ class Scrollbar : DrawingArea { 		h = height * alloc.height; 		m = alloc.height; 				-		if (move && 0 < e.y < m) {-			d = e.y - y_begin;-			dl = e.y - y_last;+		if (move && 0 < ey < m) {+			d = ey - y_begin;+			dl = ey - y_last; 			y += dl;-			y_last = e.y;+			y_last = ey; 		}  		if (y < 0) {diff --git a/src/Toolbox.vala b/src/Toolbox.valaindex 9640a5d..ecf914c 100644--- a/src/Toolbox.vala+++ b/src/Toolbox.vala@@ -88,20 +88,21 @@ class Toolbox : GLib.Object  { 		// Fixa: draw_tools.add_tool (shrink_tool);	 		 		// Draw tool modifiers-		// DELETE+		// DELETE tools:+		 		Tool new_point = new Tool ("new_point", "Right click to add new point, left click to move points and double click to ad new point on path", 'a'); 		new_point.select_action.connect ((self) => { 				select_draw_tool (); 			}); 		-		draw_tool_modifiers.add_tool (new_point);+		// draw_tool_modifiers.add_tool (new_point);  		Tool insert_point_on_path = new Tool ("insert_point_on_path", "Add new point on path", 'n'); 		insert_point_on_path.select_action.connect ((self) => { 			select_draw_tool (); 			pen_tool.begin_from_new_point_on_path (); 		});-		draw_tool_modifiers.add_tool (insert_point_on_path);+		// draw_tool_modifiers.add_tool (insert_point_on_path); 		 		if (Supplement.experimental) { 			Tool new_point_on_path = new Tool ("new_point_on_path", "Begin new path from point on path", 'n');@@ -143,7 +144,7 @@ class Toolbox : GLib.Object  { 		erase_tool.select_action.connect((self) => { 			select_draw_tool (); 		});-		draw_tool_modifiers.add_tool (erase_tool);	+		// draw_tool_modifiers.add_tool (erase_tool);	  		// adjust precision 		string precision_value = Preferences.get ("precision");

Contact

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