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"
71 #include "ardour_button.h"
72 #include "ardour_dialog.h"
73 #include "ardour_window.h"
75 #include "engine_dialog.h"
76 #include "export_video_dialog.h"
77 #include "meterbridge.h"
78 #include "ui_config.h"
80 #include "visibility_group.h"
81 #include "window_manager.h"
83 #include "add_route_dialog.h"
84 #include "add_video_dialog.h"
85 #include "big_clock_window.h"
86 #include "bundle_manager.h"
87 #include "global_port_matrix.h"
88 #include "keyeditor.h"
89 #include "location_ui.h"
90 #include "rc_option_editor.h"
91 #include "route_params_ui.h"
92 #include "session_option_editor.h"
93 #include "speaker_dialog.h"
99 class ConnectionEditor;
103 class RCOptionEditor;
104 class RouteParams_UI;
107 class SessionOptionEditor;
108 class ShuttleControl;
113 class LevelMeterHBox;
114 class GUIObjectState;
117 class ControlProtocolInfo;
126 namespace Gtkmm2ext {
134 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
137 /* This must be the first data element because constructor ordering
140 UIConfiguration* ui_config;
143 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir, UIConfiguration*);
146 bool run_startup (bool should_be_new, std::string load_template);
152 void launch_manual ();
153 void launch_reference ();
154 void launch_tracker ();
155 void launch_subscribe ();
156 void launch_cheat_sheet ();
157 void launch_website ();
158 void launch_website_dev ();
159 void launch_forums ();
160 void launch_howto_report ();
164 void load_from_application_api (const std::string& path);
167 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
169 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
170 bool session_is_new() const { return _session_is_new; }
172 ARDOUR::Session* the_session() { return _session; }
174 bool get_smart_mode () const;
176 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
177 int build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
178 bool ask_about_loading_existing_session (const std::string& session_path);
180 /// @return true if session was successfully unloaded.
181 int unload_session (bool hide_stuff = false);
182 void close_session();
184 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
185 void save_state (const std::string & state_name = "", bool switch_to_it = false);
187 static ARDOUR_UI *instance () { return theArdourUI; }
188 static UIConfiguration *config () { return theArdourUI->ui_config; }
190 PublicEditor& the_editor() { return *editor;}
191 Mixer_UI* the_mixer() { return mixer; }
193 void new_midi_tracer_window ();
194 void toggle_editing_space();
195 void toggle_mixer_space();
196 void toggle_keep_tearoffs();
198 Gtk::Tooltips& tooltips() { return _tooltips; }
200 static PublicEditor* _instance;
202 /** Emitted frequently with the audible frame, false, and the edit point as
203 * parameters respectively.
205 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
207 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
209 static void close_all_dialogs () { CloseAllDialogs(); }
210 static sigc::signal<void> CloseAllDialogs;
212 XMLNode* editor_settings() const;
213 XMLNode* mixer_settings () const;
214 XMLNode* keyboard_settings () const;
215 XMLNode* tearoff_settings (const char*) const;
217 void save_ardour_state ();
218 gboolean configure_handler (GdkEventConfigure* conf);
220 void halt_on_xrun_message ();
221 void xrun_handler (framepos_t);
222 void create_xrun_marker (framepos_t);
224 GUIObjectState* gui_object_state;
226 MainClock* primary_clock;
227 MainClock* secondary_clock;
228 void focus_on_clock ();
229 AudioClock* big_clock;
231 TimeInfoBox* time_info_box;
233 VideoTimeLine *video_timeline;
235 void store_clock_modes ();
236 void restore_clock_modes ();
237 void reset_main_clocks ();
239 void synchronize_sync_source_and_video_pullup ();
241 void add_route (Gtk::Window* float_window);
242 void add_routes_part_two ();
243 void add_routes_thread ();
245 void add_video (Gtk::Window* float_window);
246 void remove_video ();
247 void start_video_server_menu (Gtk::Window* float_window);
248 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
249 void stop_video_server (bool ask_confirm=false);
250 void flush_videotimeline_cache (bool localcacheonly=false);
251 void export_video (bool range = false);
253 void session_add_audio_track (
255 int32_t output_channels,
256 ARDOUR::TrackMode mode,
257 ARDOUR::RouteGroup* route_group,
259 std::string const & name_template
262 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
265 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
266 uint32_t how_many, std::string const & name_template) {
267 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
270 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
271 ARDOUR::PluginInfoPtr instrument) {
272 session_add_midi_route (true, route_group, how_many, name_template, instrument);
275 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,
276 ARDOUR::PluginInfoPtr instrument);
278 /*void session_add_midi_bus () {
279 session_add_midi_route (false);
282 void attach_to_engine ();
285 gint exit_on_main_window_close (GdkEventAny *);
287 void maximise_editing_space ();
288 void restore_editing_space ();
290 void show_ui_prefs ();
292 void update_tearoff_visibility ();
294 void setup_profile ();
295 void setup_tooltips ();
297 void set_shuttle_fract (double);
299 void get_process_buffers ();
300 void drop_process_buffers ();
302 void reset_peak_display ();
303 void reset_route_peak_display (ARDOUR::Route*);
304 void reset_group_peak_display (ARDOUR::RouteGroup*);
306 const std::string& announce_string() const { return _announce_string; }
308 int disconnect_from_engine ();
309 int reconnect_to_engine ();
310 void hide_application ();
313 friend class PublicEditor;
315 void toggle_auto_play ();
316 void toggle_auto_input ();
317 void toggle_punch ();
318 void unset_dual_punch ();
319 bool ignore_dual_punch;
320 void toggle_punch_in ();
321 void toggle_punch_out ();
322 void show_loop_punch_ruler_and_disallow_hide ();
323 void reenable_hide_loop_punch_ruler_if_appropriate ();
324 void toggle_auto_return ();
325 void toggle_click ();
326 void toggle_audio_midi_setup ();
327 void toggle_session_auto_loop ();
328 void toggle_rc_options_window ();
329 void toggle_session_options_window ();
332 PublicEditor* editor;
334 Gtk::Tooltips _tooltips;
338 bool _initial_verbose_plugin_scan;
339 bool first_time_engine_run;
341 void goto_editor_window ();
342 void goto_mixer_window ();
343 void toggle_mixer_window ();
344 void toggle_meterbridge ();
345 void toggle_editor_mixer ();
347 int setup_windows ();
348 void setup_transport ();
351 static ARDOUR_UI *theArdourUI;
355 int ask_about_saving_session (const std::vector<std::string>& actions);
357 void save_session_at_its_request (std::string);
358 /* periodic safety backup, to be precise */
359 gint autosave_session();
360 void update_autosave();
361 sigc::connection _autosave_connection;
363 void map_transport_state ();
364 int32_t do_engine_start ();
366 void engine_halted (const char* reason, bool free_reason);
367 void engine_stopped ();
368 void engine_running ();
372 void about_signal_response(int response);
374 Gtk::VBox top_packer;
376 sigc::connection clock_signal_connection;
377 void update_clocks ();
378 void start_clocking ();
379 void stop_clocking ();
381 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
383 void update_transport_clocks (framepos_t pos);
384 void record_state_changed ();
386 std::list<MidiTracer*> _midi_tracer_windows;
388 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
389 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
390 void reattach_all_tearoffs ();
392 /* Transport Control */
394 Gtkmm2ext::TearOff* transport_tearoff;
395 Gtk::Frame transport_frame;
396 Gtk::HBox transport_tearoff_hbox;
397 Gtk::HBox transport_hbox;
398 Gtk::Fixed transport_base;
399 Gtk::Fixed transport_button_base;
400 Gtk::Frame transport_button_frame;
401 Gtk::HBox transport_button_hbox;
402 Gtk::VBox transport_button_vbox;
403 Gtk::HBox transport_option_button_hbox;
404 Gtk::VBox transport_option_button_vbox;
405 Gtk::HBox transport_clock_hbox;
406 Gtk::VBox transport_clock_vbox;
407 Gtk::HBox primary_clock_hbox;
408 Gtk::HBox secondary_clock_hbox;
410 struct TransportControllable : public PBD::Controllable {
421 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
422 void set_value (double);
423 double get_value (void) const;
429 boost::shared_ptr<TransportControllable> roll_controllable;
430 boost::shared_ptr<TransportControllable> stop_controllable;
431 boost::shared_ptr<TransportControllable> goto_start_controllable;
432 boost::shared_ptr<TransportControllable> goto_end_controllable;
433 boost::shared_ptr<TransportControllable> auto_loop_controllable;
434 boost::shared_ptr<TransportControllable> play_selection_controllable;
435 boost::shared_ptr<TransportControllable> rec_controllable;
437 void toggle_follow_edits ();
439 void set_transport_controllable_state (const XMLNode&);
440 XMLNode& get_transport_controllable_state ();
442 ArdourButton roll_button;
443 ArdourButton stop_button;
444 ArdourButton goto_start_button;
445 ArdourButton goto_end_button;
446 ArdourButton auto_loop_button;
447 ArdourButton play_selection_button;
448 ArdourButton rec_button;
450 void toggle_external_sync ();
451 void toggle_time_master ();
452 void toggle_video_sync ();
454 ShuttleControl* shuttle_box;
456 ArdourButton auto_return_button;
457 ArdourButton follow_edits_button;
458 ArdourButton auto_input_button;
459 ArdourButton click_button;
460 ArdourButton sync_button;
462 ArdourButton auditioning_alert_button;
463 ArdourButton solo_alert_button;
464 ArdourButton feedback_alert_button;
465 ArdourButton error_alert_button;
469 LevelMeterHBox * editor_meter;
470 float editor_meter_max_peak;
471 ArdourButton editor_meter_peak_display;
472 bool editor_meter_peak_button_release (GdkEventButton*);
474 void blink_handler (bool);
475 sigc::connection blink_connection;
477 void solo_blink (bool);
478 void sync_blink (bool);
479 void audition_blink (bool);
480 void feedback_blink (bool);
481 void error_blink (bool);
483 void set_flat_buttons();
485 void soloing_changed (bool);
486 void auditioning_changed (bool);
487 void _auditioning_changed (bool);
489 bool solo_alert_press (GdkEventButton* ev);
490 bool audition_alert_press (GdkEventButton* ev);
491 bool feedback_alert_press (GdkEventButton *);
492 bool error_alert_press (GdkEventButton *);
494 void big_clock_value_changed ();
495 void primary_clock_value_changed ();
496 void secondary_clock_value_changed ();
498 /* called by Blink signal */
500 void transport_rec_enable_blink (bool onoff);
502 Gtk::Menu* session_popup_menu;
504 /* menu bar and associated stuff */
506 Gtk::MenuBar* menu_bar;
507 Gtk::EventBox menu_bar_base;
510 void use_menubar_as_top_menubar ();
511 void build_menu_bar ();
513 Gtk::Label wall_clock_label;
514 gint update_wall_clock ();
516 Gtk::Label disk_space_label;
517 void update_disk_space ();
519 Gtk::Label timecode_format_label;
520 void update_timecode_format ();
522 Gtk::Label cpu_load_label;
523 void update_cpu_load ();
525 Gtk::Label xrun_label;
526 void update_xrun_count ();
528 Gtk::Label peak_thread_work_label;
529 void update_peak_thread_work ();
531 Gtk::Label buffer_load_label;
532 void update_buffer_load ();
534 Gtk::Label sample_rate_label;
535 void update_sample_rate (ARDOUR::framecnt_t);
537 Gtk::Label format_label;
538 void update_format ();
540 void every_second ();
541 void every_point_one_seconds ();
542 void every_point_zero_something_seconds ();
544 sigc::connection second_connection;
545 sigc::connection point_one_second_connection;
546 sigc::connection point_zero_something_second_connection;
547 sigc::connection fps_connection;
549 void set_fps_timeout_connection ();
551 void open_session ();
552 void open_recent_session ();
553 void save_template ();
555 void edit_metadata ();
556 void import_metadata ();
558 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
559 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
561 void set_transport_sensitivity (bool);
563 //stuff for ProTools-style numpad
564 void transport_numpad_event (int num);
565 void transport_numpad_decimal ();
566 bool _numpad_locate_happening;
567 int _pending_locate_num;
568 gint transport_numpad_timeout ();
569 sigc::connection _numpad_timeout_connection;
571 void transport_goto_nth_marker (int nth);
572 void transport_goto_zero ();
573 void transport_goto_start ();
574 void transport_goto_end ();
575 void transport_goto_wallclock ();
576 void transport_stop ();
577 void transport_record (bool roll);
578 void transport_roll ();
579 void transport_play_selection();
580 void transport_play_preroll();
581 void transport_forward (int option);
582 void transport_rewind (int option);
583 void transport_loop ();
584 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
585 bool trx_record_enable_all_tracks ();
587 bool _session_is_new;
588 void set_session (ARDOUR::Session *);
589 void connect_dependents_to_session (ARDOUR::Session *);
590 void we_have_dependents ();
592 void setup_session_options ();
594 guint32 last_key_press_time;
596 void snapshot_session (bool switch_to_it);
598 SaveAsDialog* save_as_dialog;
600 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
601 void save_session_as ();
602 void rename_session ();
603 void setup_order_hint (AddRouteDialog::InsertAt);
606 int create_editor ();
608 Meterbridge *meterbridge;
609 int create_meterbridge ();
610 /* Dialogs that can be created via new<T> */
612 WM::Proxy<SpeakerDialog> speaker_config_window;
613 WM::Proxy<KeyEditor> key_editor;
614 WM::Proxy<RCOptionEditor> rc_option_editor;
615 WM::Proxy<AddRouteDialog> add_route_dialog;
616 WM::Proxy<About> about;
617 WM::Proxy<LocationUIWindow> location_ui;
618 WM::Proxy<RouteParams_UI> route_params;
619 WM::Proxy<EngineControl> audio_midi_setup;
620 WM::Proxy<ExportVideoDialog> export_video_dialog;
622 /* Windows/Dialogs that require a creator method */
624 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
625 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
626 WM::ProxyWithConstructor<BundleManager> bundle_manager;
627 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
628 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
629 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
631 /* creator methods */
633 SessionOptionEditor* create_session_option_editor ();
634 BundleManager* create_bundle_manager ();
635 AddVideoDialog* create_add_video_dialog ();
636 BigClockWindow* create_big_clock_window();
637 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
639 ARDOUR::SystemExec *video_server_process;
641 void handle_locations_change (ARDOUR::Location*);
643 /* Keyboard Handling */
645 ArdourKeyboard* keyboard;
647 /* Keymap handling */
649 void install_actions ();
651 void toggle_record_enable (uint32_t);
653 uint32_t rec_enabled_streams;
654 void count_recenabled_streams (ARDOUR::Route&);
658 void pop_back_splash (Gtk::Window&);
662 Gtk::MenuItem *cleanup_item;
664 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
666 void cleanup_peakfiles ();
669 bool have_configure_timeout;
670 ARDOUR::microseconds_t last_configure_time;
671 gint configure_timeout ();
673 ARDOUR::microseconds_t last_peak_grab;
674 ARDOUR::microseconds_t last_shuttle_request;
676 bool have_disk_speed_dialog_displayed;
677 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
678 void disk_overrun_handler ();
679 void disk_underrun_handler ();
680 void gui_idle_handler ();
682 void cancel_plugin_scan ();
683 void cancel_plugin_timeout ();
684 void plugin_scan_dialog (std::string type, std::string plugin, bool);
685 void plugin_scan_timeout (int);
687 void session_format_mismatch (std::string, std::string);
689 void session_dialog (std::string);
690 int pending_state_dialog ();
691 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
693 Gtk::MenuItem* jack_disconnect_item;
694 Gtk::MenuItem* jack_reconnect_item;
695 Gtk::Menu* jack_bufsize_menu;
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 ();
707 void toggle_send_midi_clock ();
709 void toggle_use_osc ();
711 void parameter_changed (std::string);
712 void session_parameter_changed (std::string);
716 void check_memory_locking ();
718 bool check_audioengine();
719 void audioengine_setup ();
721 void display_message (const char *prefix, gint prefix_len,
722 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
724 Gtk::Label status_bar_label;
725 bool status_bar_button_press (GdkEventButton*);
727 void loading_message (const std::string& msg);
729 PBD::ScopedConnectionList forever_connections;
730 PBD::ScopedConnection halt_connection;
732 void step_edit_status_change (bool);
734 void platform_specific ();
735 void platform_setup ();
737 /* these are used only in response to a platform-specific "ShouldQuit" signal
740 void queue_finish ();
741 void fontconfig_dialog ();
743 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
744 int ambiguous_file (std::string file, std::vector<std::string> hits);
746 bool click_button_clicked (GdkEventButton *);
748 VisibilityGroup _status_bar_visibility;
750 /** A ProcessThread so that we have some thread-local buffers for use by
751 * PluginEqGui::impulse_analysis ().
753 ARDOUR::ProcessThread* _process_thread;
755 void feedback_detected ();
757 ArdourButton midi_panic_button;
760 void successful_graph_sort ();
761 bool _feedback_exists;
763 enum ArdourLogLevel {
770 ArdourLogLevel _log_not_acknowledged;
772 void resize_text_widgets ();
774 bool xrun_button_release (GdkEventButton* ev);
776 std::string _announce_string;
777 void check_announcements ();
779 int do_audio_midi_setup (uint32_t);
780 void audioengine_became_silent ();
783 #endif /* __ardour_gui_h__ */