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;
115 class DuplicateRouteDialog;
118 class ArdourPrompter;
122 class SessionOptionEditor;
123 class ShuttleControl;
129 class LevelMeterHBox;
130 class GUIObjectState;
133 class ControlProtocolInfo;
142 namespace Gtkmm2ext {
150 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
153 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
156 bool run_startup (bool should_be_new, std::string load_template);
162 void launch_manual ();
163 void launch_reference ();
164 void launch_tracker ();
165 void launch_subscribe ();
166 void launch_cheat_sheet ();
167 void launch_website ();
168 void launch_website_dev ();
169 void launch_forums ();
170 void launch_howto_report ();
174 void load_from_application_api (const std::string& path);
177 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
179 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
180 bool session_is_new() const { return _session_is_new; }
182 ARDOUR::Session* the_session() { return _session; }
184 bool get_smart_mode () const;
186 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
187 int build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
188 bool ask_about_loading_existing_session (const std::string& session_path);
190 /// @return true if session was successfully unloaded.
191 int unload_session (bool hide_stuff = false);
192 void close_session();
194 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
195 void save_state (const std::string & state_name = "", bool switch_to_it = false);
197 static ARDOUR_UI *instance () { return theArdourUI; }
199 PublicEditor& the_editor() { return *editor;}
200 Mixer_UI* the_mixer() { return mixer; }
202 void new_midi_tracer_window ();
203 void toggle_editing_space();
204 void toggle_mixer_space();
205 void toggle_mixer_list();
206 void toggle_monitor_section_visibility ();
207 void toggle_keep_tearoffs();
209 static PublicEditor* _instance;
211 /** Emitted frequently with the audible frame, false, and the edit point as
212 * parameters respectively.
214 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
216 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
218 static void close_all_dialogs () { CloseAllDialogs(); }
219 static sigc::signal<void> CloseAllDialogs;
221 XMLNode* editor_settings() const;
222 XMLNode* mixer_settings () const;
223 XMLNode* keyboard_settings () const;
224 XMLNode* tearoff_settings (const char*) const;
226 void save_ardour_state ();
227 gboolean configure_handler (GdkEventConfigure* conf);
229 void halt_on_xrun_message ();
230 void xrun_handler (framepos_t);
231 void create_xrun_marker (framepos_t);
233 GUIObjectState* gui_object_state;
235 MainClock* primary_clock;
236 MainClock* secondary_clock;
237 void focus_on_clock ();
238 AudioClock* big_clock;
240 TimeInfoBox* time_info_box;
242 VideoTimeLine *video_timeline;
244 void store_clock_modes ();
245 void restore_clock_modes ();
246 void reset_main_clocks ();
248 void synchronize_sync_source_and_video_pullup ();
250 void add_route (Gtk::Window* float_window);
251 void add_routes_part_two ();
252 void add_routes_thread ();
254 void start_duplicate_routes ();
256 void add_video (Gtk::Window* float_window);
257 void remove_video ();
258 void start_video_server_menu (Gtk::Window* float_window);
259 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
260 void stop_video_server (bool ask_confirm=false);
261 void flush_videotimeline_cache (bool localcacheonly=false);
262 void export_video (bool range = false);
264 void session_add_audio_track (
266 int32_t output_channels,
267 ARDOUR::TrackMode mode,
268 ARDOUR::RouteGroup* route_group,
270 std::string const & name_template
273 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
276 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
277 uint32_t how_many, std::string const & name_template) {
278 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
281 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
282 ARDOUR::PluginInfoPtr instrument) {
283 session_add_midi_route (true, route_group, how_many, name_template, instrument);
286 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,
287 ARDOUR::PluginInfoPtr instrument);
289 /*void session_add_midi_bus () {
290 session_add_midi_route (false);
293 void attach_to_engine ();
296 gint exit_on_main_window_close (GdkEventAny *);
298 void maximise_editing_space ();
299 void restore_editing_space ();
301 void show_ui_prefs ();
303 bool check_audioengine(Gtk::Window&);
305 void update_tearoff_visibility ();
307 void setup_profile ();
308 void setup_tooltips ();
310 void set_shuttle_fract (double);
312 void get_process_buffers ();
313 void drop_process_buffers ();
315 void reset_peak_display ();
316 void reset_route_peak_display (ARDOUR::Route*);
317 void reset_group_peak_display (ARDOUR::RouteGroup*);
319 const std::string& announce_string() const { return _announce_string; }
321 void hide_application ();
324 friend class PublicEditor;
326 void toggle_auto_play ();
327 void toggle_auto_input ();
328 void toggle_punch ();
329 void unset_dual_punch ();
330 bool ignore_dual_punch;
331 void toggle_punch_in ();
332 void toggle_punch_out ();
333 void show_loop_punch_ruler_and_disallow_hide ();
334 void reenable_hide_loop_punch_ruler_if_appropriate ();
335 void toggle_auto_return ();
336 void toggle_click ();
337 void toggle_audio_midi_setup ();
338 void toggle_session_auto_loop ();
339 void toggle_rc_options_window ();
340 void toggle_session_options_window ();
343 PublicEditor* editor;
348 bool _initial_verbose_plugin_scan;
349 bool first_time_engine_run;
351 void goto_editor_window ();
352 void goto_mixer_window ();
353 void toggle_mixer_window ();
354 void toggle_meterbridge ();
355 void toggle_editor_mixer ();
357 int setup_windows ();
358 void setup_transport ();
361 static ARDOUR_UI *theArdourUI;
362 SessionDialog *_session_dialog;
366 int ask_about_saving_session (const std::vector<std::string>& actions);
368 void save_session_at_its_request (std::string);
369 /* periodic safety backup, to be precise */
370 gint autosave_session();
371 void update_autosave();
372 sigc::connection _autosave_connection;
374 void map_transport_state ();
375 int32_t do_engine_start ();
377 void engine_halted (const char* reason, bool free_reason);
378 void engine_stopped ();
379 void engine_running ();
383 void about_signal_response(int response);
385 Gtk::VBox top_packer;
387 sigc::connection clock_signal_connection;
388 void update_clocks ();
389 void start_clocking ();
390 void stop_clocking ();
392 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
394 void update_transport_clocks (framepos_t pos);
395 void record_state_changed ();
397 std::list<MidiTracer*> _midi_tracer_windows;
399 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
400 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
401 void reattach_all_tearoffs ();
403 /* Transport Control */
405 Gtkmm2ext::TearOff* transport_tearoff;
406 Gtk::Frame transport_frame;
407 Gtk::HBox transport_tearoff_hbox;
408 Gtk::HBox transport_hbox;
409 Gtk::Fixed transport_base;
410 Gtk::Fixed transport_button_base;
411 Gtk::Frame transport_button_frame;
412 Gtk::HBox transport_button_hbox;
413 Gtk::VBox transport_button_vbox;
414 Gtk::HBox transport_option_button_hbox;
415 Gtk::VBox transport_option_button_vbox;
416 Gtk::HBox transport_clock_hbox;
417 Gtk::VBox transport_clock_vbox;
418 Gtk::HBox primary_clock_hbox;
419 Gtk::HBox secondary_clock_hbox;
421 struct TransportControllable : public PBD::Controllable {
432 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
433 void set_value (double, PBD::Controllable::GroupControlDisposition group_override);
434 double get_value (void) const;
440 boost::shared_ptr<TransportControllable> roll_controllable;
441 boost::shared_ptr<TransportControllable> stop_controllable;
442 boost::shared_ptr<TransportControllable> goto_start_controllable;
443 boost::shared_ptr<TransportControllable> goto_end_controllable;
444 boost::shared_ptr<TransportControllable> auto_loop_controllable;
445 boost::shared_ptr<TransportControllable> play_selection_controllable;
446 boost::shared_ptr<TransportControllable> rec_controllable;
448 void toggle_follow_edits ();
450 void set_transport_controllable_state (const XMLNode&);
451 XMLNode& get_transport_controllable_state ();
453 ArdourButton roll_button;
454 ArdourButton stop_button;
455 ArdourButton goto_start_button;
456 ArdourButton goto_end_button;
457 ArdourButton auto_loop_button;
458 ArdourButton play_selection_button;
459 ArdourButton rec_button;
461 void toggle_external_sync ();
462 void toggle_time_master ();
463 void toggle_video_sync ();
465 ShuttleControl* shuttle_box;
467 ArdourButton auto_return_button;
468 ArdourButton follow_edits_button;
469 ArdourButton auto_input_button;
470 ArdourButton click_button;
471 ArdourButton sync_button;
473 ArdourButton auditioning_alert_button;
474 ArdourButton solo_alert_button;
475 ArdourButton feedback_alert_button;
476 ArdourButton error_alert_button;
480 LevelMeterHBox * editor_meter;
481 float editor_meter_max_peak;
482 ArdourButton editor_meter_peak_display;
483 bool editor_meter_peak_button_release (GdkEventButton*);
485 void blink_handler (bool);
486 sigc::connection blink_connection;
489 void solo_blink (bool);
490 void sync_blink (bool);
491 void audition_blink (bool);
492 void feedback_blink (bool);
493 void error_blink (bool);
495 void set_flat_buttons();
497 void soloing_changed (bool);
498 void auditioning_changed (bool);
499 void _auditioning_changed (bool);
501 bool solo_alert_press (GdkEventButton* ev);
502 bool audition_alert_press (GdkEventButton* ev);
503 bool feedback_alert_press (GdkEventButton *);
504 bool error_alert_press (GdkEventButton *);
506 void big_clock_value_changed ();
507 void primary_clock_value_changed ();
508 void secondary_clock_value_changed ();
510 /* called by Blink signal */
512 void transport_rec_enable_blink (bool onoff);
514 Gtk::Menu* session_popup_menu;
516 /* menu bar and associated stuff */
518 Gtk::MenuBar* menu_bar;
519 Gtk::EventBox menu_bar_base;
522 void use_menubar_as_top_menubar ();
523 void build_menu_bar ();
525 Gtk::Label wall_clock_label;
526 gint update_wall_clock ();
528 Gtk::Label disk_space_label;
529 void update_disk_space ();
531 Gtk::Label timecode_format_label;
532 void update_timecode_format ();
534 Gtk::Label cpu_load_label;
535 void update_cpu_load ();
537 Gtk::Label xrun_label;
538 void update_xrun_count ();
540 Gtk::Label peak_thread_work_label;
541 void update_peak_thread_work ();
543 Gtk::Label buffer_load_label;
544 void update_buffer_load ();
546 Gtk::Label sample_rate_label;
547 void update_sample_rate (ARDOUR::framecnt_t);
549 Gtk::Label format_label;
550 void update_format ();
552 void every_second ();
553 void every_point_one_seconds ();
554 void every_point_zero_something_seconds ();
556 sigc::connection second_connection;
557 sigc::connection point_one_second_connection;
558 sigc::connection point_zero_something_second_connection;
559 sigc::connection fps_connection;
561 void set_fps_timeout_connection ();
563 void open_session ();
564 void open_recent_session ();
565 bool process_save_template_prompter (ArdourPrompter& prompter);
566 void save_template ();
568 void edit_metadata ();
569 void import_metadata ();
571 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
572 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
574 void set_transport_sensitivity (bool);
576 //stuff for ProTools-style numpad
577 void transport_numpad_event (int num);
578 void transport_numpad_decimal ();
579 bool _numpad_locate_happening;
580 int _pending_locate_num;
581 gint transport_numpad_timeout ();
582 sigc::connection _numpad_timeout_connection;
584 void transport_goto_nth_marker (int nth);
585 void transport_goto_zero ();
586 void transport_goto_start ();
587 void transport_goto_end ();
588 void transport_goto_wallclock ();
589 void transport_stop ();
590 void transport_record (bool roll);
591 void transport_roll ();
592 void transport_play_selection();
593 void transport_play_preroll();
594 void transport_forward (int option);
595 void transport_rewind (int option);
596 void transport_loop ();
597 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
598 bool trx_record_enable_all_tracks ();
600 bool _session_is_new;
601 void set_session (ARDOUR::Session *);
602 void connect_dependents_to_session (ARDOUR::Session *);
603 void we_have_dependents ();
605 void setup_session_options ();
607 guint32 last_key_press_time;
609 bool process_snapshot_session_prompter (ArdourPrompter& prompter, bool switch_to_it);
610 void snapshot_session (bool switch_to_it);
612 SaveAsDialog* save_as_dialog;
614 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
615 void save_session_as ();
616 void rename_session ();
617 void setup_order_hint (AddRouteDialog::InsertAt);
620 int create_editor ();
622 Meterbridge *meterbridge;
623 int create_meterbridge ();
624 /* Dialogs that can be created via new<T> */
626 WM::Proxy<SpeakerDialog> speaker_config_window;
627 WM::Proxy<KeyEditor> key_editor;
628 WM::Proxy<RCOptionEditor> rc_option_editor;
629 WM::Proxy<AddRouteDialog> add_route_dialog;
630 WM::Proxy<About> about;
631 WM::Proxy<LocationUIWindow> location_ui;
632 WM::Proxy<RouteParams_UI> route_params;
633 WM::Proxy<EngineControl> audio_midi_setup;
634 WM::Proxy<ExportVideoDialog> export_video_dialog;
636 /* Windows/Dialogs that require a creator method */
638 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
639 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
640 WM::ProxyWithConstructor<BundleManager> bundle_manager;
641 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
642 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
643 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
645 /* creator methods */
647 SessionOptionEditor* create_session_option_editor ();
648 BundleManager* create_bundle_manager ();
649 AddVideoDialog* create_add_video_dialog ();
650 BigClockWindow* create_big_clock_window();
651 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
653 ARDOUR::SystemExec *video_server_process;
655 void handle_locations_change (ARDOUR::Location*);
657 /* Keyboard Handling */
659 ArdourKeyboard* keyboard;
661 /* Keymap handling */
663 void install_actions ();
665 void toggle_record_enable (uint32_t);
667 uint32_t rec_enabled_streams;
668 void count_recenabled_streams (ARDOUR::Route&);
672 void pop_back_splash (Gtk::Window&);
676 Gtk::MenuItem *cleanup_item;
678 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
680 void cleanup_peakfiles ();
683 bool have_configure_timeout;
684 ARDOUR::microseconds_t last_configure_time;
685 gint configure_timeout ();
687 ARDOUR::microseconds_t last_peak_grab;
688 ARDOUR::microseconds_t last_shuttle_request;
690 bool have_disk_speed_dialog_displayed;
691 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
692 void disk_overrun_handler ();
693 void disk_underrun_handler ();
694 void gui_idle_handler ();
696 void cancel_plugin_scan ();
697 void cancel_plugin_timeout ();
698 void plugin_scan_dialog (std::string type, std::string plugin, bool);
699 void plugin_scan_timeout (int);
701 void session_format_mismatch (std::string, std::string);
703 void session_dialog (std::string);
704 int pending_state_dialog ();
705 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
707 Gtk::MenuItem* jack_disconnect_item;
708 Gtk::MenuItem* jack_reconnect_item;
709 Gtk::Menu* jack_bufsize_menu;
711 Glib::RefPtr<Gtk::ActionGroup> common_actions;
713 void editor_realized ();
715 std::vector<std::string> positional_sync_strings;
717 void toggle_send_midi_feedback ();
718 void toggle_use_mmc ();
719 void toggle_send_mmc ();
720 void toggle_send_mtc ();
721 void toggle_send_midi_clock ();
723 void toggle_use_osc ();
725 void parameter_changed (std::string);
726 void session_parameter_changed (std::string);
730 void check_memory_locking ();
732 void audioengine_setup ();
734 void display_message (const char *prefix, gint prefix_len,
735 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
737 Gtk::Label status_bar_label;
738 bool status_bar_button_press (GdkEventButton*);
740 void loading_message (const std::string& msg);
742 PBD::ScopedConnectionList forever_connections;
743 PBD::ScopedConnection halt_connection;
745 void step_edit_status_change (bool);
747 void platform_specific ();
748 void platform_setup ();
750 /* these are used only in response to a platform-specific "ShouldQuit" signal
753 void queue_finish ();
754 void fontconfig_dialog ();
756 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
757 int ambiguous_file (std::string file, std::vector<std::string> hits);
759 bool click_button_clicked (GdkEventButton *);
761 VisibilityGroup _status_bar_visibility;
763 /** A ProcessThread so that we have some thread-local buffers for use by
764 * PluginEqGui::impulse_analysis ().
766 ARDOUR::ProcessThread* _process_thread;
768 void feedback_detected ();
770 ArdourButton midi_panic_button;
773 void successful_graph_sort ();
774 bool _feedback_exists;
776 enum ArdourLogLevel {
783 ArdourLogLevel _log_not_acknowledged;
785 void resize_text_widgets ();
787 bool xrun_button_release (GdkEventButton* ev);
789 std::string _announce_string;
790 void check_announcements ();
792 int do_audio_midi_setup (uint32_t);
793 void audioengine_became_silent ();
795 DuplicateRouteDialog* duplicate_routes_dialog;
798 #endif /* __ardour_gui_h__ */