From 4b806a473d03faa24f00fad5e29721622236ed43 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 14 Dec 2011 00:47:57 +0000 Subject: Custom module point and port draw handlers. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3872 a436a847-0d15-0410-975c-d299462d15a1 --- src/module.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/module.c') diff --git a/src/module.c b/src/module.c index d3ae675..3bfd378 100644 --- a/src/module.c +++ b/src/module.c @@ -569,6 +569,43 @@ ganv_module_move(GanvNode* node, } } +static double +ganv_module_point(GanvItem* item, + double x, double y, + int cx, int cy, + GanvItem** actual_item) +{ + GanvModule* module = GANV_MODULE(item); + + double d = GANV_ITEM_CLASS(parent_class)->point( + item, x, y, cx, cy, actual_item); + + if (!*actual_item) { + // Point is not inside module at all, no point in checking children + return d; + } + + FOREACH_PORT(module->impl->ports, p) { + GanvItem* const port = GANV_ITEM(*p); + + *actual_item = NULL; + d = GANV_ITEM_GET_CLASS(port)->point( + port, + x - port->x, y - port->y, + cx, cy, + actual_item); + + if (*actual_item) { + // Point is inside a port + return d; + } + } + + // Point is inside module, but not a child port + *actual_item = item; + return 0.0; +} + static void ganv_module_class_init(GanvModuleClass* class) { @@ -588,6 +625,7 @@ ganv_module_class_init(GanvModuleClass* class) item_class->update = ganv_module_update; item_class->draw = ganv_module_draw; + item_class->point = ganv_module_point; node_class->move = ganv_module_move; node_class->move_to = ganv_module_move_to; -- cgit v1.2.1