diff options
-rw-r--r-- | ganv/canvas.h | 17 | ||||
-rw-r--r-- | src/Canvas.cpp | 31 | ||||
-rw-r--r-- | wscript | 2 |
3 files changed, 47 insertions, 3 deletions
diff --git a/ganv/canvas.h b/ganv/canvas.h index b776b74..57781dc 100644 --- a/ganv/canvas.h +++ b/ganv/canvas.h @@ -368,6 +368,23 @@ ganv_canvas_arrange(GanvCanvas* canvas); void ganv_canvas_export_dot(GanvCanvas* canvas, const char* filename); +/** + * ganv_canvas_supports_sprung_layout: + * + * Returns: true iff ganv is compiled with sprung layout support. + */ +gboolean +ganv_canvas_supports_sprung_layout(GanvCanvas* canvas); + +/** + * ganv_canvas_set_sprung_layout: + * + * Enable or disable "live" force-directed canvas layout. + * + * Returns: true iff sprung layout was enabled. + */ +gboolean +ganv_canvas_set_sprung_layout(GanvCanvas* canvas, gboolean sprung_layout); /** * ganv_canvas_get_locked: diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 24cfaf4..7ab8577 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -247,6 +247,7 @@ struct GanvCanvasImpl { #ifdef GANV_FDGL this->layout_idle_id = 0; + this->sprung_layout = FALSE; #endif _animate_idle_id = g_timeout_add(120, on_animate_timeout, this); @@ -444,7 +445,8 @@ struct GanvCanvasImpl { gboolean locked; #ifdef GANV_FDGL - guint layout_idle_id; + guint layout_idle_id; + gboolean sprung_layout; #endif }; @@ -789,6 +791,9 @@ GanvCanvasImpl::layout_iteration() if (_drag_state == EDGE) { return FALSE; // Canvas is locked, halt layout process } + if (!sprung_layout) { + return FALSE; // We shouldn't be running at all + } static const double T_PER_US = .0001; // Sym time per real microsecond @@ -1948,7 +1953,7 @@ void ganv_canvas_contents_changed(GanvCanvas* canvas) { #ifdef GANV_FDGL - if (!canvas->impl->layout_idle_id) { + if (!canvas->impl->layout_idle_id && canvas->impl->sprung_layout) { canvas->impl->layout_idle_id = g_timeout_add_full( G_PRIORITY_DEFAULT_IDLE, 33, @@ -2554,6 +2559,28 @@ ganv_canvas_export_dot(GanvCanvas* canvas, const char* filename) } gboolean +ganv_canvas_supports_sprung_layout(GanvCanvas* canvas) +{ +#ifdef GANV_FDGL + return TRUE; +#else + return FALSE; +#endif +} + +gboolean +ganv_canvas_set_sprung_layout(GanvCanvas* canvas, gboolean sprung_layout) +{ +#ifndef GANV_FDGL + return FALSE; +#else + canvas->impl->sprung_layout = sprung_layout; + ganv_canvas_contents_changed(canvas); + return TRUE; +#endif +} + +gboolean ganv_canvas_get_locked(GanvCanvas* canvas) { return canvas->impl->locked; @@ -8,7 +8,7 @@ import waflib.extras.autowaf as autowaf # major increment <=> incompatible changes # minor increment <=> compatible changes (additions) # micro increment <=> no interface changes -GANV_VERSION = '1.2.1' +GANV_VERSION = '1.2.3' GANV_MAJOR_VERSION = '1' # Mandatory waf variables |