redesign toggling of editor/mixer stacking to use Gtkmm2ext::VisibilityTracker
This commit is contained in:
parent
a366fba7d0
commit
db34831b18
@ -506,7 +506,7 @@
|
||||
</menu>
|
||||
<menu action = 'WindowMenu'>
|
||||
<menuitem action='toggle-mixer'/>
|
||||
<menuitem action='toggle-mixer-on-top'/>
|
||||
<menuitem action='toggle-editor-mixer'/>
|
||||
|
||||
<separator/>
|
||||
|
||||
|
@ -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 ();
|
||||
|
@ -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 ();
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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"))
|
||||
|
@ -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 ();
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user