From 612186c6dd6549bfd3a44ba61181ce1b6ac49733 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 16 Mar 2014 00:55:18 +0000 Subject: Allow user to enable or disable sprung layout. This setting is saved with the patch so sprung patches remain sprung when loaded again, but manually arranged patches won't be mangled. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5340 a436a847-0d15-0410-975c-d299462d15a1 --- bundles/ingen.lv2/ingen.ttl | 9 +++++++++ ingen/URIs.hpp | 1 + ingen/ingen.h | 1 + src/URIs.cpp | 1 + src/gui/GraphBox.cpp | 46 ++++++++++++++++++++++++++++++++++++++++----- src/gui/GraphBox.hpp | 7 +++++-- src/gui/GraphView.cpp | 4 ++++ src/gui/ingen_gui.ui | 15 +++++++++++++-- wscript | 2 +- 9 files changed, 76 insertions(+), 10 deletions(-) diff --git a/bundles/ingen.lv2/ingen.ttl b/bundles/ingen.lv2/ingen.ttl index 42055471..e3a06bf5 100644 --- a/bundles/ingen.lv2/ingen.ttl +++ b/bundles/ingen.lv2/ingen.ttl @@ -80,6 +80,15 @@ of the Graph's children, and :polyphonic specifies whether the graph is seen as polyphonic to the Graph's parent. """ . +ingen:sprungLayout + a owl:DatatypeProperty ; + rdfs:domain ingen:Graph ; + rdfs:range xsd:boolean ; + rdfs:label "sprung layout" ; + rdfs:comment """ +Whether or not the graph has a "sprung" force-directed layout. +""" . + ingen:value a owl:DatatypeProperty ; rdfs:domain lv2:Port ; diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp index ba822947..4c31ccdc 100644 --- a/ingen/URIs.hpp +++ b/ingen/URIs.hpp @@ -90,6 +90,7 @@ public: const Quark ingen_polyphonic; const Quark ingen_polyphony; const Quark ingen_prototype; + const Quark ingen_sprungLayout; const Quark ingen_tail; const Quark ingen_uiEmbedded; const Quark ingen_value; diff --git a/ingen/ingen.h b/ingen/ingen.h index c3662c18..ba873c75 100644 --- a/ingen/ingen.h +++ b/ingen/ingen.h @@ -39,6 +39,7 @@ #define INGEN__polyphonic INGEN_NS "polyphonic" #define INGEN__polyphony INGEN_NS "polyphony" #define INGEN__prototype INGEN_NS "prototype" +#define INGEN__sprungLayout INGEN_NS "sprungLayout" #define INGEN__tail INGEN_NS "tail" #define INGEN__uiEmbedded INGEN_NS "uiEmbedded" #define INGEN__value INGEN_NS "value" diff --git a/src/URIs.cpp b/src/URIs.cpp index b6bf7ad8..6d41482d 100644 --- a/src/URIs.cpp +++ b/src/URIs.cpp @@ -80,6 +80,7 @@ URIs::URIs(Forge& f, URIMap* map) , ingen_polyphonic (forge, map, INGEN__polyphonic) , ingen_polyphony (forge, map, INGEN__polyphony) , ingen_prototype (forge, map, INGEN__prototype) + , ingen_sprungLayout (forge, map, INGEN__sprungLayout) , ingen_tail (forge, map, INGEN__tail) , ingen_uiEmbedded (forge, map, INGEN__uiEmbedded) , ingen_value (forge, map, INGEN__value) diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index ad9aea56..99debec3 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -88,7 +88,8 @@ GraphBox::GraphBox(BaseObjectType* cobject, xml->get_widget("graph_view_engine_window_menuitem", _menu_view_engine_window); xml->get_widget("graph_properties_menuitem", _menu_view_graph_properties); xml->get_widget("graph_fullscreen_menuitem", _menu_fullscreen); - xml->get_widget("graph_animate_canvas_menuitem", _menu_animate_canvas); + xml->get_widget("graph_animate_signals_menuitem", _menu_animate_signals); + xml->get_widget("graph_sprung_layout_menuitem", _menu_sprung_layout); xml->get_widget("graph_human_names_menuitem", _menu_human_names); xml->get_widget("graph_show_port_names_menuitem", _menu_show_port_names); xml->get_widget("graph_zoom_in_menuitem", _menu_zoom_in); @@ -126,8 +127,10 @@ GraphBox::GraphBox(BaseObjectType* cobject, sigc::mem_fun(this, &GraphBox::event_quit)); _menu_fullscreen->signal_activate().connect( sigc::mem_fun(this, &GraphBox::event_fullscreen_toggled)); - _menu_animate_canvas->signal_activate().connect( - sigc::mem_fun(this, &GraphBox::event_animate_canvas_toggled)); + _menu_animate_signals->signal_activate().connect( + sigc::mem_fun(this, &GraphBox::event_animate_signals_toggled)); + _menu_sprung_layout->signal_activate().connect( + sigc::mem_fun(this, &GraphBox::event_sprung_layout_toggled)); _menu_human_names->signal_activate().connect( sigc::mem_fun(this, &GraphBox::event_human_names_toggled)); _menu_show_doc_pane->signal_activate().connect( @@ -246,6 +249,16 @@ GraphBox::set_graph(SPtr graph, assert(_view); + graph->signal_property().connect( + sigc::mem_fun(this, &GraphBox::property_changed)); + + if (ganv_canvas_supports_sprung_layout(_view->canvas()->gobj())) { + _menu_sprung_layout->set_active(true); + } else { + _menu_sprung_layout->set_active(false); + _menu_sprung_layout->set_sensitive(false); + } + // Add view to our alignment if (_view->get_parent()) _view->get_parent()->remove(*_view.get()); @@ -315,6 +328,16 @@ GraphBox::graph_port_removed(SPtr port) _menu_view_control_window->property_sensitive() = false; } +void +GraphBox::property_changed(const Raul::URI& predicate, const Atom& value) +{ + if (predicate == _app->uris().ingen_sprungLayout) { + if (value.type() == _app->uris().forge.Bool) { + _menu_sprung_layout->set_active(value.get()); + } + } +} + void GraphBox::set_documentation(const std::string& doc, bool html) { @@ -702,12 +725,25 @@ GraphBox::event_status_bar_toggled() } void -GraphBox::event_animate_canvas_toggled() +GraphBox::event_animate_signals_toggled() { _app->interface()->set_property( Raul::URI("ingen:/clients/this"), _app->uris().ingen_broadcast, - _app->forge().make((bool)_menu_animate_canvas->get_active())); + _app->forge().make((bool)_menu_animate_signals->get_active())); +} + +void +GraphBox::event_sprung_layout_toggled() +{ + const bool sprung = _menu_sprung_layout->get_active(); + + ganv_canvas_set_sprung_layout(_view->canvas()->gobj(), sprung); + + Resource::Properties properties; + properties.insert(make_pair(_app->uris().ingen_sprungLayout, + _app->forge().make(sprung))); + _app->interface()->put(_graph->uri(), properties); } void diff --git a/src/gui/GraphBox.hpp b/src/gui/GraphBox.hpp index 45cfec94..e06a7c5a 100644 --- a/src/gui/GraphBox.hpp +++ b/src/gui/GraphBox.hpp @@ -94,6 +94,7 @@ public: private: void graph_port_added(SPtr port); void graph_port_removed(SPtr port); + void property_changed(const Raul::URI& predicate, const Atom& value); void show_status(const Client::ObjectModel* model); int message_dialog(const Glib::ustring& message, @@ -114,7 +115,8 @@ private: void event_fullscreen_toggled(); void event_doc_pane_toggled(); void event_status_bar_toggled(); - void event_animate_canvas_toggled(); + void event_animate_signals_toggled(); + void event_sprung_layout_toggled(); void event_human_names_toggled(); void event_port_names_toggled(); void event_zoom_in(); @@ -145,7 +147,8 @@ private: Gtk::MenuItem* _menu_select_all; Gtk::MenuItem* _menu_close; Gtk::MenuItem* _menu_quit; - Gtk::CheckMenuItem* _menu_animate_canvas; + Gtk::CheckMenuItem* _menu_animate_signals; + Gtk::CheckMenuItem* _menu_sprung_layout; Gtk::CheckMenuItem* _menu_human_names; Gtk::CheckMenuItem* _menu_show_port_names; Gtk::CheckMenuItem* _menu_show_doc_pane; diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp index 414f21f9..444075b9 100644 --- a/src/gui/GraphView.cpp +++ b/src/gui/GraphView.cpp @@ -81,6 +81,10 @@ GraphView::set_graph(SPtr graph) _poly_spin->set_increments(1, 4); _poly_spin->set_value(graph->internal_poly()); + if (ganv_canvas_supports_sprung_layout(_canvas->gobj())) { + ganv_canvas_set_sprung_layout(_canvas->gobj(), TRUE); + } + for (const auto& p : graph->properties()) property_changed(p.first, p.second); diff --git a/src/gui/ingen_gui.ui b/src/gui/ingen_gui.ui index 774127d4..8463b435 100644 --- a/src/gui/ingen_gui.ui +++ b/src/gui/ingen_gui.ui @@ -1004,16 +1004,27 @@ Contributors: False - + False True False Update control ports as values change. - _Animate Canvas + Animate Signa_ls True + + + False + True + False + Sprung Layou_t + True + True + + + False diff --git a/wscript b/wscript index dfed65d8..3b31541f 100644 --- a/wscript +++ b/wscript @@ -75,7 +75,7 @@ def configure(conf): autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='NEW_GTKMM', atleast_version='2.14.0', mandatory=False) autowaf.check_pkg(conf, 'ganv-1', uselib_store='GANV', - atleast_version='1.2.1', mandatory=False) + atleast_version='1.2.3', mandatory=False) if not Options.options.no_webkit: autowaf.check_pkg(conf, 'webkit-1.0', uselib_store='WEBKIT', atleast_version='1.4.0', mandatory=False) -- cgit v1.2.1