From ae9644045846190f13dda828e2f75115f2c8601f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 22 Nov 2008 17:29:36 +0000 Subject: Add status bar to display information about objects on mouse hover. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1769 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/PluginModel.cpp | 4 ++-- src/client/PluginModel.hpp | 4 ++-- src/engine/MidiControlNode.cpp | 2 +- src/engine/MidiNoteNode.cpp | 2 +- src/engine/MidiTriggerNode.cpp | 2 +- src/gui/BreadCrumb.hpp | 9 ++++---- src/gui/BreadCrumbBox.hpp | 16 +++++++------- src/gui/PatchView.cpp | 27 ++++++++++++++++++++++- src/gui/PatchView.hpp | 12 ++++++---- src/gui/PatchWindow.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++ src/gui/PatchWindow.hpp | 24 ++++++++++---------- src/gui/ingen_gui.glade | 19 ++++++++++++++++ src/gui/wscript | 2 +- 13 files changed, 135 insertions(+), 38 deletions(-) diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 6b7ec4c8..7198235a 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -51,7 +51,7 @@ PluginModel::PluginModel(const string& uri, const string& type_uri) string -PluginModel::default_node_symbol() +PluginModel::default_node_symbol() const { return Raul::Path::nameify(symbol()); } @@ -79,7 +79,7 @@ PluginModel::human_name() string -PluginModel::port_human_name(uint32_t index) +PluginModel::port_human_name(uint32_t index) const { #ifdef HAVE_SLV2 if (_slv2_plugin) { diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index 53bf668c..c59da63b 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -57,9 +57,9 @@ public: const string symbol() const { return string_property("lv2:symbol"); } const string name() const { return string_property("doap:name"); } - string default_node_symbol(); + string default_node_symbol() const; string human_name(); - string port_human_name(uint32_t index); + string port_human_name(uint32_t index) const; #ifdef HAVE_SLV2 static SLV2World slv2_world() { return _slv2_world; } diff --git a/src/engine/MidiControlNode.cpp b/src/engine/MidiControlNode.cpp index c30d6028..fc6098ec 100644 --- a/src/engine/MidiControlNode.cpp +++ b/src/engine/MidiControlNode.cpp @@ -36,7 +36,7 @@ MidiControlNode::MidiControlNode(const string& path, PatchImpl* parent, SampleRate srate, size_t buffer_size) - : NodeBase(new InternalPlugin(NS_INGEN "control_node", "controller", "MIDI Controller") + : NodeBase(new InternalPlugin(NS_INGEN "control_node", "controller", "Controller") , path, false, parent, srate, buffer_size) , _learning(false) { diff --git a/src/engine/MidiNoteNode.cpp b/src/engine/MidiNoteNode.cpp index 5b6da263..7918e1d2 100644 --- a/src/engine/MidiNoteNode.cpp +++ b/src/engine/MidiNoteNode.cpp @@ -37,7 +37,7 @@ namespace Ingen { MidiNoteNode::MidiNoteNode(const string& path, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size) - : NodeBase(new InternalPlugin(NS_INGEN "note_node", "note", "MIDI Note"), + : NodeBase(new InternalPlugin(NS_INGEN "note_node", "note", "Note"), path, polyphonic, parent, srate, buffer_size) , _voices(new Raul::Array(_polyphony)) , _prepared_voices(NULL) diff --git a/src/engine/MidiTriggerNode.cpp b/src/engine/MidiTriggerNode.cpp index bbf63167..c68a0b96 100644 --- a/src/engine/MidiTriggerNode.cpp +++ b/src/engine/MidiTriggerNode.cpp @@ -32,7 +32,7 @@ namespace Ingen { MidiTriggerNode::MidiTriggerNode(const string& path, bool polyphonic, PatchImpl* parent, SampleRate srate, size_t buffer_size) - : NodeBase(new InternalPlugin(NS_INGEN "trigger_node", "trigger", "MIDI Trigger"), + : NodeBase(new InternalPlugin(NS_INGEN "trigger_node", "trigger", "Trigger"), path, false, parent, srate, buffer_size) { _ports = new Raul::Array(5); diff --git a/src/gui/BreadCrumb.hpp b/src/gui/BreadCrumb.hpp index 45bdae31..62900a23 100644 --- a/src/gui/BreadCrumb.hpp +++ b/src/gui/BreadCrumb.hpp @@ -22,6 +22,7 @@ #include "raul/Path.hpp" #include "raul/SharedPtr.hpp" #include "PatchView.hpp" +#include "client/PatchModel.hpp" namespace Ingen { namespace GUI { @@ -39,7 +40,7 @@ namespace GUI { class BreadCrumb : public Gtk::ToggleButton { public: - BreadCrumb(const Path& path, SharedPtr view = SharedPtr()) + BreadCrumb(const Raul::Path& path, SharedPtr view = SharedPtr()) : _path(path) , _view(view) { @@ -54,10 +55,10 @@ public: _view = view; } - const Path& path() const { return _path; } + const Raul::Path& path() const { return _path; } SharedPtr view() const { return _view; } - void set_path(const Path& path) + void set_path(const Raul::Path& path) { remove(); const string text = (path == "/") ? "/" : path.name().c_str(); @@ -71,7 +72,7 @@ public: } private: - Path _path; + Raul::Path _path; SharedPtr _view; }; diff --git a/src/gui/BreadCrumbBox.hpp b/src/gui/BreadCrumbBox.hpp index caaca612..7c4764c1 100644 --- a/src/gui/BreadCrumbBox.hpp +++ b/src/gui/BreadCrumbBox.hpp @@ -43,23 +43,23 @@ class BreadCrumbBox : public Gtk::HBox public: BreadCrumbBox(); - SharedPtr view(const Path& path); + SharedPtr view(const Raul::Path& path); - void build(Path path, SharedPtr view); + void build(Raul::Path path, SharedPtr view); - sigc::signal > signal_patch_selected; + sigc::signal > signal_patch_selected; private: - BreadCrumb* create_crumb(const Path& path, + BreadCrumb* create_crumb(const Raul::Path& path, SharedPtr view = SharedPtr()); void breadcrumb_clicked(BreadCrumb* crumb); - void object_destroyed(const Path& path); - void object_renamed(const Path& old_path, const Path& new_path); + void object_destroyed(const Raul::Path& path); + void object_renamed(const Raul::Path& old_path, const Raul::Path& new_path); - Path _active_path; - Path _full_path; + Raul::Path _active_path; + Raul::Path _full_path; bool _enable_signal; std::list _breadcrumbs; }; diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp index 1c5c2c51..6e2ff1cd 100644 --- a/src/gui/PatchView.cpp +++ b/src/gui/PatchView.cpp @@ -107,6 +107,12 @@ PatchView::set_patch(SharedPtr patch) _poly_spin->signal_value_changed().connect( sigc::mem_fun(*this, &PatchView::poly_changed)); + _canvas->signal_port_entered.connect( + sigc::mem_fun(*this, &PatchView::canvas_port_entered)); + + _canvas->signal_item_entered.connect( + sigc::mem_fun(*this, &PatchView::canvas_item_entered)); + _canvas->grab_focus(); } @@ -121,7 +127,8 @@ SharedPtr PatchView::create(SharedPtr patch) { - const Glib::RefPtr& xml = GladeFactory::new_glade_reference("patch_view_box"); + +const Glib::RefPtr& xml = GladeFactory::new_glade_reference("patch_view_box"); PatchView* result = NULL; xml->get_widget_derived("patch_view_box", result); assert(result); @@ -147,6 +154,24 @@ PatchView::editable_toggled() } +void +PatchView::canvas_port_entered(FlowCanvas::Port* port) +{ + Port* p = dynamic_cast(port); + if (p) + signal_object_entered.emit(p->model().get()); +} + + +void +PatchView::canvas_item_entered(FlowCanvas::Item* item) +{ + NodeModule* m = dynamic_cast(item); + if (m) + signal_object_entered.emit(m->node().get()); +} + + void PatchView::process_toggled() { diff --git a/src/gui/PatchView.hpp b/src/gui/PatchView.hpp index 209480f2..beb1de2f 100644 --- a/src/gui/PatchView.hpp +++ b/src/gui/PatchView.hpp @@ -23,16 +23,17 @@ #include #include #include "raul/SharedPtr.hpp" -#include "client/PatchModel.hpp" - -using std::string; +#include "raul/Atom.hpp" namespace Ingen { namespace Client { class PortModel; class MetadataModel; + class PatchModel; + class ObjectModel; } } using namespace Ingen::Client; +namespace FlowCanvas { class Port; class Item; } namespace Ingen { namespace GUI { @@ -45,7 +46,6 @@ class NewSubpatchWindow; class NodeControlWindow; class PatchDescriptionWindow; class SubpatchModule; -class OmPort; /** The patch specific contents of a PatchWindow (ie the canvas and whatever else). @@ -64,6 +64,8 @@ public: static SharedPtr create(SharedPtr patch); + sigc::signal signal_object_entered; + private: void set_patch(SharedPtr patch); @@ -73,6 +75,8 @@ private: void refresh_clicked(); void on_editable_sig(bool locked); void editable_toggled(); + void canvas_port_entered(FlowCanvas::Port* port); + void canvas_item_entered(FlowCanvas::Item* item); void property_changed(const std::string& predicate, const Raul::Atom& value); diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index fbc85d34..7cd095f5 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "raul/AtomRDF.hpp" #include "interface/EngineInterface.hpp" #include "client/PatchModel.hpp" #include "client/ClientStore.hpp" @@ -55,6 +56,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("patch_win_vbox", _vbox); xml->get_widget("patch_win_viewport", _viewport); + xml->get_widget("patch_win_status_bar", _status_bar); //xml->get_widget("patch_win_status_bar", _status_bar); //xml->get_widget("patch_open_menuitem", _menu_open); xml->get_widget("patch_import_menuitem", _menu_import); @@ -76,6 +78,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("patch_fullscreen_menuitem", _menu_fullscreen); xml->get_widget("patch_human_names_menuitem", _menu_human_names); xml->get_widget("patch_show_port_names_menuitem", _menu_show_port_names); + xml->get_widget("patch_status_bar_menuitem", _menu_show_status_bar); xml->get_widget("patch_arrange_menuitem", _menu_arrange); xml->get_widget("patch_clear_menuitem", _menu_clear); xml->get_widget("patch_destroy_menuitem", _menu_destroy_patch); @@ -113,6 +116,8 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtrsignal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_human_names_toggled)); + _menu_show_status_bar->signal_activate().connect( + sigc::mem_fun(this, &PatchWindow::event_status_bar_toggled)); _menu_show_port_names->signal_activate().connect( sigc::mem_fun(this, &PatchWindow::event_port_names_toggled)); _menu_arrange->signal_activate().connect( @@ -186,6 +191,7 @@ PatchWindow::set_patch(SharedPtr patch, SharedPtr view) new_port_connection.disconnect(); removed_port_connection.disconnect(); + _entered_connection.disconnect(); _patch = patch; @@ -246,6 +252,8 @@ PatchWindow::set_patch(SharedPtr patch, SharedPtr view) removed_port_connection = patch->signal_removed_port.connect(sigc::mem_fun(this, &PatchWindow::patch_port_removed)); show_all(); + _view->signal_object_entered.connect(sigc::mem_fun(this, &PatchWindow::object_entered)); + _enable_signal = true; } @@ -278,6 +286,37 @@ PatchWindow::patch_port_removed(SharedPtr port) } +void +PatchWindow::object_entered(ObjectModel* model) +{ + _status_bar->pop(); + string msg = model->path(); + NodeModel* node = dynamic_cast(model); + if (node) { + PluginModel* plugin = (PluginModel*)node->plugin(); + msg.append(" \"").append(plugin->human_name()).append("\""); + } + + PortModel* port = dynamic_cast(model); + if (port) { + NodeModel* parent = dynamic_cast(port->parent().get()); + if (parent) { + const PluginModel* plugin = dynamic_cast(parent->plugin()); + if (plugin) { + msg.append(" \"").append(plugin->port_human_name(port->index())).append("\""); + const Atom& value = port->value(); + if (value.is_valid()) { + const Redland::Node node = AtomRDF::atom_to_node( + *App::instance().world()->rdf_world, value); + msg.append(" = ").append(node.to_string()); + } + } + } + } + + _status_bar->push(msg); +} + void PatchWindow::event_show_engine() @@ -538,6 +577,17 @@ PatchWindow::event_fullscreen_toggled() } +void +PatchWindow::event_status_bar_toggled() +{ + if (_menu_show_status_bar->get_active()) + _status_bar->show(); + else + _status_bar->hide(); +} + + + void PatchWindow::event_human_names_toggled() { diff --git a/src/gui/PatchWindow.hpp b/src/gui/PatchWindow.hpp index 62adf4c8..a0c9792c 100644 --- a/src/gui/PatchWindow.hpp +++ b/src/gui/PatchWindow.hpp @@ -25,17 +25,11 @@ #include #include "raul/Path.hpp" #include "raul/SharedPtr.hpp" -#include "client/PatchModel.hpp" -#include "PatchView.hpp" -using Ingen::Client::PatchModel; - -using std::string; using std::list; - namespace Ingen { namespace Client { class PatchModel; class PortModel; - class MetadataModel; + class ObjectModel; } } using namespace Ingen::Client; @@ -51,8 +45,8 @@ class NewSubpatchWindow; class NodeControlWindow; class PatchDescriptionWindow; class SubpatchModule; -class OmPort; class BreadCrumbBox; +class PatchView; /** A window for a patch. @@ -65,7 +59,7 @@ public: PatchWindow(BaseObjectType* cobject, const Glib::RefPtr& glade_xml); ~PatchWindow(); - void set_patch_from_path(const Path& path, SharedPtr view); + void set_patch_from_path(const Raul::Path& path, SharedPtr view); void set_patch(SharedPtr pc, SharedPtr view); SharedPtr patch() const { return _patch; } @@ -82,6 +76,7 @@ private: void patch_port_added(SharedPtr port); void patch_port_removed(SharedPtr port); + void object_entered(ObjectModel* model); void event_import(); void event_import_location(); @@ -96,6 +91,7 @@ private: void event_destroy(); void event_clear(); void event_fullscreen_toggled(); + void event_status_bar_toggled(); void event_human_names_toggled(); void event_port_names_toggled(); void event_arrange(); @@ -129,6 +125,7 @@ private: Gtk::MenuItem* _menu_quit; Gtk::CheckMenuItem* _menu_human_names; Gtk::CheckMenuItem* _menu_show_port_names; + Gtk::CheckMenuItem* _menu_show_status_bar; Gtk::MenuItem* _menu_fullscreen; Gtk::MenuItem* _menu_clear; Gtk::MenuItem* _menu_destroy_patch; @@ -139,13 +136,14 @@ private: Gtk::MenuItem* _menu_view_messages_window; Gtk::MenuItem* _menu_view_patch_tree_window; Gtk::MenuItem* _menu_help_about; - + Gtk::VBox* _vbox; Gtk::Viewport* _viewport; BreadCrumbBox* _breadcrumb_box; - - //Gtk::Statusbar* _status_bar; - + Gtk::Statusbar* _status_bar; + + sigc::connection _entered_connection; + /** Invisible bin used to store breadcrumbs when not shown by a view */ Gtk::Alignment _breadcrumb_bin; }; diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade index 9328893b..5d249bd4 100644 --- a/src/gui/ingen_gui.glade +++ b/src/gui/ingen_gui.glade @@ -321,6 +321,15 @@ + + + True + _Status Bar + True + True + + + @@ -468,6 +477,16 @@ 1 + + + True + 2 + + + False + 2 + + diff --git a/src/gui/wscript b/src/gui/wscript index 62cefaf5..d00606eb 100644 --- a/src/gui/wscript +++ b/src/gui/wscript @@ -42,7 +42,7 @@ def build(bld): if bld.env()['HAVE_CURL'] != 0: obj.source += 'UploadPatchWindow.cpp' - obj.includes = ['.', '..', '../common'] + obj.includes = ['.', '..', '../common', '../client', '../module'] obj.name = 'libingen_gui' obj.target = 'ingen_gui' obj.inst_dir = bld.env()['LIBDIRNAME'] + 'ingen' -- cgit v1.2.1