diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-26 14:12:52 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-26 14:12:52 -0400 |
commit | db34831b183d511d76ea1f29606e1933e5ad4caf (patch) | |
tree | e1418a7085f5879311074717f107098df63ab34c | |
parent | a366fba7d0933a8f2d97d95fefcbcdc9692d2117 (diff) |
redesign toggling of editor/mixer stacking to use Gtkmm2ext::VisibilityTracker
-rw-r--r-- | gtk2_ardour/ardour.menus.in | 2 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_dependents.cc | 50 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_ed.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor.cc | 3 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.cc | 1 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/mnemonic-us.bindings.in | 2 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h | 4 | ||||
-rw-r--r-- | libs/gtkmm2ext/visibility_tracker.cc | 19 |
11 files changed, 73 insertions, 19 deletions
diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 10881a0fb0..0279384fb5 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -506,7 +506,7 @@ </menu> <menu action = 'WindowMenu'> <menuitem action='toggle-mixer'/> - <menuitem action='toggle-mixer-on-top'/> + <menuitem action='toggle-editor-mixer'/> <separator/> diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 6300a352d5..a326669ec3 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -310,7 +310,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void goto_editor_window (); void goto_mixer_window (); void toggle_mixer_window (); - void toggle_mixer_on_top (); + void toggle_editor_mixer (); int setup_windows (); void setup_transport (); diff --git a/gtk2_ardour/ardour_ui_dependents.cc b/gtk2_ardour/ardour_ui_dependents.cc index b9b0cdb6a2..7438fab9f0 100644 --- a/gtk2_ardour/ardour_ui_dependents.cc +++ b/gtk2_ardour/ardour_ui_dependents.cc @@ -150,21 +150,49 @@ ARDOUR_UI::toggle_mixer_window () } void -ARDOUR_UI::toggle_mixer_on_top () +ARDOUR_UI::toggle_editor_mixer () { + if (editor && mixer) { - if (gtk_window_is_active(Mixer_UI::instance()->gobj())) { + if (editor->get_screen() != mixer->get_screen()) { + // different screens, so don't do anything + return; + } + + /* See if they are obscuring each other */ + + gint ex, ey, ew, eh; + gint mx, my, mw, mh; + + editor->get_position (ex, ey); + editor->get_size (ew, eh); + + mixer->get_position (mx, my); + mixer->get_size (mw, mh); + + GdkRectangle e; + GdkRectangle m; + GdkRectangle r; + + e.x = ex; + e.y = ey; + e.width = ew; + e.height = eh; + + m.x = mx; + m.y = my; + m.width = mw; + m.height = mh; + + if (!gdk_rectangle_intersect (&e, &m, &r)) { + /* they do not intersect so do not toggle */ + return; + } + } + + if (mixer && mixer->fully_visible()) { goto_editor_window (); } else { - Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("toggle-mixer")); - if (act) { - Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act); - - /* Toggle the mixer to `visible' if required */ - if (!tact->get_active ()) { - tact->set_active (true); - } - } goto_mixer_window (); } } diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 2d279385ae..66335bb55b 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -239,7 +239,7 @@ ARDOUR_UI::install_actions () ActionManager::session_sensitive_actions.push_back (act); ActionManager::register_toggle_action (common_actions, X_("toggle-mixer"), S_("Window|Mixer"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_window)); - ActionManager::register_action (common_actions, X_("toggle-mixer-on-top"), _("Mixer on Top"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_on_top)); + ActionManager::register_action (common_actions, X_("toggle-editor-mixer"), _("Toggle Editor+Mixer"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_editor_mixer)); ActionManager::register_toggle_action (common_actions, X_("ToggleRCOptionsEditor"), _("Preferences"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_rc_options_window)); ActionManager::register_toggle_action (common_actions, X_("ToggleSessionOptionsEditor"), _("Properties"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_options_window)); act = ActionManager::register_toggle_action (common_actions, X_("ToggleInspector"), _("Tracks and Busses"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_route_params_window)); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index b7cc7b9f27..280f401fdf 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -233,7 +233,8 @@ pane_size_watcher (Paned* pane) } Editor::Editor () - : _join_object_range_state (JOIN_OBJECT_RANGE_NONE) + : VisibilityTracker (*((Gtk::Window*) this)) + , _join_object_range_state (JOIN_OBJECT_RANGE_NONE) /* time display buttons */ , minsec_label (_("Mins:Secs")) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 910df94c26..1c246a3f3b 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -43,6 +43,7 @@ #include "gtkmm2ext/dndtreeview.h" #include "gtkmm2ext/stateful_button.h" #include "gtkmm2ext/bindings.h" +#include "gtkmm2ext/visibility_tracker.h" #include "pbd/stateful.h" #include "pbd/signals.h" @@ -146,7 +147,7 @@ class ImageFrameSocketHandler ; class TimeAxisViewItem ; /* </CMT Additions> */ -class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr +class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr, public Gtkmm2ext::VisibilityTracker { public: Editor (); diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 74556c8eda..e3a97daa6f 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -83,6 +83,7 @@ Mixer_UI::instance () Mixer_UI::Mixer_UI () : Window (Gtk::WINDOW_TOPLEVEL) + , VisibilityTracker (*((Gtk::Window*) this)) , _visible (false) , no_track_list_redisplay (false) , in_group_row_change (false) diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 2946d0ae59..8a293f7f9f 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -40,6 +40,8 @@ #include "ardour/types.h" #include "ardour/session_handle.h" +#include "gtkmm2ext/visibility_tracker.h" + #include "enums.h" #include "mixer_actor.h" @@ -53,7 +55,7 @@ class PluginSelector; class MixerGroupTabs; class MonitorSection; -class Mixer_UI : public Gtk::Window, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr, public MixerActor +class Mixer_UI : public Gtk::Window, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr, public MixerActor, public Gtkmm2ext::VisibilityTracker { public: static Mixer_UI* instance(); diff --git a/gtk2_ardour/mnemonic-us.bindings.in b/gtk2_ardour/mnemonic-us.bindings.in index 0f0415c983..ef596478fc 100644 --- a/gtk2_ardour/mnemonic-us.bindings.in +++ b/gtk2_ardour/mnemonic-us.bindings.in @@ -219,7 +219,7 @@ This mode provides many different operations on both regions and control points, @sess|Main/AddTrackBus|<@PRIMARY@><@TERTIARY@>n|add track(s) or bus(ses) @sess|Main/New|<@PRIMARY@>n|open a new session @rop|Region/toggle-region-mute|<@PRIMARY@>m|mute/unmute -@wvis|Common/toggle-mixer-on-top|<@WINDOW@>m|rotate editor \& mixer window +@wvis|Common/toggle-editor-mixer|<@WINDOW@>m|rotate editor \& mixer window ;; arrow keys, navigation etc. diff --git a/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h b/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h index 6415dd6d2b..f4ed62bb21 100644 --- a/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h +++ b/libs/gtkmm2ext/gtkmm2ext/visibility_tracker.h @@ -35,6 +35,10 @@ class VisibilityTracker { void cycle_visibility (); + bool fully_visible() const; + bool not_visible() const; + bool partially_visible() const; + private: Gtk::Window& window; GdkVisibilityState _visibility; diff --git a/libs/gtkmm2ext/visibility_tracker.cc b/libs/gtkmm2ext/visibility_tracker.cc index c0aabdfca6..d5a020d370 100644 --- a/libs/gtkmm2ext/visibility_tracker.cc +++ b/libs/gtkmm2ext/visibility_tracker.cc @@ -41,10 +41,27 @@ VisibilityTracker::handle_visibility_notify_event (GdkEventVisibility* ev) void VisibilityTracker::cycle_visibility () { - if (window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED)) { + if (fully_visible ()) { window.hide (); } else { window.present (); } } +bool +VisibilityTracker::fully_visible () const +{ + return window.is_mapped() && (_visibility == GDK_VISIBILITY_UNOBSCURED); +} + +bool +VisibilityTracker::not_visible () const +{ + return !window.is_mapped() || (_visibility == GDK_VISIBILITY_FULLY_OBSCURED); +} + +bool +VisibilityTracker::partially_visible () const +{ + return window.is_mapped() && (_visibility == GDK_VISIBILITY_PARTIAL); +} |