From 4883072dcfabfe0ee5dff955250ea25b13c32563 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 2 Feb 2013 23:26:18 +0000 Subject: GUI support for integer controls. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5034 a436a847-0d15-0410-975c-d299462d15a1 --- src/Canvas.cpp | 2 +- src/ganv-private.h | 1 + src/port.c | 25 +++++++++++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src') 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) { -- cgit v1.2.1