small rationalization of naming and code for managing plugin GUI visibility
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 4 Aug 2015 18:30:41 +0000 (14:30 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 22 Feb 2016 20:31:23 +0000 (15:31 -0500)
gtk2_ardour/processor_box.cc
gtk2_ardour/processor_box.h
gtk2_ardour/window_manager.cc
libs/gtkmm2ext/gtkmm2ext/window_proxy.h
libs/gtkmm2ext/window_proxy.cc

index abfae955438c2a9252f5cc6d4351edad28279739..b54a7817c8036ebbc54738b259d647552b2abd6d 100644 (file)
@@ -3087,7 +3087,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        if (proxy) {
                proxy->set_custom_ui_mode (true);
-               proxy->toggle ();
+               proxy->show_the_right_window ();
        }
 }
 
@@ -3105,7 +3105,7 @@ ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
 
        if (proxy) {
                proxy->set_custom_ui_mode (false);
-               proxy->toggle ();
+               proxy->show_the_right_window ();
        }
 }
 
@@ -3371,13 +3371,16 @@ ProcessorWindowProxy::get (bool create)
 }
 
 void
-ProcessorWindowProxy::toggle ()
+ProcessorWindowProxy::show_the_right_window ()
 {
        if (_window && (is_custom != want_custom)) {
                /* drop existing window - wrong type */
                drop_window ();
+               get (true);
+               setup ();
+               assert (_window);
+               is_custom = want_custom;
        }
-       is_custom = want_custom;
 
-       WM::ProxyBase::toggle ();
+       toggle ();
 }
index a30b05b561f42a7109c922beb6ce14c5ad0ee9e3..151788ec24ec16665051bf70bd2cbfe9111f4e81 100644 (file)
@@ -90,7 +90,7 @@ class ProcessorWindowProxy : public WM::ProxyBase
        }
        
        ARDOUR::SessionHandlePtr* session_handle();
-       void toggle();
+       void show_the_right_window ();
        void set_custom_ui_mode(bool use_custom) { want_custom = use_custom; }
        
        int set_state (const XMLNode&, int);
index e5913c59e8edddab342bb220409a76362ef1e943..eadfc196c32598ca227c7d4415437505fc48c259 100644 (file)
@@ -89,8 +89,20 @@ Manager::remove (const ProxyBase* info)
 void
 Manager::toggle_window (ProxyBase* proxy)
 {
-       if (proxy) {
-               proxy->toggle ();
+
+       Glib::RefPtr<Gtk::Action> act = ARDOUR_UI::instance()->global_actions.find_action (string_compose ("%1/%2", window_actions->get_name(), proxy->action_name()));
+       if (!act) {
+               return;
+       }
+       Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic (act);
+       if (!tact) {
+               return;
+       }
+
+       if (tact->get_active()) {
+               proxy->present ();
+       } else {
+               proxy->hide ();
        }
 }
 
index a0026d9f970071b11cf2a165dce20f61506f2f42..e2f4d70951216b05bbde36b7cd90e3f9223d6671 100644 (file)
@@ -66,8 +66,6 @@ class LIBGTKMM2EXT_API WindowProxy : public PBD::StatefulDestructible, public vi
     
        virtual Gtk::Window* get (bool create = false) = 0;
     
-       virtual void toggle ();
-    
        virtual int set_state (const XMLNode&, int version);
        virtual XMLNode& get_state ();
     
@@ -93,6 +91,7 @@ class LIBGTKMM2EXT_API WindowProxy : public PBD::StatefulDestructible, public vi
        virtual bool delete_event_handler (GdkEventAny *ev);
     
        virtual void setup ();
+       void toggle ();
 };
 
 }
index 6f20eaa8d5673ecd411e3aa713b30f4218a42316..d7670cb89e8726c7ff0397c2fb49cc682354cd5b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "pbd/convert.h"
 #include "pbd/xml++.h"
+#include "pbd/stacktrace.h"
 
 #include "gtkmm2ext/window_proxy.h"
 #include "gtkmm2ext/visibility_tracker.h"
@@ -139,6 +140,7 @@ WindowProxy::toggle()
 {
        if (!_window) {
                (void) get (true);
+               setup ();
                assert (_window);
                /* XXX this is a hack - the window object should really
                   ensure its components are all visible. sigh.
@@ -146,12 +148,13 @@ WindowProxy::toggle()
                _window->show_all();
                /* we'd like to just call this and nothing else */
                _window->present ();
-
        } else {
                if (_window->is_mapped()) {
                        save_pos_and_size();
                }
+
                vistracker->cycle_visibility ();
+
                if (_window->is_mapped()) {
                        if (_width != -1 && _height != -1) {
                                _window->set_default_size (_width, _height);
@@ -279,7 +282,12 @@ WindowProxy::hide ()
 bool
 WindowProxy::delete_event_handler (GdkEventAny* /*ev*/)
 {
-       hide();
+       if (_action) {
+               _action->activate ();
+       } else {
+               hide();
+       }
+
        return true;
 }