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__
25 /* need _BSD_SOURCE to get timersub macros */
39 #include "pbd/xml++.h"
40 #include "pbd/controllable.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/textbuffer.h>
55 #include <gtkmm/adjustment.h>
57 #include "gtkmm2ext/gtk_ui.h"
58 #include "gtkmm2ext/click_box.h"
59 #include "gtkmm2ext/stateful_button.h"
60 #include "gtkmm2ext/bindable_button.h"
61 #include "gtkmm2ext/bindings.h"
63 #include "ardour/ardour.h"
64 #include "ardour/types.h"
65 #include "ardour/utils.h"
66 #include "ardour/plugin.h"
67 #include "ardour/session_handle.h"
68 #include "ardour/system_exec.h"
70 #include "video_timeline.h"
72 #include "add_route_dialog.h"
73 #include "ardour_button.h"
74 #include "ardour_dialog.h"
75 #include "ardour_window.h"
78 #include "visibility_group.h"
79 #include "window_manager.h"
83 #include "add_video_dialog.h"
84 #include "big_clock_window.h"
85 #include "bundle_manager.h"
86 #include "engine_dialog.h"
87 #include "export_video_dialog.h"
88 #include "global_port_matrix.h"
89 #include "keyeditor.h"
90 #include "location_ui.h"
91 #include "rc_option_editor.h"
92 #include "route_params_ui.h"
93 #include "session_option_editor.h"
94 #include "speaker_dialog.h"
102 class ExportVideoDialog;
104 class LocationUIWindow;
105 class RCOptionEditor;
106 class RouteParams_UI;
107 class SessionOptionEditor;
109 class GlobalPortMatrixWindow;
113 class ArdourKeyboard;
116 class ConnectionEditor;
117 class DuplicateRouteDialog;
120 class ArdourPrompter;
124 class SessionOptionEditor;
125 class ShuttleControl;
131 class LevelMeterHBox;
132 class GUIObjectState;
135 class ControlProtocolInfo;
144 namespace Gtkmm2ext {
152 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
155 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
158 bool run_startup (bool should_be_new, std::string load_template);
164 void launch_manual ();
165 void launch_reference ();
166 void launch_tracker ();
167 void launch_subscribe ();
168 void launch_cheat_sheet ();
169 void launch_website ();
170 void launch_website_dev ();
171 void launch_forums ();
172 void launch_howto_report ();
176 void load_from_application_api (const std::string& path);
179 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
181 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
182 bool session_is_new() const { return _session_is_new; }
184 ARDOUR::Session* the_session() { return _session; }
186 bool get_smart_mode () const;
188 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
189 int build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
190 bool ask_about_loading_existing_session (const std::string& session_path);
192 /// @return true if session was successfully unloaded.
193 int unload_session (bool hide_stuff = false);
194 void close_session();
196 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
197 void save_state (const std::string & state_name = "", bool switch_to_it = false);
199 static ARDOUR_UI *instance () { return theArdourUI; }
201 PublicEditor& the_editor() { return *editor;}
202 Mixer_UI* the_mixer() { return mixer; }
204 void new_midi_tracer_window ();
205 void toggle_editing_space();
206 void toggle_mixer_space();
207 void toggle_mixer_list();
208 void toggle_monitor_section_visibility ();
209 void toggle_keep_tearoffs();
211 static PublicEditor* _instance;
213 /** Emitted frequently with the audible frame, false, and the edit point as
214 * parameters respectively.
216 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
218 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
220 static void close_all_dialogs () { CloseAllDialogs(); }
221 static sigc::signal<void> CloseAllDialogs;
223 XMLNode* main_window_settings() const;
224 XMLNode* editor_settings() const;
225 XMLNode* mixer_settings () const;
226 XMLNode* keyboard_settings () const;
227 XMLNode* tearoff_settings (const char*) const;
229 void save_ardour_state ();
230 gboolean configure_handler (GdkEventConfigure* conf);
232 void halt_on_xrun_message ();
233 void xrun_handler (framepos_t);
234 void create_xrun_marker (framepos_t);
236 GUIObjectState* gui_object_state;
238 MainClock* primary_clock;
239 MainClock* secondary_clock;
240 void focus_on_clock ();
241 AudioClock* big_clock;
243 TimeInfoBox* time_info_box;
245 VideoTimeLine *video_timeline;
247 void store_clock_modes ();
248 void restore_clock_modes ();
249 void reset_main_clocks ();
251 void synchronize_sync_source_and_video_pullup ();
253 void add_route (Gtk::Window* float_window);
254 void add_routes_part_two ();
255 void add_routes_thread ();
257 void start_duplicate_routes ();
259 void add_video (Gtk::Window* float_window);
260 void remove_video ();
261 void start_video_server_menu (Gtk::Window* float_window);
262 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
263 void stop_video_server (bool ask_confirm=false);
264 void flush_videotimeline_cache (bool localcacheonly=false);
265 void export_video (bool range = false);
267 void session_add_audio_track (
269 int32_t output_channels,
270 ARDOUR::TrackMode mode,
271 ARDOUR::RouteGroup* route_group,
273 std::string const & name_template
276 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
279 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
280 uint32_t how_many, std::string const & name_template) {
281 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
284 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
285 ARDOUR::PluginInfoPtr instrument) {
286 session_add_midi_route (true, route_group, how_many, name_template, instrument);
289 void session_add_mixed_track (const ARDOUR::ChanCount& input, const ARDOUR::ChanCount& output, ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
290 ARDOUR::PluginInfoPtr instrument);
292 /*void session_add_midi_bus () {
293 session_add_midi_route (false);
296 void attach_to_engine ();
299 gint exit_on_main_window_close (GdkEventAny *);
301 void maximise_editing_space ();
302 void restore_editing_space ();
304 void show_ui_prefs ();
306 bool check_audioengine(Gtk::Window&);
308 void update_tearoff_visibility ();
310 void setup_profile ();
311 void setup_tooltips ();
313 void set_shuttle_fract (double);
315 void get_process_buffers ();
316 void drop_process_buffers ();
318 void reset_peak_display ();
319 void reset_route_peak_display (ARDOUR::Route*);
320 void reset_group_peak_display (ARDOUR::RouteGroup*);
322 const std::string& announce_string() const { return _announce_string; }
324 void hide_application ();
326 Gtk::Notebook& tabs();
327 Gtk::Window& main_window () { return _main_window; }
329 void setup_toplevel_window (Gtk::Window&, const std::string& name, void* owner);
331 /* called from a static C function */
333 GtkNotebook* tab_window_root_drop (GtkNotebook* src,
339 bool tabbed_window_state_event_handler (GdkEventWindowState*, void* object);
340 bool key_event_handler (GdkEventKey*, Gtk::Window* window);
343 friend class PublicEditor;
345 void toggle_auto_play ();
346 void toggle_auto_input ();
347 void toggle_punch ();
348 void unset_dual_punch ();
349 bool ignore_dual_punch;
350 void toggle_punch_in ();
351 void toggle_punch_out ();
352 void show_loop_punch_ruler_and_disallow_hide ();
353 void reenable_hide_loop_punch_ruler_if_appropriate ();
354 void toggle_auto_return ();
355 void toggle_click ();
356 void toggle_audio_midi_setup ();
357 void toggle_session_auto_loop ();
358 void toggle_rc_options_window ();
359 void toggle_session_options_window ();
362 Gtk::Window _main_window;
363 Gtk::VBox main_vpacker;
364 Gtk::HBox status_bar_hpacker;
366 PublicEditor* editor;
368 Gtk::Tooltips _tooltips;
372 bool _initial_verbose_plugin_scan;
373 bool first_time_engine_run;
375 Gtkmm2ext::Bindings _global_bindings;
377 bool tabs_button_event (GdkEventButton* ev);
379 void show_tabbable (Gtkmm2ext::Tabbable*);
380 void hide_tabbable (Gtkmm2ext::Tabbable*);
381 void detach_tabbable (Gtkmm2ext::Tabbable*);
382 void attach_tabbable (Gtkmm2ext::Tabbable*);
384 void tabbable_state_change (Gtkmm2ext::Tabbable&);
386 void toggle_meterbridge ();
388 int setup_windows ();
389 void setup_transport ();
392 static ARDOUR_UI *theArdourUI;
393 SessionDialog *_session_dialog;
397 int ask_about_saving_session (const std::vector<std::string>& actions);
399 void save_session_at_its_request (std::string);
400 /* periodic safety backup, to be precise */
401 gint autosave_session();
402 void update_autosave();
403 sigc::connection _autosave_connection;
405 void session_dirty_changed ();
406 void update_title ();
408 void map_transport_state ();
409 int32_t do_engine_start ();
411 void engine_halted (const char* reason, bool free_reason);
412 void engine_stopped ();
413 void engine_running ();
417 void about_signal_response(int response);
419 Gtk::VBox top_packer;
421 sigc::connection clock_signal_connection;
422 void update_clocks ();
423 void start_clocking ();
424 void stop_clocking ();
426 void update_transport_clocks (framepos_t pos);
427 void record_state_changed ();
429 std::list<MidiTracer*> _midi_tracer_windows;
431 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
432 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
433 void reattach_all_tearoffs ();
435 /* Transport Control */
437 Gtkmm2ext::TearOff* transport_tearoff;
438 Gtk::Frame transport_frame;
439 Gtk::HBox transport_tearoff_hbox;
440 Gtk::HBox transport_hbox;
441 Gtk::Fixed transport_base;
442 Gtk::Fixed transport_button_base;
443 Gtk::Frame transport_button_frame;
444 Gtk::HBox transport_button_hbox;
445 Gtk::VBox transport_button_vbox;
446 Gtk::HBox transport_option_button_hbox;
447 Gtk::VBox transport_option_button_vbox;
448 Gtk::HBox transport_clock_hbox;
449 Gtk::VBox transport_clock_vbox;
450 Gtk::HBox primary_clock_hbox;
451 Gtk::HBox secondary_clock_hbox;
453 struct TransportControllable : public PBD::Controllable {
464 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
465 void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
466 double get_value (void) const;
472 boost::shared_ptr<TransportControllable> roll_controllable;
473 boost::shared_ptr<TransportControllable> stop_controllable;
474 boost::shared_ptr<TransportControllable> goto_start_controllable;
475 boost::shared_ptr<TransportControllable> goto_end_controllable;
476 boost::shared_ptr<TransportControllable> auto_loop_controllable;
477 boost::shared_ptr<TransportControllable> play_selection_controllable;
478 boost::shared_ptr<TransportControllable> rec_controllable;
480 void toggle_follow_edits ();
482 void set_transport_controllable_state (const XMLNode&);
483 XMLNode& get_transport_controllable_state ();
485 ArdourButton roll_button;
486 ArdourButton stop_button;
487 ArdourButton goto_start_button;
488 ArdourButton goto_end_button;
489 ArdourButton auto_loop_button;
490 ArdourButton play_selection_button;
491 ArdourButton rec_button;
493 void toggle_external_sync ();
494 void toggle_time_master ();
495 void toggle_video_sync ();
497 ShuttleControl* shuttle_box;
499 ArdourButton auto_return_button;
500 ArdourButton follow_edits_button;
501 ArdourButton auto_input_button;
502 ArdourButton click_button;
503 ArdourButton sync_button;
505 ArdourButton auditioning_alert_button;
506 ArdourButton solo_alert_button;
507 ArdourButton feedback_alert_button;
508 ArdourButton error_alert_button;
512 LevelMeterHBox * editor_meter;
513 float editor_meter_max_peak;
514 ArdourButton editor_meter_peak_display;
515 bool editor_meter_peak_button_release (GdkEventButton*);
517 void blink_handler (bool);
518 sigc::connection blink_connection;
521 void solo_blink (bool);
522 void sync_blink (bool);
523 void audition_blink (bool);
524 void feedback_blink (bool);
525 void error_blink (bool);
527 void set_flat_buttons();
529 void soloing_changed (bool);
530 void auditioning_changed (bool);
531 void _auditioning_changed (bool);
533 bool solo_alert_press (GdkEventButton* ev);
534 bool audition_alert_press (GdkEventButton* ev);
535 bool feedback_alert_press (GdkEventButton *);
536 bool error_alert_press (GdkEventButton *);
538 void big_clock_value_changed ();
539 void primary_clock_value_changed ();
540 void secondary_clock_value_changed ();
542 /* called by Blink signal */
544 void transport_rec_enable_blink (bool onoff);
546 Gtk::Menu* session_popup_menu;
548 /* menu bar and associated stuff */
550 Gtk::MenuBar* menu_bar;
551 Gtk::EventBox menu_bar_base;
554 void use_menubar_as_top_menubar ();
555 void build_menu_bar ();
557 Gtk::Label wall_clock_label;
558 gint update_wall_clock ();
560 Gtk::Label disk_space_label;
561 void update_disk_space ();
563 Gtk::Label timecode_format_label;
564 void update_timecode_format ();
566 Gtk::Label cpu_load_label;
567 void update_cpu_load ();
569 Gtk::Label xrun_label;
570 void update_xrun_count ();
572 Gtk::Label peak_thread_work_label;
573 void update_peak_thread_work ();
575 Gtk::Label buffer_load_label;
576 void update_buffer_load ();
578 Gtk::Label sample_rate_label;
579 void update_sample_rate (ARDOUR::framecnt_t);
581 Gtk::Label format_label;
582 void update_format ();
584 void every_second ();
585 void every_point_one_seconds ();
586 void every_point_zero_something_seconds ();
588 sigc::connection second_connection;
589 sigc::connection point_one_second_connection;
590 sigc::connection point_zero_something_second_connection;
591 sigc::connection fps_connection;
593 void set_fps_timeout_connection ();
595 void open_session ();
596 void open_recent_session ();
597 bool process_save_template_prompter (ArdourPrompter& prompter);
598 void save_template ();
600 void edit_metadata ();
601 void import_metadata ();
603 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
604 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
606 void set_transport_sensitivity (bool);
608 //stuff for ProTools-style numpad
609 void transport_numpad_event (int num);
610 void transport_numpad_decimal ();
611 bool _numpad_locate_happening;
612 int _pending_locate_num;
613 gint transport_numpad_timeout ();
614 sigc::connection _numpad_timeout_connection;
616 void transport_goto_nth_marker (int nth);
617 void transport_goto_zero ();
618 void transport_goto_start ();
619 void transport_goto_end ();
620 void transport_goto_wallclock ();
621 void transport_stop ();
622 void transport_record (bool roll);
623 void transport_roll ();
624 void transport_play_selection();
625 void transport_play_preroll();
626 void transport_forward (int option);
627 void transport_rewind (int option);
628 void transport_loop ();
629 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
630 bool trx_record_enable_all_tracks ();
632 bool _session_is_new;
633 void set_session (ARDOUR::Session *);
634 void connect_dependents_to_session (ARDOUR::Session *);
635 void we_have_dependents ();
637 void setup_session_options ();
639 guint32 last_key_press_time;
641 bool process_snapshot_session_prompter (ArdourPrompter& prompter, bool switch_to_it);
642 void snapshot_session (bool switch_to_it);
644 void quick_snapshot_session (bool switch_to_it); //does not promtp for name, just makes a timestamped file
646 SaveAsDialog* save_as_dialog;
648 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
649 void save_session_as ();
650 void rename_session ();
651 void setup_order_hint (AddRouteDialog::InsertAt);
654 int create_editor ();
656 Meterbridge *meterbridge;
657 int create_meterbridge ();
659 /* Dialogs that can be created via new<T> */
661 RCOptionEditor* rc_option_editor;
662 Gtk::HBox rc_option_editor_placeholder;
664 WM::Proxy<SpeakerDialog> speaker_config_window;
665 WM::Proxy<KeyEditor> key_editor;
666 WM::Proxy<AddRouteDialog> add_route_dialog;
667 WM::Proxy<About> about;
668 WM::Proxy<LocationUIWindow> location_ui;
669 WM::Proxy<RouteParams_UI> route_params;
670 WM::Proxy<EngineControl> audio_midi_setup;
671 WM::Proxy<ExportVideoDialog> export_video_dialog;
673 /* Windows/Dialogs that require a creator method */
675 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
676 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
677 WM::ProxyWithConstructor<BundleManager> bundle_manager;
678 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
679 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
680 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
682 /* creator methods */
684 SessionOptionEditor* create_session_option_editor ();
685 BundleManager* create_bundle_manager ();
686 AddVideoDialog* create_add_video_dialog ();
687 BigClockWindow* create_big_clock_window();
688 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
690 ARDOUR::SystemExec *video_server_process;
692 void handle_locations_change (ARDOUR::Location*);
694 /* Keyboard Handling */
696 ArdourKeyboard* keyboard;
698 /* Keymap handling */
700 void install_actions ();
702 void toggle_record_enable (uint32_t);
704 uint32_t rec_enabled_streams;
705 void count_recenabled_streams (ARDOUR::Route&);
709 void pop_back_splash (Gtk::Window&);
713 Gtk::MenuItem *cleanup_item;
715 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
717 void cleanup_peakfiles ();
720 bool have_configure_timeout;
721 ARDOUR::microseconds_t last_configure_time;
722 gint configure_timeout ();
724 ARDOUR::microseconds_t last_peak_grab;
725 ARDOUR::microseconds_t last_shuttle_request;
727 bool have_disk_speed_dialog_displayed;
728 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
729 void disk_overrun_handler ();
730 void disk_underrun_handler ();
731 void gui_idle_handler ();
733 void cancel_plugin_scan ();
734 void cancel_plugin_timeout ();
735 void plugin_scan_dialog (std::string type, std::string plugin, bool);
736 void plugin_scan_timeout (int);
738 void session_format_mismatch (std::string, std::string);
740 void session_dialog (std::string);
741 int pending_state_dialog ();
742 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
744 Gtk::MenuItem* jack_disconnect_item;
745 Gtk::MenuItem* jack_reconnect_item;
746 Gtk::Menu* jack_bufsize_menu;
748 Glib::RefPtr<Gtk::ActionGroup> common_actions;
750 void editor_realized ();
752 std::vector<std::string> positional_sync_strings;
754 void toggle_send_midi_feedback ();
755 void toggle_use_mmc ();
756 void toggle_send_mmc ();
757 void toggle_send_mtc ();
758 void toggle_send_midi_clock ();
760 void toggle_use_osc ();
762 void parameter_changed (std::string);
763 void session_parameter_changed (std::string);
767 void check_memory_locking ();
769 void audioengine_setup ();
771 void display_message (const char *prefix, gint prefix_len,
772 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
774 Gtk::Label status_bar_label;
775 bool status_bar_button_press (GdkEventButton*);
777 void loading_message (const std::string& msg);
779 PBD::ScopedConnectionList forever_connections;
780 PBD::ScopedConnection halt_connection;
782 void step_edit_status_change (bool);
784 void platform_specific ();
785 void platform_setup ();
787 /* these are used only in response to a platform-specific "ShouldQuit" signal
790 void queue_finish ();
791 void fontconfig_dialog ();
793 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
794 int ambiguous_file (std::string file, std::vector<std::string> hits);
796 bool click_button_clicked (GdkEventButton *);
798 VisibilityGroup _status_bar_visibility;
800 /** A ProcessThread so that we have some thread-local buffers for use by
801 * PluginEqGui::impulse_analysis ().
803 ARDOUR::ProcessThread* _process_thread;
805 void feedback_detected ();
807 ArdourButton midi_panic_button;
810 void successful_graph_sort ();
811 bool _feedback_exists;
813 enum ArdourLogLevel {
820 ArdourLogLevel _log_not_acknowledged;
822 void resize_text_widgets ();
824 bool xrun_button_release (GdkEventButton* ev);
826 std::string _announce_string;
827 void check_announcements ();
829 int do_audio_midi_setup (uint32_t);
830 void audioengine_became_silent ();
832 DuplicateRouteDialog* duplicate_routes_dialog;
834 void grab_focus_after_dialog ();
836 void tabs_switch (GtkNotebookPage*, guint page_number);
837 void tabs_page_added (Gtk::Widget*, guint page_number);
838 void tabs_page_removed (Gtk::Widget*, guint page_number);
839 bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev, Gtkmm2ext::Bindings*);
840 bool try_gtk_accel_binding (GtkWindow* win, GdkEventKey* ev, bool translate, GdkModifierType modifier);
842 bool main_window_delete_event (GdkEventAny*);
843 bool idle_ask_about_quit ();
846 #endif /* __ardour_gui_h__ */