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 <gtkmm2ext/gtk_ui.h>
42 #include <gtkmm2ext/pix.h>
43 #include <gtkmm2ext/click_box.h>
44 #include <ardour/ardour.h>
45 #include <ardour/session.h>
47 #include "audio_clock.h"
48 #include "ardour_dialog.h"
57 class ConnectionEditor;
59 class SoundFileSelector;
62 class NewSessionDialog;
77 class MultiChannelDevice;
80 #define FRAME_NAME "BaseFrame"
82 class ARDOUR_UI : public Gtkmm2ext::UI
85 ARDOUR_UI (int *argcp, char **argvp[], string rcfile);
89 bool shown() { return shown_flag; }
94 int load_session (string path, string snapshot, string* mix_template = 0);
96 int build_session (string path, string snapshot,
99 ARDOUR::Session::AutoConnectOption input_connect,
100 ARDOUR::Session::AutoConnectOption output_connect,
103 jack_nframes_t initial_length);
104 bool session_is_new() const { return _session_is_new; }
106 ARDOUR::Session* the_session() { return session; }
108 bool will_create_new_session_automatically() const {
109 return _will_create_new_session_automatically;
112 void set_will_create_new_session_automatically (bool yn) {
113 _will_create_new_session_automatically = yn;
116 void new_session (bool startup = false, std::string path = string());
117 gint cmdline_new_session (std::string path);
118 int unload_session ();
119 void close_session() { unload_session(); }
121 int save_state_canfail (string state_name = "");
122 void save_state (string state_name = "");
123 void restore_state (string state_name = "");
125 static double gain_to_slider_position (ARDOUR::gain_t g);
126 static ARDOUR::gain_t slider_position_to_gain (double pos);
128 static ARDOUR_UI *instance () { return theArdourUI; }
130 PublicEditor& the_editor(){return *editor;}
131 Mixer_UI* the_mixer() { return mixer; }
133 void allow_focus (bool yn);
135 static gint generic_focus_in_event (GdkEventFocus *);
136 static gint generic_focus_out_event (GdkEventFocus *);
138 void toggle_location_window ();
139 void toggle_big_clock_window ();
140 void toggle_connection_editor ();
141 void toggle_route_params_window ();
142 void toggle_tempo_window ();
143 void toggle_sfdb_window ();
145 SoundFileSelector& get_sfdb_window();
147 gint32 select_diskstream (GdkEventButton *ev);
149 Gtk::Tooltips& tooltips() { return _tooltips; }
151 static sigc::signal<void,bool> Blink;
152 static sigc::signal<void> RapidScreenUpdate;
153 static sigc::signal<void> SuperRapidScreenUpdate;
154 static sigc::signal<void,jack_nframes_t> Clock;
156 /* this is a helper function to centralize the (complex) logic for
157 blinking rec-enable buttons.
160 void rec_enable_button_blink (bool onoff, ARDOUR::DiskStream *, Gtk::Widget *w);
162 void name_io_setup (ARDOUR::AudioEngine&, string&, ARDOUR::IO& io, bool in);
163 void choose_io (ARDOUR::IO&, bool input);
165 static gint hide_and_quit (GdkEventAny *ev, ArdourDialog *);
167 XMLNode* editor_settings() const;
168 XMLNode* mixer_settings () const;
169 XMLNode* keyboard_settings () const;
171 void save_ardour_state ();
172 gboolean configure_handler (GdkEventConfigure* conf);
174 void do_transport_locate (jack_nframes_t position);
175 void halt_on_xrun_message ();
177 AudioClock primary_clock;
178 AudioClock secondary_clock;
179 AudioClock preroll_clock;
180 AudioClock postroll_clock;
184 void session_add_audio_track (int input_channels, int32_t output_channels) {
185 session_add_audio_route (true, input_channels, output_channels);
188 void session_add_audio_bus (int input_channels, int32_t output_channels) {
189 session_add_audio_route (false, input_channels, output_channels);
192 void session_add_midi_track ();
194 void set_engine (ARDOUR::AudioEngine&);
196 gint exit_on_main_window_close (GdkEventAny *);
199 friend class PublicEditor;
201 void toggle_metering ();
202 void toggle_clocking ();
203 void toggle_auto_play ();
204 void toggle_auto_input ();
205 void toggle_punch_in ();
206 void toggle_punch_out ();
207 void toggle_auto_return ();
208 void toggle_click ();
209 void toggle_follow ();
211 void toggle_session_auto_loop ();
212 void toggle_session_punch_in ();
214 void toggle_options_window ();
217 struct GlobalClickBox : public Gtk::VBox {
218 Gtkmm2ext::ClickBox *box;
221 vector<string> &strings;
222 Gtk::Adjustment adjustment;
224 static void printer (char buf[32], Gtk::Adjustment &adj, void *arg);
226 GlobalClickBox (const string &str, vector<string> &vs)
228 adjustment (0, 0, vs.size() - 1, 1, 1, 0) {
229 box = new Gtkmm2ext::ClickBox (&adjustment, "ClickButton");
230 label.set_text (str);
231 label.set_name ("GlobalButtonLabel");
233 frame.set_shadow_type (Gtk::SHADOW_IN);
236 box->set_print_func (printer, this);
237 box->set_wrap (true);
241 ARDOUR::AudioEngine *engine;
242 ARDOUR::Session *session;
244 Gtk::Tooltips _tooltips;
246 void goto_editor_window ();
247 void goto_mixer_window ();
249 Gtk::Table adjuster_table;
250 Gtk::Frame adjuster_frame;
251 Gtk::Fixed adjuster_base;
253 GlobalClickBox *online_control_button;
254 vector<string> online_control_strings;
256 GlobalClickBox *crossfade_time_button;
257 vector<string> crossfade_time_strings;
259 GlobalClickBox *mmc_id_button;
260 vector<string> mmc_id_strings;
262 Gtk::ToggleButton preroll_button;
263 Gtk::ToggleButton postroll_button;
265 Gtk::Table transport_table;
266 Gtk::Table option_table;
268 static SoundFileSelector* sfdb_window;
270 int setup_windows ();
271 void setup_session_menu ();
272 void setup_transport ();
274 void setup_session_info ();
275 void setup_adjustables ();
277 Gtk::MenuBar* make_menubar ();
279 static ARDOUR_UI *theArdourUI;
285 int ask_about_saving_session (string why);
286 gint ask_about_save_deleted (GdkEventAny*);
287 void save_session_choice_made (int);
288 int save_the_session;
290 void queue_transport_change ();
291 void map_transport_state ();
292 int32_t do_engine_start ();
293 gint start_engine ();
295 void engine_halted ();
296 void engine_stopped ();
297 void engine_running ();
299 void map_some_session_state (Gtk::ToggleButton& button,
300 bool (ARDOUR::Session::*get)() const);
302 void toggle_some_session_state (Gtk::ToggleButton& button,
303 bool (ARDOUR::Session::*get)() const,
304 void (ARDOUR::Session::*set)(bool));
305 void map_button_state ();
307 void clear_meters ();
309 static gint _blink (void *);
311 gint blink_timeout_tag;
313 void start_blinking ();
314 void stop_blinking ();
316 void control_methods_adjusted ();
317 void mmc_device_id_adjusted ();
320 Gtk::VBox top_packer;
322 sigc::connection clock_signal_connection;
323 void update_clocks ();
324 void start_clocking ();
325 void stop_clocking ();
327 class BigClockWindow : public ArdourDialog
330 BigClockWindow () : ArdourDialog ("big clock window") {};
333 AudioClock big_clock;
334 Gtk::Frame big_clock_frame;
335 BigClockWindow* big_clock_window;
337 void big_clock_size_event (GtkAllocation *alloc);
338 void big_clock_realize ();
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 ();
662 void option_hiding ();
664 /* Various options */
666 void toggle_recording_plugins ();
670 OptionEditor *option_editor;
674 AddRouteDialog *add_route_dialog;
675 void add_route_dialog_done (int status);
677 /* Keyboard Handling */
681 /* Keymap handling */
683 void install_keybindings ();
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__ */