2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /* This file contains any ARDOUR_UI methods that require knowledge of
21 the various dialog boxes, and exists so that no compilation dependency
22 exists between the main ARDOUR_UI modules and their respective classes.
23 This is to cut down on the compile times. It also helps with my sanity.
26 #include <ardour/session.h>
28 #include "ardour_ui.h"
29 #include "connection_editor.h"
30 #include "location_ui.h"
32 #include "option_editor.h"
33 #include "public_editor.h"
34 #include "route_params_ui.h"
39 using namespace ARDOUR;
41 using namespace Gtkmm2ext;
44 ARDOUR_UI::connect_to_session (Session *s)
48 session->HaltOnXrun.connect (mem_fun(*this, &ARDOUR_UI::halt_on_xrun_message));
50 /* sensitize menu bar options that are now valid */
52 // save_as_item->set_sensitive (true);
53 save_template_item->set_sensitive (true);
54 snapshot_item->set_sensitive (true);
55 save_item->set_sensitive (true);
56 add_track_item->set_sensitive (true);
57 export_item->set_sensitive (true);
58 close_item->set_sensitive (true);
59 locations_dialog_check->set_sensitive (true);
60 route_params_check->set_sensitive (true);
61 connection_editor_check->set_sensitive (true);
63 cleanup_item->set_sensitive (true);
65 /* sensitize transport bar */
67 goto_start_button.set_sensitive (true);
68 goto_end_button.set_sensitive (true);
69 roll_button.set_sensitive (true);
70 stop_button.set_sensitive (true);
71 play_selection_button.set_sensitive (true);
72 rec_button.set_sensitive (true);
73 auto_loop_button.set_sensitive (true);
74 shuttle_box.set_sensitive (true);
77 if (image_compositor_item) {
78 image_compositor_item->set_sensitive(true) ;
80 /* </CMT Additions> */
83 if (session->n_diskstreams() == 0) {
84 session->DiskStreamAdded.connect (mem_fun(*this, &ARDOUR_UI::diskstream_added));
87 if (connection_editor) {
88 connection_editor->set_session (s);
92 location_ui->set_session(s);
96 route_params->set_session (s);
100 option_editor->set_session (s);
104 Blink.connect (mem_fun(*this, &ARDOUR_UI::transport_rec_enable_blink));
105 Blink.connect (mem_fun(*this, &ARDOUR_UI::solo_blink));
106 Blink.connect (mem_fun(*this, &ARDOUR_UI::audition_blink));
108 /* these are all need to be handled in an RT-safe and MT way, so don't
109 do any GUI work, just queue it for handling by the GUI thread.
112 session->TransportStateChange.connect (mem_fun(*this, &ARDOUR_UI::queue_transport_change));
113 session->ControlChanged.connect (mem_fun(*this, &ARDOUR_UI::queue_map_control_change));
115 /* alert the user to these things happening */
117 session->AuditionActive.connect (mem_fun(*this, &ARDOUR_UI::auditioning_changed));
118 session->SoloActive.connect (mem_fun(*this, &ARDOUR_UI::soloing_changed));
120 solo_alert_button.set_active (session->soloing());
122 /* can't be auditioning here */
124 primary_clock.set_session (s);
125 secondary_clock.set_session (s);
126 big_clock.set_session (s);
127 preroll_clock.set_session (s);
128 postroll_clock.set_session (s);
130 /* Clocks are on by default after we are connected to a session, so show that here.
135 connect_dependents_to_session (s);
144 transport_stopped ();
146 second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_second), 1000);
147 point_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_one_seconds), 100);
148 point_zero_one_second_connection = Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
152 ARDOUR_UI::unload_session ()
154 if (session && session->dirty()) {
155 switch (ask_about_saving_session (_("close session"))) {
160 session->save_state ("");
165 second_connection.disconnect ();
166 point_one_second_connection.disconnect ();
167 point_zero_one_second_connection.disconnect();
169 /* desensitize menu bar options that are now invalid */
171 // save_as_item->set_sensitive (false);
172 save_template_item->set_sensitive (false);
173 snapshot_item->set_sensitive (false);
174 save_item->set_sensitive (false);
175 add_track_item->set_sensitive (false);
176 export_item->set_sensitive (false);
177 close_item->set_sensitive (false);
178 connection_editor_check->set_sensitive (false);
179 locations_dialog_check->set_sensitive (false);
180 connection_editor_check->set_active(false);
181 locations_dialog_check->set_active(false);
182 route_params_check->set_sensitive (false);
184 /* desensitize transport bar */
186 goto_start_button.set_sensitive (false);
187 goto_end_button.set_sensitive (false);
188 roll_button.set_sensitive (false);
189 stop_button.set_sensitive (false);
190 play_selection_button.set_sensitive (false);
191 rec_button.set_sensitive (false);
192 auto_loop_button.set_sensitive (false);
193 shuttle_box.set_sensitive (false);
198 /* drop everything attached to the blink signal */
202 primary_clock.set_session (0);
203 secondary_clock.set_session (0);
204 big_clock.set_session (0);
205 preroll_clock.set_session (0);
206 postroll_clock.set_session (0);
209 option_editor->set_session (0);
219 update_buffer_load ();
220 // update_disk_rate ();
226 ARDOUR_UI::create_connection_editor ()
228 if (connection_editor == 0) {
230 // connection_editor = new ConnectionEditor ();
231 // connection_editor->signal_unmap().connect (mem_fun(*this, &ARDOUR_UI::connection_editor_hiding));
235 // connection_editor->set_session (session);
242 ARDOUR_UI::toggle_connection_editor ()
244 if (create_connection_editor()) {
251 if (connection_editor->within_hiding()) {
256 if (connection_editor_check->get_active()){
257 connection_editor->show_all();
259 connection_editor->hide_all();
265 ARDOUR_UI::connection_editor_hiding()
268 // connection_editor_check->set_active(false);
272 ARDOUR_UI::big_clock_hiding()
274 big_clock_check->set_active(false);
278 ARDOUR_UI::toggle_big_clock_window ()
280 if (big_clock_window->is_visible()) {
281 big_clock_window->hide ();
283 big_clock_window->present ();
288 ARDOUR_UI::toggle_options_window ()
290 if (option_editor == 0) {
291 option_editor = new OptionEditor (*this, *editor, *mixer);
292 option_editor->signal_unmap().connect(mem_fun(*this, &ARDOUR_UI::option_hiding));
293 option_editor->set_session (session);
294 } else if (option_editor->within_hiding()) {
298 if (option_editor->is_visible()) {
299 option_editor->hide ();
301 option_editor->present ();
306 ARDOUR_UI::option_hiding ()
308 options_window_check->set_active(false);
312 ARDOUR_UI::toggle_auto_input ()
315 toggle_some_session_state (auto_input_button,
316 &Session::get_auto_input,
317 &Session::set_auto_input);
321 ARDOUR_UI::create_location_ui ()
323 if (location_ui == 0) {
324 location_ui = new LocationUI ();
325 location_ui->set_session (session);
326 location_ui->signal_unmap().connect (mem_fun(*this, &ARDOUR_UI::location_ui_hiding));
332 ARDOUR_UI::toggle_location_window ()
334 if (create_location_ui()) {
338 if (location_ui->within_hiding()) {
342 if (location_ui->is_visible()) {
345 location_ui->present();
350 ARDOUR_UI::location_ui_hiding()
352 locations_dialog_check->set_active(false);
356 ARDOUR_UI::create_route_params ()
358 if (route_params == 0) {
359 route_params = new RouteParams_UI (*engine);
360 route_params->set_session (session);
361 route_params->signal_unmap().connect (mem_fun(*this, &ARDOUR_UI::route_params_hiding));
367 ARDOUR_UI::toggle_route_params_window ()
369 if (create_route_params ()) {
373 if (route_params->within_hiding()) {
377 if (route_params->is_visible ()) {
378 route_params->hide ();
380 route_params->present ();
385 ARDOUR_UI::route_params_hiding ()
387 route_params_check->set_active (false);
391 ARDOUR_UI::toggle_sound_file_browser ()
393 if (sfdb_check->get_active()) {
394 SoundFileBrowser sfdb(_("Sound File Browser"));
396 sfdb_check->signal_toggled().connect (bind (mem_fun (sfdb, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL));
398 sfdb_check->set_active(false);