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 <libgnomecanvasmm/canvas.h>
40 #include <pbd/xml++.h>
41 #include <gtkmm/box.h>
42 #include <gtkmm/frame.h>
43 #include <gtkmm/label.h>
44 #include <gtkmm/table.h>
45 #include <gtkmm/fixed.h>
46 #include <gtkmm/drawingarea.h>
47 #include <gtkmm/eventbox.h>
48 #include <gtkmm/menu.h>
49 #include <gtkmm/menuitem.h>
50 #include <gtkmm/button.h>
51 #include <gtkmm/togglebutton.h>
52 #include <gtkmm/treeview.h>
53 #include <gtkmm/menubar.h>
54 #include <gtkmm/adjustment.h>
55 #include <gtkmm2ext/gtk_ui.h>
56 #include <gtkmm2ext/pix.h>
57 #include <gtkmm2ext/click_box.h>
58 #include <ardour/ardour.h>
59 #include <ardour/session.h>
61 #include "audio_clock.h"
62 #include "ardour_dialog.h"
71 class ConnectionEditor;
73 class SoundFileChooser;
76 class NewSessionDialog;
91 class MultiChannelDevice;
94 #define FRAME_NAME "BaseFrame"
96 class ARDOUR_UI : public Gtkmm2ext::UI
99 ARDOUR_UI (int *argcp, char **argvp[], string rcfile);
103 bool shown() { return shown_flag; }
108 int load_session (string path, string snapshot, string* mix_template = 0);
110 int build_session (string path, string snapshot,
112 uint32_t master_chns,
113 ARDOUR::Session::AutoConnectOption input_connect,
114 ARDOUR::Session::AutoConnectOption output_connect,
117 jack_nframes_t initial_length);
118 bool session_is_new() const { return _session_is_new; }
120 ARDOUR::Session* the_session() { return session; }
122 bool will_create_new_session_automatically() const {
123 return _will_create_new_session_automatically;
126 void set_will_create_new_session_automatically (bool yn) {
127 _will_create_new_session_automatically = yn;
130 void new_session (bool startup = false, std::string path = string());
131 gint cmdline_new_session (std::string path);
132 int unload_session ();
133 void close_session() { unload_session(); }
135 int save_state_canfail (string state_name = "");
136 void save_state (string state_name = "");
137 void restore_state (string state_name = "");
139 static double gain_to_slider_position (ARDOUR::gain_t g);
140 static ARDOUR::gain_t slider_position_to_gain (double pos);
142 static ARDOUR_UI *instance () { return theArdourUI; }
144 PublicEditor& the_editor(){return *editor;}
145 Mixer_UI* the_mixer() { return mixer; }
147 void allow_focus (bool yn);
149 static gint generic_focus_in_event (GdkEventFocus *);
150 static gint generic_focus_out_event (GdkEventFocus *);
152 void toggle_location_window ();
153 void toggle_big_clock_window ();
154 void toggle_connection_editor ();
155 void toggle_route_params_window ();
156 void toggle_tempo_window ();
158 gint32 select_diskstream (GdkEventButton *ev);
160 Gtk::Tooltips& tooltips() { return _tooltips; }
162 static sigc::signal<void,bool> Blink;
163 static sigc::signal<void> RapidScreenUpdate;
164 static sigc::signal<void> SuperRapidScreenUpdate;
165 static sigc::signal<void,jack_nframes_t> Clock;
167 /* this is a helper function to centralize the (complex) logic for
168 blinking rec-enable buttons.
171 void rec_enable_button_blink (bool onoff, ARDOUR::DiskStream *, Gtk::Widget *w);
173 void name_io_setup (ARDOUR::AudioEngine&, string&, ARDOUR::IO& io, bool in);
174 void choose_io (ARDOUR::IO&, bool input);
176 static gint hide_and_quit (GdkEventAny *ev, ArdourDialog *);
178 XMLNode* editor_settings() const;
179 XMLNode* mixer_settings () const;
180 XMLNode* keyboard_settings () const;
182 void save_ardour_state ();
183 gboolean configure_handler (GdkEventConfigure* conf);
185 void do_transport_locate (jack_nframes_t position);
186 void halt_on_xrun_message ();
188 AudioClock primary_clock;
189 AudioClock secondary_clock;
190 AudioClock preroll_clock;
191 AudioClock postroll_clock;
195 void session_add_audio_track (int input_channels, int32_t output_channels) {
196 session_add_audio_route (true, input_channels, output_channels);
199 void session_add_audio_bus (int input_channels, int32_t output_channels) {
200 session_add_audio_route (false, input_channels, output_channels);
203 void session_add_midi_track ();
205 void set_engine (ARDOUR::AudioEngine&);
207 gint exit_on_main_window_close (GdkEventAny *);
210 friend class PublicEditor;
212 void toggle_metering ();
213 void toggle_clocking ();
214 void toggle_auto_play ();
215 void toggle_auto_input ();
216 void toggle_punch_in ();
217 void toggle_punch_out ();
218 void toggle_auto_return ();
219 void toggle_click ();
220 void toggle_follow ();
222 void toggle_session_auto_loop ();
223 void toggle_session_punch_in ();
225 void toggle_options_window ();
228 struct GlobalClickBox : public Gtk::VBox {
229 Gtkmm2ext::ClickBox *box;
232 vector<string> &strings;
233 Gtk::Adjustment adjustment;
235 static void printer (char buf[32], Gtk::Adjustment &adj, void *arg);
237 GlobalClickBox (const string &str, vector<string> &vs)
239 adjustment (0, 0, vs.size() - 1, 1, 1, 0) {
240 box = new Gtkmm2ext::ClickBox (&adjustment, "ClickButton");
241 label.set_text (str);
242 label.set_name ("GlobalButtonLabel");
244 frame.set_shadow_type (Gtk::SHADOW_IN);
247 box->set_print_func (printer, this);
248 box->set_wrap (true);
252 ARDOUR::AudioEngine *engine;
253 ARDOUR::Session *session;
255 Gtk::Tooltips _tooltips;
257 void goto_editor_window ();
258 void goto_mixer_window ();
260 Gtk::Table adjuster_table;
261 Gtk::Frame adjuster_frame;
262 Gtk::Fixed adjuster_base;
264 GlobalClickBox *online_control_button;
265 vector<string> online_control_strings;
267 GlobalClickBox *crossfade_time_button;
268 vector<string> crossfade_time_strings;
270 GlobalClickBox *mmc_id_button;
271 vector<string> mmc_id_strings;
273 Gtk::ToggleButton preroll_button;
274 Gtk::ToggleButton postroll_button;
276 Gtk::Table transport_table;
277 Gtk::Table option_table;
279 int setup_windows ();
280 void setup_session_menu ();
281 void setup_transport ();
283 void setup_session_info ();
284 void setup_adjustables ();
286 Gtk::MenuBar* make_menubar ();
288 static ARDOUR_UI *theArdourUI;
294 int ask_about_saving_session (string why);
295 gint ask_about_save_deleted (GdkEventAny*);
296 void save_session_choice_made (int);
297 int save_the_session;
299 void queue_transport_change ();
300 void map_transport_state ();
301 int32_t do_engine_start ();
302 gint start_engine ();
304 void engine_halted ();
305 void engine_stopped ();
306 void engine_running ();
308 void map_some_session_state (Gtk::ToggleButton& button,
309 bool (ARDOUR::Session::*get)() const);
311 void toggle_some_session_state (Gtk::ToggleButton& button,
312 bool (ARDOUR::Session::*get)() const,
313 void (ARDOUR::Session::*set)(bool));
314 void map_button_state ();
316 void clear_meters ();
318 static gint _blink (void *);
320 gint blink_timeout_tag;
322 void start_blinking ();
323 void stop_blinking ();
325 void control_methods_adjusted ();
326 void mmc_device_id_adjusted ();
329 Gtk::VBox top_packer;
331 sigc::connection clock_signal_connection;
332 void update_clocks ();
333 void start_clocking ();
334 void stop_clocking ();
336 AudioClock big_clock;
337 Gtk::Frame big_clock_frame;
338 ArdourDialog* big_clock_window;
340 /* Transport Control */
342 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
343 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
345 Gtkmm2ext::TearOff* transport_tearoff;
346 Gtk::Frame transport_frame;
347 Gtk::HBox transport_tearoff_hbox;
348 Gtk::HBox transport_hbox;
349 Gtk::Fixed transport_base;
350 Gtk::Fixed transport_button_base;
351 Gtk::Frame transport_button_frame;
352 Gtk::HBox transport_button_hbox;
353 Gtk::VBox transport_button_vbox;
354 Gtk::HBox transport_option_button_hbox;
355 Gtk::VBox transport_option_button_vbox;
356 Gtk::HBox transport_clock_hbox;
357 Gtk::VBox transport_clock_vbox;
358 Gtk::HBox primary_clock_hbox;
359 Gtk::HBox secondary_clock_hbox;
361 Gtk::Button goto_start_button;
362 Gtk::Button goto_end_button;
363 Gtk::Button rewind_button;
364 Gtk::Button forward_button;
365 Gtk::Button stop_button;
367 enum ShuttleBehaviour {
377 Gtk::DrawingArea shuttle_box;
378 Gtk::EventBox speed_display_box;
379 Gtk::Label speed_display_label;
380 Gtk::Button shuttle_units_button;
381 Gtk::Button shuttle_style_button;
382 Gtk::Menu* shuttle_unit_menu;
383 Gtk::Menu* shuttle_style_menu;
384 ShuttleBehaviour shuttle_behaviour;
385 ShuttleUnits shuttle_units;
387 void shuttle_style_clicked ();
388 void shuttle_unit_clicked ();
389 void set_shuttle_behaviour (ShuttleBehaviour);
390 void set_shuttle_units (ShuttleUnits);
391 void update_speed_display ();
393 gint shuttle_box_button_press (GdkEventButton*);
394 gint shuttle_box_button_release (GdkEventButton*);
395 gint shuttle_box_motion (GdkEventMotion*);
396 gint shuttle_box_expose (GdkEventExpose*);
397 gint mouse_shuttle (double x, bool force);
398 void use_shuttle_fract (bool force);
400 bool shuttle_grabbed;
401 double shuttle_fract;
403 Gtk::ToggleButton auto_loop_button;
404 Gtk::ToggleButton play_selection_button;
405 Gtk::ToggleButton roll_button;
407 Gtk::ToggleButton rec_button;
408 Gtk::ToggleButton punch_in_button;
409 Gtk::ToggleButton punch_out_button;
410 Gtk::ToggleButton auto_return_button;
411 Gtk::ToggleButton auto_play_button;
412 Gtk::ToggleButton auto_input_button;
413 Gtk::ToggleButton click_button;
414 Gtk::ToggleButton follow_button;
415 Gtk::ToggleButton auditioning_alert_button;
416 Gtk::ToggleButton solo_alert_button;
420 void follow_changed ();
422 void solo_blink (bool);
423 void audition_blink (bool);
425 void soloing_changed (bool);
426 void auditioning_changed (bool);
427 void _auditioning_changed (bool);
429 void solo_alert_toggle ();
430 void audition_alert_toggle ();
432 void primary_clock_value_changed ();
433 void secondary_clock_value_changed ();
435 /* called by Blink signal */
437 void transport_rec_enable_blink (bool onoff);
439 /* These change where we accept control from:
440 MMC, X (local) or both.
443 void allow_mmc_only ();
444 void allow_mmc_and_local ();
445 void allow_local_only ();
447 static void rate_printer (char buf[32], Gtk::Adjustment &, void *);
449 Gtk::Menu* session_popup_menu;
451 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
452 RecentSessionModelColumns() {
456 Gtk::TreeModelColumn<Glib::ustring> visible_name;
457 Gtk::TreeModelColumn<Glib::ustring> fullpath;
460 RecentSessionModelColumns recent_session_columns;
461 Gtk::TreeView recent_session_display;
462 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
464 ArdourDialog* session_selector_window;
465 Gtk::FileChooserDialog* open_session_selector;
467 void build_session_selector();
468 void recent_session_selection_changed ();
469 void redisplay_recent_sessions();
471 struct RecentSessionsSorter {
472 bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
473 return cmp_nocase(a.first, b.first) == -1;
477 /* menu bar and associated stuff */
479 Gtk::MenuBar* menu_bar;
480 Gtk::Fixed menu_bar_base;
483 void build_menu_bar ();
484 void pack_toplevel_controls();
486 /* handles on the menu bar items that need to
487 be sensitive to whether or not we have
491 Gtk::MenuItem *add_track_item;
492 Gtk::MenuItem *save_item;
493 Gtk::MenuItem *snapshot_item;
494 Gtk::MenuItem *save_as_item;
495 Gtk::MenuItem *save_template_item;
496 Gtk::MenuItem *export_item;
497 Gtk::MenuItem *close_item;
499 Gtk::CheckMenuItem *meter_bridge_dialog_check;
500 Gtk::CheckMenuItem *connection_editor_check;
501 Gtk::CheckMenuItem *route_params_check;
502 Gtk::CheckMenuItem *locations_dialog_check;
503 Gtk::CheckMenuItem *big_clock_check;
504 Gtk::CheckMenuItem *tempo_editor_check;
505 // Gtk::CheckMenuItem *sfdb_check;
506 Gtk::CheckMenuItem *options_window_check;
508 /* <CMT Additions> */
509 Gtk::MenuItem *image_compositor_item ;
510 /* </CMT Additions> */
513 Gtk::Label wall_clock_label;
514 Gtk::EventBox wall_clock_box;
515 gint update_wall_clock ();
517 Gtk::Label disk_space_label;
518 Gtk::EventBox disk_space_box;
519 void update_disk_space ();
521 Gtk::Label cpu_load_label;
522 Gtk::EventBox cpu_load_box;
523 void update_cpu_load ();
525 Gtk::Label disk_rate_label;
526 Gtk::EventBox disk_rate_box;
527 void update_disk_rate();
529 Gtk::Label buffer_load_label;
530 Gtk::EventBox buffer_load_box;
531 void update_buffer_load ();
533 Gtk::Label sample_rate_label;
534 Gtk::EventBox sample_rate_box;
535 void update_sample_rate (jack_nframes_t);
537 gint every_second ();
538 gint every_point_one_seconds ();
539 gint every_point_zero_one_seconds ();
541 sigc::connection second_connection;
542 sigc::connection point_one_second_connection;
543 sigc::connection point_zero_one_second_connection;
545 void diskstream_added (ARDOUR::DiskStream*);
547 gint session_menu (GdkEventButton *);
549 bool _will_create_new_session_automatically;
551 NewSessionDialog* new_session_window;
552 string template_name;
554 void new_session_ok_clicked ();
555 void new_session_template_choice (Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection>);
556 void hide_dialog (ArdourDialog *dialog);
558 void fs_cancel_clicked (Gtk::FileSelection*);
559 gint fs_delete_event (GdkEventAny*, Gtk::FileSelection*);
561 void open_session ();
562 void open_recent_session ();
563 void open_ok_clicked ();
565 void save_template ();
568 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels);
570 void add_diskstream_to_menu (ARDOUR::DiskStream&);
571 void diskstream_selected (gint32);
572 Gtk::Menu *diskstream_menu;
573 gint32 selected_dstream;
575 gint mouse_transport_goto_start (GdkEventButton *) {
576 transport_goto_start (); return TRUE;
578 gint mouse_transport_goto_end (GdkEventButton *) {
579 transport_goto_end (); return TRUE;
581 gint mouse_transport_record (GdkEventButton *) {
582 transport_record (); return TRUE;
584 gint mouse_transport_forward (GdkEventButton *) {
585 transport_forward (0); return TRUE;
587 gint mouse_transport_rewind (GdkEventButton *) {
588 transport_rewind (0); return TRUE;
590 gint mouse_transport_loop (GdkEventButton *) {
591 transport_loop (); return TRUE;
593 gint mouse_transport_play_selection (GdkEventButton *) {
594 transport_play_selection (); return TRUE;
597 gint mouse_transport_roll (GdkEventButton *);
598 gint mouse_transport_stop (GdkEventButton *);
600 void set_transport_sensitivity (bool);
602 void remove_last_capture ();
604 void transport_goto_start ();
605 void transport_goto_end ();
606 void transport_stop ();
607 void transport_stop_and_forget_capture ();
608 void transport_record ();
609 void transport_roll ();
610 void transport_play_selection();
611 void transport_forward (int option);
612 void transport_rewind (int option);
613 void transport_loop ();
615 void transport_locating ();
616 void transport_rolling ();
617 void transport_rewinding ();
618 void transport_forwarding ();
619 void transport_stopped ();
621 void send_all_midi_feedback ();
623 bool _session_is_new;
624 void connect_to_session (ARDOUR::Session *);
625 void connect_dependents_to_session (ARDOUR::Session *);
626 void we_have_dependents ();
627 void setup_keybindings ();
629 guint32 last_key_press_time;
631 void snapshot_session ();
633 void map_control_change (ARDOUR::Session::ControlType);
634 void queue_map_control_change (ARDOUR::Session::ControlType);
635 void map_record_state ();
636 void queue_map_record_state ();
641 PublicEditor *editor;
642 int create_editor ();
644 MeterBridge *meter_bridge;
645 int create_meter_bridge ();
647 RouteParams_UI *route_params;
648 int create_route_params ();
650 ConnectionEditor *connection_editor;
651 int create_connection_editor ();
653 LocationUI *location_ui;
654 int create_location_ui ();
656 void meter_bridge_hiding ();
657 void location_ui_hiding ();
658 void big_clock_hiding ();
659 void route_params_hiding ();
660 void connection_editor_hiding ();
661 void option_hiding ();
663 /* Various options */
665 void toggle_recording_plugins ();
669 OptionEditor *option_editor;
673 AddRouteDialog *add_route_dialog;
674 void add_route_dialog_done (int status);
676 /* Keyboard Handling */
680 /* Keymap handling */
682 void install_keybindings ();
683 void install_actions ();
684 void test_binding_action (const char *);
685 void start_keyboard_prefix();
687 void toggle_record_enable (guint32);
688 void toggle_monitor_enable (guint32);
690 uint32_t rec_enabled_diskstreams;
691 void count_recenabled_diskstreams (ARDOUR::DiskStream&);
697 Gtk::MenuItem *cleanup_item;
699 void display_cleanup_results (ARDOUR::Session::cleanup_report& rep, const gchar* list_title, string msg);
703 bool have_configure_timeout;
704 struct timeval last_configure_time;
705 gint configure_timeout ();
707 struct timeval last_peak_grab;
708 struct timeval last_shuttle_request;
710 void cannot_record_no_input (ARDOUR::DiskStream*);
712 void delete_sources_in_the_right_thread (list<ARDOUR::Source*>*);
714 void editor_display_control_changed (Editing::DisplayControl c);
716 bool have_disk_overrun_displayed;
717 bool have_disk_underrun_displayed;
719 void disk_overrun_message_gone ();
720 void disk_underrun_message_gone ();
721 void disk_overrun_handler ();
722 void disk_underrun_handler ();
724 int pending_state_dialog ();
726 void disconnect_from_jack ();
727 void reconnect_to_jack ();
728 void set_jack_buffer_size (jack_nframes_t);
730 Gtk::MenuItem* jack_disconnect_item;
731 Gtk::MenuItem* jack_reconnect_item;
732 Gtk::Menu* jack_bufsize_menu;
734 int make_session_clean ();
735 bool filter_ardour_session_dirs (const Gtk::FileFilter::Info&);
737 Glib::RefPtr<Gtk::UIManager> ui_manager;
740 #endif /* __ardour_gui_h__ */