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 int disconnect_from_engine ();
316 int reconnect_to_engine ();
317 void hide_application ();
320 friend class PublicEditor;
322 void toggle_auto_play ();
323 void toggle_auto_input ();
324 void toggle_punch ();
325 void unset_dual_punch ();
326 bool ignore_dual_punch;
327 void toggle_punch_in ();
328 void toggle_punch_out ();
329 void show_loop_punch_ruler_and_disallow_hide ();
330 void reenable_hide_loop_punch_ruler_if_appropriate ();
331 void toggle_auto_return ();
332 void toggle_click ();
333 void toggle_audio_midi_setup ();
334 void toggle_session_auto_loop ();
335 void toggle_rc_options_window ();
336 void toggle_session_options_window ();
339 PublicEditor* editor;
344 bool _initial_verbose_plugin_scan;
345 bool first_time_engine_run;
347 void goto_editor_window ();
348 void goto_mixer_window ();
349 void toggle_mixer_window ();
350 void toggle_meterbridge ();
351 void toggle_editor_mixer ();
353 int setup_windows ();
354 void setup_transport ();
357 static ARDOUR_UI *theArdourUI;
361 int ask_about_saving_session (const std::vector<std::string>& actions);
363 void save_session_at_its_request (std::string);
364 /* periodic safety backup, to be precise */
365 gint autosave_session();
366 void update_autosave();
367 sigc::connection _autosave_connection;
369 void map_transport_state ();
370 int32_t do_engine_start ();
372 void engine_halted (const char* reason, bool free_reason);
373 void engine_stopped ();
374 void engine_running ();
378 void about_signal_response(int response);
380 Gtk::VBox top_packer;
382 sigc::connection clock_signal_connection;
383 void update_clocks ();
384 void start_clocking ();
385 void stop_clocking ();
387 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
389 void update_transport_clocks (framepos_t pos);
390 void record_state_changed ();
392 std::list<MidiTracer*> _midi_tracer_windows;
394 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
395 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
396 void reattach_all_tearoffs ();
398 /* Transport Control */
400 Gtkmm2ext::TearOff* transport_tearoff;
401 Gtk::Frame transport_frame;
402 Gtk::HBox transport_tearoff_hbox;
403 Gtk::HBox transport_hbox;
404 Gtk::Fixed transport_base;
405 Gtk::Fixed transport_button_base;
406 Gtk::Frame transport_button_frame;
407 Gtk::HBox transport_button_hbox;
408 Gtk::VBox transport_button_vbox;
409 Gtk::HBox transport_option_button_hbox;
410 Gtk::VBox transport_option_button_vbox;
411 Gtk::HBox transport_clock_hbox;
412 Gtk::VBox transport_clock_vbox;
413 Gtk::HBox primary_clock_hbox;
414 Gtk::HBox secondary_clock_hbox;
416 struct TransportControllable : public PBD::Controllable {
427 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
428 void set_value (double);
429 double get_value (void) const;
435 boost::shared_ptr<TransportControllable> roll_controllable;
436 boost::shared_ptr<TransportControllable> stop_controllable;
437 boost::shared_ptr<TransportControllable> goto_start_controllable;
438 boost::shared_ptr<TransportControllable> goto_end_controllable;
439 boost::shared_ptr<TransportControllable> auto_loop_controllable;
440 boost::shared_ptr<TransportControllable> play_selection_controllable;
441 boost::shared_ptr<TransportControllable> rec_controllable;
443 void toggle_follow_edits ();
445 void set_transport_controllable_state (const XMLNode&);
446 XMLNode& get_transport_controllable_state ();
448 ArdourButton roll_button;
449 ArdourButton stop_button;
450 ArdourButton goto_start_button;
451 ArdourButton goto_end_button;
452 ArdourButton auto_loop_button;
453 ArdourButton play_selection_button;
454 ArdourButton rec_button;
456 void toggle_external_sync ();
457 void toggle_time_master ();
458 void toggle_video_sync ();
460 ShuttleControl* shuttle_box;
462 ArdourButton auto_return_button;
463 ArdourButton follow_edits_button;
464 ArdourButton auto_input_button;
465 ArdourButton click_button;
466 ArdourButton sync_button;
468 ArdourButton auditioning_alert_button;
469 ArdourButton solo_alert_button;
470 ArdourButton feedback_alert_button;
471 ArdourButton error_alert_button;
475 LevelMeterHBox * editor_meter;
476 float editor_meter_max_peak;
477 ArdourButton editor_meter_peak_display;
478 bool editor_meter_peak_button_release (GdkEventButton*);
480 void blink_handler (bool);
481 sigc::connection blink_connection;
483 void solo_blink (bool);
484 void sync_blink (bool);
485 void audition_blink (bool);
486 void feedback_blink (bool);
487 void error_blink (bool);
489 void set_flat_buttons();
491 void soloing_changed (bool);
492 void auditioning_changed (bool);
493 void _auditioning_changed (bool);
495 bool solo_alert_press (GdkEventButton* ev);
496 bool audition_alert_press (GdkEventButton* ev);
497 bool feedback_alert_press (GdkEventButton *);
498 bool error_alert_press (GdkEventButton *);
500 void big_clock_value_changed ();
501 void primary_clock_value_changed ();
502 void secondary_clock_value_changed ();
504 /* called by Blink signal */
506 void transport_rec_enable_blink (bool onoff);
508 Gtk::Menu* session_popup_menu;
510 /* menu bar and associated stuff */
512 Gtk::MenuBar* menu_bar;
513 Gtk::EventBox menu_bar_base;
516 void use_menubar_as_top_menubar ();
517 void build_menu_bar ();
519 Gtk::Label wall_clock_label;
520 gint update_wall_clock ();
522 Gtk::Label disk_space_label;
523 void update_disk_space ();
525 Gtk::Label timecode_format_label;
526 void update_timecode_format ();
528 Gtk::Label cpu_load_label;
529 void update_cpu_load ();
531 Gtk::Label xrun_label;
532 void update_xrun_count ();
534 Gtk::Label peak_thread_work_label;
535 void update_peak_thread_work ();
537 Gtk::Label buffer_load_label;
538 void update_buffer_load ();
540 Gtk::Label sample_rate_label;
541 void update_sample_rate (ARDOUR::framecnt_t);
543 Gtk::Label format_label;
544 void update_format ();
546 void every_second ();
547 void every_point_one_seconds ();
548 void every_point_zero_something_seconds ();
550 sigc::connection second_connection;
551 sigc::connection point_one_second_connection;
552 sigc::connection point_zero_something_second_connection;
553 sigc::connection fps_connection;
555 void set_fps_timeout_connection ();
557 void open_session ();
558 void open_recent_session ();
559 void save_template ();
561 void edit_metadata ();
562 void import_metadata ();
564 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
565 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
567 void set_transport_sensitivity (bool);
569 //stuff for ProTools-style numpad
570 void transport_numpad_event (int num);
571 void transport_numpad_decimal ();
572 bool _numpad_locate_happening;
573 int _pending_locate_num;
574 gint transport_numpad_timeout ();
575 sigc::connection _numpad_timeout_connection;
577 void transport_goto_nth_marker (int nth);
578 void transport_goto_zero ();
579 void transport_goto_start ();
580 void transport_goto_end ();
581 void transport_goto_wallclock ();
582 void transport_stop ();
583 void transport_record (bool roll);
584 void transport_roll ();
585 void transport_play_selection();
586 void transport_play_preroll();
587 void transport_forward (int option);
588 void transport_rewind (int option);
589 void transport_loop ();
590 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
591 bool trx_record_enable_all_tracks ();
593 bool _session_is_new;
594 void set_session (ARDOUR::Session *);
595 void connect_dependents_to_session (ARDOUR::Session *);
596 void we_have_dependents ();
598 void setup_session_options ();
600 guint32 last_key_press_time;
602 void snapshot_session (bool switch_to_it);
604 SaveAsDialog* save_as_dialog;
606 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
607 void save_session_as ();
608 void rename_session ();
609 void setup_order_hint (AddRouteDialog::InsertAt);
612 int create_editor ();
614 Meterbridge *meterbridge;
615 int create_meterbridge ();
616 /* Dialogs that can be created via new<T> */
618 WM::Proxy<SpeakerDialog> speaker_config_window;
619 WM::Proxy<KeyEditor> key_editor;
620 WM::Proxy<RCOptionEditor> rc_option_editor;
621 WM::Proxy<AddRouteDialog> add_route_dialog;
622 WM::Proxy<About> about;
623 WM::Proxy<LocationUIWindow> location_ui;
624 WM::Proxy<RouteParams_UI> route_params;
625 WM::Proxy<EngineControl> audio_midi_setup;
626 WM::Proxy<ExportVideoDialog> export_video_dialog;
628 /* Windows/Dialogs that require a creator method */
630 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
631 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
632 WM::ProxyWithConstructor<BundleManager> bundle_manager;
633 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
634 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
635 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
637 /* creator methods */
639 SessionOptionEditor* create_session_option_editor ();
640 BundleManager* create_bundle_manager ();
641 AddVideoDialog* create_add_video_dialog ();
642 BigClockWindow* create_big_clock_window();
643 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
645 ARDOUR::SystemExec *video_server_process;
647 void handle_locations_change (ARDOUR::Location*);
649 /* Keyboard Handling */
651 ArdourKeyboard* keyboard;
653 /* Keymap handling */
655 void install_actions ();
657 void toggle_record_enable (uint32_t);
659 uint32_t rec_enabled_streams;
660 void count_recenabled_streams (ARDOUR::Route&);
664 void pop_back_splash (Gtk::Window&);
668 Gtk::MenuItem *cleanup_item;
670 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
672 void cleanup_peakfiles ();
675 bool have_configure_timeout;
676 ARDOUR::microseconds_t last_configure_time;
677 gint configure_timeout ();
679 ARDOUR::microseconds_t last_peak_grab;
680 ARDOUR::microseconds_t last_shuttle_request;
682 bool have_disk_speed_dialog_displayed;
683 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
684 void disk_overrun_handler ();
685 void disk_underrun_handler ();
686 void gui_idle_handler ();
688 void cancel_plugin_scan ();
689 void cancel_plugin_timeout ();
690 void plugin_scan_dialog (std::string type, std::string plugin, bool);
691 void plugin_scan_timeout (int);
693 void session_format_mismatch (std::string, std::string);
695 void session_dialog (std::string);
696 int pending_state_dialog ();
697 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
699 Gtk::MenuItem* jack_disconnect_item;
700 Gtk::MenuItem* jack_reconnect_item;
701 Gtk::Menu* jack_bufsize_menu;
703 Glib::RefPtr<Gtk::ActionGroup> common_actions;
705 void editor_realized ();
707 std::vector<std::string> positional_sync_strings;
709 void toggle_send_midi_feedback ();
710 void toggle_use_mmc ();
711 void toggle_send_mmc ();
712 void toggle_send_mtc ();
713 void toggle_send_midi_clock ();
715 void toggle_use_osc ();
717 void parameter_changed (std::string);
718 void session_parameter_changed (std::string);
722 void check_memory_locking ();
724 void audioengine_setup ();
726 void display_message (const char *prefix, gint prefix_len,
727 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
729 Gtk::Label status_bar_label;
730 bool status_bar_button_press (GdkEventButton*);
732 void loading_message (const std::string& msg);
734 PBD::ScopedConnectionList forever_connections;
735 PBD::ScopedConnection halt_connection;
737 void step_edit_status_change (bool);
739 void platform_specific ();
740 void platform_setup ();
742 /* these are used only in response to a platform-specific "ShouldQuit" signal
745 void queue_finish ();
746 void fontconfig_dialog ();
748 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
749 int ambiguous_file (std::string file, std::vector<std::string> hits);
751 bool click_button_clicked (GdkEventButton *);
753 VisibilityGroup _status_bar_visibility;
755 /** A ProcessThread so that we have some thread-local buffers for use by
756 * PluginEqGui::impulse_analysis ().
758 ARDOUR::ProcessThread* _process_thread;
760 void feedback_detected ();
762 ArdourButton midi_panic_button;
765 void successful_graph_sort ();
766 bool _feedback_exists;
768 enum ArdourLogLevel {
775 ArdourLogLevel _log_not_acknowledged;
777 void resize_text_widgets ();
779 bool xrun_button_release (GdkEventButton* ev);
781 std::string _announce_string;
782 void check_announcements ();
784 int do_audio_midi_setup (uint32_t);
785 void audioengine_became_silent ();
788 #endif /* __ardour_gui_h__ */