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"
30 #include "meter_bridge.h"
31 #include "connection_editor.h"
32 #include "public_editor.h"
33 #include "option_editor.h"
34 #include "location_ui.h"
35 #include "route_params_ui.h"
36 #include "library_ui.h"
40 using namespace ARDOUR;
42 using namespace Gtkmmext;
45 ARDOUR_UI::connect_to_session (Session *s)
49 session->HaltOnXrun.connect (slot (*this, &ARDOUR_UI::halt_on_xrun_message));
51 /* sensitize menu bar options that are now valid */
53 // save_as_item->set_sensitive (true);
54 save_template_item->set_sensitive (true);
55 snapshot_item->set_sensitive (true);
56 save_item->set_sensitive (true);
57 add_track_item->set_sensitive (true);
58 export_item->set_sensitive (true);
59 close_item->set_sensitive (true);
60 locations_dialog_check->set_sensitive (true);
61 route_params_check->set_sensitive (true);
62 connection_editor_check->set_sensitive (true);
64 cleanup_item->set_sensitive (true);
66 /* sensitize transport bar */
68 goto_start_button.set_sensitive (true);
69 goto_end_button.set_sensitive (true);
70 roll_button.set_sensitive (true);
71 stop_button.set_sensitive (true);
72 play_selection_button.set_sensitive (true);
73 rec_button.set_sensitive (true);
74 auto_loop_button.set_sensitive (true);
75 shuttle_box.set_sensitive (true);
78 if (image_compositor_item) {
79 image_compositor_item->set_sensitive(true) ;
81 /* </CMT Additions> */
84 if (session->n_diskstreams()) {
85 // meter_bridge_dialog_check->set_sensitive (true);
87 session->DiskStreamAdded.connect (slot (*this, &ARDOUR_UI::diskstream_added));
90 if (connection_editor) {
91 connection_editor->set_session (s);
95 location_ui->set_session(s);
99 route_params->set_session (s);
103 option_editor->set_session (s);
107 Blink.connect (slot (*this, &ARDOUR_UI::transport_rec_enable_blink));
108 Blink.connect (slot (*this, &ARDOUR_UI::solo_blink));
109 Blink.connect (slot (*this, &ARDOUR_UI::audition_blink));
111 /* these are all need to be handled in an RT-safe and MT way, so don't
112 do any GUI work, just queue it for handling by the GUI thread.
115 session->TransportStateChange.connect (slot (*this, &ARDOUR_UI::queue_transport_change));
116 session->ControlChanged.connect (slot (*this, &ARDOUR_UI::queue_map_control_change));
118 /* alert the user to these things happening */
120 session->AuditionActive.connect (slot (*this, &ARDOUR_UI::auditioning_changed));
121 session->SoloActive.connect (slot (*this, &ARDOUR_UI::soloing_changed));
123 solo_alert_button.set_active (session->soloing());
125 /* can't be auditioning here */
127 primary_clock.set_session (s);
128 secondary_clock.set_session (s);
129 big_clock.set_session (s);
130 preroll_clock.set_session (s);
131 postroll_clock.set_session (s);
133 /* Clocks are on by default after we are connected to a session, so show that here.
138 connect_dependents_to_session (s);
144 editor->window().realize();
147 transport_stopped ();
149 second_connection = Main::timeout.connect (slot (*this, &ARDOUR_UI::every_second), 1000);
150 point_one_second_connection = Main::timeout.connect (slot (*this, &ARDOUR_UI::every_point_one_seconds), 100);
151 point_zero_one_second_connection = Main::timeout.connect (slot (*this, &ARDOUR_UI::every_point_zero_one_seconds), 40);
155 ARDOUR_UI::unload_session ()
157 if (session && session->dirty()) {
158 switch (ask_about_saving_session (_("close session"))) {
163 session->save_state ("");
168 second_connection.disconnect ();
169 point_one_second_connection.disconnect ();
170 point_zero_one_second_connection.disconnect();
172 /* desensitize menu bar options that are now invalid */
174 // save_as_item->set_sensitive (false);
175 save_template_item->set_sensitive (false);
176 snapshot_item->set_sensitive (false);
177 save_item->set_sensitive (false);
178 add_track_item->set_sensitive (false);
179 export_item->set_sensitive (false);
180 close_item->set_sensitive (false);
181 // meter_bridge_dialog_check->set_sensitive (false);
182 connection_editor_check->set_sensitive (false);
183 locations_dialog_check->set_sensitive (false);
184 // meter_bridge_dialog_check->set_active(false);
185 connection_editor_check->set_active(false);
186 locations_dialog_check->set_active(false);
187 route_params_check->set_sensitive (false);
189 /* desensitize transport bar */
191 goto_start_button.set_sensitive (false);
192 goto_end_button.set_sensitive (false);
193 roll_button.set_sensitive (false);
194 stop_button.set_sensitive (false);
195 play_selection_button.set_sensitive (false);
196 rec_button.set_sensitive (false);
197 auto_loop_button.set_sensitive (false);
198 shuttle_box.set_sensitive (false);
203 /* drop everything attached to the blink signal */
207 primary_clock.set_session (0);
208 secondary_clock.set_session (0);
209 big_clock.set_session (0);
210 preroll_clock.set_session (0);
211 postroll_clock.set_session (0);
214 option_editor->set_session (0);
224 update_buffer_load ();
225 // update_disk_rate ();
231 ARDOUR_UI::create_meter_bridge ()
233 if (meter_bridge == 0) {
234 meter_bridge = new MeterBridge ();
235 meter_bridge->Hiding.connect (slot (*this, &ARDOUR_UI::meter_bridge_hiding));
241 ARDOUR_UI::meter_bridge_hiding()
243 // meter_bridge_dialog_check->set_active(false);
247 ARDOUR_UI::create_connection_editor ()
249 if (connection_editor == 0) {
250 connection_editor = new ConnectionEditor ();
251 connection_editor->Hiding.connect (slot (*this, &ARDOUR_UI::connection_editor_hiding));
255 connection_editor->set_session (session);
262 ARDOUR_UI::toggle_connection_editor ()
264 if (create_connection_editor()) {
268 if (connection_editor->within_hiding()) {
273 if (connection_editor_check->get_active()){
274 connection_editor->show_all();
276 connection_editor->hide_all();
281 ARDOUR_UI::connection_editor_hiding()
283 connection_editor_check->set_active(false);
287 ARDOUR_UI::big_clock_hiding()
289 big_clock_check->set_active(false);
293 ARDOUR_UI::toggle_big_clock_window ()
295 if (big_clock_window->within_hiding()) {
299 if (big_clock_window->is_visible()) {
300 big_clock_window->hide_all ();
302 big_clock_window->show_all ();
307 ARDOUR_UI::toggle_options_window ()
309 if (option_editor == 0) {
310 option_editor = new OptionEditor (*this, *editor, *mixer);
311 option_editor->Hiding.connect(slot(*this, &ARDOUR_UI::option_hiding));
312 option_editor->set_session (session);
313 } else if (option_editor->within_hiding()) {
317 if (option_editor->is_visible()) {
318 option_editor->hide_all ();
320 option_editor->show_all ();
325 ARDOUR_UI::option_hiding ()
327 options_window_check->set_active(false);
331 ARDOUR_UI::toggle_auto_input ()
334 toggle_some_session_state (auto_input_button,
335 &Session::get_auto_input,
336 &Session::set_auto_input);
338 meter_bridge->clear_all_meters ();
342 ARDOUR_UI::toggle_metering ()
345 if (global_meter_button.get_active()) {
346 meter_bridge->toggle_metering ();
352 ARDOUR_UI::create_location_ui ()
354 if (location_ui == 0) {
355 location_ui = new LocationUI ();
356 location_ui->set_session (session);
357 location_ui->Hiding.connect (slot (*this, &ARDOUR_UI::location_ui_hiding));
363 ARDOUR_UI::toggle_location_window ()
365 if (create_location_ui()) {
369 if (location_ui->within_hiding()) {
373 if (location_ui->is_visible()) {
374 location_ui->hide_all();
376 location_ui->show_all();
381 ARDOUR_UI::location_ui_hiding()
383 locations_dialog_check->set_active(false);
387 ARDOUR_UI::create_route_params ()
389 if (route_params == 0) {
390 route_params = new RouteParams_UI (*engine);
391 route_params->set_session (session);
392 route_params->Hiding.connect (slot (*this, &ARDOUR_UI::route_params_hiding));
398 ARDOUR_UI::toggle_route_params_window ()
400 if (create_route_params ()) {
404 if (route_params->within_hiding()) {
408 if (route_params->is_visible ()) {
409 route_params->hide_all ();
411 route_params->show_all ();
416 ARDOUR_UI::route_params_hiding ()
418 route_params_check->set_active (false);
422 ARDOUR_UI::get_sfdb_window ()
424 if (sfdb_window == 0) {
425 sfdb_window = new SoundFileSelector ();
426 sfdb_window->Hiding.connect (slot (*this, &ARDOUR_UI::sfdb_hiding));
427 sfdb_window->hide_all ();
434 ARDOUR_UI::toggle_sfdb_window ()
438 if (sfdb_window->within_hiding()) {
442 if (sfdb_window->is_visible ()) {
443 sfdb_window->hide_all ();
445 sfdb_window->show_all ();
446 sfdb_window->hide_import_stuff();
451 ARDOUR_UI::sfdb_hiding ()
453 sfdb_check->set_active (false);