2 Copyright (C) 1999-2002 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.
21 #ifndef __ardour_gui_h__
22 #define __ardour_gui_h__
24 /* need _BSD_SOURCE to get timersub macros */
38 #include <gtk-canvas.h>
40 #include <pbd/xml++.h>
41 #include <gtkmm2ext/gtk_ui.h>
42 #include <gtkmm2ext/pix.h>
43 #include <gtkmm2ext/spinner.h>
44 #include <gtkmm2ext/pixmap_button.h>
45 #include <gtkmm2ext/popup_selector.h>
46 #include <gtkmm2ext/click_box.h>
47 #include <gtkmm2ext/selector.h>
48 #include <ardour/ardour.h>
49 #include <ardour/session.h>
51 #include "audio_clock.h"
52 #include "ardour_dialog.h"
61 class ConnectionEditor;
63 class SoundFileSelector;
66 class NewSessionDialog;
81 class MultiChannelDevice;
84 #define FRAME_NAME "BaseFrame"
86 class ARDOUR_UI : public Gtkmm2ext::UI
89 ARDOUR_UI (int *argcp, char **argvp[], string rcfile);
93 bool shown() { return shown_flag; }
98 int load_session (string path, string snapshot, string* mix_template = 0);
100 int build_session (string path, string snapshot,
102 uint32_t master_chns,
103 ARDOUR::Session::AutoConnectOption input_connect,
104 ARDOUR::Session::AutoConnectOption output_connect,
107 jack_nframes_t initial_length);
108 bool session_is_new() const { return _session_is_new; }
110 ARDOUR::Session* the_session() { return session; }
112 bool will_create_new_session_automatically() const {
113 return _will_create_new_session_automatically;
116 void set_will_create_new_session_automatically (bool yn) {
117 _will_create_new_session_automatically = yn;
120 void new_session (bool startup = false, std::string path = string());
121 gint cmdline_new_session (std::string path);
122 int unload_session ();
123 void close_session() { unload_session(); }
125 int save_state_canfail (string state_name = "");
126 void save_state (string state_name = "");
127 void restore_state (string state_name = "");
129 static double gain_to_slider_position (ARDOUR::gain_t g);
130 static ARDOUR::gain_t slider_position_to_gain (double pos);
132 static ARDOUR_UI *instance () { return theArdourUI; }
134 PublicEditor& the_editor(){return *editor;}
135 Mixer_UI* the_mixer() { return mixer; }
137 void allow_focus (bool yn);
139 static gint generic_focus_in_event (GdkEventFocus *);
140 static gint generic_focus_out_event (GdkEventFocus *);
142 void toggle_location_window ();
143 void toggle_big_clock_window ();
144 void toggle_connection_editor ();
145 void toggle_route_params_window ();
146 void toggle_tempo_window ();
147 void toggle_sfdb_window ();
149 SoundFileSelector& get_sfdb_window();
151 gint32 select_diskstream (GdkEventButton *ev);
153 Gtk::Tooltips& tooltips() { return _tooltips; }
155 static sigc::signal<void,bool> Blink;
156 static sigc::signal<void> RapidScreenUpdate;
157 static sigc::signal<void> SuperRapidScreenUpdate;
158 static sigc::signal<void,jack_nframes_t> Clock;
160 /* this is a helper function to centralize the (complex) logic for
161 blinking rec-enable buttons.
164 void rec_enable_button_blink (bool onoff, ARDOUR::DiskStream *, Gtk::Widget *w);
166 void name_io_setup (ARDOUR::AudioEngine&, string&, ARDOUR::IO& io, bool in);
167 void choose_io (ARDOUR::IO&, bool input);
169 static gint hide_and_quit (GdkEventAny *ev, ArdourDialog *);
171 XMLNode* editor_settings() const;
172 XMLNode* mixer_settings () const;
173 XMLNode* keyboard_settings () const;
175 void save_ardour_state ();
176 gboolean configure_handler (GdkEventConfigure* conf);
178 void do_transport_locate (jack_nframes_t position);
179 void halt_on_xrun_message ();
181 AudioClock primary_clock;
182 AudioClock secondary_clock;
183 AudioClock preroll_clock;
184 AudioClock postroll_clock;
188 void session_add_audio_track (int input_channels, int32_t output_channels) {
189 session_add_audio_route (true, input_channels, output_channels);
192 void session_add_audio_bus (int input_channels, int32_t output_channels) {
193 session_add_audio_route (false, input_channels, output_channels);
196 void session_add_midi_track ();
198 void set_engine (ARDOUR::AudioEngine&);
200 gint exit_on_main_window_close (GdkEventAny *);
203 friend class PublicEditor;
205 void toggle_metering ();
206 void toggle_clocking ();
207 void toggle_auto_play ();
208 void toggle_auto_input ();
209 void toggle_punch_in ();
210 void toggle_punch_out ();
211 void toggle_auto_return ();
212 void toggle_click ();
213 void toggle_follow ();
215 void toggle_session_auto_loop ();
216 void toggle_session_punch_in ();
218 void toggle_options_window ();
221 struct GlobalClickBox : public Gtk::VBox {
222 Gtkmm2ext::ClickBox *box;
225 vector<string> &strings;
226 Gtk::Adjustment adjustment;
228 static void printer (char buf[32], Gtk::Adjustment &adj, void *arg);
230 GlobalClickBox (const string &str, vector<string> &vs)
232 adjustment (0, 0, vs.size() - 1, 1, 1, 0) {
233 box = new Gtkmm2ext::ClickBox (&adjustment, "ClickButton");
234 label.set_text (str);
235 label.set_name ("GlobalButtonLabel");
237 frame.set_shadow_type (Gtk::SHADOW_IN);
240 box->set_print_func (printer, this);
241 box->set_wrap (true);
245 ARDOUR::AudioEngine *engine;
246 ARDOUR::Session *session;
248 Gtk::Tooltips _tooltips;
250 void goto_editor_window ();
251 void goto_mixer_window ();
253 Gtk::Table adjuster_table;
254 Gtk::Frame adjuster_frame;
255 Gtk::Fixed adjuster_base;
257 GlobalClickBox *online_control_button;
258 vector<string> online_control_strings;
260 GlobalClickBox *crossfade_time_button;
261 vector<string> crossfade_time_strings;
263 GlobalClickBox *mmc_id_button;
264 vector<string> mmc_id_strings;
266 Gtk::ToggleButton preroll_button;
267 Gtk::ToggleButton postroll_button;
269 Gtk::Table transport_table;
270 Gtk::Table option_table;
272 static SoundFileSelector* sfdb_window;
274 int setup_windows ();
275 void setup_session_menu ();
276 void setup_transport ();
278 void setup_session_info ();
279 void setup_adjustables ();
281 Gtk::MenuBar* make_menubar ();
283 static ARDOUR_UI *theArdourUI;
289 int ask_about_saving_session (string why);
290 gint ask_about_save_deleted (GdkEventAny*);
291 void save_session_choice_made (int);
292 int save_the_session;
294 void queue_transport_change ();
295 void map_transport_state ();
296 int32_t do_engine_start ();
297 gint start_engine ();
299 void engine_halted ();
300 void engine_stopped ();
301 void engine_running ();
303 void map_some_session_state (Gtk::ToggleButton& button,
304 bool (ARDOUR::Session::*get)() const);
306 void toggle_some_session_state (Gtk::ToggleButton& button,
307 bool (ARDOUR::Session::*get)() const,
308 void (ARDOUR::Session::*set)(bool));
309 void map_button_state ();
311 void clear_meters ();
313 static gint _blink (void *);
315 gint blink_timeout_tag;
317 void start_blinking ();
318 void stop_blinking ();
320 void control_methods_adjusted ();
321 void mmc_device_id_adjusted ();
324 Gtk::VBox top_packer;
326 sigc::connection clock_signal_connection;
327 void update_clocks ();
328 void start_clocking ();
329 void stop_clocking ();
331 class BigClockWindow : public ArdourDialog
334 BigClockWindow () : ArdourDialog ("big clock window") {};
337 AudioClock big_clock;
338 Gtk::Frame big_clock_frame;
339 BigClockWindow* big_clock_window;
341 void big_clock_size_event (GtkAllocation *alloc);
342 void big_clock_realize ();
344 /* Transport Control */
346 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
347 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
349 Gtkmm2ext::TearOff* transport_tearoff;
350 Gtk::Frame transport_frame;
351 Gtk::HBox transport_tearoff_hbox;
352 Gtk::HBox transport_hbox;
353 Gtk::Fixed transport_base;
354 Gtk::Fixed transport_button_base;
355 Gtk::Frame transport_button_frame;
356 Gtk::HBox transport_button_hbox;
357 Gtk::VBox transport_button_vbox;
358 Gtk::HBox transport_option_button_hbox;
359 Gtk::VBox transport_option_button_vbox;
360 Gtk::HBox transport_clock_hbox;
361 Gtk::VBox transport_clock_vbox;
362 Gtk::HBox primary_clock_hbox;
363 Gtk::HBox secondary_clock_hbox;
365 Gtk::Button goto_start_button;
366 Gtk::Button goto_end_button;
367 Gtk::Button rewind_button;
368 Gtk::Button forward_button;
369 Gtk::Button stop_button;
371 enum ShuttleBehaviour {
381 Gtk::DrawingArea shuttle_box;
382 Gtk::EventBox speed_display_box;
383 Gtk::Label speed_display_label;
384 Gtk::Button shuttle_units_button;
385 Gtk::Button shuttle_style_button;
386 Gtk::Menu shuttle_unit_menu;
387 Gtk::Menu shuttle_style_menu;
388 ShuttleBehaviour shuttle_behaviour;
389 ShuttleUnits shuttle_units;
391 void shuttle_style_clicked ();
392 void shuttle_unit_clicked ();
393 void set_shuttle_behaviour (ShuttleBehaviour);
394 void set_shuttle_units (ShuttleUnits);
395 void update_speed_display ();
397 gint shuttle_box_button_press (GdkEventButton*);
398 gint shuttle_box_button_release (GdkEventButton*);
399 gint shuttle_box_motion (GdkEventMotion*);
400 gint shuttle_box_expose (GdkEventExpose*);
401 gint mouse_shuttle (double x, bool force);
402 void use_shuttle_fract (bool force);
404 bool shuttle_grabbed;
405 double shuttle_fract;
407 Gtk::ToggleButton auto_loop_button;
408 Gtk::ToggleButton play_selection_button;
409 Gtk::ToggleButton roll_button;
411 Gtk::ToggleButton rec_button;
412 Gtk::ToggleButton punch_in_button;
413 Gtk::ToggleButton punch_out_button;
414 Gtk::ToggleButton auto_return_button;
415 Gtk::ToggleButton auto_play_button;
416 Gtk::ToggleButton auto_input_button;
417 Gtk::ToggleButton click_button;
418 Gtk::ToggleButton follow_button;
419 Gtk::ToggleButton auditioning_alert_button;
420 Gtk::ToggleButton solo_alert_button;
424 void follow_changed ();
426 void solo_blink (bool);
427 void audition_blink (bool);
429 void soloing_changed (bool);
430 void auditioning_changed (bool);
431 void _auditioning_changed (bool);
433 void solo_alert_toggle ();
434 void audition_alert_toggle ();
436 void primary_clock_value_changed ();
437 void secondary_clock_value_changed ();
439 /* called by Blink signal */
441 void transport_rec_enable_blink (bool onoff);
443 /* These change where we accept control from:
444 MMC, X (local) or both.
447 void allow_mmc_only ();
448 void allow_mmc_and_local ();
449 void allow_local_only ();
451 static void rate_printer (char buf[32], Gtk::Adjustment &, void *);
453 Gtk::Menu* session_popup_menu;
454 Gtk::CTree session_selector;
455 ArdourDialog* session_selector_window;
457 Gtk::FileSelection* open_session_selector;
459 void build_session_selector();
460 void session_selection (Gtk::CTree::Row, gint col);
461 struct RecentSessionsSorter {
462 bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
463 return cmp_nocase(a.first, b.first) == -1;
466 void redisplay_recent_sessions();
468 /* menu bar and associated stuff */
470 Gtk::MenuBar menu_bar;
471 Gtk::Fixed menu_bar_base;
474 void build_menu_bar ();
475 void pack_toplevel_controls();
477 /* handles on the menu bar items that need to
478 be sensitive to whether or not we have
482 Gtk::MenuItem *add_track_item;
483 Gtk::MenuItem *save_item;
484 Gtk::MenuItem *snapshot_item;
485 Gtk::MenuItem *save_as_item;
486 Gtk::MenuItem *save_template_item;
487 Gtk::MenuItem *export_item;
488 Gtk::MenuItem *close_item;
490 Gtk::CheckMenuItem *meter_bridge_dialog_check;
491 Gtk::CheckMenuItem *connection_editor_check;
492 Gtk::CheckMenuItem *route_params_check;
493 Gtk::CheckMenuItem *locations_dialog_check;
494 Gtk::CheckMenuItem *big_clock_check;
495 Gtk::CheckMenuItem *tempo_editor_check;
496 Gtk::CheckMenuItem *sfdb_check;
497 Gtk::CheckMenuItem *options_window_check;
499 /* <CMT Additions> */
500 Gtk::MenuItem *image_compositor_item ;
501 /* </CMT Additions> */
504 Gtk::Label wall_clock_label;
505 Gtk::EventBox wall_clock_box;
506 gint update_wall_clock ();
508 Gtk::Label disk_space_label;
509 Gtk::EventBox disk_space_box;
510 void update_disk_space ();
512 Gtk::Label cpu_load_label;
513 Gtk::EventBox cpu_load_box;
514 void update_cpu_load ();
516 Gtk::Label disk_rate_label;
517 Gtk::EventBox disk_rate_box;
518 void update_disk_rate();
520 Gtk::Label buffer_load_label;
521 Gtk::EventBox buffer_load_box;
522 void update_buffer_load ();
524 Gtk::Label sample_rate_label;
525 Gtk::EventBox sample_rate_box;
526 void update_sample_rate (jack_nframes_t);
528 gint every_second ();
529 gint every_point_one_seconds ();
530 gint every_point_zero_one_seconds ();
532 sigc::connection second_connection;
533 sigc::connection point_one_second_connection;
534 sigc::connection point_zero_one_second_connection;
536 void diskstream_added (ARDOUR::DiskStream*);
538 gint session_menu (GdkEventButton *);
540 bool _will_create_new_session_automatically;
542 NewSessionDialog* new_session_window;
543 string template_name;
545 void new_session_ok_clicked ();
546 void new_session_template_choice (Gtkmm2ext::Selector *, Gtkmm2ext::SelectionResult*);
547 void hide_dialog (ArdourDialog *dialog);
549 void fs_cancel_clicked (Gtk::FileSelection*);
550 gint fs_delete_event (GdkEventAny*, Gtk::FileSelection*);
552 void open_session ();
553 void open_recent_session ();
554 void open_ok_clicked ();
556 void save_template ();
559 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels);
561 void add_diskstream_to_menu (ARDOUR::DiskStream&);
562 void diskstream_selected (gint32);
563 Gtk::Menu *diskstream_menu;
564 gint32 selected_dstream;
566 gint mouse_transport_goto_start (GdkEventButton *) {
567 transport_goto_start (); return TRUE;
569 gint mouse_transport_goto_end (GdkEventButton *) {
570 transport_goto_end (); return TRUE;
572 gint mouse_transport_record (GdkEventButton *) {
573 transport_record (); return TRUE;
575 gint mouse_transport_forward (GdkEventButton *) {
576 transport_forward (0); return TRUE;
578 gint mouse_transport_rewind (GdkEventButton *) {
579 transport_rewind (0); return TRUE;
581 gint mouse_transport_loop (GdkEventButton *) {
582 transport_loop (); return TRUE;
584 gint mouse_transport_play_selection (GdkEventButton *) {
585 transport_play_selection (); return TRUE;
588 gint mouse_transport_roll (GdkEventButton *);
589 gint mouse_transport_stop (GdkEventButton *);
591 void set_transport_sensitivity (bool);
593 void remove_last_capture ();
595 void transport_goto_start ();
596 void transport_goto_end ();
597 void transport_stop ();
598 void transport_stop_and_forget_capture ();
599 void transport_record ();
600 void transport_roll ();
601 void transport_play_selection();
602 void transport_forward (int option);
603 void transport_rewind (int option);
604 void transport_loop ();
606 void transport_locating ();
607 void transport_rolling ();
608 void transport_rewinding ();
609 void transport_forwarding ();
610 void transport_stopped ();
612 void send_all_midi_feedback ();
614 bool _session_is_new;
615 void connect_to_session (ARDOUR::Session *);
616 void connect_dependents_to_session (ARDOUR::Session *);
617 void we_have_dependents ();
618 void setup_keybindings ();
620 guint32 last_key_press_time;
622 void snapshot_session ();
624 void map_control_change (ARDOUR::Session::ControlType);
625 void queue_map_control_change (ARDOUR::Session::ControlType);
626 void map_record_state ();
627 void queue_map_record_state ();
632 PublicEditor *editor;
633 int create_editor ();
635 MeterBridge *meter_bridge;
636 int create_meter_bridge ();
638 RouteParams_UI *route_params;
639 int create_route_params ();
641 ConnectionEditor *connection_editor;
642 int create_connection_editor ();
644 LocationUI *location_ui;
645 int create_location_ui ();
647 void meter_bridge_hiding ();
648 void location_ui_hiding ();
649 void big_clock_hiding ();
650 void route_params_hiding ();
651 void connection_editor_hiding ();
653 void option_hiding ();
655 /* Various options */
657 void toggle_recording_plugins ();
661 OptionEditor *option_editor;
665 AddRouteDialog *add_route_dialog;
666 void add_route_dialog_done (int status);
668 /* Keyboard Handling */
672 /* Keymap handling */
674 void install_keybindings ();
675 void test_binding_action (const char *);
676 void start_keyboard_prefix();
678 void toggle_record_enable (guint32);
679 void toggle_monitor_enable (guint32);
681 uint32_t rec_enabled_diskstreams;
682 void count_recenabled_diskstreams (ARDOUR::DiskStream&);
688 Gtk::MenuItem *cleanup_item;
690 void display_cleanup_results (ARDOUR::Session::cleanup_report& rep, const gchar* list_title, string msg);
694 bool have_configure_timeout;
695 struct timeval last_configure_time;
696 gint configure_timeout ();
698 struct timeval last_peak_grab;
699 struct timeval last_shuttle_request;
701 void cannot_record_no_input (ARDOUR::DiskStream*);
703 void delete_sources_in_the_right_thread (list<ARDOUR::Source*>*);
705 void editor_display_control_changed (Editing::DisplayControl c);
707 bool have_disk_overrun_displayed;
708 bool have_disk_underrun_displayed;
710 void disk_overrun_message_gone ();
711 void disk_underrun_message_gone ();
712 void disk_overrun_handler ();
713 void disk_underrun_handler ();
715 int pending_state_dialog ();
717 void disconnect_from_jack ();
718 void reconnect_to_jack ();
719 void set_jack_buffer_size (jack_nframes_t);
721 Gtk::MenuItem* jack_disconnect_item;
722 Gtk::MenuItem* jack_reconnect_item;
723 Gtk::Menu* jack_bufsize_menu;
725 int make_session_clean ();
728 #endif /* __ardour_gui_h__ */