Clone in a terminal:
Commit 5d43b5e
Johan Mattsson - 2015-03-17T15:26:17+00:00
5d43b5e722c337aaf157e14a9b3cc805fe44f85ajohan.mattsson.m@gmail.com

Adapt spin button to settings tab

Changed files (3)

Diff

diff --git a/libbirdfont/SettingsDisplay.vala b/libbirdfont/SettingsDisplay.valaindex fd8ac47..3f52085 100644--- a/libbirdfont/SettingsDisplay.vala+++ b/libbirdfont/SettingsDisplay.vala@@ -322,16 +322,18 @@ public class SettingsDisplay : FontDisplay { 		} 	} -	public override void button_press (uint button, double x, double y) {	+	public override void button_press (uint button, double x, double y) { 		foreach (SettingsItem s in tools) { 			if (s.handle_events && s.button != null) { 				if (((!) s.button).is_over (x, y)) {-					((!) s.button).panel_press_action ((!) s.button, button, x, y);+					 					((!) s.button).set_selected (! ((!) s.button).selected); 					 					if (((!) s.button).selected) { 						((!) s.button).select_action ((!) s.button); 					}+					+					((!) s.button).panel_press_action ((!) s.button, button, x, y); 				} 			} 		}@@ -341,10 +343,6 @@ public class SettingsDisplay : FontDisplay { 	public override void button_release (int button, double x, double y) { 		foreach (SettingsItem s in tools) { 			if (s.handle_events && s.button != null) {-				if (((!) s.button).is_over (x, y) || ((!) s.button).is_active ()) {-					((!) s.button).panel_release_action ((!) s.button, button, x, y);-				}-				 				((!) s.button).panel_release_action (((!) s.button), button, x, y); 			} 			@@ -357,6 +355,23 @@ public class SettingsDisplay : FontDisplay {  	public override void motion_notify (double x, double y) { 		bool consumed = false;+		bool active;+		bool update = false;+		+		foreach (SettingsItem si in tools) {+			+			if (si.handle_events && si.button != null) {+				active = ((!) si.button).is_over (x, y);++				if (!active && ((!) si.button).is_active ()) {+					((!) si.button).move_out_action ((!) si.button);+				}+						+				if (((!) si.button).set_active (active)) {+					update = true;+				}	+			}	+		} 		 		foreach (SettingsItem s in tools) { 			if (s.handle_events && s.button != null) {@@ -366,7 +381,7 @@ public class SettingsDisplay : FontDisplay { 			} 		} 		-		if (consumed) {+		if (consumed || update) { 			GlyphCanvas.redraw (); 		} 	}diff --git a/libbirdfont/SpinButton.vala b/libbirdfont/SpinButton.valaindex 519c713..d393d52 100644--- a/libbirdfont/SpinButton.vala+++ b/libbirdfont/SpinButton.vala@@ -58,6 +58,8 @@ public class SpinButton : Tool { 			if (button == 3 || KeyBindings.modifier == LOGO) { 				set_from_text (); 				n = 0;+				set_selected (false);+				return; 			} 				 			if (is_selected ()) {@@ -93,7 +95,7 @@ public class SpinButton : Tool { 				show_adjustmet_icon (); 			} 			-			if (value_from_motion) {+			if (value_from_motion && is_selected ()) { 				d = (begin_y - ty) / 200; 				d = (d < 0) ? -Math.pow (d, 2) : Math.pow (d, 2); 				d *= 1000;diff --git a/libbirdfont/Tool.vala b/libbirdfont/Tool.valaindex 774be93..580241b 100644--- a/libbirdfont/Tool.vala+++ b/libbirdfont/Tool.vala@@ -223,7 +223,8 @@ public class Tool : Widget { 	}  	public new bool is_over (double xp, double yp) {-		return (x <= xp <= x + w  && y <= yp <= y + h);  +		bool r = (x <= xp <= x + w  && y <= yp <= y + h);+		return r; 	} 	 	public bool set_selected (bool a) {						

Contact

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