The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Adapt spin button to settings tab

These changes was commited to the Birdfont repository Tue, 17 Mar 2015 15:26:17 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 17 Mar 2015 15:26:17 +0000 (16:26 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 17 Mar 2015 15:26:17 +0000 (16:26 +0100)
commit 5d43b5e722c337aaf157e14a9b3cc805fe44f85a
tree d93c642541c9134e77985b6e74fd33cff91c785f
parent 31ecbc4883e83b5b1478b4ddd5257c2190d879ab
Adapt spin button to settings tab

libbirdfont/SettingsDisplay.vala
libbirdfont/SpinButton.vala
libbirdfont/Tool.vala
--- a/libbirdfont/SettingsDisplay.vala +++ b/libbirdfont/SettingsDisplay.vala @@ -322,16 +322,18 @@ } } - 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 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 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 @@ } } - if (consumed) { + if (consumed || update) { GlyphCanvas.redraw (); } }
--- a/libbirdfont/SpinButton.vala +++ b/libbirdfont/SpinButton.vala @@ -58,6 +58,8 @@ if (button == 3 || KeyBindings.modifier == LOGO) { set_from_text (); n = 0; + set_selected (false); + return; } if (is_selected ()) { @@ -93,7 +95,7 @@ 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;
--- a/libbirdfont/Tool.vala +++ b/libbirdfont/Tool.vala @@ -223,7 +223,8 @@ } 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) {