summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ganv/Port.hpp1
-rw-r--r--ganv/port.h4
-rw-r--r--src/Canvas.cpp2
-rw-r--r--src/ganv-private.h1
-rw-r--r--src/port.c25
5 files changed, 26 insertions, 7 deletions
diff --git a/ganv/Port.hpp b/ganv/Port.hpp
index 47136a5..ac1a5f9 100644
--- a/ganv/Port.hpp
+++ b/ganv/Port.hpp
@@ -56,6 +56,7 @@ public:
METHOD0(ganv_port, show_control)
METHOD0(ganv_port, hide_control)
METHOD1(ganv_port, set_control_is_toggle, gboolean, is_toggle)
+ METHOD1(ganv_port, set_control_is_integer, gboolean, is_integer)
METHOD1(ganv_port, set_control_value, float, value)
METHOD1(ganv_port, set_control_min, float, min)
METHOD1(ganv_port, set_control_max, float, max)
diff --git a/ganv/port.h b/ganv/port.h
index ff258cb..9775ac6 100644
--- a/ganv/port.h
+++ b/ganv/port.h
@@ -67,6 +67,10 @@ ganv_port_set_control_is_toggle(GanvPort* port,
gboolean is_toggle);
void
+ganv_port_set_control_is_integer(GanvPort* port,
+ gboolean is_integer);
+
+void
ganv_port_set_control_value(GanvPort* port,
float value);
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) {