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>
61 #include <ardour/configuration.h>
63 #include "audio_clock.h"
64 #include "ardour_dialog.h"
66 #include "ui_config.h"
74 class ConnectionEditor;
79 class NewSessionDialog;
93 class ControlProtocolInfo;
97 class MultiChannelDevice;
100 #define FRAME_NAME "BaseFrame"
102 extern sigc::signal<void> ColorsChanged;
104 class ARDOUR_UI : public Gtkmm2ext::UI
107 ARDOUR_UI (int *argcp, char **argvp[]);
111 bool shown() { return shown_flag; }
119 int load_session (const Glib::ustring & path, const Glib::ustring& snapshot, Glib::ustring mix_template = Glib::ustring());
121 int build_session (const Glib::ustring& path, const Glib::ustring& snapshot,
123 uint32_t master_chns,
124 ARDOUR::AutoConnectOption input_connect,
125 ARDOUR::AutoConnectOption output_connect,
128 nframes_t initial_length);
129 bool session_is_new() const { return _session_is_new; }
131 ARDOUR::Session* the_session() { return session; }
133 bool will_create_new_session_automatically() const {
134 return _will_create_new_session_automatically;
137 void set_will_create_new_session_automatically (bool yn) {
138 _will_create_new_session_automatically = yn;
141 bool get_session_parameters (bool have_engine = false, bool should_be_new = false);
142 void parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session);
143 int load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session);
144 int build_session_from_nsd (const Glib::ustring& session_name, const Glib::ustring& session_path);
145 bool ask_about_loading_existing_session (const Glib::ustring& session_path);
147 /// @return true if session was successfully unloaded.
148 int unload_session (bool hide_stuff = false);
149 void close_session();
151 int save_state_canfail (string state_name = "");
152 void save_state (const string & state_name = "");
153 void restore_state (string state_name = "");
155 static double gain_to_slider_position (ARDOUR::gain_t g);
156 static ARDOUR::gain_t slider_position_to_gain (double pos);
158 static ARDOUR_UI *instance () { return theArdourUI; }
159 static UIConfiguration *config () { return ui_config; }
161 PublicEditor& the_editor(){return *editor;}
162 Mixer_UI* the_mixer() { return mixer; }
164 ARDOUR::AudioEngine& the_engine() const { return *engine; }
166 void toggle_key_editor ();
167 void toggle_location_window ();
168 void toggle_theme_manager ();
169 void toggle_bundle_manager ();
170 void toggle_big_clock_window ();
171 void toggle_connection_editor ();
172 void toggle_route_params_window ();
173 void toggle_editing_space();
175 Gtk::Tooltips& tooltips() { return _tooltips; }
177 static sigc::signal<void,bool> Blink;
178 static sigc::signal<void> RapidScreenUpdate;
179 static sigc::signal<void> SuperRapidScreenUpdate;
180 static sigc::signal<void,nframes_t, bool, nframes_t> Clock;
182 /* this is a helper function to centralize the (complex) logic for
183 blinking rec-enable buttons.
186 void rec_enable_button_blink (bool onoff, ARDOUR::AudioDiskstream *, Gtk::Widget *w);
188 void name_io_setup (ARDOUR::AudioEngine&, string&, ARDOUR::IO& io, bool in);
190 static gint hide_and_quit (GdkEventAny *ev, ArdourDialog *);
192 XMLNode* editor_settings() const;
193 XMLNode* mixer_settings () const;
194 XMLNode* keyboard_settings () const;
196 void save_ardour_state ();
197 gboolean configure_handler (GdkEventConfigure* conf);
199 void do_transport_locate (nframes_t position);
200 void halt_on_xrun_message ();
202 AudioClock primary_clock;
203 AudioClock secondary_clock;
204 AudioClock preroll_clock;
205 AudioClock postroll_clock;
207 void store_clock_modes ();
208 void restore_clock_modes ();
210 void add_route (Gtk::Window* float_window);
212 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many) {
213 session_add_audio_route (true, input_channels, output_channels, mode, how_many);
216 void session_add_audio_bus (int input_channels, int32_t output_channels, uint32_t how_many) {
217 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, how_many);
220 void session_add_midi_track (uint32_t how_many) {
221 session_add_midi_route (true, how_many);
224 /*void session_add_midi_bus () {
225 session_add_midi_route (false);
228 int create_engine ();
231 gint exit_on_main_window_close (GdkEventAny *);
233 void maximise_editing_space ();
234 void restore_editing_space ();
236 void set_native_file_header_format (ARDOUR::HeaderFormat sf);
237 void set_native_file_data_format (ARDOUR::SampleFormat sf);
239 void set_keybindings_path (std::string path);
240 void save_keybindings ();
242 void setup_profile ();
245 void set_shuttle_fract (double);
248 friend class PublicEditor;
250 void toggle_clocking ();
251 void toggle_auto_play ();
252 void toggle_auto_input ();
253 void toggle_punch_in ();
254 void toggle_punch_out ();
255 void toggle_auto_return ();
256 void toggle_click ();
258 void toggle_session_auto_loop ();
260 void toggle_options_window ();
263 struct GlobalClickBox : public Gtk::VBox {
264 Gtkmm2ext::ClickBox *box;
267 vector<string> &strings;
268 Gtk::Adjustment adjustment;
270 static void printer (char buf[32], Gtk::Adjustment &adj, void *arg);
272 GlobalClickBox (const string &str, vector<string> &vs)
274 adjustment (0, 0, vs.size() - 1, 1, 1, 0) {
275 box = new Gtkmm2ext::ClickBox (&adjustment, "ClickButton");
276 label.set_text (str);
277 label.set_name ("GlobalButtonLabel");
279 frame.set_shadow_type (Gtk::SHADOW_IN);
282 box->set_print_func (printer, this);
283 box->set_wrap (true);
287 ARDOUR::AudioEngine *engine;
288 ARDOUR::Session *session;
290 Gtk::Tooltips _tooltips;
292 void goto_editor_window ();
293 void goto_mixer_window ();
295 Gtk::Table adjuster_table;
296 Gtk::Frame adjuster_frame;
297 Gtk::Fixed adjuster_base;
299 GlobalClickBox *online_control_button;
300 vector<string> online_control_strings;
302 GlobalClickBox *crossfade_time_button;
303 vector<string> crossfade_time_strings;
305 Gtk::ToggleButton preroll_button;
306 Gtk::ToggleButton postroll_button;
308 Gtk::Table transport_table;
309 Gtk::Table option_table;
311 int setup_windows ();
312 void setup_transport ();
315 static ARDOUR_UI *theArdourUI;
317 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
322 int ask_about_saving_session (const string & why);
323 int save_the_session;
325 /* periodic safety backup, to be precise */
326 gint autosave_session();
327 void update_autosave();
328 sigc::connection _autosave_connection;
330 void queue_transport_change ();
331 void map_transport_state ();
332 int32_t do_engine_start ();
334 void engine_halted ();
335 void engine_stopped ();
336 void engine_running ();
340 static gint _blink (void *);
342 gint blink_timeout_tag;
344 void start_blinking ();
345 void stop_blinking ();
347 void about_signal_response(int response);
350 Gtk::VBox top_packer;
352 sigc::connection clock_signal_connection;
353 void update_clocks ();
354 void start_clocking ();
355 void stop_clocking ();
357 void manage_window (Gtk::Window&);
359 AudioClock big_clock;
360 Gtk::Frame big_clock_frame;
361 Gtk::Window* big_clock_window;
363 void update_transport_clocks (nframes_t pos);
364 void record_state_changed ();
366 /* Transport Control */
368 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
369 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
371 Gtkmm2ext::TearOff* transport_tearoff;
372 Gtk::Frame transport_frame;
373 Gtk::HBox transport_tearoff_hbox;
374 Gtk::HBox transport_hbox;
375 Gtk::Fixed transport_base;
376 Gtk::Fixed transport_button_base;
377 Gtk::Frame transport_button_frame;
378 Gtk::HBox transport_button_hbox;
379 Gtk::VBox transport_button_vbox;
380 Gtk::HBox transport_option_button_hbox;
381 Gtk::VBox transport_option_button_vbox;
382 Gtk::HBox transport_clock_hbox;
383 Gtk::VBox transport_clock_vbox;
384 Gtk::HBox primary_clock_hbox;
385 Gtk::HBox secondary_clock_hbox;
388 struct TransportControllable : public PBD::Controllable {
401 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
402 void set_value (float);
403 float get_value (void) const;
405 void set_id (const std::string&);
411 TransportControllable roll_controllable;
412 TransportControllable stop_controllable;
413 TransportControllable goto_start_controllable;
414 TransportControllable goto_end_controllable;
415 TransportControllable auto_loop_controllable;
416 TransportControllable play_selection_controllable;
417 TransportControllable rec_controllable;
418 TransportControllable shuttle_controllable;
419 BindingProxy shuttle_controller_binding_proxy;
421 void set_transport_controllable_state (const XMLNode&);
422 XMLNode& get_transport_controllable_state ();
424 BindableButton roll_button;
425 BindableButton stop_button;
426 BindableButton goto_start_button;
427 BindableButton goto_end_button;
428 BindableButton auto_loop_button;
429 BindableButton play_selection_button;
430 BindableButton rec_button;
432 Gtk::ComboBoxText sync_option_combo;
434 void sync_option_changed ();
435 void toggle_time_master ();
436 void toggle_video_sync ();
438 Gtk::DrawingArea shuttle_box;
439 Gtk::EventBox speed_display_box;
440 Gtk::Label speed_display_label;
441 Gtk::Button shuttle_units_button;
442 Gtk::ComboBoxText shuttle_style_button;
443 Gtk::Menu* shuttle_unit_menu;
444 Gtk::Menu* shuttle_style_menu;
445 float shuttle_max_speed;
446 Gtk::Menu* shuttle_context_menu;
448 void build_shuttle_context_menu ();
449 void show_shuttle_context_menu ();
450 void shuttle_style_changed();
451 void shuttle_unit_clicked ();
452 void set_shuttle_max_speed (float);
453 void update_speed_display ();
454 float last_speed_displayed;
456 gint shuttle_box_button_press (GdkEventButton*);
457 gint shuttle_box_button_release (GdkEventButton*);
458 gint shuttle_box_scroll (GdkEventScroll*);
459 gint shuttle_box_motion (GdkEventMotion*);
460 gint shuttle_box_expose (GdkEventExpose*);
461 gint mouse_shuttle (double x, bool force);
462 void use_shuttle_fract (bool force);
464 bool shuttle_grabbed;
465 double shuttle_fract;
467 Gtkmm2ext::StatefulToggleButton punch_in_button;
468 Gtkmm2ext::StatefulToggleButton punch_out_button;
469 Gtkmm2ext::StatefulToggleButton auto_return_button;
470 Gtkmm2ext::StatefulToggleButton auto_play_button;
471 Gtkmm2ext::StatefulToggleButton auto_input_button;
472 Gtkmm2ext::StatefulToggleButton click_button;
473 Gtkmm2ext::StatefulToggleButton time_master_button;
475 Gtk::ToggleButton auditioning_alert_button;
476 Gtk::ToggleButton solo_alert_button;
480 void solo_blink (bool);
481 void audition_blink (bool);
483 void soloing_changed (bool);
484 void auditioning_changed (bool);
485 void _auditioning_changed (bool);
487 void solo_alert_toggle ();
488 void audition_alert_toggle ();
490 void big_clock_value_changed ();
491 void primary_clock_value_changed ();
492 void secondary_clock_value_changed ();
494 /* called by Blink signal */
496 void transport_rec_enable_blink (bool onoff);
498 Gtk::Menu* session_popup_menu;
500 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
501 RecentSessionModelColumns() {
505 Gtk::TreeModelColumn<Glib::ustring> visible_name;
506 Gtk::TreeModelColumn<Glib::ustring> fullpath;
509 RecentSessionModelColumns recent_session_columns;
510 Gtk::TreeView recent_session_display;
511 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
513 ArdourDialog* session_selector_window;
514 Gtk::FileChooserDialog* open_session_selector;
516 void build_session_selector();
517 void redisplay_recent_sessions();
518 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
520 struct RecentSessionsSorter {
521 bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
522 return cmp_nocase(a.first, b.first) == -1;
526 /* menu bar and associated stuff */
528 Gtk::MenuBar* menu_bar;
529 Gtk::EventBox menu_bar_base;
532 void use_menubar_as_top_menubar ();
533 void build_menu_bar ();
534 void build_control_surface_menu ();
536 Gtk::Label wall_clock_label;
537 Gtk::EventBox wall_clock_box;
538 gint update_wall_clock ();
540 Gtk::Label disk_space_label;
541 Gtk::EventBox disk_space_box;
542 void update_disk_space ();
544 Gtk::Label cpu_load_label;
545 Gtk::EventBox cpu_load_box;
546 void update_cpu_load ();
548 Gtk::Label buffer_load_label;
549 Gtk::EventBox buffer_load_box;
550 void update_buffer_load ();
552 Gtk::Label sample_rate_label;
553 Gtk::EventBox sample_rate_box;
554 void update_sample_rate (nframes_t);
556 gint every_second ();
557 gint every_point_one_seconds ();
558 gint every_point_zero_one_seconds ();
560 sigc::connection second_connection;
561 sigc::connection point_one_second_connection;
562 sigc::connection point_oh_five_second_connection;
563 sigc::connection point_zero_one_second_connection;
565 gint session_menu (GdkEventButton *);
567 bool _will_create_new_session_automatically;
569 NewSessionDialog* new_session_dialog;
571 void open_session ();
572 void open_recent_session ();
573 void save_template ();
575 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many);
576 void session_add_midi_route (bool disk, uint32_t how_many);
578 void set_transport_sensitivity (bool);
580 void remove_last_capture ();
582 void transport_goto_zero ();
583 void transport_goto_start ();
584 void transport_goto_end ();
585 void transport_stop ();
586 void transport_stop_and_forget_capture ();
587 void transport_record (bool roll);
588 void transport_roll ();
589 void transport_play_selection();
590 void transport_forward (int option);
591 void transport_rewind (int option);
592 void transport_loop ();
594 void transport_rolling ();
595 void transport_rewinding ();
596 void transport_forwarding ();
597 void transport_stopped ();
599 bool _session_is_new;
600 void connect_to_session (ARDOUR::Session *);
601 void connect_dependents_to_session (ARDOUR::Session *);
602 void we_have_dependents ();
604 std::string keybindings_path;
605 std::string user_keybindings_path;
607 void setup_keybindings ();
608 void setup_session_options ();
610 guint32 last_key_press_time;
612 void snapshot_session ();
617 PublicEditor *editor;
618 int create_editor ();
620 RouteParams_UI *route_params;
621 int create_route_params ();
623 BundleManager *bundle_manager;
624 void create_bundle_manager ();
626 ConnectionEditor *connection_editor;
627 int create_connection_editor ();
629 LocationUI *location_ui;
630 int create_location_ui ();
631 void handle_locations_change (ARDOUR::Location*);
633 static UIConfiguration *ui_config;
634 ThemeManager *theme_manager;
636 /* Key bindings editor */
638 KeyEditor *key_editor;
642 OptionEditor *option_editor;
646 AddRouteDialog *add_route_dialog;
648 /* Keyboard Handling */
652 /* Keymap handling */
654 void install_actions ();
656 void toggle_record_enable (uint32_t);
658 uint32_t rec_enabled_streams;
659 void count_recenabled_streams (ARDOUR::Route&);
666 Gtk::MenuItem *cleanup_item;
668 void display_cleanup_results (ARDOUR::Session::cleanup_report& rep, const gchar* list_title, const string & msg);
672 bool have_configure_timeout;
673 struct timeval last_configure_time;
674 gint configure_timeout ();
676 struct timeval last_peak_grab;
677 struct timeval last_shuttle_request;
679 bool have_disk_speed_dialog_displayed;
680 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
681 void disk_overrun_handler ();
682 void disk_underrun_handler ();
684 int pending_state_dialog ();
686 void disconnect_from_jack ();
687 void reconnect_to_jack ();
688 void set_jack_buffer_size (nframes_t);
690 Gtk::MenuItem* jack_disconnect_item;
691 Gtk::MenuItem* jack_reconnect_item;
692 Gtk::Menu* jack_bufsize_menu;
694 int make_session_clean ();
695 bool filter_ardour_session_dirs (const Gtk::FileFilter::Info&);
697 Glib::RefPtr<Gtk::ActionGroup> common_actions;
699 void editor_realized ();
701 std::vector<std::string> positional_sync_strings;
703 void toggle_send_midi_feedback ();
704 void toggle_use_mmc ();
705 void toggle_send_mmc ();
706 void toggle_send_mtc ();
708 void toggle_use_osc ();
710 void toggle_denormal_protection ();
712 void set_input_auto_connect (ARDOUR::AutoConnectOption);
713 void set_output_auto_connect (ARDOUR::AutoConnectOption);
714 void set_solo_model (ARDOUR::SoloModel);
715 void set_monitor_model (ARDOUR::MonitorModel);
716 void set_remote_model (ARDOUR::RemoteModel);
717 void set_denormal_model (ARDOUR::DenormalModel);
719 void toggle_sync_order_keys ();
720 void toggle_StopPluginsWithTransport();
721 void toggle_DoNotRunPluginsWhileRecording();
722 void toggle_VerifyRemoveLastCapture();
723 void toggle_PeriodicSafetyBackups();
724 void toggle_StopRecordingOnXrun();
725 void toggle_StopTransportAtEndOfSession();
726 void toggle_GainReduceFastTransport();
727 void toggle_LatchedSolo();
728 void toggle_ShowSoloMutes();
729 void toggle_LatchedRecordEnable ();
730 void toggle_RegionEquivalentsOverlap ();
731 void toggle_PrimaryClockDeltaEditCursor ();
732 void toggle_SecondaryClockDeltaEditCursor ();
733 void toggle_ShowTrackMeters ();
734 void toggle_only_copy_imported_files ();
735 void toggle_use_narrow_ms();
737 void mtc_port_changed ();
738 void map_solo_model ();
739 void map_monitor_model ();
740 void map_denormal_model ();
741 void map_denormal_protection ();
742 void map_remote_model ();
743 void map_file_header_format ();
744 void map_file_data_format ();
745 void map_input_auto_connect ();
746 void map_output_auto_connect ();
747 void map_only_copy_imported_files ();
748 void parameter_changed (const char*);
750 void set_meter_hold (ARDOUR::MeterHold);
751 void set_meter_falloff (ARDOUR::MeterFalloff);
752 void map_meter_hold ();
753 void map_meter_falloff ();
755 void toggle_control_protocol (ARDOUR::ControlProtocolInfo*);
756 void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo*, const char* group_name, std::string action_name);
758 bool can_save_keybindings;
761 void no_memory_warning ();
762 void check_memory_locking ();
764 bool check_audioengine();
765 void audioengine_setup ();
767 void display_message (const char *prefix, gint prefix_len,
768 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, const char *msg);
769 Gtk::Label status_bar_label;
770 Gtk::ToggleButton error_log_button;
772 void loading_message (const std::string& msg);
773 void end_loading_messages ();
775 void platform_specific ();
776 void platform_setup ();
777 void fontconfig_dialog ();
780 #endif /* __ardour_gui_h__ */