summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-08 02:36:32 +0000
committerDavid Robillard <d@drobilla.net>2011-12-08 02:36:32 +0000
commitf808fa7d26df3b42c0bb33c49894920b0f975ec9 (patch)
tree9df274dab4180ed1de229041869694447c3fd607 /src
parent7e11058ba3b1b8339441c9559d36a938f1ecfdc0 (diff)
downloadganv-f808fa7d26df3b42c0bb33c49894920b0f975ec9.tar.gz
ganv-f808fa7d26df3b42c0bb33c49894920b0f975ec9.tar.bz2
ganv-f808fa7d26df3b42c0bb33c49894920b0f975ec9.zip
Clean up port event stuff.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3836 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/Canvas.cpp37
-rw-r--r--src/port.c4
2 files changed, 11 insertions, 30 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index ca2b08a..d0c307e 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -1067,10 +1067,7 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
static double control_start_y = 0;
static float control_start_value = 0;
- bool handled = true;
-
- switch (event->type) {
-
+switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1) {
GanvModule* const module = ganv_port_get_module(port);
@@ -1086,26 +1083,11 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
control_start_x = event->button.x_root;
control_start_y = event->button.y_root;
control_start_value = ganv_port_get_control_value(port);
- #if 0
- const double port_x = module->get_x() + port->get_x();
- float new_control = ((event->button.x - port_x) / (double)port->get_width());
- if (new_control < 0.0)
- new_control = 0.0;
- else if (new_control > 1.0)
- new_control = 1.0;
-
- new_control *= (port->control_max() - port->control_min());
- new_control += port->control_min();
- if (new_control < port->control_min())
- new_control = port->control_min();
- if (new_control > port->control_max())
- new_control = port->control_max();
- if (new_control != port->control_value())
- port->set_control_value(new_control);
- #endif
}
+ return true;
} else if (!port->is_input) {
port_dragging = true;
+ return true;
}
}
break;
@@ -1140,6 +1122,7 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
const double dvalue = (dx * value_range) * sens;
const double value = control_start_value + dvalue;
ganv_port_set_control_value(port, value);
+ return true;
}
break;
@@ -1158,20 +1141,18 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
}
}
port_dragging = false;
+ return true;
} else if (control_dragging) {
control_dragging = false;
- } else {
- handled = false;
+ return true;
}
break;
case GDK_ENTER_NOTIFY:
- //signal_item_entered.emit(port);
gboolean selected;
g_object_get(G_OBJECT(port), "selected", &selected, NULL);
if (!control_dragging && !selected) {
g_object_set(G_OBJECT(port), "highlighted", TRUE, NULL);
- return true;
}
break;
@@ -1184,17 +1165,17 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
GNOME_CANVAS_ITEM(_base_rect),
GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK,
NULL, event->crossing.time);
+ return true;
} else if (!control_dragging) {
g_object_set(G_OBJECT(port), "highlighted", FALSE, NULL);
}
- //signal_item_left.emit(port);
break;
default:
- handled = false;
+ break;
}
- return handled;
+ return false;
}
/** Called when two ports are 'toggled' (connected or disconnected)
diff --git a/src/port.c b/src/port.c
index c5dcb05..f260662 100644
--- a/src/port.c
+++ b/src/port.c
@@ -199,8 +199,8 @@ ganv_port_set_height(GanvBox* box,
static gboolean
on_event(GanvNode* node, GdkEvent* event)
{
- GnomeCanvasItem* item = GNOME_CANVAS_ITEM(node);
- GanvCanvas* canvas = GANV_CANVAS(item->canvas);
+ GnomeCanvasItem* item = GNOME_CANVAS_ITEM(node);
+ GanvCanvas* canvas = GANV_CANVAS(item->canvas);
return ganv_canvas_port_event(canvas, GANV_PORT(node), event);
}