diff options
author | David Robillard <d@drobilla.net> | 2013-01-08 19:02:11 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-08 19:02:11 +0000 |
commit | 19b6f2d1c1e8ddcc52b45b4a2c17d4f0317ceabc (patch) | |
tree | 72c29bc1ec7f8937c11de859d99f0b50e4cb3386 /src/gui | |
parent | e6996e3794a0cebe3d196759c98eaa6103bd559c (diff) | |
download | ingen-19b6f2d1c1e8ddcc52b45b4a2c17d4f0317ceabc.tar.gz ingen-19b6f2d1c1e8ddcc52b45b4a2c17d4f0317ceabc.tar.bz2 ingen-19b6f2d1c1e8ddcc52b45b4a2c17d4f0317ceabc.zip |
Re-enable node documentation.
Separate setting documentation from showing documentation pane, and make the latter a user option.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4909 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/GraphBox.cpp | 45 | ||||
-rw-r--r-- | src/gui/GraphBox.hpp | 6 | ||||
-rw-r--r-- | src/gui/GraphCanvas.cpp | 2 | ||||
-rw-r--r-- | src/gui/GraphWindow.hpp | 8 | ||||
-rw-r--r-- | src/gui/NodeModule.cpp | 39 | ||||
-rw-r--r-- | src/gui/NodeModule.hpp | 2 | ||||
-rw-r--r-- | src/gui/Port.cpp | 8 | ||||
-rw-r--r-- | src/gui/ingen_gui.ui | 13 |
8 files changed, 66 insertions, 57 deletions
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 0401143c..17631794 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -72,10 +72,7 @@ GraphBox::GraphBox(BaseObjectType* cobject, xml->get_widget("graph_win_alignment", _alignment); xml->get_widget("graph_win_status_bar", _status_bar); - //xml->get_widget("graph_win_status_bar", _status_bar); - //xml->get_widget("graph_open_menuitem", _menu_open); xml->get_widget("graph_import_menuitem", _menu_import); - //xml->get_widget("graph_open_into_menuitem", _menu_open_into); xml->get_widget("graph_save_menuitem", _menu_save); xml->get_widget("graph_save_as_menuitem", _menu_save_as); xml->get_widget("graph_draw_menuitem", _menu_draw); @@ -95,6 +92,7 @@ GraphBox::GraphBox(BaseObjectType* cobject, xml->get_widget("graph_zoom_in_menuitem", _menu_zoom_in); xml->get_widget("graph_zoom_out_menuitem", _menu_zoom_out); xml->get_widget("graph_zoom_normal_menuitem", _menu_zoom_normal); + xml->get_widget("graph_doc_pane_menuitem", _menu_show_doc_pane); xml->get_widget("graph_status_bar_menuitem", _menu_show_status_bar); xml->get_widget("graph_arrange_menuitem", _menu_arrange); xml->get_widget("graph_view_messages_window_menuitem", _menu_view_messages_window); @@ -128,6 +126,8 @@ GraphBox::GraphBox(BaseObjectType* cobject, sigc::mem_fun(this, &GraphBox::event_fullscreen_toggled)); _menu_human_names->signal_activate().connect( sigc::mem_fun(this, &GraphBox::event_human_names_toggled)); + _menu_show_doc_pane->signal_activate().connect( + sigc::mem_fun(this, &GraphBox::event_doc_pane_toggled)); _menu_show_status_bar->signal_activate().connect( sigc::mem_fun(this, &GraphBox::event_status_bar_toggled)); _menu_show_port_names->signal_activate().connect( @@ -273,7 +273,6 @@ GraphBox::set_graph(SharedPtr<const GraphModel> graph, show(); _alignment->show_all(); - hide_documentation(); _view->signal_object_entered.connect( sigc::mem_fun(this, &GraphBox::object_entered)); @@ -314,32 +313,21 @@ GraphBox::graph_port_removed(SharedPtr<const PortModel> port) } void -GraphBox::show_documentation(const std::string& doc, bool html) +GraphBox::set_documentation(const std::string& doc, bool html) { + _doc_scrolledwindow->remove(); #ifdef HAVE_WEBKIT WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new()); webkit_web_view_load_html_string(view, doc.c_str(), ""); - _doc_scrolledwindow->add(*Gtk::manage(Glib::wrap(GTK_WIDGET(view)))); - _doc_scrolledwindow->show_all(); + Gtk::Widget* widget = Gtk::manage(Glib::wrap(GTK_WIDGET(view))); + _doc_scrolledwindow->add(*widget); + widget->show(); #else Gtk::TextView* view = Gtk::manage(new Gtk::TextView()); view->get_buffer()->set_text(doc); _doc_scrolledwindow->add(*view); - _doc_scrolledwindow->show_all(); + view->show(); #endif - if (!_has_shown_documentation) { - const Gtk::Allocation allocation = get_allocation(); - _doc_paned->set_position(allocation.get_width() / 1.61803399); - } - _has_shown_documentation = true; -} - -void -GraphBox::hide_documentation() -{ - _doc_scrolledwindow->remove(); - _doc_scrolledwindow->hide(); - _doc_paned->set_position(INT_MAX); } void @@ -682,6 +670,21 @@ GraphBox::event_fullscreen_toggled() } void +GraphBox::event_doc_pane_toggled() +{ + if (_menu_show_doc_pane->get_active()) { + _doc_scrolledwindow->show_all(); + if (!_has_shown_documentation) { + const Gtk::Allocation allocation = get_allocation(); + _doc_paned->set_position(allocation.get_width() / 1.61803399); + _has_shown_documentation = true; + } + } else { + _doc_scrolledwindow->hide(); + } +} + +void GraphBox::event_status_bar_toggled() { if (_menu_show_status_bar->get_active()) diff --git a/src/gui/GraphBox.hpp b/src/gui/GraphBox.hpp index e8ee3d8b..f78d8a2b 100644 --- a/src/gui/GraphBox.hpp +++ b/src/gui/GraphBox.hpp @@ -77,8 +77,8 @@ public: void set_window(GraphWindow* win) { _window = win; } - void show_documentation(const std::string& doc, bool html); - void hide_documentation(); + bool documentation_is_visible() { return _doc_scrolledwindow->is_visible(); } + void set_documentation(const std::string& doc, bool html); SharedPtr<const Client::GraphModel> graph() const { return _graph; } SharedPtr<GraphView> view() const { return _view; } @@ -112,6 +112,7 @@ private: void event_close(); void event_quit(); void event_fullscreen_toggled(); + void event_doc_pane_toggled(); void event_status_bar_toggled(); void event_human_names_toggled(); void event_port_names_toggled(); @@ -145,6 +146,7 @@ private: Gtk::MenuItem* _menu_quit; Gtk::CheckMenuItem* _menu_human_names; Gtk::CheckMenuItem* _menu_show_port_names; + Gtk::CheckMenuItem* _menu_show_doc_pane; Gtk::CheckMenuItem* _menu_show_status_bar; Gtk::MenuItem* _menu_zoom_in; Gtk::MenuItem* _menu_zoom_out; diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index d35e678f..8f87a2c1 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -619,7 +619,7 @@ GraphCanvas::clear_selection() { GraphWindow* win = _app.window_factory()->graph_window(_graph); if (win) { - win->hide_documentation(); + win->set_documentation("", false); } Ganv::Canvas::clear_selection(); diff --git a/src/gui/GraphWindow.hpp b/src/gui/GraphWindow.hpp index 794619b8..a45177ce 100644 --- a/src/gui/GraphWindow.hpp +++ b/src/gui/GraphWindow.hpp @@ -51,12 +51,10 @@ public: SharedPtr<const Client::GraphModel> graph() const { return _box->graph(); } GraphBox* box() const { return _box; } - void show_documentation(const std::string& doc, bool html) { - _box->show_documentation(doc, html); - } + bool documentation_is_visible() { return _box->documentation_is_visible(); } - void hide_documentation() { - _box->hide_documentation(); + void set_documentation(const std::string& doc, bool html) { + _box->set_documentation(doc, html); } void show_port_status(const Client::PortModel* model, diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index d38bea21..5542bef6 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -72,6 +72,9 @@ NodeModule::NodeModule(GraphCanvas& canvas, signal_moved().connect( sigc::mem_fun(this, &NodeModule::store_location)); + signal_selected().connect( + sigc::mem_fun(this, &NodeModule::on_selected)); + const PluginModel* plugin = dynamic_cast<const PluginModel*>(block->plugin()); if (plugin) { plugin->signal_changed().connect( @@ -427,29 +430,25 @@ NodeModule::property_changed(const Raul::URI& key, const Raul::Atom& value) } } -void -NodeModule::set_selected(gboolean b) +bool +NodeModule::on_selected(gboolean selected) { - if (b != get_selected()) { - Ganv::Module::set_selected(b); - #if 0 - if (b) { - GraphWindow* win = app().window_factory()->parent_graph_window(block()); - if (win) { - std::string doc; - bool html = false; - if (block()->plugin_model()) { - doc = block()->plugin_model()->documentation(&html); - } - if (!doc.empty()) { - win->show_documentation(doc, html); - } else { - win->hide_documentation(); - } - } + GraphWindow* win = app().window_factory()->parent_graph_window(block()); + if (!win) { + return true; + } + + if (selected && win->documentation_is_visible()) { + GraphWindow* win = app().window_factory()->parent_graph_window(block()); + std::string doc; + bool html = false; + if (block()->plugin_model()) { + doc = block()->plugin_model()->documentation(&html); } - #endif + win->set_documentation(doc, html); } + + return true; } } // namespace GUI diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp index 2d63b047..3dc7e93e 100644 --- a/src/gui/NodeModule.hpp +++ b/src/gui/NodeModule.hpp @@ -61,7 +61,6 @@ public: virtual void store_location(double x, double y); void show_human_names(bool b); - void set_selected(gboolean b); SharedPtr<const Client::BlockModel> block() const { return _block; } @@ -76,6 +75,7 @@ protected: void embed_gui(bool embed); bool popup_gui(); void on_gui_window_close(); + bool on_selected(gboolean selected); void rename(); void property_changed(const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index f6e1e46b..6a6cdfe2 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -428,14 +428,10 @@ Port::set_selected(gboolean b) if (pm && b) { SharedPtr<const BlockModel> block = PtrCast<BlockModel>(pm->parent()); GraphWindow* win = _app.window_factory()->parent_graph_window(block); - if (win && block->plugin_model()) { + if (win && win->documentation_is_visible() && block->plugin_model()) { const std::string& doc = block->plugin_model()->port_documentation( pm->index()); - if (!doc.empty()) { - win->show_documentation(doc, false); - } else { - win->hide_documentation(); - } + win->set_documentation(doc, false); } } } diff --git a/src/gui/ingen_gui.ui b/src/gui/ingen_gui.ui index 9d79a353..8d999d57 100644 --- a/src/gui/ingen_gui.ui +++ b/src/gui/ingen_gui.ui @@ -1642,7 +1642,7 @@ Contributors: <property name="use_action_appearance">False</property> <property name="use_underline">True</property> <property name="use_stock">False</property> - <accelerator key="D" signal="activate" modifiers="GDK_CONTROL_MASK"/> + <accelerator key="R" signal="activate" modifiers="GDK_CONTROL_MASK"/> <signal name="activate" handler="on_graph_draw_menuitem_activate" swapped="no"/> </object> </child> @@ -1845,6 +1845,17 @@ Contributors: </object> </child> <child> + <object class="GtkCheckMenuItem" id="graph_doc_pane_menuitem"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Documentation Pane</property> + <property name="use_underline">True</property> + <property name="active">False</property> + <accelerator key="D" signal="activate" modifiers="GDK_CONTROL_MASK"/> + </object> + </child> + <child> <object class="GtkCheckMenuItem" id="graph_status_bar_menuitem"> <property name="visible">True</property> <property name="can_focus">False</property> |