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>
56 #include <gtkmm2ext/gtk_ui.h>
57 #include <gtkmm2ext/click_box.h>
58 #include <gtkmm2ext/stateful_button.h>
59 #include <gtkmm2ext/bindable_button.h>
61 #include "ardour/ardour.h"
62 #include "ardour/types.h"
63 #include "ardour/utils.h"
64 #include "ardour/plugin.h"
65 #include "ardour/session_handle.h"
66 #include "ardour/system_exec.h"
68 #include "video_timeline.h"
70 #include "add_route_dialog.h"
71 #include "ardour_button.h"
72 #include "ardour_dialog.h"
73 #include "ardour_window.h"
76 #include "visibility_group.h"
77 #include "window_manager.h"
81 #include "add_video_dialog.h"
82 #include "big_clock_window.h"
83 #include "bundle_manager.h"
84 #include "engine_dialog.h"
85 #include "export_video_dialog.h"
86 #include "global_port_matrix.h"
87 #include "keyeditor.h"
88 #include "location_ui.h"
89 #include "rc_option_editor.h"
90 #include "route_params_ui.h"
91 #include "session_option_editor.h"
92 #include "speaker_dialog.h"
100 class ExportVideoDialog;
102 class LocationUIWindow;
103 class RCOptionEditor;
104 class RouteParams_UI;
105 class SessionOptionEditor;
107 class GlobalPortMatrixWindow;
111 class ArdourKeyboard;
114 class ConnectionEditor;
120 class SessionOptionEditor;
121 class ShuttleControl;
127 class LevelMeterHBox;
128 class GUIObjectState;
131 class ControlProtocolInfo;
140 namespace Gtkmm2ext {
148 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
151 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
154 bool run_startup (bool should_be_new, std::string load_template);
160 void launch_manual ();
161 void launch_reference ();
162 void launch_tracker ();
163 void launch_subscribe ();
164 void launch_cheat_sheet ();
165 void launch_website ();
166 void launch_website_dev ();
167 void launch_forums ();
168 void launch_howto_report ();
172 void load_from_application_api (const std::string& path);
175 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
177 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
178 bool session_is_new() const { return _session_is_new; }
180 ARDOUR::Session* the_session() { return _session; }
182 bool get_smart_mode () const;
184 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
185 int build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
186 bool ask_about_loading_existing_session (const std::string& session_path);
188 /// @return true if session was successfully unloaded.
189 int unload_session (bool hide_stuff = false);
190 void close_session();
192 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
193 void save_state (const std::string & state_name = "", bool switch_to_it = false);
195 static ARDOUR_UI *instance () { return theArdourUI; }
197 PublicEditor& the_editor() { return *editor;}
198 Mixer_UI* the_mixer() { return mixer; }
200 void new_midi_tracer_window ();
201 void toggle_editing_space();
202 void toggle_mixer_space();
203 void toggle_keep_tearoffs();
205 static PublicEditor* _instance;
207 /** Emitted frequently with the audible frame, false, and the edit point as
208 * parameters respectively.
210 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
212 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
214 static void close_all_dialogs () { CloseAllDialogs(); }
215 static sigc::signal<void> CloseAllDialogs;
217 XMLNode* editor_settings() const;
218 XMLNode* mixer_settings () const;
219 XMLNode* keyboard_settings () const;
220 XMLNode* tearoff_settings (const char*) const;
222 void save_ardour_state ();
223 gboolean configure_handler (GdkEventConfigure* conf);
225 void halt_on_xrun_message ();
226 void xrun_handler (framepos_t);
227 void create_xrun_marker (framepos_t);
229 GUIObjectState* gui_object_state;
231 MainClock* primary_clock;
232 MainClock* secondary_clock;
233 void focus_on_clock ();
234 AudioClock* big_clock;
236 TimeInfoBox* time_info_box;
238 VideoTimeLine *video_timeline;
240 void store_clock_modes ();
241 void restore_clock_modes ();
242 void reset_main_clocks ();
244 void synchronize_sync_source_and_video_pullup ();
246 void add_route (Gtk::Window* float_window);
247 void add_routes_part_two ();
248 void add_routes_thread ();
250 void add_video (Gtk::Window* float_window);
251 void remove_video ();
252 void start_video_server_menu (Gtk::Window* float_window);
253 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
254 void stop_video_server (bool ask_confirm=false);
255 void flush_videotimeline_cache (bool localcacheonly=false);
256 void export_video (bool range = false);
258 void session_add_audio_track (
260 int32_t output_channels,
261 ARDOUR::TrackMode mode,
262 ARDOUR::RouteGroup* route_group,
264 std::string const & name_template
267 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
270 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
271 uint32_t how_many, std::string const & name_template) {
272 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
275 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
276 ARDOUR::PluginInfoPtr instrument) {
277 session_add_midi_route (true, route_group, how_many, name_template, instrument);
280 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,
281 ARDOUR::PluginInfoPtr instrument);
283 /*void session_add_midi_bus () {
284 session_add_midi_route (false);
287 void attach_to_engine ();
290 gint exit_on_main_window_close (GdkEventAny *);
292 void maximise_editing_space ();
293 void restore_editing_space ();
295 void show_ui_prefs ();
297 bool check_audioengine(Gtk::Window&);
299 void update_tearoff_visibility ();
301 void setup_profile ();
302 void setup_tooltips ();
304 void set_shuttle_fract (double);
306 void get_process_buffers ();
307 void drop_process_buffers ();
309 void reset_peak_display ();
310 void reset_route_peak_display (ARDOUR::Route*);
311 void reset_group_peak_display (ARDOUR::RouteGroup*);
313 const std::string& announce_string() const { return _announce_string; }
315 void hide_application ();
318 friend class PublicEditor;
320 void toggle_auto_play ();
321 void toggle_auto_input ();
322 void toggle_punch ();
323 void unset_dual_punch ();
324 bool ignore_dual_punch;
325 void toggle_punch_in ();
326 void toggle_punch_out ();
327 void show_loop_punch_ruler_and_disallow_hide ();
328 void reenable_hide_loop_punch_ruler_if_appropriate ();
329 void toggle_auto_return ();
330 void toggle_click ();
331 void toggle_audio_midi_setup ();
332 void toggle_session_auto_loop ();
333 void toggle_rc_options_window ();
334 void toggle_session_options_window ();
337 PublicEditor* editor;
342 bool _initial_verbose_plugin_scan;
343 bool first_time_engine_run;
345 void goto_editor_window ();
346 void goto_mixer_window ();
347 void toggle_mixer_window ();
348 void toggle_meterbridge ();
349 void toggle_editor_mixer ();
351 int setup_windows ();
352 void setup_transport ();
355 static ARDOUR_UI *theArdourUI;
359 int ask_about_saving_session (const std::vector<std::string>& actions);
361 void save_session_at_its_request (std::string);
362 /* periodic safety backup, to be precise */
363 gint autosave_session();
364 void update_autosave();
365 sigc::connection _autosave_connection;
367 void map_transport_state ();
368 int32_t do_engine_start ();
370 void engine_halted (const char* reason, bool free_reason);
371 void engine_stopped ();
372 void engine_running ();
376 void about_signal_response(int response);
378 Gtk::VBox top_packer;
380 sigc::connection clock_signal_connection;
381 void update_clocks ();
382 void start_clocking ();
383 void stop_clocking ();
385 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
387 void update_transport_clocks (framepos_t pos);
388 void record_state_changed ();
390 std::list<MidiTracer*> _midi_tracer_windows;
392 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
393 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
394 void reattach_all_tearoffs ();
396 /* Transport Control */
398 Gtkmm2ext::TearOff* transport_tearoff;
399 Gtk::Frame transport_frame;
400 Gtk::HBox transport_tearoff_hbox;
401 Gtk::HBox transport_hbox;
402 Gtk::Fixed transport_base;
403 Gtk::Fixed transport_button_base;
404 Gtk::Frame transport_button_frame;
405 Gtk::HBox transport_button_hbox;
406 Gtk::VBox transport_button_vbox;
407 Gtk::HBox transport_option_button_hbox;
408 Gtk::VBox transport_option_button_vbox;
409 Gtk::HBox transport_clock_hbox;
410 Gtk::VBox transport_clock_vbox;
411 Gtk::HBox primary_clock_hbox;
412 Gtk::HBox secondary_clock_hbox;
414 struct TransportControllable : public PBD::Controllable {
425 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
426 void set_value (double);
427 double get_value (void) const;
433 boost::shared_ptr<TransportControllable> roll_controllable;
434 boost::shared_ptr<TransportControllable> stop_controllable;
435 boost::shared_ptr<TransportControllable> goto_start_controllable;
436 boost::shared_ptr<TransportControllable> goto_end_controllable;
437 boost::shared_ptr<TransportControllable> auto_loop_controllable;
438 boost::shared_ptr<TransportControllable> play_selection_controllable;
439 boost::shared_ptr<TransportControllable> rec_controllable;
441 void toggle_follow_edits ();
443 void set_transport_controllable_state (const XMLNode&);
444 XMLNode& get_transport_controllable_state ();
446 ArdourButton roll_button;
447 ArdourButton stop_button;
448 ArdourButton goto_start_button;
449 ArdourButton goto_end_button;
450 ArdourButton auto_loop_button;
451 ArdourButton play_selection_button;
452 ArdourButton rec_button;
454 void toggle_external_sync ();
455 void toggle_time_master ();
456 void toggle_video_sync ();
458 ShuttleControl* shuttle_box;
460 ArdourButton auto_return_button;
461 ArdourButton follow_edits_button;
462 ArdourButton auto_input_button;
463 ArdourButton click_button;
464 ArdourButton sync_button;
466 ArdourButton auditioning_alert_button;
467 ArdourButton solo_alert_button;
468 ArdourButton feedback_alert_button;
469 ArdourButton error_alert_button;
473 LevelMeterHBox * editor_meter;
474 float editor_meter_max_peak;
475 ArdourButton editor_meter_peak_display;
476 bool editor_meter_peak_button_release (GdkEventButton*);
478 void blink_handler (bool);
479 sigc::connection blink_connection;
482 void solo_blink (bool);
483 void sync_blink (bool);
484 void audition_blink (bool);
485 void feedback_blink (bool);
486 void error_blink (bool);
488 void set_flat_buttons();
490 void soloing_changed (bool);
491 void auditioning_changed (bool);
492 void _auditioning_changed (bool);
494 bool solo_alert_press (GdkEventButton* ev);
495 bool audition_alert_press (GdkEventButton* ev);
496 bool feedback_alert_press (GdkEventButton *);
497 bool error_alert_press (GdkEventButton *);
499 void big_clock_value_changed ();
500 void primary_clock_value_changed ();
501 void secondary_clock_value_changed ();
503 /* called by Blink signal */
505 void transport_rec_enable_blink (bool onoff);
507 Gtk::Menu* session_popup_menu;
509 /* menu bar and associated stuff */
511 Gtk::MenuBar* menu_bar;
512 Gtk::EventBox menu_bar_base;
515 void use_menubar_as_top_menubar ();
516 void build_menu_bar ();
518 Gtk::Label wall_clock_label;
519 gint update_wall_clock ();
521 Gtk::Label disk_space_label;
522 void update_disk_space ();
524 Gtk::Label timecode_format_label;
525 void update_timecode_format ();
527 Gtk::Label cpu_load_label;
528 void update_cpu_load ();
530 Gtk::Label xrun_label;
531 void update_xrun_count ();
533 Gtk::Label peak_thread_work_label;
534 void update_peak_thread_work ();
536 Gtk::Label buffer_load_label;
537 void update_buffer_load ();
539 Gtk::Label sample_rate_label;
540 void update_sample_rate (ARDOUR::framecnt_t);
542 Gtk::Label format_label;
543 void update_format ();
545 void every_second ();
546 void every_point_one_seconds ();
547 void every_point_zero_something_seconds ();
549 sigc::connection second_connection;
550 sigc::connection point_one_second_connection;
551 sigc::connection point_zero_something_second_connection;
552 sigc::connection fps_connection;
554 void set_fps_timeout_connection ();
556 void open_session ();
557 void open_recent_session ();
558 void save_template ();
560 void edit_metadata ();
561 void import_metadata ();
563 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
564 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
566 void set_transport_sensitivity (bool);
568 //stuff for ProTools-style numpad
569 void transport_numpad_event (int num);
570 void transport_numpad_decimal ();
571 bool _numpad_locate_happening;
572 int _pending_locate_num;
573 gint transport_numpad_timeout ();
574 sigc::connection _numpad_timeout_connection;
576 void transport_goto_nth_marker (int nth);
577 void transport_goto_zero ();
578 void transport_goto_start ();
579 void transport_goto_end ();
580 void transport_goto_wallclock ();
581 void transport_stop ();
582 void transport_record (bool roll);
583 void transport_roll ();
584 void transport_play_selection();
585 void transport_play_preroll();
586 void transport_forward (int option);
587 void transport_rewind (int option);
588 void transport_loop ();
589 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
590 bool trx_record_enable_all_tracks ();
592 bool _session_is_new;
593 void set_session (ARDOUR::Session *);
594 void connect_dependents_to_session (ARDOUR::Session *);
595 void we_have_dependents ();
597 void setup_session_options ();
599 guint32 last_key_press_time;
601 void snapshot_session (bool switch_to_it);
603 SaveAsDialog* save_as_dialog;
605 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
606 void save_session_as ();
607 void rename_session ();
608 void setup_order_hint (AddRouteDialog::InsertAt);
611 int create_editor ();
613 Meterbridge *meterbridge;
614 int create_meterbridge ();
615 /* Dialogs that can be created via new<T> */
617 WM::Proxy<SpeakerDialog> speaker_config_window;
618 WM::Proxy<KeyEditor> key_editor;
619 WM::Proxy<RCOptionEditor> rc_option_editor;
620 WM::Proxy<AddRouteDialog> add_route_dialog;
621 WM::Proxy<About> about;
622 WM::Proxy<LocationUIWindow> location_ui;
623 WM::Proxy<RouteParams_UI> route_params;
624 WM::Proxy<EngineControl> audio_midi_setup;
625 WM::Proxy<ExportVideoDialog> export_video_dialog;
627 /* Windows/Dialogs that require a creator method */
629 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
630 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
631 WM::ProxyWithConstructor<BundleManager> bundle_manager;
632 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
633 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
634 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
636 /* creator methods */
638 SessionOptionEditor* create_session_option_editor ();
639 BundleManager* create_bundle_manager ();
640 AddVideoDialog* create_add_video_dialog ();
641 BigClockWindow* create_big_clock_window();
642 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
644 ARDOUR::SystemExec *video_server_process;
646 void handle_locations_change (ARDOUR::Location*);
648 /* Keyboard Handling */
650 ArdourKeyboard* keyboard;
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&);
663 void pop_back_splash (Gtk::Window&);
667 Gtk::MenuItem *cleanup_item;
669 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
671 void cleanup_peakfiles ();
674 bool have_configure_timeout;
675 ARDOUR::microseconds_t last_configure_time;
676 gint configure_timeout ();
678 ARDOUR::microseconds_t last_peak_grab;
679 ARDOUR::microseconds_t last_shuttle_request;
681 bool have_disk_speed_dialog_displayed;
682 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
683 void disk_overrun_handler ();
684 void disk_underrun_handler ();
685 void gui_idle_handler ();
687 void cancel_plugin_scan ();
688 void cancel_plugin_timeout ();
689 void plugin_scan_dialog (std::string type, std::string plugin, bool);
690 void plugin_scan_timeout (int);
692 void session_format_mismatch (std::string, std::string);
694 void session_dialog (std::string);
695 int pending_state_dialog ();
696 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
698 Gtk::MenuItem* jack_disconnect_item;
699 Gtk::MenuItem* jack_reconnect_item;
700 Gtk::Menu* jack_bufsize_menu;
702 Glib::RefPtr<Gtk::ActionGroup> common_actions;
704 void editor_realized ();
706 std::vector<std::string> positional_sync_strings;
708 void toggle_send_midi_feedback ();
709 void toggle_use_mmc ();
710 void toggle_send_mmc ();
711 void toggle_send_mtc ();
712 void toggle_send_midi_clock ();
714 void toggle_use_osc ();
716 void parameter_changed (std::string);
717 void session_parameter_changed (std::string);
721 void check_memory_locking ();
723 void audioengine_setup ();
725 void display_message (const char *prefix, gint prefix_len,
726 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
728 Gtk::Label status_bar_label;
729 bool status_bar_button_press (GdkEventButton*);
731 void loading_message (const std::string& msg);
733 PBD::ScopedConnectionList forever_connections;
734 PBD::ScopedConnection halt_connection;
736 void step_edit_status_change (bool);
738 void platform_specific ();
739 void platform_setup ();
741 /* these are used only in response to a platform-specific "ShouldQuit" signal
744 void queue_finish ();
745 void fontconfig_dialog ();
747 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
748 int ambiguous_file (std::string file, std::vector<std::string> hits);
750 bool click_button_clicked (GdkEventButton *);
752 VisibilityGroup _status_bar_visibility;
754 /** A ProcessThread so that we have some thread-local buffers for use by
755 * PluginEqGui::impulse_analysis ().
757 ARDOUR::ProcessThread* _process_thread;
759 void feedback_detected ();
761 ArdourButton midi_panic_button;
764 void successful_graph_sort ();
765 bool _feedback_exists;
767 enum ArdourLogLevel {
774 ArdourLogLevel _log_not_acknowledged;
776 void resize_text_widgets ();
778 bool xrun_button_release (GdkEventButton* ev);
780 std::string _announce_string;
781 void check_announcements ();
783 int do_audio_midi_setup (uint32_t);
784 void audioengine_became_silent ();
787 #endif /* __ardour_gui_h__ */