From 100d4f66654f8b11c73186e22c600a69d94aebe5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 3 Jun 2009 01:49:40 +0000 Subject: Put breadcrumb stuff all in one place. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2073 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/BreadCrumbs.hpp | 55 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'src/gui/BreadCrumbs.hpp') diff --git a/src/gui/BreadCrumbs.hpp b/src/gui/BreadCrumbs.hpp index 6938c154..adabe88f 100644 --- a/src/gui/BreadCrumbs.hpp +++ b/src/gui/BreadCrumbs.hpp @@ -24,24 +24,22 @@ #include #include "raul/Path.hpp" #include "raul/SharedPtr.hpp" +#include "client/PatchModel.hpp" #include "PatchView.hpp" namespace Ingen { namespace GUI { -class BreadCrumb; - /** Collection of breadcrumb buttons forming a path. - * * This doubles as a cache for PatchViews. * * \ingroup GUI */ -class BreadCrumbBox : public Gtk::HBox +class BreadCrumbs : public Gtk::HBox { public: - BreadCrumbBox(); + BreadCrumbs(); SharedPtr view(const Raul::Path& path); @@ -50,6 +48,53 @@ public: sigc::signal > signal_patch_selected; private: + /** Breadcrumb button. + * + * Each Breadcrumb stores a reference to a PatchView for quick switching. + * So, the amount of allocated PatchViews at a given time is equal to the + * number of visible breadcrumbs (which is the perfect cache for GUI + * responsiveness balanced with mem consumption). + * + * \ingroup GUI + */ + class BreadCrumb : public Gtk::ToggleButton + { + public: + BreadCrumb(const Raul::Path& path, SharedPtr view = SharedPtr()) + : _path(path) + , _view(view) + { + assert( !view || view->patch()->path() == path); + set_border_width(0); + set_path(path); + show_all(); + } + + void set_view(SharedPtr view) { + assert( !view || view->patch()->path() == _path); + _view = view; + } + + const Raul::Path& path() const { return _path; } + SharedPtr view() const { return _view; } + + void set_path(const Raul::Path& path) { + remove(); + const std::string text = (path.is_root()) ? "/" : path.name().c_str(); + Gtk::Label* lab = manage(new Gtk::Label(text)); + lab->set_padding(0, 0); + lab->show(); + add(*lab); + + if (_view && _view->patch()->path() != path) + _view.reset(); + } + + private: + Raul::Path _path; + SharedPtr _view; + }; + BreadCrumb* create_crumb(const Raul::Path& path, SharedPtr view = SharedPtr()); -- cgit v1.2.1