X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fcontrol_protocol%2Fbasic_ui.cc;h=bf6bb25f2cac17fd7900078299c0e8bef08dde75;hb=432e0073f6d8a91edb213e535c47a7e4ff686284;hp=3d336adb47e5088c9d6fa33e2dbc63f348d7f98b;hpb=4a3d7877f6b03fac7755f997b945583ba5732d13;p=ardour.git diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index 3d336adb47..bf6bb25f2c 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -19,6 +19,7 @@ */ #include "pbd/pthread_utils.h" +#include "pbd/memento_command.h" #include "ardour/session.h" #include "ardour/location.h" @@ -28,9 +29,8 @@ #include "i18n.h" using namespace ARDOUR; -using ARDOUR::nframes_t; -sigc::signal BasicUI::AccessAction; +PBD::Signal2 BasicUI::AccessAction; BasicUI::BasicUI (Session& s) : session (&s) @@ -53,7 +53,6 @@ BasicUI::register_thread (std::string name) std::string pool_name = name; pool_name += " events"; - PBD::notify_gui_about_thread_creation (pthread_self(), name); SessionEvent::create_per_thread_pool (pool_name, 64); } @@ -80,6 +79,20 @@ BasicUI::loop_toggle () } } +void +BasicUI::loop_location (framepos_t start, framepos_t end) +{ + Location* tll; + if ((tll = session->locations()->auto_loop_location()) == 0) { + Location* loc = new Location (*session, start, end, _("Loop"), Location::IsAutoLoop); + session->locations()->add (loc, true); + session->set_auto_loop_location (loc); + } else { + tll->set_hidden (false, this); + tll->set (start, end); + } +} + void BasicUI::goto_start () { @@ -93,22 +106,28 @@ BasicUI::goto_end () } void -BasicUI::add_marker () +BasicUI::add_marker (const std::string& markername) { - nframes_t when = session->audible_frame(); - session->locations()->add (new Location (when, when, _("unnamed"), Location::IsMark)); + framepos_t where = session->audible_frame(); + Location *location = new Location (*session, where, where, markername, Location::IsMark); + session->begin_reversible_command (_("add marker")); + XMLNode &before = session->locations()->get_state(); + session->locations()->add (location, true); + XMLNode &after = session->locations()->get_state(); + session->add_command (new MementoCommand(*(session->locations()), &before, &after)); + session->commit_reversible_command (); } void BasicUI::rewind () { - session->request_transport_speed (-2.0f); + session->request_transport_speed (session->transport_speed() - 1.5); } void BasicUI::ffwd () { - session->request_transport_speed (2.0f); + session->request_transport_speed (session->transport_speed() + 1.5); } void @@ -127,7 +146,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) { @@ -166,10 +185,10 @@ BasicUI::save_state () void BasicUI::prev_marker () { - Location *location = session->locations()->first_location_before (session->transport_frame()); + framepos_t pos = session->locations()->first_mark_before (session->transport_frame()); - if (location) { - session->request_locate (location->start(), session->transport_rolling()); + if (pos >= 0) { + session->request_locate (pos, session->transport_rolling()); } else { session->goto_start (); } @@ -178,12 +197,12 @@ BasicUI::prev_marker () void BasicUI::next_marker () { - Location *location = session->locations()->first_location_after (session->transport_frame()); + framepos_t pos = session->locations()->first_mark_after (session->transport_frame()); - if (location) { - session->request_locate (location->start(), session->transport_rolling()); + if (pos >= 0) { + session->request_locate (pos, session->transport_rolling()); } else { - session->request_locate (session->current_end_frame()); + session->goto_end(); } } @@ -215,9 +234,9 @@ 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 (); } } @@ -249,14 +268,14 @@ BasicUI::set_record_enable (bool yn) } } -nframes_t +framepos_t BasicUI::transport_frame () { return session->transport_frame(); } void -BasicUI::locate (nframes_t where, bool roll_after_locate) +BasicUI::locate (framepos_t where, bool roll_after_locate) { session->request_locate (where, roll_after_locate); } @@ -273,26 +292,122 @@ BasicUI::locked () return session->transport_locked (); } -nframes_t +ARDOUR::framecnt_t BasicUI::timecode_frames_per_hour () { return session->timecode_frames_per_hour (); } void -BasicUI::timecode_time (nframes_t where, Timecode::Time& timecode) +BasicUI::timecode_time (framepos_t where, Timecode::Time& timecode) { session->timecode_time (where, *((Timecode::Time *) &timecode)); } void -BasicUI::timecode_to_sample (Timecode::Time& timecode, nframes_t& sample, bool use_offset, bool use_subframes) const +BasicUI::timecode_to_sample (Timecode::Time& timecode, framepos_t & sample, bool use_offset, bool use_subframes) const { session->timecode_to_sample (*((Timecode::Time*)&timecode), sample, use_offset, use_subframes); } void -BasicUI::sample_to_timecode (nframes_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes) const +BasicUI::sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes) const { 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 r) +{ +} + +void +BasicUI::solo_press (boost::shared_ptr 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 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 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