summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-23 00:02:42 +0000
committerDavid Robillard <d@drobilla.net>2012-04-23 00:02:42 +0000
commitf77f74472a6e46c0af101e7f1d52635c0147efd9 (patch)
tree8f883953ef1b981570c4075f05fb05a46e86456b /src
parent91c3158e31fb55b55eb75951e6e32b4ba5edce93 (diff)
downloadganv-f77f74472a6e46c0af101e7f1d52635c0147efd9.tar.gz
ganv-f77f74472a6e46c0af101e7f1d52635c0147efd9.tar.bz2
ganv-f77f74472a6e46c0af101e7f1d52635c0147efd9.zip
Resize modules when port labels change.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4242 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/ganv-private.h1
-rw-r--r--src/module.c11
-rw-r--r--src/node.c18
-rw-r--r--src/text.c3
4 files changed, 16 insertions, 17 deletions
diff --git a/src/ganv-private.h b/src/ganv-private.h
index 1c25716..35943e0 100644
--- a/src/ganv-private.h
+++ b/src/ganv-private.h
@@ -94,7 +94,6 @@ struct _GanvModuleImpl
double widest_output;
gboolean show_port_labels;
gboolean must_resize;
- gboolean port_size_changed;
};
/* Node */
diff --git a/src/module.c b/src/module.c
index 4b319bc..cebd458 100644
--- a/src/module.c
+++ b/src/module.c
@@ -66,7 +66,6 @@ ganv_module_init(GanvModule* module)
impl->widest_output = 0.0;
impl->show_port_labels = FALSE;
impl->must_resize = TRUE;
- impl->port_size_changed = FALSE;
}
static void
@@ -108,7 +107,6 @@ ganv_module_set_property(GObject* object,
const gboolean tmp = g_value_get_boolean(value);
if (impl->show_port_labels != tmp) {
impl->show_port_labels = tmp;
- impl->port_size_changed = TRUE;
impl->must_resize = TRUE;
/* FIXME
FOREACH_PORT_CONST(gobj()->ports, p) {
@@ -474,10 +472,7 @@ layout(GanvNode* self)
ganv_box_set_width(GANV_BOX(module), label_w + (MODULE_LABEL_PAD * 2.0));
ganv_box_set_height(GANV_BOX(module), label_h);
- if (impl->port_size_changed) {
- measure_ports(module);
- impl->port_size_changed = FALSE;
- }
+ measure_ports(module);
switch (canvas->direction) {
case GANV_DIRECTION_RIGHT:
@@ -496,9 +491,7 @@ ganv_module_resize(GanvNode* self)
{
GanvModule* module = GANV_MODULE(self);
- if (module->impl->must_resize) {
- layout(self);
- }
+ layout(self);
if (parent_class->parent_class.resize) {
parent_class->parent_class.resize(self);
diff --git a/src/node.c b/src/node.c
index b873450..a8db7c4 100644
--- a/src/node.c
+++ b/src/node.c
@@ -331,6 +331,15 @@ ganv_node_default_move_to(GanvNode* node,
}
}
+static void
+ganv_node_default_resize(GanvNode* node)
+{
+ GanvItem* item = GANV_ITEM(node);
+ if (GANV_IS_NODE(item->parent)) {
+ ganv_node_resize(GANV_NODE(item->parent));
+ }
+}
+
static gboolean
ganv_node_default_event(GanvItem* item,
GdkEvent* event)
@@ -591,6 +600,7 @@ ganv_node_class_init(GanvNodeClass* class)
class->disconnect = ganv_node_default_disconnect;
class->move = ganv_node_default_move;
class->move_to = ganv_node_default_move_to;
+ class->resize = ganv_node_default_resize;
class->tick = ganv_node_default_tick;
class->tail_vector = ganv_node_default_tail_vector;
class->head_vector = ganv_node_default_head_vector;
@@ -665,9 +675,6 @@ ganv_node_get_partner(const GanvNode* node)
return node->impl->partner;
}
-void ganv_node_set_label(GanvNode* node,
- const char* str);
-
void
ganv_node_move(GanvNode* node,
double dx,
@@ -687,10 +694,7 @@ ganv_node_move_to(GanvNode* node,
void
ganv_node_resize(GanvNode* node)
{
- GanvNodeClass* klass = GANV_NODE_GET_CLASS(node);
- if (klass->resize) {
- klass->resize(node);
- }
+ GANV_NODE_GET_CLASS(node)->resize(node);
}
void
diff --git a/src/text.c b/src/text.c
index 290eccc..9d70051 100644
--- a/src/text.c
+++ b/src/text.c
@@ -165,6 +165,9 @@ ganv_text_set_property(GObject* object,
free(impl->text);
impl->text = g_value_dup_string(value);
impl->needs_layout = TRUE;
+ if (GANV_IS_NODE(GANV_ITEM(text)->parent)) {
+ ganv_node_resize(GANV_NODE(GANV_ITEM(text)->parent));
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);