summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-02-02 23:26:18 +0000
committerDavid Robillard <d@drobilla.net>2013-02-02 23:26:18 +0000
commit4883072dcfabfe0ee5dff955250ea25b13c32563 (patch)
tree5828bf7c72af7337c8a5404dfad0ba209c016329 /src
parent87a6387a120fb93503c2d728f57c8f8e1497fe74 (diff)
downloadganv-4883072dcfabfe0ee5dff955250ea25b13c32563.tar.gz
ganv-4883072dcfabfe0ee5dff955250ea25b13c32563.tar.bz2
ganv-4883072dcfabfe0ee5dff955250ea25b13c32563.zip
GUI support for integer controls.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5034 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/Canvas.cpp2
-rw-r--r--src/ganv-private.h1
-rw-r--r--src/port.c25
3 files changed, 21 insertions, 7 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index c96a437..37a99f9 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -1297,7 +1297,7 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
return false;
}
-/** Called when two ports are 'toggled' (connected or disconnected)
+/** Called when two ports are 'joined' (connected or disconnected)
*/
void
GanvCanvasImpl::ports_joined(GanvPort* port1, GanvPort* port2)
diff --git a/src/ganv-private.h b/src/ganv-private.h
index 4c264a7..85ed1ab 100644
--- a/src/ganv-private.h
+++ b/src/ganv-private.h
@@ -123,6 +123,7 @@ typedef struct {
float min;
float max;
gboolean is_toggle;
+ gboolean is_integer;
} GanvPortControl;
struct _GanvPortImpl {
diff --git a/src/port.c b/src/port.c
index edb34cb..5780571 100644
--- a/src/port.c
+++ b/src/port.c
@@ -439,12 +439,13 @@ ganv_port_show_control(GanvPort* port)
guint control_col = highlight_color(GANV_NODE(port)->impl->fill_color, 0x40);
- control->value = 0.0f;
- control->min = 0.0f;
- control->max = 0.0f;
- control->is_toggle = FALSE;
- control->label = NULL;
- control->rect = GANV_BOX(
+ control->value = 0.0f;
+ control->min = 0.0f;
+ control->max = 0.0f;
+ control->is_toggle = FALSE;
+ control->is_integer = FALSE;
+ control->label = NULL;
+ control->rect = GANV_BOX(
ganv_item_new(GANV_ITEM(port),
ganv_box_get_type(),
"x1", 0.0,
@@ -506,6 +507,16 @@ ganv_port_set_control_is_toggle(GanvPort* port,
}
}
+void
+ganv_port_set_control_is_integer(GanvPort* port,
+ gboolean is_integer)
+{
+ if (port->impl->control) {
+ port->impl->control->is_integer = is_integer;
+ ganv_port_set_control_value(port, lrintf(port->impl->control->value));
+ }
+}
+
static void
ganv_port_update_control_slider(GanvPort* port,
float value)
@@ -521,6 +532,8 @@ ganv_port_update_control_slider(GanvPort* port,
} else {
value = impl->control->min;
}
+ } else if (impl->control->is_integer) {
+ value = lrintf(value);
}
if (value < impl->control->min) {