megaopus commit: (1) add __STD_(LIMIT|FORMAT)_MACROS to command line flags for cc...
[ardour.git] / libs / surfaces / control_protocol / basic_ui.cc
index 44445192be017b44875c19a1ee29700001ce1b40..3d00b6283f4c6025d33f62544f38e6712acb64ce 100644 (file)
 
 */
 
-#include <pbd/pthread_utils.h>
+#include "pbd/pthread_utils.h"
 
-#include <ardour/session.h>
-#include <ardour/location.h>
+#include "ardour/session.h"
+#include "ardour/location.h"
 
-#include <control_protocol/basic_ui.h>
+#include "control_protocol/basic_ui.h"
 
 #include "i18n.h"
 
 using namespace ARDOUR;
 using ARDOUR::nframes_t;
 
+PBD::Signal2<void,std::string,std::string> BasicUI::AccessAction;
+
 BasicUI::BasicUI (Session& s)
        : session (&s)
 {
@@ -48,7 +50,20 @@ BasicUI::~BasicUI ()
 void
 BasicUI::register_thread (std::string name)
 {
-       PBD::ThreadCreated (pthread_self(), name);
+       std::string pool_name = name;
+       pool_name += " events";
+
+       SessionEvent::create_per_thread_pool (pool_name, 64);
+}
+
+void
+BasicUI::access_action ( std::string action_path ) 
+{
+       int split_at = action_path.find( "/" );
+       std::string group = action_path.substr( 0, split_at );
+       std::string item = action_path.substr( split_at + 1 );
+
+       AccessAction( group, item );
 }
 
 void
@@ -80,7 +95,7 @@ void
 BasicUI::add_marker ()
 {
        nframes_t when = session->audible_frame();
-       session->locations()->add (new Location (when, when, _("unnamed"), Location::IsMark));
+       session->locations()->add (new Location (*session, when, when, _("unnamed"), Location::IsMark));
 }
 
 void
@@ -111,7 +126,7 @@ BasicUI::transport_play (bool from_last_start)
        } 
 
        if (session->get_play_range ()) {
-               session->request_play_range (false);
+               session->request_play_range (0);
        }
        
        if (from_last_start && rolling) {
@@ -172,12 +187,12 @@ BasicUI::next_marker ()
 }
 
 void
-BasicUI::set_transport_speed (float speed)
+BasicUI::set_transport_speed (double speed)
 {
        session->request_transport_speed (speed);
 }
 
-float
+double
 BasicUI::get_transport_speed ()
 {
        return session->transport_speed ();
@@ -199,22 +214,22 @@ void
 BasicUI::toggle_all_rec_enables ()
 {
        if (session->get_record_enabled()) {
-               session->record_disenable_all ();
+               // session->record_disenable_all ();
        } else {
-               session->record_enable_all ();
+               // session->record_enable_all ();
        }
 }
 
 void
 BasicUI::toggle_punch_in ()
 {
-       Config->set_punch_in (!Config->get_punch_in());
+       session->config.set_punch_in (!session->config.get_punch_in());
 }
 
 void
 BasicUI::toggle_punch_out ()
 {
-       Config->set_punch_out (!Config->get_punch_out());
+       session->config.set_punch_out (!session->config.get_punch_out());
 }
 
 bool
@@ -258,25 +273,121 @@ BasicUI::locked ()
 }
 
 nframes_t
-BasicUI::smpte_frames_per_hour ()
+BasicUI::timecode_frames_per_hour ()
 {
-       return session->smpte_frames_per_hour ();
+       return session->timecode_frames_per_hour ();
 }
 
 void
-BasicUI::smpte_time (nframes_t where, SMPTE::Time& smpte)
+BasicUI::timecode_time (nframes_t where, Timecode::Time& timecode)
 {
-       session->smpte_time (where, *((SMPTE::Time *) &smpte));
+       session->timecode_time (where, *((Timecode::Time *) &timecode));
 }
 
 void 
