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_dropdown.h"
74 #include "ardour_window.h"
76 #include "engine_dialog.h"
77 #include "export_video_dialog.h"
78 #include "meterbridge.h"
79 #include "ui_config.h"
81 #include "visibility_group.h"
82 #include "window_manager.h"
84 #include "add_route_dialog.h"
85 #include "add_video_dialog.h"
86 #include "big_clock_window.h"
87 #include "bundle_manager.h"
88 #include "global_port_matrix.h"
89 #include "keyeditor.h"
90 #include "location_ui.h"
91 #include "rc_option_editor.h"
92 #include "route_params_ui.h"
93 #include "session_option_editor.h"
94 #include "speaker_dialog.h"
100 class ConnectionEditor;
104 class RCOptionEditor;
105 class RouteParams_UI;
108 class SessionOptionEditor;
109 class ShuttleControl;
114 class LevelMeterHBox;
115 class GUIObjectState;
118 class ControlProtocolInfo;
127 namespace Gtkmm2ext {
135 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
138 /* This must be the first data element because constructor ordering
141 UIConfiguration* ui_config;
144 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir, UIConfiguration*);
147 bool run_startup (bool should_be_new, std::string load_template);
153 void launch_manual ();
154 void launch_reference ();
155 void launch_tracker ();
156 void launch_subscribe ();
157 void launch_cheat_sheet ();
158 void launch_website ();
159 void launch_website_dev ();
160 void launch_forums ();
161 void launch_howto_report ();
165 void load_from_application_api (const std::string& path);
168 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
170 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
171 bool session_is_new() const { return _session_is_new; }
173 ARDOUR::Session* the_session() { return _session; }
175 bool get_smart_mode () const;
177 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
178 int build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
179 bool ask_about_loading_existing_session (const std::string& session_path);
181 /// @return true if session was successfully unloaded.
182 int unload_session (bool hide_stuff = false);
183 void close_session();
185 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
186 void save_state (const std::string & state_name = "", bool switch_to_it = false);
188 static ARDOUR_UI *instance () { return theArdourUI; }
189 static UIConfiguration *config () { return theArdourUI->ui_config; }
190 static float ui_scale;
192 PublicEditor& the_editor() { return *editor;}
193 Mixer_UI* the_mixer() { return mixer; }
195 void new_midi_tracer_window ();
196 void toggle_editing_space();
197 void toggle_mixer_space();
198 void toggle_keep_tearoffs();
200 Gtk::Tooltips& tooltips() { return _tooltips; }
202 static PublicEditor* _instance;
204 /** Emitted frequently with the audible frame, false, and the edit point as
205 * parameters respectively.
207 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
209 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
211 static void close_all_dialogs () { CloseAllDialogs(); }
212 static sigc::signal<void> CloseAllDialogs;
214 XMLNode* editor_settings() const;
215 XMLNode* mixer_settings () const;
216 XMLNode* keyboard_settings () const;
217 XMLNode* tearoff_settings (const char*) const;
219 void save_ardour_state ();
220 gboolean configure_handler (GdkEventConfigure* conf);
222 void halt_on_xrun_message ();
223 void xrun_handler (framepos_t);
224 void create_xrun_marker (framepos_t);
226 GUIObjectState* gui_object_state;
228 MainClock* primary_clock;
229 MainClock* secondary_clock;
230 void focus_on_clock ();
231 AudioClock* big_clock;
233 TimeInfoBox* time_info_box;
235 VideoTimeLine *video_timeline;
237 void store_clock_modes ();
238 void restore_clock_modes ();
239 void reset_main_clocks ();
241 void synchronize_sync_source_and_video_pullup ();
243 void add_route (Gtk::Window* float_window);
244 void add_routes_part_two ();
245 void add_routes_thread ();
247 void add_video (Gtk::Window* float_window);
248 void remove_video ();
249 void start_video_server_menu (Gtk::Window* float_window);
250 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
251 void stop_video_server (bool ask_confirm=false);
252 void flush_videotimeline_cache (bool localcacheonly=false);
253 void export_video (bool range = false);
255 void session_add_audio_track (
257 int32_t output_channels,
258 ARDOUR::TrackMode mode,
259 ARDOUR::RouteGroup* route_group,
261 std::string const & name_template
264 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
267 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
268 uint32_t how_many, std::string const & name_template) {
269 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
272 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
273 ARDOUR::PluginInfoPtr instrument) {
274 session_add_midi_route (true, route_group, how_many, name_template, instrument);
277 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,
278 ARDOUR::PluginInfoPtr instrument);
280 /*void session_add_midi_bus () {
281 session_add_midi_route (false);
284 void attach_to_engine ();
287 gint exit_on_main_window_close (GdkEventAny *);
289 void maximise_editing_space ();
290 void restore_editing_space ();
292 void show_ui_prefs ();
294 void update_tearoff_visibility ();
296 void setup_profile ();
297 void setup_tooltips ();
299 void set_shuttle_fract (double);
301 void get_process_buffers ();
302 void drop_process_buffers ();
304 void reset_peak_display ();
305 void reset_route_peak_display (ARDOUR::Route*);
306 void reset_group_peak_display (ARDOUR::RouteGroup*);
308 const std::string& announce_string() const { return _announce_string; }
310 int disconnect_from_engine ();
311 int reconnect_to_engine ();
312 void hide_application ();
315 friend class PublicEditor;
317 void toggle_auto_play ();
318 void toggle_auto_input ();
319 void toggle_punch ();
320 void unset_dual_punch ();
321 bool ignore_dual_punch;
322 void toggle_punch_in ();
323 void toggle_punch_out ();
324 void show_loop_punch_ruler_and_disallow_hide ();
325 void reenable_hide_loop_punch_ruler_if_appropriate ();
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 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 ArdourDropdown auto_return_dropdown;
457 Gtk::CheckMenuItem *auto_return_last_locate;
458 Gtk::CheckMenuItem *auto_return_range_selection;
459 Gtk::CheckMenuItem *auto_return_region_selection;
460 Gtk::CheckMenuItem *auto_return_loop;
461 Gtk::MenuItem *auto_return_toggle;
463 void toggle_auto_return_state (ARDOUR::AutoReturnTarget);
464 void toggle_all_auto_return ();
466 ArdourButton follow_edits_button;
467 ArdourButton auto_input_button;
468 ArdourButton click_button;
469 ArdourButton sync_button;
471 ArdourButton auditioning_alert_button;
472 ArdourButton solo_alert_button;
473 ArdourButton feedback_alert_button;
474 ArdourButton error_alert_button;
478 LevelMeterHBox * editor_meter;
479 float editor_meter_max_peak;
480 ArdourButton editor_meter_peak_display;
481 bool editor_meter_peak_button_release (GdkEventButton*);
483 void blink_handler (bool);
484 sigc::connection blink_connection;
486 void solo_blink (bool);
487 void sync_blink (bool);
488 void audition_blink (bool);
489 void feedback_blink (bool);
490 void error_blink (bool);
492 void set_flat_buttons();
494 void soloing_changed (bool);
495 void auditioning_changed (bool);
496 void _auditioning_changed (bool);
498 bool solo_alert_press (GdkEventButton* ev);
499 bool audition_alert_press (GdkEventButton* ev);
500 bool feedback_alert_press (GdkEventButton *);
501 bool error_alert_press (GdkEventButton *);
503 void big_clock_value_changed ();
504 void primary_clock_value_changed ();
505 void secondary_clock_value_changed ();
507 /* called by Blink signal */
509 void transport_rec_enable_blink (bool onoff);
511 Gtk::Menu* session_popup_menu;
513 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
514 RecentSessionModelColumns() {
519 Gtk::TreeModelColumn<std::string> visible_name;
520 Gtk::TreeModelColumn<std::string> tip;
521 Gtk::TreeModelColumn<std::string> fullpath;
524 RecentSessionModelColumns recent_session_columns;
525 Gtk::TreeView recent_session_display;
526 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
528 ArdourDialog* session_selector_window;
529 Gtk::FileChooserDialog* open_session_selector;
531 void build_session_selector();
532 void redisplay_recent_sessions();
533 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
535 struct RecentSessionsSorter {
536 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
537 return ARDOUR::cmp_nocase(a.first, b.first) == -1;
541 /* menu bar and associated stuff */
543 Gtk::MenuBar* menu_bar;
544 Gtk::EventBox menu_bar_base;
547 void use_menubar_as_top_menubar ();
548 void build_menu_bar ();
550 Gtk::Label wall_clock_label;
551 gint update_wall_clock ();
553 Gtk::Label disk_space_label;
554 void update_disk_space ();
556 Gtk::Label timecode_format_label;
557 void update_timecode_format ();
559 Gtk::Label cpu_load_label;
560 void update_cpu_load ();
562 Gtk::Label xrun_label;
563 void update_xrun_count ();
565 Gtk::Label buffer_load_label;
566 void update_buffer_load ();
568 Gtk::Label sample_rate_label;
569 void update_sample_rate (ARDOUR::framecnt_t);
571 Gtk::Label format_label;
572 void update_format ();
574 void every_second ();
575 void every_point_one_seconds ();
576 void every_point_zero_something_seconds ();
578 sigc::connection second_connection;
579 sigc::connection point_one_second_connection;
580 sigc::connection point_zero_something_second_connection;
581 sigc::connection fps_connection;
583 void set_fps_timeout_connection ();
585 void open_session ();
586 void open_recent_session ();
587 void save_template ();
589 void edit_metadata ();
590 void import_metadata ();
592 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
593 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
595 void set_transport_sensitivity (bool);
597 //stuff for ProTools-style numpad
598 void transport_numpad_event (int num);
599 void transport_numpad_decimal ();
600 bool _numpad_locate_happening;
601 int _pending_locate_num;
602 gint transport_numpad_timeout ();
603 sigc::connection _numpad_timeout_connection;
605 void transport_goto_nth_marker (int nth);
606 void transport_goto_zero ();
607 void transport_goto_start ();
608 void transport_goto_end ();
609 void transport_goto_wallclock ();
610 void transport_stop ();
611 void transport_record (bool roll);
612 void transport_roll ();
613 void transport_play_selection();
614 void transport_play_preroll();
615 void transport_forward (int option);
616 void transport_rewind (int option);
617 void transport_loop ();
618 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
619 bool trx_record_enable_all_tracks ();
621 bool _session_is_new;
622 void set_session (ARDOUR::Session *);
623 void connect_dependents_to_session (ARDOUR::Session *);
624 void we_have_dependents ();
626 void setup_session_options ();
628 guint32 last_key_press_time;
630 void snapshot_session (bool switch_to_it);
632 SaveAsDialog* save_as_dialog;
634 bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
635 void save_session_as ();
636 void rename_session ();
637 void setup_order_hint (AddRouteDialog::InsertAt);
640 int create_editor ();
642 Meterbridge *meterbridge;
643 int create_meterbridge ();
644 /* Dialogs that can be created via new<T> */
646 WM::Proxy<SpeakerDialog> speaker_config_window;
647 WM::Proxy<KeyEditor> key_editor;
648 WM::Proxy<RCOptionEditor> rc_option_editor;
649 WM::Proxy<AddRouteDialog> add_route_dialog;
650 WM::Proxy<About> about;
651 WM::Proxy<LocationUIWindow> location_ui;
652 WM::Proxy<RouteParams_UI> route_params;
653 WM::Proxy<EngineControl> audio_midi_setup;
654 WM::Proxy<ExportVideoDialog> export_video_dialog;
656 /* Windows/Dialogs that require a creator method */
658 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
659 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
660 WM::ProxyWithConstructor<BundleManager> bundle_manager;
661 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
662 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
663 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
665 /* creator methods */
667 SessionOptionEditor* create_session_option_editor ();
668 BundleManager* create_bundle_manager ();
669 AddVideoDialog* create_add_video_dialog ();
670 BigClockWindow* create_big_clock_window();
671 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
673 ARDOUR::SystemExec *video_server_process;
675 void handle_locations_change (ARDOUR::Location*);
677 /* Keyboard Handling */
679 ArdourKeyboard* keyboard;
681 /* Keymap handling */
683 void install_actions ();
685 void toggle_record_enable (uint32_t);
687 uint32_t rec_enabled_streams;
688 void count_recenabled_streams (ARDOUR::Route&);
692 void pop_back_splash (Gtk::Window&);
696 Gtk::MenuItem *cleanup_item;
698 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
702 bool have_configure_timeout;
703 ARDOUR::microseconds_t last_configure_time;
704 gint configure_timeout ();
706 ARDOUR::microseconds_t last_peak_grab;
707 ARDOUR::microseconds_t last_shuttle_request;
709 bool have_disk_speed_dialog_displayed;
710 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
711 void disk_overrun_handler ();
712 void disk_underrun_handler ();
713 void gui_idle_handler ();
715 void cancel_plugin_scan ();
716 void cancel_plugin_timeout ();
717 void plugin_scan_dialog (std::string type, std::string plugin, bool);
718 void plugin_scan_timeout (int);
720 void session_format_mismatch (std::string, std::string);
722 void session_dialog (std::string);
723 int pending_state_dialog ();
724 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
726 Gtk::MenuItem* jack_disconnect_item;
727 Gtk::MenuItem* jack_reconnect_item;
728 Gtk::Menu* jack_bufsize_menu;
730 Glib::RefPtr<Gtk::ActionGroup> common_actions;
732 void editor_realized ();
734 std::vector<std::string> positional_sync_strings;
736 void toggle_send_midi_feedback ();
737 void toggle_use_mmc ();
738 void toggle_send_mmc ();
739 void toggle_send_mtc ();
740 void toggle_send_midi_clock ();
742 void toggle_use_osc ();
744 void parameter_changed (std::string);
745 void session_parameter_changed (std::string);
749 void check_memory_locking ();
751 bool check_audioengine();
752 void audioengine_setup ();
754 void display_message (const char *prefix, gint prefix_len,
755 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
757 Gtk::Label status_bar_label;
758 bool status_bar_button_press (GdkEventButton*);
760 void loading_message (const std::string& msg);
762 PBD::ScopedConnectionList forever_connections;
763 PBD::ScopedConnection halt_connection;
765 void step_edit_status_change (bool);
767 void platform_specific ();
768 void platform_setup ();
770 /* these are used only in response to a platform-specific "ShouldQuit" signal
773 void queue_finish ();
774 void fontconfig_dialog ();
776 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
777 int ambiguous_file (std::string file, std::vector<std::string> hits);
779 bool click_button_clicked (GdkEventButton *);
781 VisibilityGroup _status_bar_visibility;
783 /** A ProcessThread so that we have some thread-local buffers for use by
784 * PluginEqGui::impulse_analysis ().
786 ARDOUR::ProcessThread* _process_thread;
788 void feedback_detected ();
790 ArdourButton midi_panic_button;
793 void successful_graph_sort ();
794 bool _feedback_exists;
796 enum ArdourLogLevel {
803 ArdourLogLevel _log_not_acknowledged;
805 void resize_text_widgets ();
807 bool xrun_button_release (GdkEventButton* ev);
809 std::string _announce_string;
810 void check_announcements ();
812 int do_audio_midi_setup (uint32_t);
813 void audioengine_became_silent ();
816 #endif /* __ardour_gui_h__ */