diff options
author | David Robillard <d@drobilla.net> | 2011-12-14 00:47:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-12-14 00:47:57 +0000 |
commit | 4b806a473d03faa24f00fad5e29721622236ed43 (patch) | |
tree | 2023a9ebaa82558b957a500c54b14165334730a4 /src/module.c | |
parent | 61cae4344c83e4439d6ed57f16082b0440f26581 (diff) | |
download | ganv-4b806a473d03faa24f00fad5e29721622236ed43.tar.gz ganv-4b806a473d03faa24f00fad5e29721622236ed43.tar.bz2 ganv-4b806a473d03faa24f00fad5e29721622236ed43.zip |
Custom module point and port draw handlers.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3872 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/module.c')
-rw-r--r-- | src/module.c | 38 |
1 files changed, 38 insertions, 0 deletions
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; |