-BasicUI::smpte_to_sample (SMPTE::Time& smpte, nframes_t& sample, bool use_offset, bool use_subframes) const
+BasicUI::timecode_to_sample (Timecode::Time& timecode, int64_t& sample, bool use_offset, bool use_subframes) const
 {
-       session->smpte_to_sample (*((SMPTE::Time*)&smpte), sample, use_offset, use_subframes);
+       session->timecode_to_sample (*((Timecode::Time*)&timecode), sample, use_offset, use_subframes);
 }
 
 void 
-BasicUI::sample_to_smpte (nframes_t sample, SMPTE::Time& smpte, bool use_offset, bool use_subframes) const
+BasicUI::sample_to_timecode (int64_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes) const
 {
-       session->sample_to_smpte (sample, *((SMPTE::Time*)&smpte), use_offset, use_subframes);
+       session->sample_to_timecode (sample, *((Timecode::Time*)&timecode), use_offset, use_subframes);
+}
+
+#if 0
+this stuff is waiting to go in so that all UIs can offer complex solo/mute functionality
+
+void
+BasicUI::solo_release (boost::shared_ptr<Route> r)
+{
+}
+
+void
+BasicUI::solo_press (boost::shared_ptr<Route> r, bool momentary, bool global, bool exclusive, bool isolate, bool solo_group)
+{
+       if (momentary) {
+               _solo_release = new SoloMuteRelease (_route->soloed());
+       }
+       
+       if (global) {
+               
+               if (_solo_release) {
+                       _solo_release->routes = _session->get_routes ();
+               }
+               
+               if (Config->get_solo_control_is_listen_control()) {
+                       _session->set_listen (_session->get_routes(), !_route->listening(),  Session::rt_cleanup, true);
+               } else {
+                       _session->set_solo (_session->get_routes(), !_route->soloed(),  Session::rt_cleanup, true);
+               }
+               
+       } else if (exclusive) {
+               
+               if (_solo_release) {
+                       _solo_release->exclusive = true;
+                       
+                       boost::shared_ptr<RouteList> routes = _session->get_routes();
+                       
+                       for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
+                               if ((*i)->soloed ()) {
+                                       _solo_release->routes_on->push_back (*i);
+                               } else {
+                                       _solo_release->routes_off->push_back (*i);
+                               }
+                       }
+               }
+               
+               if (Config->get_solo_control_is_listen_control()) {
+                       /* ??? we need a just_one_listen() method */
+               } else {
+                       _session->set_just_one_solo (_route, true);
+               }
+               
+       } else if (isolate) {
+               
+               // shift-click: toggle solo isolated status
+               
+               _route->set_solo_isolated (!_route->solo_isolated(), this);
+               delete _solo_release;
+               _solo_release = 0;
+               
+       } else if (solo_group) {
+               
+               /* Primary-button1: solo mix group.
+                  NOTE: Primary-button2 is MIDI learn.
+               */
+               
+               if (_route->route_group()) {
+                       
+                       if (_solo_release) {
+                               _solo_release->routes = _route->route_group()->route_list();
+                       }
+                       
+                       if (Config->get_solo_control_is_listen_control()) {
+                               _session->set_listen (_route->route_group()->route_list(), !_route->listening(),  Session::rt_cleanup, true);
+                       } else {
+                               _session->set_solo (_route->route_group()->route_list(), !_route->soloed(),  Session::rt_cleanup, true);
+                       }
+               }
+               
+       } else {
+               
+               /* click: solo this route */
+               
+               boost::shared_ptr<RouteList> rl (new RouteList);
+               rl->push_back (route());
+               
+               if (_solo_release) {
+                       _solo_release->routes = rl;
+               }
+               
+               if (Config->get_solo_control_is_listen_control()) {
+                       _session->set_listen (rl, !_route->listening());
+               } else {
+                       _session->set_solo (rl, !_route->soloed());
+               }
+       }
 }
+#endif