summaryrefslogtreecommitdiffstats
path: root/src/libs/gui/ControlGroups.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-04 03:58:49 +0000
committerDavid Robillard <d@drobilla.net>2007-07-04 03:58:49 +0000
commit417623b0033b12969e4e84c61c21922d4ab7f534 (patch)
treed6ac7058406e42a6e6b894cefaaa60bccee5d987 /src/libs/gui/ControlGroups.cpp
parentbb79ba74ab813c3126ad905e6453dae56b6192bc (diff)
downloadingen-417623b0033b12969e4e84c61c21922d4ab7f534.tar.gz
ingen-417623b0033b12969e4e84c61c21922d4ab7f534.tar.bz2
ingen-417623b0033b12969e4e84c61c21922d4ab7f534.zip
Added metadata (ie integer, toggle) to builtin node control ports.
Treat integer/toggle ports as.... integer ports (still with just a slider though). Closes ticket #40. git-svn-id: http://svn.drobilla.net/lad/ingen@571 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/gui/ControlGroups.cpp')
-rw-r--r--src/libs/gui/ControlGroups.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp
index 2d68492c..14d67870 100644
--- a/src/libs/gui/ControlGroups.cpp
+++ b/src/libs/gui/ControlGroups.cpp
@@ -93,7 +93,7 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
_slider->set_draw_value(false);
- _name_label->signal_button_press_event().connect(sigc::mem_fun(*this, &SliderControlGroup::clicked));
+ signal_button_press_event().connect(sigc::mem_fun(*this, &SliderControlGroup::clicked));
_slider->signal_button_press_event().connect(sigc::mem_fun(*this, &SliderControlGroup::clicked));
_slider->signal_event().connect(
@@ -138,7 +138,13 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
if (max <= min)
max = min + 1.0f;
- _slider->set_increments(0, 0);
+ if (pm->is_integer() || pm->is_toggle()) {
+ _slider->set_increments(1, 10);
+ _value_spinner->set_digits(0);
+ } else {
+ _slider->set_increments(0, 0);
+ }
+
_slider->set_range(min, max);
//_value_spinner->set_range(min, max);
@@ -177,6 +183,9 @@ SliderControlGroup::menu_properties()
void
SliderControlGroup::set_value(float val)
{
+ if (_port_model->is_integer())
+ val = lrintf(val);
+
_enable_signal = false;
if (_enabled) {
if (_slider->get_value() != val) {
@@ -237,12 +246,22 @@ void
SliderControlGroup::update_value_from_slider()
{
if (_enable_signal) {
- const float value = _slider->get_value();
+ float value = _slider->get_value();
+ bool change = true;
+
_enable_signal = false;
- _value_spinner->set_value(value);
- _control_panel->value_changed(_port_model, value);
-
+ if (_port_model->is_integer()) {
+ value = lrintf(value);
+ if (value == lrintf(_port_model->value()))
+ change = false;
+ }
+
+ if (change) {
+ _value_spinner->set_value(value);
+ _control_panel->value_changed(_port_model, value);
+ }
+
_enable_signal = true;
}
}