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* editor_settings() const;
224 XMLNode* mixer_settings () const;
225 XMLNode* keyboard_settings () const;
226 XMLNode* tearoff_settings (const char*) const;
228 void save_ardour_state ();
229 gboolean configure_handler (GdkEventConfigure* conf);
231 void halt_on_xrun_message ();
232 void xrun_handler (framepos_t);
233 void create_xrun_marker (framepos_t);
235 GUIObjectState* gui_object_state;
237 MainClock* primary_clock;
238 MainClock* secondary_clock;
239 void focus_on_clock ();
240 AudioClock* big_clock;
242 TimeInfoBox* time_info_box;
244 VideoTimeLine *video_timeline;
246 void store_clock_modes ();
247 void restore_clock_modes ();
248 void reset_main_clocks ();
250 void synchronize_sync_source_and_video_pullup ();
252 void add_route (Gtk::Window* float_window);
253 void add_routes_part_two ();
254 void add_routes_thread ();
256 void start_duplicate_routes ();
258 void add_video (Gtk::Window* float_window);
259 void remove_video ();
260 void start_video_server_menu (Gtk::Window* float_window);
261 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
262 void stop_video_server (bool ask_confirm=false);
263 void flush_videotimeline_cache (bool localcacheonly=false);
264 void export_video (bool range = false);
266 void session_add_audio_track (
268 int32_t output_channels,
269 ARDOUR::TrackMode mode,
270 ARDOUR::RouteGroup* route_group,
272 std::string const & name_template
275 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
278 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
279 uint32_t how_many, std::string const & name_template) {
280 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
283 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
284 ARDOUR::PluginInfoPtr instrument) {
285 session_add_midi_route (true, route_group, how_many, name_template, instrument);
288 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,
289 ARDOUR::PluginInfoPtr instrument);
291 /*void session_add_midi_bus () {
292 session_add_midi_route (false);
295 void attach_to_engine ();
298 gint exit_on_main_window_close (GdkEventAny *);
300 void maximise_editing_space ();
301 void restore_editing_space ();
303 void show_ui_prefs ();
305 bool check_audioengine(Gtk::Window&);
307 void update_tearoff_visibility ();
309 void setup_profile ();
310 void setup_tooltips ();
312 void set_shuttle_fract (double);
314 void get_process_buffers ();
315 void drop_process_buffers ();
317 void reset_peak_display ();
318 void reset_route_peak_display (ARDOUR::Route*);
319 void reset_group_peak_display (ARDOUR::RouteGroup*);
321 const std::string& announce_string() const { return _announce_string; }
323 void hide_application ();
325 Gtk::Notebook& tabs();
326 Gtk::Window& main_window () { return _main_window; }
328 void setup_toplevel_window (Gtk::Window&, const std::string& name, void* owner);
330 /* called from a static C function */
332 GtkNotebook* tab_window_root_drop (GtkNotebook* src,
338 bool tabbed_window_state_event_handler (GdkEventWindowState*, void* object);
339 bool key_event_handler (GdkEventKey*, Gtk::Window* window);
342 friend class PublicEditor;
344 void toggle_auto_play ();
345 void toggle_auto_input ();
346 void toggle_punch ();
347 void unset_dual_punch ();
348 bool ignore_dual_punch;
349 void toggle_punch_in ();
350 void toggle_punch_out ();
351 void show_loop_punch_ruler_and_disallow_hide ();
352 void reenable_hide_loop_punch_ruler_if_appropriate ();
353 void toggle_auto_return ();
354 void toggle_click ();
355 void toggle_audio_midi_setup ();
356 void toggle_session_auto_loop ();
357 void toggle_rc_options_window ();
358 void toggle_session_options_window ();
361 Gtk::Window _main_window;
362 Gtk::VBox main_vpacker;
363 Gtk::HBox status_bar_hpacker;
365 PublicEditor* editor;
367 Gtk::Tooltips _tooltips;
371 bool _initial_verbose_plugin_scan;
372 bool first_time_engine_run;
374 Gtkmm2ext::Bindings _global_bindings;
376 void goto_editor_window ();
377 void goto_mixer_window ();
378 void toggle_mixer_window ();
379 void toggle_meterbridge ();
380 void toggle_editor_mixer ();
382 int setup_windows ();
383 void setup_transport ();
386 static ARDOUR_UI *theArdourUI;
387 SessionDialog *_session_dialog;
391 int ask_about_saving_session (const std::vector<std::string>& actions);
393 void save_session_at_its_request (std::string);
394 /* periodic safety backup, to be precise */
395 gint autosave_session();
396 void update_autosave();
397 sigc::connection _autosave_connection;
399 void session_dirty_changed ();
400 void update_title ();
402 void map_transport_state ();
403 int32_t do_engine_start ();
405 void engine_halted (const char* reason, bool free_reason);
406 void engine_stopped ();
407 void engine_running ();
411 void about_signal_response(int response);
413 Gtk::VBox top_packer;
415 sigc::connection clock_signal_connection;
416 void update_clocks ();
417 void start_clocking ();
418 void stop_clocking ();
420 void update_transport_clocks (framepos_t pos);
421 void record_state_changed ();
423 std::list<MidiTracer*> _midi_tracer_windows;
425 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
426 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
427 void reattach_all_tearoffs ();
429 /* Transport Control */
431 Gtkmm2ext::TearOff* transport_tearoff;
432 Gtk::Frame transport_frame;
433 Gtk::HBox transport_tearoff_hbox;
434 Gtk::HBox transport_hbox;
435 Gtk::Fixed transport_base;
436 Gtk::Fixed transport_button_base;
437 Gtk::Frame transport_button_frame;
438 Gtk::HBox transport_button_hbox;
439 Gtk::VBox transport_button_vbox;
440 Gtk::HBox transport_option_button_hbox;
441 Gtk::VBox transport_option_button_vbox;
442 Gtk::HBox transport_clock_hbox;
443 Gtk::VBox transport_clock_vbox;
444 Gtk::HBox primary_clock_hbox;
445 Gtk::HBox secondary_clock_hbox;
447 struct TransportControllable : public PBD::Controllable {
458 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
459 void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
460 double get_value (void) const;
466 boost::shared_ptr<TransportControllable> roll_controllable;
467 boost::shared_ptr<TransportControllable> stop_controllable;
468 boost::shared_ptr<TransportControllable> goto_start_controllable;
469 boost::shared_ptr<TransportControllable> goto_end_controllable;
470 boost::shared_ptr<TransportControllable> auto_loop_controllable;
471 boost::shared_ptr<TransportControllable> play_selection_controllable;
472 boost::shared_ptr<TransportControllable> rec_controllable;
474 void toggle_follow_edits ();
476 void set_transport_controllable_state (const XMLNode&);
477 XMLNode& get_transport_controllable_state ();
479 ArdourButton roll_button;
480 ArdourButton stop_button;
481 ArdourButton goto_start_button;
482 ArdourButton goto_end_button;
483 ArdourButton auto_loop_button;
484 ArdourButton play_selection_button;
485 ArdourButton rec_button;
487 void toggle_external_sync ();
488 void toggle_time_master ();
489 void toggle_video_sync ();
491 ShuttleControl* shuttle_box;
493 ArdourButton auto_return_button;
494 ArdourButton follow_edits_button;
495 ArdourButton auto_input_button;
496 ArdourButton click_button;
497 ArdourButton sync_button;
499 ArdourButton auditioning_alert_button;
500 ArdourButton solo_alert_button;
501 ArdourButton feedback_alert_button;
502 ArdourButton error_alert_button;
506 LevelMeterHBox * editor_meter;
507 float editor_meter_max_peak;
508 ArdourButton editor_meter_peak_display;
509 bool editor_meter_peak_button_release (GdkEventButton*);
511 void blink_handler (bool);
512 sigc::connection blink_connection;
515 void solo_blink (bool);
516 void sync_blink (bool);
517 void audition_blink (bool);
518 void feedback_blink (bool);
519 void error_blink (bool);
521 void set_flat_buttons();
523 void soloing_changed (bool);
524 void auditioning_changed (bool);
525 void _auditioning_changed (bool);
527 bool solo_alert_press (GdkEventButton* ev);
528 bool audition_alert_press (GdkEventButton* ev);
529 bool feedback_alert_press (GdkEventButton *);
530 bool error_alert_press (GdkEventButton *);
532 void big_clock_value_changed ();
533 void primary_clock_value_changed ();
534 void secondary_clock_value_changed ();
536 /* called by Blink signal */
538 void transport_rec_enable_blink (bool onoff);
540 Gtk::Menu* session_popup_menu;
542 /* menu bar and associated stuff */
544 Gtk::MenuBar* menu_bar;
545 Gtk::EventBox menu_bar_base;
548 void use_menubar_as_top_menubar ();
549 void build_menu_bar ();
551 Gtk::Label wall_clock_label;
552 gint update_wall_clock ();
554 Gtk::Label disk_space_label;
555 void update_disk_space ();
557 Gtk::Label timecode_format_label;
558 void update_timecode_format ();
560 Gtk::Label cpu_load_label;
561 void update_cpu_load ();
563 Gtk::Label xrun_label;
564 void update_xrun_count ();
566 Gtk::Label peak_thread_work_label;
567 void update_peak_thread_work ();
569 Gtk::Label buffer_load_label;
570 void update_buffer_load ();
572 Gtk::Label sample_rate_label;
573 void update_sample_rate (ARDOUR::framecnt_t);
575 Gtk::Label format_label;
576 void update_format ();
578 void every_second ();
579 void every_point_one_seconds ();
580 void every_point_zero_something_seconds ();
582 sigc::connection second_connection;
583 sigc::connection point_one_second_connection;
584 sigc::connection point_zero_something_second_connection;
585 sigc::connection fps_connection;
587 void set_fps_timeout_connection ();
589 void open_session ();
590 void open_recent_session ();
591 bool process_save_template_prompter (ArdourPrompter& prompter);
592 void save_template ();
594 void edit_metadata ();
595 void import_metadata ();
597 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
598 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
600 void set_transport_sensitivity (bool);
602 //stuff for ProTools-style numpad
603 void transport_numpad_event (int num);
604 void transport_numpad_decimal ();
605 bool _numpad_locate_happening;
606 int _pending_locate_num;
607 gint transport_numpad_timeout ();
608 sigc::connection _numpad_timeout_connection;
610 void transport_goto_nth_marker (int nth);
611 void transport_goto_zero ();
612 void transport_goto_start ();
613 void transport_goto_end ();
614 void transport_goto_wallclock ();
615 void transport_stop ();
616 void transport_record (bool roll);
617 void transport_roll ();
618 void transport_play_selection();
619 void transport_play_preroll();
620 void transport_forward (int option);
621 void transport_rewind (int option);
622 void transport_loop ();
623 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
624 bool trx_record_enable_all_tracks ();
626 bool _session_is_new;
627 void set_session (ARDOUR::Session *);
628 void connect_dependents_to_session (ARDOUR::Session *);
629 void we_have_dependents ();
631 void setup_session_options ();
633 guint32 last_key_press_time;
635 bool process_snapshot_session_prompter (ArdourPrompter& prompter, bool switch_to_it);
636 void snapshot_session (bool switch_to_it);
638 void quick_snapshot_session (bool switch_to_it); //does not promtp for name, just makes a timestamped file
640 SaveAsDialog* save_as_dialog;
642 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
643 void save_session_as ();
644 void rename_session ();
645 void setup_order_hint (AddRouteDialog::InsertAt);
648 int create_editor ();
650 Meterbridge *meterbridge;
651 int create_meterbridge ();
653 /* Dialogs that can be created via new<T> */
655 RCOptionEditor* rc_option_editor;
656 Gtk::HBox rc_option_editor_placeholder;
658 WM::Proxy<SpeakerDialog> speaker_config_window;
659 WM::Proxy<KeyEditor> key_editor;
660 WM::Proxy<AddRouteDialog> add_route_dialog;
661 WM::Proxy<About> about;
662 WM::Proxy<LocationUIWindow> location_ui;
663 WM::Proxy<RouteParams_UI> route_params;
664 WM::Proxy<EngineControl> audio_midi_setup;
665 WM::Proxy<ExportVideoDialog> export_video_dialog;
667 /* Windows/Dialogs that require a creator method */
669 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
670 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
671 WM::ProxyWithConstructor<BundleManager> bundle_manager;
672 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
673 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
674 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
676 /* creator methods */
678 SessionOptionEditor* create_session_option_editor ();
679 BundleManager* create_bundle_manager ();
680 AddVideoDialog* create_add_video_dialog ();
681 BigClockWindow* create_big_clock_window();
682 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
684 ARDOUR::SystemExec *video_server_process;
686 void handle_locations_change (ARDOUR::Location*);
688 /* Keyboard Handling */
690 ArdourKeyboard* keyboard;
692 /* Keymap handling */
694 void install_actions ();
696 void toggle_record_enable (uint32_t);
698 uint32_t rec_enabled_streams;
699 void count_recenabled_streams (ARDOUR::Route&);
703 void pop_back_splash (Gtk::Window&);
707 Gtk::MenuItem *cleanup_item;
709 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
711 void cleanup_peakfiles ();
714 bool have_configure_timeout;
715 ARDOUR::microseconds_t last_configure_time;
716 gint configure_timeout ();
718 ARDOUR::microseconds_t last_peak_grab;
719 ARDOUR::microseconds_t last_shuttle_request;
721 bool have_disk_speed_dialog_displayed;
722 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
723 void disk_overrun_handler ();
724 void disk_underrun_handler ();
725 void gui_idle_handler ();
727 void cancel_plugin_scan ();
728 void cancel_plugin_timeout ();
729 void plugin_scan_dialog (std::string type, std::string plugin, bool);
730 void plugin_scan_timeout (int);
732 void session_format_mismatch (std::string, std::string);
734 void session_dialog (std::string);
735 int pending_state_dialog ();
736 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
738 Gtk::MenuItem* jack_disconnect_item;
739 Gtk::MenuItem* jack_reconnect_item;
740 Gtk::Menu* jack_bufsize_menu;
742 Glib::RefPtr<Gtk::ActionGroup> common_actions;
744 void editor_realized ();
746 std::vector<std::string> positional_sync_strings;
748 void toggle_send_midi_feedback ();
749 void toggle_use_mmc ();
750 void toggle_send_mmc ();
751 void toggle_send_mtc ();
752 void toggle_send_midi_clock ();
754 void toggle_use_osc ();
756 void parameter_changed (std::string);
757 void session_parameter_changed (std::string);
761 void check_memory_locking ();
763 void audioengine_setup ();
765 void display_message (const char *prefix, gint prefix_len,
766 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
768 Gtk::Label status_bar_label;
769 bool status_bar_button_press (GdkEventButton*);
771 void loading_message (const std::string& msg);
773 PBD::ScopedConnectionList forever_connections;
774 PBD::ScopedConnection halt_connection;
776 void step_edit_status_change (bool);
778 void platform_specific ();
779 void platform_setup ();
781 /* these are used only in response to a platform-specific "ShouldQuit" signal
784 void queue_finish ();
785 void fontconfig_dialog ();
787 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
788 int ambiguous_file (std::string file, std::vector<std::string> hits);
790 bool click_button_clicked (GdkEventButton *);
792 VisibilityGroup _status_bar_visibility;
794 /** A ProcessThread so that we have some thread-local buffers for use by
795 * PluginEqGui::impulse_analysis ().
797 ARDOUR::ProcessThread* _process_thread;
799 void feedback_detected ();
801 ArdourButton midi_panic_button;
804 void successful_graph_sort ();
805 bool _feedback_exists;
807 enum ArdourLogLevel {
814 ArdourLogLevel _log_not_acknowledged;
816 void resize_text_widgets ();
818 bool xrun_button_release (GdkEventButton* ev);
820 std::string _announce_string;
821 void check_announcements ();
823 int do_audio_midi_setup (uint32_t);
824 void audioengine_became_silent ();
826 DuplicateRouteDialog* duplicate_routes_dialog;
828 void grab_focus_after_dialog ();
830 void tabs_switch (GtkNotebookPage*, guint page_number);
831 void tabs_page_added (Gtk::Widget*, guint page_number);
832 void tabs_page_removed (Gtk::Widget*, guint page_number);
833 bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev, Gtkmm2ext::Bindings*);
836 #endif /* __ardour_gui_h__ */