Commit 5d43b5e
Adapt spin button to settings tab
Changed files (3)
modifiedlibbirdfont/SettingsDisplay.valamodifiedlibbirdfont/SpinButton.valamodifiedlibbirdfont/Tool.vala
Diff
@@ -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 (); } }@@ -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;@@ -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) {