From 791587fe9408856a658e5780f0dc5b9231f6c021 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 28 Mar 2012 04:26:07 +0000 Subject: Fix control rect colour and label stacking. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4124 a436a847-0d15-0410-975c-d299462d15a1 --- src/box.c | 2 +- src/module.c | 9 ++++++++- src/node.c | 11 ++++------- src/port.c | 12 +++++++++++- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/box.c b/src/box.c index cbd9006..f3d65cd 100644 --- a/src/box.c +++ b/src/box.c @@ -51,7 +51,7 @@ ganv_box_init(GanvBox* box) box, GANV_TYPE_BOX, GanvBoxImpl); memset(&box->impl->coords, '\0', sizeof(GanvBoxCoords)); - box->impl->coords.border_width = box->node.impl->border_width; + box->impl->coords.border_width = 0.0; box->impl->old_coords = box->impl->coords; box->impl->radius_tl = 0.0; diff --git a/src/module.c b/src/module.c index ff85c6f..36d45a2 100644 --- a/src/module.c +++ b/src/module.c @@ -656,13 +656,20 @@ ganv_module_draw(GanvItem* item, int cx, int cy, int width, int height) { + GanvNode* node = GANV_NODE(item); GanvModule* module = GANV_MODULE(item); - // Draw box and label + // Draw box if (GANV_ITEM_CLASS(parent_class)->draw) { (*GANV_ITEM_CLASS(parent_class)->draw)(item, cr, cx, cy, width, height); } + // Draw label + if (node->impl->label) { + GanvItem* label_item = GANV_ITEM(node->impl->label); + GANV_ITEM_GET_CLASS(label_item)->draw(label_item, cr, cx, cy, width, height); + } + // Draw ports FOREACH_PORT(module->impl->ports, p) { GANV_ITEM_GET_CLASS(GANV_ITEM(*p))->draw( diff --git a/src/node.c b/src/node.c index e2b6213..b873450 100644 --- a/src/node.c +++ b/src/node.c @@ -109,13 +109,10 @@ ganv_node_draw(GanvItem* item, int cx, int cy, int width, int height) { - GanvNode* node = GANV_NODE(item); - - // Draw label - if (node->impl->label) { - GanvItem* label_item = GANV_ITEM(node->impl->label); - GANV_ITEM_GET_CLASS(label_item)->draw(label_item, cr, cx, cy, width, height); - } + /* TODO: Label is not drawn here because ports need to draw control + rects then the label on top. I can't see a way of solving this since + there's no single time parent class draw needs to be called, so perhaps + label shouldn't be part of this class... */ } static void diff --git a/src/port.c b/src/port.c index 58e7629..45376e2 100644 --- a/src/port.c +++ b/src/port.c @@ -21,6 +21,7 @@ #include "ganv/module.h" #include "./boilerplate.h" +#include "./color.h" #include "./ganv-private.h" #include "./gettext.h" @@ -132,6 +133,12 @@ ganv_port_draw(GanvItem* item, GanvItem* const rect = GANV_ITEM(port->impl->control->rect); GANV_ITEM_GET_CLASS(rect)->draw(rect, cr, cx, cy, width, height); } + + GanvNode* node = GANV_NODE(item); + if (node->impl->label) { + GanvItem* label_item = GANV_ITEM(node->impl->label); + GANV_ITEM_GET_CLASS(label_item)->draw(label_item, cr, cx, cy, width, height); + } } static void @@ -334,6 +341,8 @@ ganv_port_show_control(GanvPort* port) GanvPortControl* control = (GanvPortControl*)malloc(sizeof(GanvPortControl)); port->impl->control = control; + guint control_col = highlight_color(GANV_NODE(port)->impl->fill_color, 0x40); + control->value = 0.0f; control->min = 0.0f; control->max = 0.0f; @@ -345,7 +354,8 @@ ganv_port_show_control(GanvPort* port) "y1", 0.0, "x2", 0.0, "y2", ganv_box_get_height(&port->box), - "fill-color", 0xFFFFFF80, + "fill-color", control_col, + "border-color", control_col, "border-width", 0.0, NULL)); ganv_item_show(GANV_ITEM(control->rect)); -- cgit v1.2.1