diff options
author | David Robillard <d@drobilla.net> | 2014-01-03 00:31:10 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-01-03 00:31:10 +0000 |
commit | a6aba9a3e541b8f193e93c653bac7bbae111de17 (patch) | |
tree | d8f243e3432556706878441f563f8872088085ec /src | |
parent | 023925ef7ecf8314e51f2bb14717f88b92240438 (diff) | |
download | ganv-a6aba9a3e541b8f193e93c653bac7bbae111de17.tar.gz ganv-a6aba9a3e541b8f193e93c653bac7bbae111de17.tar.bz2 ganv-a6aba9a3e541b8f193e93c653bac7bbae111de17.zip |
Don't abuse show_label property for vertical/horizontal mode.
Don't use g_object_get to get x and y coordinates of items.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5246 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/Canvas.cpp | 31 | ||||
-rw-r--r-- | src/circle.c | 13 | ||||
-rw-r--r-- | src/node.c | 16 | ||||
-rw-r--r-- | src/port.c | 7 |
4 files changed, 31 insertions, 36 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp index abf809f..c70aaf3 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -339,8 +339,8 @@ void GanvCanvasImpl::selection_move_finished() { FOREACH_ITEM(_selected_items, i) { - double x, y; - g_object_get(*i, "x", &x, "y", &y, NULL); + const double x = GANV_ITEM(*i)->x; + const double y = GANV_ITEM(*i)->y; g_signal_emit(*i, signal_moved, 0, x, y, NULL); } } @@ -765,7 +765,7 @@ GanvCanvasImpl::layout_iteration() gboolean GanvCanvasImpl::layout_calculate(double dur, bool update) { - static const double SPRING_K = 48.0; + static const double SPRING_K = 64.0; // A light directional force to push sources to the top left static const double DIR_MAGNITUDE = -2200.0; @@ -815,15 +815,15 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) const Region preg = get_region(partner); apply_force(node, partner, edge_force(dir, preg.pos, reg.pos, - preg.area.x, SPRING_K)); + preg.area.x + reg.area.x, SPRING_K / 2.0)); } if (node->impl->is_source) { // Add fake weak spring from origin to sources to anchor graph layout - const Vector anchor = { 16.0, 16.0 }; + const Vector anchor = { 0.0, 0.0 }; node->impl->force = vec_add( node->impl->force, - spring_force(anchor, reg.pos, 12.0, SPRING_K / 6.0)); + spring_force(anchor, reg.pos, 32.0, SPRING_K / 8.0)); } else if (!node->impl->partner && !node->impl->has_in_edges && !node->impl->has_out_edges) { @@ -863,7 +863,7 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) GanvNode* const node = GANV_NODE(*i); - static const float damp = 0.4; // Velocity damping + static const float damp = 0.3; // Velocity damping const bool has_edges = (node->impl->has_in_edges || node->impl->has_out_edges); @@ -2126,17 +2126,16 @@ ganv_canvas_zoom_full(GanvCanvas* canvas) double bottom = DBL_MAX; FOREACH_ITEM(canvas->impl->_items, i) { - GObject* const obj = G_OBJECT(*i); + GanvItem* const item = GANV_ITEM(*i); + const double x = item->x; + const double y = item->y; if (GANV_IS_CIRCLE(*i)) { - double x = 0.0, y = 0.0, r = 0.0; - g_object_get(obj, "x", &x, "y", &y, "radius", &r, NULL); + const double r = GANV_CIRCLE(*i)->impl->coords.radius; left = MIN(left, x - r); right = MAX(right, x + r); bottom = MIN(bottom, y - r); top = MAX(top, y + r); } else { - double x = 0.0, y = 0.0; - g_object_get(obj, "x", &x, "y", &y, NULL); left = MIN(left, x); right = MAX(right, x + ganv_box_get_width(GANV_BOX(*i))); bottom = MIN(bottom, y); @@ -2388,8 +2387,8 @@ ganv_canvas_move_contents_to(GanvCanvas* canvas, double x, double y) { double min_x=HUGE_VAL, min_y=HUGE_VAL; FOREACH_ITEM(canvas->impl->_items, i) { - double x, y; - g_object_get(*i, "x", &x, "y", &y, NULL); + const double x = GANV_ITEM(*i)->x; + const double y = GANV_ITEM(*i)->y; min_x = std::min(min_x, x); min_y = std::min(min_y, y); } @@ -2472,8 +2471,8 @@ ganv_canvas_arrange(GanvCanvas* canvas) ganv_canvas_base_scroll_to(GANV_CANVAS_BASE(canvas->impl->_gcanvas), 0, 0); FOREACH_ITEM(canvas->impl->_items, i) { - double x, y; - g_object_get(*i, "x", &x, "y", &y, NULL); + const double x = GANV_ITEM(*i)->x; + const double y = GANV_ITEM(*i)->y; g_signal_emit(*i, signal_moved, 0, x, y, NULL); } #endif diff --git a/src/circle.c b/src/circle.c index 54f28cb..077ecc9 100644 --- a/src/circle.c +++ b/src/circle.c @@ -175,8 +175,8 @@ ganv_circle_is_within(const GanvNode* self, double x2, double y2) { - double x, y; - g_object_get(G_OBJECT(self), "x", &x, "y", &y, NULL); + const double x = GANV_ITEM(self)->x; + const double y = GANV_ITEM(self)->y; return x >= x1 && x <= x2 @@ -194,11 +194,10 @@ ganv_circle_vector(const GanvNode* self, { GanvCircle* circle = GANV_CIRCLE(self); - double cx, cy; - g_object_get(G_OBJECT(circle), "x", &cx, "y", &cy, NULL); - - double other_x, other_y; - g_object_get(G_OBJECT(other), "x", &other_x, "y", &other_y, NULL); + const double cx = GANV_ITEM(self)->x; + const double cy = GANV_ITEM(self)->y; + const double other_x = GANV_ITEM(other)->x; + const double other_y = GANV_ITEM(other)->y; const double xdist = other_x - cx; const double ydist = other_y - cy; @@ -232,10 +232,8 @@ ganv_node_default_tail_vector(const GanvNode* self, { GanvCanvas* canvas = GANV_CANVAS(GANV_ITEM(self)->canvas); - g_object_get(G_OBJECT(self), - "x", x, - "y", y, - NULL); + *x = GANV_ITEM(self)->x; + *y = GANV_ITEM(self)->y; switch (canvas->direction) { case GANV_DIRECTION_RIGHT: @@ -261,10 +259,8 @@ ganv_node_default_head_vector(const GanvNode* self, { GanvCanvas* canvas = GANV_CANVAS(GANV_ITEM(self)->canvas); - g_object_get(G_OBJECT(self), - "x", x, - "y", y, - NULL); + *x = GANV_ITEM(self)->x; + *y = GANV_ITEM(self)->y; switch (canvas->direction) { case GANV_DIRECTION_RIGHT: @@ -467,8 +463,8 @@ ganv_node_default_event(GanvItem* item, if (selected) { ganv_canvas_selection_move_finished(canvas); } else { - double x, y; - g_object_get(node, "x", &x, "y", &y, NULL); + const double x = GANV_ITEM(node)->x; + const double y = GANV_ITEM(node)->y; g_signal_emit(node, signal_moved, 0, x, y, NULL); } } else { @@ -127,7 +127,8 @@ ganv_port_draw(GanvItem* item, int cx, int cy, int width, int height) { - GanvPort* port = GANV_PORT(item); + GanvPort* port = GANV_PORT(item); + GanvCanvas* canvas = GANV_CANVAS(item->canvas); // Draw Box GanvItemClass* item_class = GANV_ITEM_CLASS(parent_class); @@ -138,7 +139,8 @@ ganv_port_draw(GanvItem* item, GANV_ITEM_GET_CLASS(rect)->draw(rect, cr, cx, cy, width, height); } - if (!GANV_NODE(port)->impl->show_label) { + if (canvas->direction == GANV_DIRECTION_DOWN || + !GANV_NODE(port)->impl->show_label) { return; } @@ -429,7 +431,6 @@ ganv_port_set_direction(GanvPort* port, box->impl->radius_bl = (is_input ? 4.0 : 0.0); break; } - ganv_node_set_show_label(node, direction == GANV_DIRECTION_RIGHT); ganv_node_resize(node); } |