summaryrefslogtreecommitdiffstats
path: root/src/gui/BreadCrumbs.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-11-24 13:44:03 +0100
committerDavid Robillard <d@drobilla.net>2018-11-24 13:44:03 +0100
commita7d83f19b08eb4c6f79a82fe60c2b86db13f4420 (patch)
treed9b620bfba1e7462df4ddb3f6225cc5216c0ca81 /src/gui/BreadCrumbs.cpp
parentd63edc742cebd685f8a05936682210aa5c1e69a9 (diff)
downloadingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.tar.gz
ingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.tar.bz2
ingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.zip
Squashed 'waflib/' changes from 6e726eb1..5ea8f99f
5ea8f99f Improve test output spacing 0e23b29f Raise exception when test suite fails to ensure non-zero exit status d6de073b Show run time of unit tests 5b655541 Add short configure option for ultra-strict flags 4687ba6d Use gtest-like test output 258903d9 Fix failure count in test group summaries da07e738 Fix verbose tests with Python 3 git-subtree-dir: waflib git-subtree-split: 5ea8f99f6e1246079c1fe6bb590c38a53aadd40d
Diffstat (limited to 'src/gui/BreadCrumbs.cpp')
-rw-r--r--src/gui/BreadCrumbs.cpp229
1 files changed, 0 insertions, 229 deletions
diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp
deleted file mode 100644
index ae7882e3..00000000
--- a/src/gui/BreadCrumbs.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
-
- Ingen is free software: you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
- Software Foundation, either version 3 of the License, or any later version.
-
- Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <list>
-#include <string>
-
-#include <boost/variant/get.hpp>
-
-#include "ingen/client/SigClientInterface.hpp"
-
-#include "App.hpp"
-#include "BreadCrumbs.hpp"
-
-namespace Ingen {
-namespace GUI {
-
-using std::string;
-
-BreadCrumbs::BreadCrumbs(App& app)
- : Gtk::HBox()
- , _active_path("/")
- , _full_path("/")
- , _enable_signal(true)
-{
- app.sig_client()->signal_message().connect(
- sigc::mem_fun(this, &BreadCrumbs::message));
-
- set_can_focus(false);
-}
-
-SPtr<GraphView>
-BreadCrumbs::view(const Raul::Path& path)
-{
- for (const auto& b : _breadcrumbs) {
- if (b->path() == path) {
- return b->view();
- }
- }
-
- return SPtr<GraphView>();
-}
-
-/** Sets up the crumbs to display `path`.
- *
- * If `path` is already part of the shown path, it will be selected and the
- * children preserved.
- */
-void
-BreadCrumbs::build(Raul::Path path, SPtr<GraphView> view)
-{
- bool old_enable_signal = _enable_signal;
- _enable_signal = false;
-
- if (!_breadcrumbs.empty() && (path.is_parent_of(_full_path) || path == _full_path)) {
- // Moving to a path we already contain, just switch the active button
- for (const auto& b : _breadcrumbs) {
- if (b->path() == path) {
- b->set_active(true);
- if (!b->view()) {
- b->set_view(view);
- }
-
- // views are expensive, having two around for the same graph is a bug
- assert(b->view() == view);
-
- } else {
- b->set_active(false);
- }
- }
-
- _active_path = path;
- _enable_signal = old_enable_signal;
-
- } else if (!_breadcrumbs.empty() && path.is_child_of(_full_path)) {
- // Moving to a child of the full path, just append crumbs (preserve view cache)
-
- string suffix = path.substr(_full_path.length());
- while (suffix.length() > 0) {
- if (suffix[0] == '/') {
- suffix = suffix.substr(1);
- }
- const string name = suffix.substr(0, suffix.find("/"));
- _full_path = _full_path.child(Raul::Symbol(name));
- BreadCrumb* but = create_crumb(_full_path, view);
- pack_start(*but, false, false, 1);
- _breadcrumbs.push_back(but);
- but->show();
- if (suffix.find("/") == string::npos) {
- break;
- } else {
- suffix = suffix.substr(suffix.find("/")+1);
- }
- }
-
- for (const auto& b : _breadcrumbs) {
- b->set_active(false);
- }
- _breadcrumbs.back()->set_active(true);
-
- } else {
- // Rebuild from scratch
- // Getting here is bad unless absolutely necessary, since the GraphView cache is lost
-
- _full_path = path;
- _active_path = path;
-
- // Empty existing breadcrumbs
- for (const auto& b : _breadcrumbs) {
- remove(*b);
- }
- _breadcrumbs.clear();
-
- // Add root
- BreadCrumb* root_but = create_crumb(Raul::Path("/"), view);
- pack_start(*root_but, false, false, 1);
- _breadcrumbs.push_front(root_but);
- root_but->set_active(root_but->path() == _active_path);
-
- Raul::Path working_path("/");
- string suffix = path.substr(1);
- while (suffix.length() > 0) {
- if (suffix[0] == '/') {
- suffix = suffix.substr(1);
- }
- const string name = suffix.substr(0, suffix.find("/"));
- working_path = working_path.child(Raul::Symbol(name));
- BreadCrumb* but = create_crumb(working_path, view);
- pack_start(*but, false, false, 1);
- _breadcrumbs.push_back(but);
- but->set_active(working_path == _active_path);
- but->show();
- if (suffix.find("/") == string::npos) {
- break;
- } else {
- suffix = suffix.substr(suffix.find("/")+1);
- }
- }
- }
-
- _enable_signal = old_enable_signal;
-}
-
-/** Create a new crumb, assigning it a reference to `view` if their paths
- * match, otherwise ignoring `view`.
- */
-BreadCrumbs::BreadCrumb*
-BreadCrumbs::create_crumb(const Raul::Path& path,
- SPtr<GraphView> view)
-{
- BreadCrumb* but = manage(
- new BreadCrumb(path,
- ((view && path == view->graph()->path())
- ? view : SPtr<GraphView>())));
-
- but->signal_toggled().connect(
- sigc::bind(sigc::mem_fun(this, &BreadCrumbs::breadcrumb_clicked),
- but));
-
- return but;
-}
-
-void
-BreadCrumbs::breadcrumb_clicked(BreadCrumb* crumb)
-{
- if (_enable_signal) {
- _enable_signal = false;
-
- if (!crumb->get_active()) {
- // Tried to turn off the current active button, bad user, no cookie
- crumb->set_active(true);
- } else {
- signal_graph_selected.emit(crumb->path(), crumb->view());
- if (crumb->path() != _active_path) {
- crumb->set_active(false);
- }
- }
- _enable_signal = true;
- }
-}
-
-void
-BreadCrumbs::message(const Message& msg)
-{
- if (const Del* const del = boost::get<Del>(&msg)) {
- object_destroyed(del->uri);
- }
-}
-
-void
-BreadCrumbs::object_destroyed(const URI& uri)
-{
- for (auto i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) {
- if ((*i)->path() == uri.c_str()) {
- // Remove all crumbs after the removed one (inclusive)
- for (auto j = i; j != _breadcrumbs.end(); ) {
- BreadCrumb* bc = *j;
- j = _breadcrumbs.erase(j);
- remove(*bc);
- }
- break;
- }
- }
-}
-
-void
-BreadCrumbs::object_moved(const Raul::Path& old_path, const Raul::Path& new_path)
-{
- for (const auto& b : _breadcrumbs) {
- if (b->path() == old_path) {
- b->set_path(new_path);
- }
- }
-}
-
-} // namespace GUI
-} // namespace Ingen