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.
20 #ifndef __ardour_gui_h__
21 #define __ardour_gui_h__
23 /* need _BSD_SOURCE to get timersub macros */
37 #include <libgnomecanvasmm/canvas.h>
39 #include <pbd/xml++.h>
40 #include <gtkmm/box.h>
41 #include <gtkmm/frame.h>
42 #include <gtkmm/label.h>
43 #include <gtkmm/table.h>
44 #include <gtkmm/fixed.h>
45 #include <gtkmm/drawingarea.h>
46 #include <gtkmm/eventbox.h>
47 #include <gtkmm/menu.h>
48 #include <gtkmm/menuitem.h>
49 #include <gtkmm/button.h>
50 #include <gtkmm/togglebutton.h>
51 #include <gtkmm/treeview.h>
52 #include <gtkmm/menubar.h>
53 #include <gtkmm/textbuffer.h>
54 #include <gtkmm/adjustment.h>
55 #include <gtkmm2ext/gtk_ui.h>
56 #include <gtkmm2ext/click_box.h>
57 #include <gtkmm2ext/stateful_button.h>
58 #include <gtkmm2ext/bindable_button.h>
59 #include <ardour/ardour.h>
60 #include <ardour/session.h>
62 #include "audio_clock.h"
63 #include "ardour_dialog.h"
65 #include "ui_config.h"
73 class ConnectionEditor;
80 class NewSessionDialog;
91 class ControlProtocolInfo;
95 class MultiChannelDevice;
98 #define FRAME_NAME "BaseFrame"
100 extern sigc::signal<void> ColorsChanged;
102 class ARDOUR_UI : public Gtkmm2ext::UI
105 ARDOUR_UI (int *argcp, char **argvp[]);
109 bool shown() { return shown_flag; }
117 int load_session (const Glib::ustring & path, const Glib::ustring& snapshot, Glib::ustring mix_template = Glib::ustring());
119 int build_session (const Glib::ustring& path, const Glib::ustring& snapshot,
121 uint32_t master_chns,
122 ARDOUR::AutoConnectOption input_connect,
123 ARDOUR::AutoConnectOption output_connect,
126 nframes_t initial_length);
127 bool session_is_new() const { return _session_is_new; }
129 ARDOUR::Session* the_session() { return session; }
131 bool will_create_new_session_automatically() const {
132 return _will_create_new_session_automatically;
135 void set_will_create_new_session_automatically (bool yn) {
136 _will_create_new_session_automatically = yn;
139 bool get_session_parameters (bool have_engine = false, bool should_be_new = false);
140 void parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session);
141 int load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session);
142 int build_session_from_nsd (const Glib::ustring& session_name, const Glib::ustring& session_path);
143 bool ask_about_loading_existing_session (const Glib::ustring& session_path);
144 int unload_session (bool hide_stuff = false);
145 void close_session();
147 int save_state_canfail (string state_name = "");
148 void save_state (const string & state_name = "");
149 void restore_state (string state_name = "");
151 static double gain_to_slider_position (ARDOUR::gain_t g);
152 static ARDOUR::gain_t slider_position_to_gain (double pos);
154 static ARDOUR_UI *instance () { return theArdourUI; }
155 static UIConfiguration *config () { return ui_config; }
157 PublicEditor& the_editor(){return *editor;}
158 Mixer_UI* the_mixer() { return mixer; }
160 ARDOUR::AudioEngine& the_engine() const { return *engine; }
162 void toggle_key_editor ();
163 void toggle_location_window ();
164 void toggle_theme_manager ();
165 void toggle_big_clock_window ();
166 void toggle_connection_editor ();
167 void toggle_route_params_window ();
168 void toggle_editing_space();
170 Gtk::Tooltips& tooltips() { return _tooltips; }
172 static sigc::signal<void,bool> Blink;
173 static sigc::signal<void> RapidScreenUpdate;
174 static sigc::signal<void> SuperRapidScreenUpdate;
175 static sigc::signal<void,nframes_t, bool, nframes_t> Clock;
177 /* this is a helper function to centralize the (complex) logic for
178 blinking rec-enable buttons.
181 void rec_enable_button_blink (bool onoff, ARDOUR::AudioDiskstream *, Gtk::Widget *w);
183 void name_io_setup (ARDOUR::AudioEngine&, string&, ARDOUR::IO& io, bool in);
185 static gint hide_and_quit (GdkEventAny *ev, ArdourDialog *);
187 XMLNode* editor_settings() const;
188 XMLNode* mixer_settings () const;
189 XMLNode* keyboard_settings () const;
191 void save_ardour_state ();
192 gboolean configure_handler (GdkEventConfigure* conf);
194 void do_transport_locate (nframes_t position);
195 void halt_on_xrun_message ();
196 void xrun_handler (nframes_t);
197 void create_xrun_marker (nframes_t);
199 AudioClock primary_clock;
200 AudioClock secondary_clock;
201 AudioClock preroll_clock;
202 AudioClock postroll_clock;
204 void store_clock_modes ();
205 void restore_clock_modes ();
207 void add_route (Gtk::Window* float_window);
209 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many) {
210 session_add_audio_route (true, input_channels, output_channels, mode, how_many);
213 void session_add_audio_bus (int input_channels, int32_t output_channels, uint32_t how_many) {
214 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, how_many);
217 void session_add_midi_track ();
219 int create_engine ();
222 gint exit_on_main_window_close (GdkEventAny *);
224 void maximise_editing_space ();
225 void restore_editing_space ();
227 void set_native_file_header_format (ARDOUR::HeaderFormat sf);
228 void set_native_file_data_format (ARDOUR::SampleFormat sf);
230 void setup_profile ();
233 void set_shuttle_fract (double);
236 friend class PublicEditor;
238 void toggle_clocking ();
239 void toggle_auto_play ();
240 void toggle_auto_input ();
241 void toggle_punch_in ();
242 void toggle_punch_out ();
243 void toggle_auto_return ();
244 void toggle_click ();
246 void toggle_session_auto_loop ();
248 void toggle_options_window ();
251 struct GlobalClickBox : public Gtk::VBox {
252 Gtkmm2ext::ClickBox *box;
255 vector<string> &strings;
256 Gtk::Adjustment adjustment;
258 static void printer (char buf[32], Gtk::Adjustment &adj, void *arg);
260 GlobalClickBox (const string &str, vector<string> &vs)
262 adjustment (0, 0, vs.size() - 1, 1, 1, 0) {
263 box = new Gtkmm2ext::ClickBox (&adjustment, "ClickButton");
264 label.set_text (str);
265 label.set_name ("GlobalButtonLabel");
267 frame.set_shadow_type (Gtk::SHADOW_IN);
270 box->set_print_func (printer, this);
271 box->set_wrap (true);
275 ARDOUR::AudioEngine *engine;
276 ARDOUR::Session *session;
278 Gtk::Tooltips _tooltips;
280 void goto_editor_window ();
281 void goto_mixer_window ();
283 Gtk::Table adjuster_table;
284 Gtk::Frame adjuster_frame;
285 Gtk::Fixed adjuster_base;
287 GlobalClickBox *online_control_button;
288 vector<string> online_control_strings;
290 GlobalClickBox *crossfade_time_button;
291 vector<string> crossfade_time_strings;
293 Gtk::ToggleButton preroll_button;
294 Gtk::ToggleButton postroll_button;
296 Gtk::Table transport_table;
297 Gtk::Table option_table;
299 int setup_windows ();
300 void setup_transport ();
303 static ARDOUR_UI *theArdourUI;
305 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
310 int ask_about_saving_session (const string & why);
311 int save_the_session;
313 /* periodic safety backup, to be precise */
314 gint autosave_session();
315 void update_autosave();
316 sigc::connection _autosave_connection;
318 void queue_transport_change ();
319 void map_transport_state ();
320 int32_t do_engine_start ();
322 void engine_halted ();
323 void engine_stopped ();
324 void engine_running ();
328 static gint _blink (void *);
330 gint blink_timeout_tag;
332 void start_blinking ();
333 void stop_blinking ();
335 void about_signal_response(int response);
339 Gtk::VBox top_packer;
341 sigc::connection clock_signal_connection;
342 void update_clocks ();
343 void start_clocking ();
344 void stop_clocking ();
346 void manage_window (Gtk::Window&);
348 AudioClock big_clock;
349 Gtk::Frame big_clock_frame;
350 Gtk::Window* big_clock_window;
352 void update_transport_clocks (nframes_t pos);
353 void record_state_changed ();
355 /* Transport Control */
357 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
358 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
360 Gtkmm2ext::TearOff* transport_tearoff;
361 Gtk::Frame transport_frame;
362 Gtk::HBox transport_tearoff_hbox;
363 Gtk::HBox transport_hbox;
364 Gtk::Fixed transport_base;
365 Gtk::Fixed transport_button_base;
366 Gtk::Frame transport_button_frame;
367 Gtk::HBox transport_button_hbox;
368 Gtk::VBox transport_button_vbox;
369 Gtk::HBox transport_option_button_hbox;
370 Gtk::VBox transport_option_button_vbox;
371 Gtk::HBox transport_clock_hbox;
372 Gtk::VBox transport_clock_vbox;
373 Gtk::HBox primary_clock_hbox;
374 Gtk::HBox secondary_clock_hbox;
377 struct TransportControllable : public PBD::Controllable {
390 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
391 void set_value (float);
392 float get_value (void) const;
394 void set_id (const std::string&);
400 TransportControllable roll_controllable;
401 TransportControllable stop_controllable;
402 TransportControllable goto_start_controllable;
403 TransportControllable goto_end_controllable;
404 TransportControllable auto_loop_controllable;
405 TransportControllable play_selection_controllable;
406 TransportControllable rec_controllable;
407 TransportControllable shuttle_controllable;
408 BindingProxy shuttle_controller_binding_proxy;
410 void set_transport_controllable_state (const XMLNode&);
411 XMLNode& get_transport_controllable_state ();
413 BindableButton roll_button;
414 BindableButton stop_button;
415 BindableButton goto_start_button;
416 BindableButton goto_end_button;
417 BindableButton auto_loop_button;
418 BindableButton play_selection_button;
419 BindableButton rec_button;
421 Gtk::ComboBoxText sync_option_combo;
423 void sync_option_changed ();
424 void toggle_time_master ();
425 void toggle_video_sync ();
427 Gtk::DrawingArea shuttle_box;
428 Gtk::EventBox speed_display_box;
429 Gtk::Label speed_display_label;
430 Gtk::Button shuttle_units_button;
431 Gtk::ComboBoxText shuttle_style_button;
432 Gtk::Menu* shuttle_unit_menu;
433 Gtk::Menu* shuttle_style_menu;
434 float shuttle_max_speed;
435 Gtk::Menu* shuttle_context_menu;
437 void build_shuttle_context_menu ();
438 void show_shuttle_context_menu ();
439 void shuttle_style_changed();
440 void shuttle_unit_clicked ();
441 void set_shuttle_max_speed (float);
442 void update_speed_display ();
443 float last_speed_displayed;
445 gint shuttle_box_button_press (GdkEventButton*);
446 gint shuttle_box_button_release (GdkEventButton*);
447 gint shuttle_box_scroll (GdkEventScroll*);
448 gint shuttle_box_motion (GdkEventMotion*);
449 gint shuttle_box_expose (GdkEventExpose*);
450 gint mouse_shuttle (double x, bool force);
451 void use_shuttle_fract (bool force);
453 bool shuttle_grabbed;
454 double shuttle_fract;
456 Gtkmm2ext::StatefulToggleButton punch_in_button;
457 Gtkmm2ext::StatefulToggleButton punch_out_button;
458 Gtkmm2ext::StatefulToggleButton auto_return_button;
459 Gtkmm2ext::StatefulToggleButton auto_play_button;
460 Gtkmm2ext::StatefulToggleButton auto_input_button;
461 Gtkmm2ext::StatefulToggleButton click_button;
462 Gtkmm2ext::StatefulToggleButton time_master_button;
464 Gtk::ToggleButton auditioning_alert_button;
465 Gtk::ToggleButton solo_alert_button;
469 void solo_blink (bool);
470 void audition_blink (bool);
472 void soloing_changed (bool);
473 void auditioning_changed (bool);
474 void _auditioning_changed (bool);
476 void solo_alert_toggle ();
477 void audition_alert_toggle ();
479 void big_clock_value_changed ();
480 void primary_clock_value_changed ();
481 void secondary_clock_value_changed ();
483 /* called by Blink signal */
485 void transport_rec_enable_blink (bool onoff);
487 Gtk::Menu* session_popup_menu;
489 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
490 RecentSessionModelColumns() {
494 Gtk::TreeModelColumn<Glib::ustring> visible_name;
495 Gtk::TreeModelColumn<Glib::ustring> fullpath;
498 RecentSessionModelColumns recent_session_columns;
499 Gtk::TreeView recent_session_display;
500 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
502 ArdourDialog* session_selector_window;
503 Gtk::FileChooserDialog* open_session_selector;
505 void build_session_selector();
506 void redisplay_recent_sessions();
507 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
509 struct RecentSessionsSorter {
510 bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
511 return cmp_nocase(a.first, b.first) == -1;
515 /* menu bar and associated stuff */
517 Gtk::MenuBar* menu_bar;
518 Gtk::EventBox menu_bar_base;
521 void use_menubar_as_top_menubar ();
523 void build_menu_bar ();
524 void build_control_surface_menu ();
526 Gtk::Label wall_clock_label;
527 Gtk::EventBox wall_clock_box;
528 gint update_wall_clock ();
530 Gtk::Label disk_space_label;
531 Gtk::EventBox disk_space_box;
532 void update_disk_space ();
534 Gtk::Label cpu_load_label;
535 Gtk::EventBox cpu_load_box;
536 void update_cpu_load ();
538 Gtk::Label buffer_load_label;
539 Gtk::EventBox buffer_load_box;
540 void update_buffer_load ();
542 Gtk::Label sample_rate_label;
543 Gtk::EventBox sample_rate_box;
544 void update_sample_rate (nframes_t);
546 gint every_second ();
547 gint every_point_one_seconds ();
548 gint every_point_zero_one_seconds ();
550 sigc::connection second_connection;
551 sigc::connection point_one_second_connection;
552 sigc::connection point_oh_five_second_connection;
553 sigc::connection point_zero_one_second_connection;
555 gint session_menu (GdkEventButton *);
557 bool _will_create_new_session_automatically;
559 NewSessionDialog* new_session_dialog;
561 void open_session ();
562 void open_recent_session ();
563 void save_template ();
565 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many);
567 void set_transport_sensitivity (bool);
569 void remove_last_capture ();
571 void transport_goto_zero ();
572 void transport_goto_start ();
573 void transport_goto_end ();
574 void transport_stop ();
575 void transport_stop_and_forget_capture ();
576 void transport_record (bool roll);
577 void transport_roll ();
578 void transport_play_selection();
579 void transport_forward (int option);
580 void transport_rewind (int option);
581 void transport_loop ();
583 void transport_rolling ();
584 void transport_rewinding ();
585 void transport_forwarding ();
586 void transport_stopped ();
588 bool _session_is_new;
589 void connect_to_session (ARDOUR::Session *);
590 void connect_dependents_to_session (ARDOUR::Session *);
591 void we_have_dependents ();
593 void setup_session_options ();
595 guint32 last_key_press_time;
597 void snapshot_session ();
602 PublicEditor *editor;
603 int create_editor ();
605 RouteParams_UI *route_params;
606 int create_route_params ();
608 ConnectionEditor *connection_editor;
609 int create_connection_editor ();
611 LocationUI *location_ui;
612 int create_location_ui ();
613 void handle_locations_change (ARDOUR::Location*);
615 static UIConfiguration *ui_config;
616 ThemeManager *theme_manager;
618 /* Key bindings editor */
620 KeyEditor *key_editor;
624 OptionEditor *option_editor;
628 AddRouteDialog *add_route_dialog;
630 /* Keyboard Handling */
634 /* Keymap handling */
636 void install_actions ();
638 void toggle_record_enable (uint32_t);
640 uint32_t rec_enabled_streams;
641 void count_recenabled_streams (ARDOUR::Route&);
645 void pop_back_splash ();
650 Gtk::MenuItem *cleanup_item;
652 void display_cleanup_results (ARDOUR::Session::cleanup_report& rep, const gchar* list_title, const string & msg);
656 bool have_configure_timeout;
657 struct timeval last_configure_time;
658 gint configure_timeout ();
660 struct timeval last_peak_grab;
661 struct timeval last_shuttle_request;
663 bool have_disk_speed_dialog_displayed;
664 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
665 void disk_overrun_handler ();
666 void disk_underrun_handler ();
668 int pending_state_dialog ();
669 int sr_mismatch_dialog (nframes_t, nframes_t);
671 void disconnect_from_jack ();
672 void reconnect_to_jack ();
673 void set_jack_buffer_size (nframes_t);
675 Gtk::MenuItem* jack_disconnect_item;
676 Gtk::MenuItem* jack_reconnect_item;
677 Gtk::Menu* jack_bufsize_menu;
679 int make_session_clean ();
680 bool filter_ardour_session_dirs (const Gtk::FileFilter::Info&);
682 Glib::RefPtr<Gtk::ActionGroup> common_actions;
684 void editor_realized ();
686 std::vector<std::string> positional_sync_strings;
688 void toggle_send_midi_feedback ();
689 void toggle_use_mmc ();
690 void toggle_send_mmc ();
691 void toggle_send_mtc ();
693 void toggle_use_osc ();
695 void toggle_denormal_protection ();
697 void set_input_auto_connect (ARDOUR::AutoConnectOption);
698 void set_output_auto_connect (ARDOUR::AutoConnectOption);
699 void set_solo_model (ARDOUR::SoloModel);
700 void set_monitor_model (ARDOUR::MonitorModel);
701 void set_remote_model (ARDOUR::RemoteModel);
702 void set_denormal_model (ARDOUR::DenormalModel);
704 void toggle_sync_order_keys ();
705 void toggle_StopPluginsWithTransport();
706 void toggle_DoNotRunPluginsWhileRecording();
707 void toggle_VerifyRemoveLastCapture();
708 void toggle_PeriodicSafetyBackups();
709 void toggle_StopRecordingOnXrun();
710 void toggle_CreateXrunMarker();
711 void toggle_StopTransportAtEndOfSession();
712 void toggle_GainReduceFastTransport();
713 void toggle_LatchedSolo();
714 void toggle_ShowSoloMutes();
715 void toggle_LatchedRecordEnable ();
716 void toggle_RegionEquivalentsOverlap ();
717 void toggle_PrimaryClockDeltaEditCursor ();
718 void toggle_SecondaryClockDeltaEditCursor ();
719 void toggle_only_copy_imported_files ();
720 void toggle_ShowTrackMeters ();
721 void toggle_use_narrow_ms();
722 void toggle_rubberbanding_snaps_to_grid ();
723 void toggle_TapeMachineMode();
725 void mtc_port_changed ();
726 void map_solo_model ();
727 void map_monitor_model ();
728 void map_denormal_model ();
729 void map_denormal_protection ();
730 void map_remote_model ();
731 void map_file_header_format ();
732 void map_file_data_format ();
733 void map_input_auto_connect ();
734 void map_output_auto_connect ();
735 void map_only_copy_imported_files ();
736 void parameter_changed (const char*);
738 void set_meter_hold (ARDOUR::MeterHold);
739 void set_meter_falloff (ARDOUR::MeterFalloff);
740 void map_meter_hold ();
741 void map_meter_falloff ();
743 void toggle_control_protocol (ARDOUR::ControlProtocolInfo*);
744 void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo*, const char* group_name, std::string action_name);
748 void no_memory_warning ();
749 void check_memory_locking ();
751 bool check_audioengine();
752 void audioengine_setup ();
754 void display_message (const char *prefix, gint prefix_len,
755 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, const char *msg);
756 Gtk::Label status_bar_label;
757 Gtk::ToggleButton error_log_button;
759 void loading_message (const std::string& msg);
760 void end_loading_messages ();
762 void platform_specific ();
763 void platform_setup ();
764 void fontconfig_dialog ();
767 #endif /* __ardour_gui_h__ */