summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-01-28 15:08:19 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-01-28 15:08:26 -0500
commitea895efb970246ff2bc5d8fae1dbb269aa86ac52 (patch)
tree78237987473c5f337ccabebc7af546394958c69e
parentd19b1b64b1ac0d5c3d73f1423cc43c1d70f13988 (diff)
mackie: improvements to display when switching subview modes
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.cc103
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.h2
-rw-r--r--libs/surfaces/mackie/surface.cc22
-rw-r--r--libs/surfaces/mackie/surface.h3
4 files changed, 97 insertions, 33 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc
index 5ac4804eb8..da74660477 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol.cc
@@ -1654,19 +1654,30 @@ MackieControlProtocol::subview_mode_would_be_ok (SubViewMode mode, boost::shared
return false;
}
+bool
+MackieControlProtocol::redisplay_subview_mode ()
+{
+ Surfaces copy; /* can't hold surfaces lock while calling Strip::subview_mode_changed */
+
+ {
+ Glib::Threads::Mutex::Lock lm (surfaces_lock);
+ copy = surfaces;
+ }
+
+ for (Surfaces::iterator s = copy.begin(); s != copy.end(); ++s) {
+ (*s)->subview_mode_changed ();
+ }
+
+ /* don't call this again from a timeout */
+ return false;
+}
+
int
MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Route> r)
{
SubViewMode old_mode = _subview_mode;
boost::shared_ptr<Route> old_route = _subview_route;
- _subview_mode = sm;
-
- if (r) {
- /* retain _subview_route even if it is reset to null implicitly */
- _subview_route = r;
- }
-
if (!subview_mode_would_be_ok (sm, r)) {
Glib::Threads::Mutex::Lock lm (surfaces_lock);
@@ -1690,12 +1701,27 @@ MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Route
}
if (!msg.empty()) {
surfaces.front()->display_message_for (msg, 1000);
+ if (_subview_mode != None) {
+ /* redisplay current subview mode after
+ that message goes away.
+ */
+ Glib::RefPtr<Glib::TimeoutSource> redisplay_timeout = Glib::TimeoutSource::create (1000); // milliseconds
+ redisplay_timeout->connect (sigc::mem_fun (*this, &MackieControlProtocol::redisplay_subview_mode));
+ redisplay_timeout->attach (main_loop()->get_context());
+ }
}
}
return -1;
}
+ _subview_mode = sm;
+
+ if (r) {
+ /* retain _subview_route even if it is reset to null implicitly */
+ _subview_route = r;
+ }
+
if ((_subview_mode != old_mode) || (_subview_route != old_route)) {
if (r != old_route) {
@@ -1707,18 +1733,7 @@ MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Route
/* subview mode did actually change */
- {
- Surfaces copy; /* can't hold surfaces lock while calling Strip::subview_mode_changed */
-
- {
- Glib::Threads::Mutex::Lock lm (surfaces_lock);
- copy = surfaces;
- }
-
- for (Surfaces::iterator s = copy.begin(); s != copy.end(); ++s) {
- (*s)->subview_mode_changed ();
- }
- }
+ redisplay_subview_mode ();
if (_subview_mode != old_mode) {
@@ -1776,12 +1791,10 @@ MackieControlProtocol::set_view_mode (ViewMode m)
void
MackieControlProtocol::display_view_mode ()
{
- {
- Glib::Threads::Mutex::Lock lm (surfaces_lock);
+ Glib::Threads::Mutex::Lock lm (surfaces_lock);
- for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
- (*s)->update_view_mode_display ();
- }
+ for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
+ (*s)->update_view_mode_display (true);
}
}
@@ -1924,7 +1937,18 @@ MackieControlProtocol::_gui_track_selection_changed (ARDOUR::RouteNotificationLi
if (gui_selection_did_change) {
- /* actual GUI selection changed, which may affect subview state */
+ /* note: this method is also called when we switch banks.
+ * But ... we don't allow bank switching when in subview mode.
+ *
+ * so .. we only have to care about subview mode if the
+ * GUI selection has changed.
+ *
+ * It is possible that first_selected_route() may return null if we
+ * are no longer displaying/mapping that route. In that case,
+ * we will exit subview mode. If first_selected_route() is
+ * null, and subview mode is not None, then the first call to
+ * set_subview_mode() will fail, and we will reset to None.
+ */
if (set_subview_mode (_subview_mode, first_selected_route())) {
set_subview_mode (None, boost::shared_ptr<Route>());
@@ -2294,6 +2318,20 @@ MackieControlProtocol::is_hidden (boost::shared_ptr<Route> r) const
return (((r->remote_control_id()) >>31) != 0);
}
+bool
+MackieControlProtocol::is_mapped (boost::shared_ptr<Route> r) const
+{
+ Glib::Threads::Mutex::Lock lm (surfaces_lock);
+
+ for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
+ if ((*s)->route_is_mapped (r)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
boost::shared_ptr<Route>
MackieControlProtocol::first_selected_route () const
{
@@ -2303,6 +2341,21 @@ MackieControlProtocol::first_selected_route () const
boost::shared_ptr<Route> r = _last_selected_routes.front().lock();
+ if (r) {
+ /* check it is on one of our surfaces */
+
+ if (is_mapped (r)) {
+ return r;
+ }
+
+ /* route is not mapped. thus, the currently selected route is
+ * not on the surfaces, and so from our perspective, there is
+ * no currently selected route.
+ */
+
+ r.reset ();
+ }
+
return r; /* may be null */
}
diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h
index 680d3c2819..8871002424 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.h
+++ b/libs/surfaces/mackie/mackie_control_protocol.h
@@ -163,6 +163,7 @@ class MackieControlProtocol
bool is_midi_track (boost::shared_ptr<ARDOUR::Route>) const;
bool selected (boost::shared_ptr<ARDOUR::Route>) const;
bool is_hidden (boost::shared_ptr<ARDOUR::Route>) const;
+ bool is_mapped (boost::shared_ptr<ARDOUR::Route>) const;
boost::shared_ptr<ARDOUR::Route> first_selected_route () const;
void set_view_mode (ViewMode);
@@ -367,6 +368,7 @@ class MackieControlProtocol
int create_surfaces ();
bool periodic();
bool redisplay();
+ bool redisplay_subview_mode ();
bool hui_heartbeat ();
void build_gui ();
bool midi_input_handler (Glib::IOCondition ioc, MIDI::Port* port);
diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc
index c7dd289e01..fdb4d666b0 100644
--- a/libs/surfaces/mackie/surface.cc
+++ b/libs/surfaces/mackie/surface.cc
@@ -788,7 +788,7 @@ Surface::turn_it_on ()
(*s)->notify_all ();
}
- update_view_mode_display ();
+ update_view_mode_display (false);
if (_mcp.device_info ().has_global_controls ()) {
_mcp.update_global_button (Button::Read, _mcp.metering_active ());
@@ -1037,14 +1037,10 @@ Surface::subview_mode_changed ()
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
(*s)->subview_mode_changed ();
}
-
- if (_mcp.subview_mode() == MackieControlProtocol::None) {
- update_view_mode_display ();
- }
}
void
-Surface::update_view_mode_display ()
+Surface::update_view_mode_display (bool with_helpful_text)
{
string text;
int id = -1;
@@ -1129,7 +1125,7 @@ Surface::update_view_mode_display ()
}
}
- if (!text.empty()) {
+ if (with_helpful_text && !text.empty()) {
display_message_for (text, 1000);
}
}
@@ -1177,6 +1173,18 @@ Surface::route_is_locked_to_strip (boost::shared_ptr<Route> r) const
return false;
}
+bool
+Surface::route_is_mapped (boost::shared_ptr<Route> r) const
+{
+ for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) {
+ if ((*s)->route() == r) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void
Surface::notify_metering_state_changed()
{
diff --git a/libs/surfaces/mackie/surface.h b/libs/surfaces/mackie/surface.h
index 5246cf9857..122335d9a7 100644
--- a/libs/surfaces/mackie/surface.h
+++ b/libs/surfaces/mackie/surface.h
@@ -80,6 +80,7 @@ public:
Strip* nth_strip (uint32_t n) const;
bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const;
+ bool route_is_mapped (boost::shared_ptr<ARDOUR::Route>) const;
/// This collection owns the groups
typedef std::map<std::string,Group*> Groups;
@@ -151,7 +152,7 @@ public:
void show_two_char_display (const std::string & msg, const std::string & dots = " ");
void show_two_char_display (unsigned int value, const std::string & dots = " ");
- void update_view_mode_display ();
+ void update_view_mode_display (bool with_helpful_text);
void update_flip_mode_display ();
void update_potmode ();