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; }
189 static float ui_scale;
191 PublicEditor& the_editor() { return *editor;}
192 Mixer_UI* the_mixer() { return mixer; }
194 void new_midi_tracer_window ();
195 void toggle_editing_space();
196 void toggle_mixer_space();
197 void toggle_keep_tearoffs();
199 Gtk::Tooltips& tooltips() { return _tooltips; }
201 static PublicEditor* _instance;
203 /** Emitted frequently with the audible frame, false, and the edit point as
204 * parameters respectively.
206 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
208 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
210 static void close_all_dialogs () { CloseAllDialogs(); }
211 static sigc::signal<void> CloseAllDialogs;
213 XMLNode* editor_settings() const;
214 XMLNode* mixer_settings () const;
215 XMLNode* keyboard_settings () const;
216 XMLNode* tearoff_settings (const char*) const;
218 void save_ardour_state ();
219 gboolean configure_handler (GdkEventConfigure* conf);
221 void halt_on_xrun_message ();
222 void xrun_handler (framepos_t);
223 void create_xrun_marker (framepos_t);
225 GUIObjectState* gui_object_state;
227 MainClock* primary_clock;
228 MainClock* secondary_clock;
229 void focus_on_clock ();
230 AudioClock* big_clock;
232 TimeInfoBox* time_info_box;
234 VideoTimeLine *video_timeline;
236 void store_clock_modes ();
237 void restore_clock_modes ();
238 void reset_main_clocks ();
240 void synchronize_sync_source_and_video_pullup ();
242 void add_route (Gtk::Window* float_window);
243 void add_routes_part_two ();
244 void add_routes_thread ();
246 void add_video (Gtk::Window* float_window);
247 void remove_video ();
248 void start_video_server_menu (Gtk::Window* float_window);
249 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
250 void stop_video_server (bool ask_confirm=false);
251 void flush_videotimeline_cache (bool localcacheonly=false);
252 void export_video (bool range = false);
254 void session_add_audio_track (
256 int32_t output_channels,
257 ARDOUR::TrackMode mode,
258 ARDOUR::RouteGroup* route_group,
260 std::string const & name_template
263 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
266 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
267 uint32_t how_many, std::string const & name_template) {
268 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
271 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
272 ARDOUR::PluginInfoPtr instrument) {
273 session_add_midi_route (true, route_group, how_many, name_template, instrument);
276 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,
277 ARDOUR::PluginInfoPtr instrument);
279 /*void session_add_midi_bus () {
280 session_add_midi_route (false);
283 void attach_to_engine ();
286 gint exit_on_main_window_close (GdkEventAny *);
288 void maximise_editing_space ();
289 void restore_editing_space ();
291 void show_ui_prefs ();
293 void update_tearoff_visibility ();
295 void setup_profile ();
296 void setup_tooltips ();
298 void set_shuttle_fract (double);
300 void get_process_buffers ();
301 void drop_process_buffers ();
303 void reset_peak_display ();
304 void reset_route_peak_display (ARDOUR::Route*);
305 void reset_group_peak_display (ARDOUR::RouteGroup*);
307 const std::string& announce_string() const { return _announce_string; }
309 int disconnect_from_engine ();
310 int reconnect_to_engine ();
311 void hide_application ();
314 friend class PublicEditor;
316 void toggle_auto_play ();
317 void toggle_auto_input ();
318 void toggle_punch ();
319 void unset_dual_punch ();
320 bool ignore_dual_punch;
321 void toggle_punch_in ();
322 void toggle_punch_out ();
323 void show_loop_punch_ruler_and_disallow_hide ();
324 void reenable_hide_loop_punch_ruler_if_appropriate ();
325 void toggle_auto_return ();
326 void toggle_click ();
327 void toggle_audio_midi_setup ();
328 void toggle_session_auto_loop ();
329 void toggle_rc_options_window ();
330 void toggle_session_options_window ();
333 PublicEditor* editor;
335 Gtk::Tooltips _tooltips;
339 bool _initial_verbose_plugin_scan;
340 bool first_time_engine_run;
342 void goto_editor_window ();
343 void goto_mixer_window ();
344 void toggle_mixer_window ();
345 void toggle_meterbridge ();
346 void toggle_editor_mixer ();
348 int setup_windows ();
349 void setup_transport ();
352 static ARDOUR_UI *theArdourUI;
356 int ask_about_saving_session (const std::vector<std::string>& actions);
358 void save_session_at_its_request (std::string);
359 /* periodic safety backup, to be precise */
360 gint autosave_session();
361 void update_autosave();
362 sigc::connection _autosave_connection;
364 void map_transport_state ();
365 int32_t do_engine_start ();
367 void engine_halted (const char* reason, bool free_reason);
368 void engine_stopped ();
369 void engine_running ();
373 void about_signal_response(int response);
375 Gtk::VBox top_packer;
377 sigc::connection clock_signal_connection;
378 void update_clocks ();
379 void start_clocking ();
380 void stop_clocking ();
382 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
384 void update_transport_clocks (framepos_t pos);
385 void record_state_changed ();
387 std::list<MidiTracer*> _midi_tracer_windows;
389 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
390 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
391 void reattach_all_tearoffs ();
393 /* Transport Control */
395 Gtkmm2ext::TearOff* transport_tearoff;
396 Gtk::Frame transport_frame;
397 Gtk::HBox transport_tearoff_hbox;
398 Gtk::HBox transport_hbox;
399 Gtk::Fixed transport_base;
400 Gtk::Fixed transport_button_base;
401 Gtk::Frame transport_button_frame;
402 Gtk::HBox transport_button_hbox;
403 Gtk::VBox transport_button_vbox;
404 Gtk::HBox transport_option_button_hbox;
405 Gtk::VBox transport_option_button_vbox;
406 Gtk::HBox transport_clock_hbox;
407 Gtk::VBox transport_clock_vbox;
408 Gtk::HBox primary_clock_hbox;
409 Gtk::HBox secondary_clock_hbox;
411 struct TransportControllable : public PBD::Controllable {
422 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
423 void set_value (double);
424 double get_value (void) const;
430 boost::shared_ptr<TransportControllable> roll_controllable;
431 boost::shared_ptr<TransportControllable> stop_controllable;
432 boost::shared_ptr<TransportControllable> goto_start_controllable;
433 boost::shared_ptr<TransportControllable> goto_end_controllable;
434 boost::shared_ptr<TransportControllable> auto_loop_controllable;
435 boost::shared_ptr<TransportControllable> play_selection_controllable;
436 boost::shared_ptr<TransportControllable> rec_controllable;
438 void toggle_follow_edits ();
440 void set_transport_controllable_state (const XMLNode&);
441 XMLNode& get_transport_controllable_state ();
443 ArdourButton roll_button;
444 ArdourButton stop_button;
445 ArdourButton goto_start_button;
446 ArdourButton goto_end_button;
447 ArdourButton auto_loop_button;
448 ArdourButton play_selection_button;
449 ArdourButton rec_button;
451 void toggle_external_sync ();
452 void toggle_time_master ();
453 void toggle_video_sync ();
455 ShuttleControl* shuttle_box;
457 ArdourButton auto_return_button;
458 ArdourButton follow_edits_button;
459 ArdourButton auto_input_button;
460 ArdourButton click_button;
461 ArdourButton sync_button;
463 ArdourButton auditioning_alert_button;
464 ArdourButton solo_alert_button;
465 ArdourButton feedback_alert_button;
466 ArdourButton error_alert_button;
470 LevelMeterHBox * editor_meter;
471 float editor_meter_max_peak;
472 ArdourButton editor_meter_peak_display;
473 bool editor_meter_peak_button_release (GdkEventButton*);
475 void blink_handler (bool);
476 sigc::connection blink_connection;
478 void solo_blink (bool);
479 void sync_blink (bool);
480 void audition_blink (bool);
481 void feedback_blink (bool);
482 void error_blink (bool);
484 void set_flat_buttons();
486 void soloing_changed (bool);
487 void auditioning_changed (bool);
488 void _auditioning_changed (bool);
490 bool solo_alert_press (GdkEventButton* ev);
491 bool audition_alert_press (GdkEventButton* ev);
492 bool feedback_alert_press (GdkEventButton *);
493 bool error_alert_press (GdkEventButton *);
495 void big_clock_value_changed ();
496 void primary_clock_value_changed ();
497 void secondary_clock_value_changed ();
499 /* called by Blink signal */
501 void transport_rec_enable_blink (bool onoff);
503 Gtk::Menu* session_popup_menu;
505 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
506 RecentSessionModelColumns() {
511 Gtk::TreeModelColumn<std::string> visible_name;
512 Gtk::TreeModelColumn<std::string> tip;
513 Gtk::TreeModelColumn<std::string> fullpath;
516 RecentSessionModelColumns recent_session_columns;
517 Gtk::TreeView recent_session_display;
518 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
520 ArdourDialog* session_selector_window;
522 void build_session_selector();
523 void redisplay_recent_sessions();
524 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
526 struct RecentSessionsSorter {
527 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
528 return ARDOUR::cmp_nocase(a.first, b.first) == -1;
532 /* menu bar and associated stuff */
534 Gtk::MenuBar* menu_bar;
535 Gtk::EventBox menu_bar_base;
538 void use_menubar_as_top_menubar ();
539 void build_menu_bar ();
541 Gtk::Label wall_clock_label;
542 gint update_wall_clock ();
544 Gtk::Label disk_space_label;
545 void update_disk_space ();
547 Gtk::Label timecode_format_label;
548 void update_timecode_format ();
550 Gtk::Label cpu_load_label;
551 void update_cpu_load ();
553 Gtk::Label xrun_label;
554 void update_xrun_count ();
556 Gtk::Label peak_thread_work_label;
557 void update_peak_thread_work ();
559 Gtk::Label buffer_load_label;
560 void update_buffer_load ();
562 Gtk::Label sample_rate_label;
563 void update_sample_rate (ARDOUR::framecnt_t);
565 Gtk::Label format_label;
566 void update_format ();
568 void every_second ();
569 void every_point_one_seconds ();
570 void every_point_zero_something_seconds ();
572 sigc::connection second_connection;
573 sigc::connection point_one_second_connection;
574 sigc::connection point_zero_something_second_connection;
575 sigc::connection fps_connection;
577 void set_fps_timeout_connection ();
579 void open_session ();
580 void open_recent_session ();
581 void save_template ();
583 void edit_metadata ();
584 void import_metadata ();
586 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
587 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
589 void set_transport_sensitivity (bool);
591 //stuff for ProTools-style numpad
592 void transport_numpad_event (int num);
593 void transport_numpad_decimal ();
594 bool _numpad_locate_happening;
595 int _pending_locate_num;
596 gint transport_numpad_timeout ();
597 sigc::connection _numpad_timeout_connection;
599 void transport_goto_nth_marker (int nth);
600 void transport_goto_zero ();
601 void transport_goto_start ();
602 void transport_goto_end ();
603 void transport_goto_wallclock ();
604 void transport_stop ();
605 void transport_record (bool roll);
606 void transport_roll ();
607 void transport_play_selection();
608 void transport_play_preroll();
609 void transport_forward (int option);
610 void transport_rewind (int option);
611 void transport_loop ();
612 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
613 bool trx_record_enable_all_tracks ();
615 bool _session_is_new;
616 void set_session (ARDOUR::Session *);
617 void connect_dependents_to_session (ARDOUR::Session *);
618 void we_have_dependents ();
620 void setup_session_options ();
622 guint32 last_key_press_time;
624 void snapshot_session (bool switch_to_it);
626 SaveAsDialog* save_as_dialog;
628 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
629 void save_session_as ();
630 void rename_session ();
631 void setup_order_hint (AddRouteDialog::InsertAt);
634 int create_editor ();
636 Meterbridge *meterbridge;
637 int create_meterbridge ();
638 /* Dialogs that can be created via new<T> */
640 WM::Proxy<SpeakerDialog> speaker_config_window;
641 WM::Proxy<KeyEditor> key_editor;
642 WM::Proxy<RCOptionEditor> rc_option_editor;
643 WM::Proxy<AddRouteDialog> add_route_dialog;
644 WM::Proxy<About> about;
645 WM::Proxy<LocationUIWindow> location_ui;
646 WM::Proxy<RouteParams_UI> route_params;
647 WM::Proxy<EngineControl> audio_midi_setup;
648 WM::Proxy<ExportVideoDialog> export_video_dialog;
650 /* Windows/Dialogs that require a creator method */
652 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
653 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
654 WM::ProxyWithConstructor<BundleManager> bundle_manager;
655 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
656 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
657 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
659 /* creator methods */
661 SessionOptionEditor* create_session_option_editor ();
662 BundleManager* create_bundle_manager ();
663 AddVideoDialog* create_add_video_dialog ();
664 BigClockWindow* create_big_clock_window();
665 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
667 ARDOUR::SystemExec *video_server_process;
669 void handle_locations_change (ARDOUR::Location*);
671 /* Keyboard Handling */
673 ArdourKeyboard* keyboard;
675 /* Keymap handling */
677 void install_actions ();
679 void toggle_record_enable (uint32_t);
681 uint32_t rec_enabled_streams;
682 void count_recenabled_streams (ARDOUR::Route&);
686 void pop_back_splash (Gtk::Window&);
690 Gtk::MenuItem *cleanup_item;
692 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
694 void cleanup_peakfiles ();
697 bool have_configure_timeout;
698 ARDOUR::microseconds_t last_configure_time;
699 gint configure_timeout ();
701 ARDOUR::microseconds_t last_peak_grab;
702 ARDOUR::microseconds_t last_shuttle_request;
704 bool have_disk_speed_dialog_displayed;
705 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
706 void disk_overrun_handler ();
707 void disk_underrun_handler ();
708 void gui_idle_handler ();
710 void cancel_plugin_scan ();
711 void cancel_plugin_timeout ();
712 void plugin_scan_dialog (std::string type, std::string plugin, bool);
713 void plugin_scan_timeout (int);
715 void session_format_mismatch (std::string, std::string);
717 void session_dialog (std::string);
718 int pending_state_dialog ();
719 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
721 Gtk::MenuItem* jack_disconnect_item;
722 Gtk::MenuItem* jack_reconnect_item;
723 Gtk::Menu* jack_bufsize_menu;
725 Glib::RefPtr<Gtk::ActionGroup> common_actions;
727 void editor_realized ();
729 std::vector<std::string> positional_sync_strings;
731 void toggle_send_midi_feedback ();
732 void toggle_use_mmc ();
733 void toggle_send_mmc ();
734 void toggle_send_mtc ();
735 void toggle_send_midi_clock ();
737 void toggle_use_osc ();
739 void parameter_changed (std::string);
740 void session_parameter_changed (std::string);
744 void check_memory_locking ();
746 bool check_audioengine();
747 void audioengine_setup ();
749 void display_message (const char *prefix, gint prefix_len,
750 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
752 Gtk::Label status_bar_label;
753 bool status_bar_button_press (GdkEventButton*);
755 void loading_message (const std::string& msg);
757 PBD::ScopedConnectionList forever_connections;
758 PBD::ScopedConnection halt_connection;
760 void step_edit_status_change (bool);
762 void platform_specific ();
763 void platform_setup ();
765 /* these are used only in response to a platform-specific "ShouldQuit" signal
768 void queue_finish ();
769 void fontconfig_dialog ();
771 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
772 int ambiguous_file (std::string file, std::vector<std::string> hits);
774 bool click_button_clicked (GdkEventButton *);
776 VisibilityGroup _status_bar_visibility;
778 /** A ProcessThread so that we have some thread-local buffers for use by
779 * PluginEqGui::impulse_analysis ().
781 ARDOUR::ProcessThread* _process_thread;
783 void feedback_detected ();
785 ArdourButton midi_panic_button;
788 void successful_graph_sort ();
789 bool _feedback_exists;
791 enum ArdourLogLevel {
798 ArdourLogLevel _log_not_acknowledged;
800 void resize_text_widgets ();
802 bool xrun_button_release (GdkEventButton* ev);
804 std::string _announce_string;
805 void check_announcements ();
807 int do_audio_midi_setup (uint32_t);
808 void audioengine_became_silent ();
811 #endif /* __ardour_gui_h__ */