2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it
5 and/or modify it under the terms of the GNU Lesser
6 General Public License as published by the Free Software
7 Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <pbd/pthread_utils.h>
23 #include <ardour/session.h>
24 #include <ardour/location.h>
26 #include <control_protocol/basic_ui.h>
30 using namespace ARDOUR;
31 using ARDOUR::nframes_t;
33 sigc::signal<void,std::string,std::string> BasicUI::AccessAction;
35 BasicUI::BasicUI (Session& s)
51 BasicUI::register_thread (std::string name)
53 PBD::notify_gui_about_thread_creation (pthread_self(), name);
57 BasicUI::access_action ( std::string action_path )
59 int split_at = action_path.find( "/" );
60 std::string group = action_path.substr( 0, split_at );
61 std::string item = action_path.substr( split_at + 1 );
63 AccessAction( group, item );
67 BasicUI::loop_toggle ()
69 if (session->get_play_loop()) {
70 session->request_play_loop (false);
72 session->request_play_loop (true);
73 if (!session->transport_rolling()) {
74 session->request_transport_speed (1.0);
80 BasicUI::goto_start ()
82 session->goto_start ();
92 BasicUI::add_marker ()
94 nframes_t when = session->audible_frame();
95 session->locations()->add (new Location (when, when, _("unnamed"), Location::IsMark));
101 session->request_transport_speed (-2.0f);
107 session->request_transport_speed (2.0f);
111 BasicUI::transport_stop ()
113 session->request_transport_speed (0.0);
117 BasicUI::transport_play (bool from_last_start)
119 bool rolling = session->transport_rolling ();
121 if (session->get_play_loop()) {
122 session->request_play_loop (false);
125 if (session->get_play_range ()) {
126 session->request_play_range (false);
129 if (from_last_start && rolling) {
130 session->request_locate (session->last_transport_start(), true);
134 session->request_transport_speed (1.0f);
138 BasicUI::rec_enable_toggle ()
140 switch (session->record_status()) {
141 case Session::Disabled:
142 if (session->ntracks() == 0) {
143 // string txt = _("Please create 1 or more track\nbefore trying to record.\nCheck the Session menu.");
144 // MessageDialog msg (*editor, txt);
148 session->maybe_enable_record ();
150 case Session::Recording:
151 case Session::Enabled:
152 session->disable_record (true);
157 BasicUI::save_state ()
159 session->save_state ("");
163 BasicUI::prev_marker ()
165 Location *location = session->locations()->first_location_before (session->transport_frame());
168 session->request_locate (location->start(), session->transport_rolling());
170 session->goto_start ();
175 BasicUI::next_marker ()
177 Location *location = session->locations()->first_location_after (session->transport_frame());
180 session->request_locate (location->start(), session->transport_rolling());
182 session->request_locate (session->current_end_frame());
187 BasicUI::set_transport_speed (double speed)
189 session->request_transport_speed (speed);
193 BasicUI::get_transport_speed ()
195 return session->transport_speed ();
211 BasicUI::toggle_all_rec_enables ()
213 if (session->get_record_enabled()) {
214 session->record_disenable_all ();
216 session->record_enable_all ();
221 BasicUI::toggle_punch_in ()
223 session->config.set_punch_in (!session->config.get_punch_in());
227 BasicUI::toggle_punch_out ()
229 session->config.set_punch_out (!session->config.get_punch_out());
233 BasicUI::get_record_enabled ()
235 return session->get_record_enabled();
239 BasicUI::set_record_enable (bool yn)
242 session->maybe_enable_record ();
244 session->disable_record (false, true);
249 BasicUI::transport_frame ()
251 return session->transport_frame();
255 BasicUI::locate (nframes_t where, bool roll_after_locate)
257 session->request_locate (where, roll_after_locate);
263 return session->locate_pending();
269 return session->transport_locked ();
273 BasicUI::timecode_frames_per_hour ()
275 return session->timecode_frames_per_hour ();
279 BasicUI::timecode_time (nframes_t where, Timecode::Time& timecode)
281 session->timecode_time (where, *((Timecode::Time *) &timecode));
285 BasicUI::timecode_to_sample (Timecode::Time& timecode, nframes_t& sample, bool use_offset, bool use_subframes) const
287 session->timecode_to_sample (*((Timecode::Time*)&timecode), sample, use_offset, use_subframes);
291 BasicUI::sample_to_timecode (nframes_t sample, Timecode::Time& timecode, bool use_offset, bool use_subframes) const
293 session->sample_to_timecode (sample, *((Timecode::Time*)&timecode), use_offset, use_subframes);