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 "about_dialog.h"
71 #include "ardour_button.h"
72 #include "ardour_dialog.h"
73 #include "ardour_window.h"
75 #include "session_lock_dialog.h"
76 #include "tracks_control_panel.h"
77 //#include "meterbridge.h"
78 #include "ui_config.h"
80 #include "visibility_group.h"
81 #include "window_manager.h"
83 #include "add_tracks_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"
94 #include "theme_manager.h"
98 #include "timecode/time.h"
102 class ArdourKeyboard;
105 class ConnectionEditor;
109 class RCOptionEditor;
110 class RouteParams_UI;
112 class SessionOptionEditor;
113 class ShuttleControl;
118 class LevelMeterHBox;
119 class GUIObjectState;
121 namespace Gtkmm2ext {
126 class ControlProtocolInfo;
135 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
138 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
141 bool run_startup (bool should_be_new, std::string load_template);
147 void launch_manual ();
148 void launch_reference ();
151 void open_media_folder ();
153 void idle_load (const std::string& path);
156 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
158 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
159 bool session_is_new() const { return _session_is_new; }
161 ARDOUR::Session* the_session() { return _session; }
163 bool get_smart_mode () const;
165 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
166 int build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
167 bool ask_about_loading_existing_session (const std::string& session_path);
169 /// @return true if session was successfully unloaded.
170 int unload_session (bool hide_stuff = false);
171 void close_session();
172 void lock_session ();
174 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
175 void save_state (const std::string & state_name = "", bool switch_to_it = false);
177 static ARDOUR_UI *instance () { return theArdourUI; }
178 static UIConfiguration *config () { return ui_config; }
180 PublicEditor& the_editor(){return *editor;}
181 Mixer_UI* the_mixer() { return mixer; }
183 void new_midi_tracer_window ();
184 void toggle_editing_space();
185 void toggle_mixer_space();
186 void toggle_keep_tearoffs();
188 Gtk::Tooltips& tooltips() { return _tooltips; }
190 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
192 static PublicEditor* _instance;
193 static sigc::signal<void,bool> Blink;
195 /** point_zero_one_seconds -- 10Hz ^= 100ms */
196 static sigc::signal<void> RapidScreenUpdate;
198 /** point_zero_something_seconds -- currently 25Hz ^= 40ms */
199 static sigc::signal<void> SuperRapidScreenUpdate;
201 /** every_fps -- see set_fps_timeout_connection() 25Hz < x < 120Hz */
202 static sigc::signal<void> FPSUpdate;
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 WavesButton* _tracks_button;
234 void on_tracks_button (WavesButton*);
235 WavesButton* _bit_depth_button;
236 WavesButton* _frame_rate_button;
237 void on_bit_depth_button (WavesButton*);
238 void on_frame_rate_button (WavesButton*);
240 uint32_t _ignore_changes;
242 WavesDropdown* _sample_rate_dropdown;
243 void on_sample_rate_dropdown_item_clicked (WavesDropdown* from_which, void* my_cookie);
244 void sample_rate_changed();
245 ARDOUR::framecnt_t get_sample_rate () const;
246 void populate_sample_rate_dropdown ();
248 WavesDropdown* _display_format_dropdown;
249 void on_display_format_dropdown_item_clicked (WavesDropdown* from_which, void* my_cookie);
250 void populate_display_format_dropdown ();
252 WavesDropdown* _timecode_source_dropdown;
253 void on_timecode_source_dropdown_item_clicked (WavesDropdown* from_which, void* my_cookie);
254 void populate_timecode_source_dropdown ();
256 void update_bit_depth_button ();
257 void update_sample_rate_dropdown ();
258 void update_frame_rate_button ();
260 PBD::ScopedConnectionList update_connections_to_toolbar_buttons;
262 TimeInfoBox* time_info_box;
264 VideoTimeLine *video_timeline;
266 void store_clock_modes ();
267 void restore_clock_modes ();
268 void reset_main_clocks ();
270 void synchronize_sync_source_and_video_pullup ();
272 void add_route (Gtk::Window* float_window);
273 void delete_selected_tracks();
274 void add_routes_part_two ();
275 void add_routes_thread ();
277 void add_audio_track_instantly ();
279 void add_video (Gtk::Window* float_window);
280 void remove_video ();
281 void start_video_server_menu (Gtk::Window* float_window);
282 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
283 void stop_video_server (bool ask_confirm=false);
284 void flush_videotimeline_cache (bool localcacheonly=false);
286 void session_add_audio_track (
288 int32_t output_channels,
289 ARDOUR::TrackMode mode,
290 ARDOUR::RouteGroup* route_group,
292 std::string const & name_template
295 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
298 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
299 uint32_t how_many, std::string const & name_template) {
300 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
303 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
304 ARDOUR::PluginInfoPtr instrument) {
305 session_add_midi_route (true, route_group, how_many, name_template, instrument);
308 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,
309 ARDOUR::PluginInfoPtr instrument);
311 /*void session_add_midi_bus () {
312 session_add_midi_route (false);
315 void attach_to_engine ();
318 void update_output_operation_mode_buttons();
320 gint exit_on_main_window_close (GdkEventAny *);
322 void maximise_editing_space ();
323 void restore_editing_space ();
325 void show_ui_prefs ();
327 void update_tearoff_visibility ();
329 void setup_profile ();
330 void setup_tooltips ();
332 void set_shuttle_fract (double);
334 void get_process_buffers ();
335 void drop_process_buffers ();
337 void reset_peak_display ();
338 void reset_route_peak_display (ARDOUR::Route*);
339 void reset_group_peak_display (ARDOUR::RouteGroup*);
341 const std::string& announce_string() const { return _announce_string; }
343 int disconnect_from_engine ();
344 int reconnect_to_engine ();
346 void set_sample_format(ARDOUR::SampleFormat sf) {_sample_format = sf;}
347 void set_header_format(ARDOUR::HeaderFormat hf) {_header_format = hf;}
348 void set_timecode_format(Timecode::TimecodeFormat tc) {_timecode_format = tc;}
350 bool screen_lock_is_allowed() const;
351 void on_lock_button_pressed ();
352 PBD::Signal0<void> lock_button_was_pressed;
354 bool session_auto_save_is_allowed() const;
357 friend class PublicEditor;
359 void toggle_auto_play ();
360 void toggle_auto_input ();
361 void toggle_punch ();
362 void unset_dual_punch ();
363 bool ignore_dual_punch;
364 void toggle_punch_in ();
365 void toggle_punch_out ();
366 void show_loop_punch_ruler_and_disallow_hide ();
367 void reenable_hide_loop_punch_ruler_if_appropriate ();
368 void toggle_auto_return ();
369 void toggle_click ();
370 void toggle_audio_midi_setup ();
371 void toggle_session_auto_loop ();
372 void toggle_multi_out_mode ();
373 void toggle_stereo_out_mode ();
375 void toggle_rc_options_window ();
376 void toggle_session_options_window ();
379 Gtk::Tooltips _tooltips;
383 bool first_time_engine_run;
385 void goto_editor_window ();
386 void goto_mixer_window ();
387 void toggle_mixer_window ();
388 void toggle_meterbridge ();
389 void toggle_editor_mixer ();
391 int setup_windows ();
392 void setup_transport ();
395 bool delete_session_files(std::string session_path);
397 static ARDOUR_UI *theArdourUI;
401 int ask_about_saving_session (const std::vector<std::string>& actions);
403 /* periodic safety backup, to be precise */
404 gint autosave_session();
405 void update_autosave();
406 sigc::connection _autosave_connection;
408 void map_transport_state ();
409 int32_t do_engine_start ();
411 void engine_halted (const char* reason, bool free_reason);
412 void engine_stopped ();
413 void engine_running ();
417 static gint _blink (void *);
419 gint blink_timeout_tag;
421 void start_blinking ();
422 void stop_blinking ();
424 void about_signal_response(int response);
426 Gtk::VBox top_packer;
427 Gtk::VBox tracks_tools_packer;
429 sigc::connection clock_signal_connection;
430 void update_clocks ();
431 void start_clocking ();
432 void stop_clocking ();
434 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
436 void update_transport_clocks (framepos_t pos);
437 void record_state_changed ();
439 std::list<MidiTracer*> _midi_tracer_windows;
441 /* Transport Control */
443 Gtk::Frame transport_frame;
444 Gtk::HBox _editor_transport_box;
445 Gtk::HBox transport_hbox;
446 Gtk::Fixed transport_base;
447 Gtk::Fixed transport_button_base;
448 Gtk::Frame transport_button_frame;
449 Gtk::HBox transport_button_hbox;
450 Gtk::VBox transport_button_vbox;
451 Gtk::HBox transport_option_button_hbox;
452 Gtk::VBox transport_option_button_vbox;
454 struct TransportControllable : public PBD::Controllable {
465 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
466 void set_value (double);
467 double get_value (void) const;
473 boost::shared_ptr<TransportControllable> roll_controllable;
474 boost::shared_ptr<TransportControllable> stop_controllable;
475 boost::shared_ptr<TransportControllable> goto_start_controllable;
476 boost::shared_ptr<TransportControllable> goto_end_controllable;
477 boost::shared_ptr<TransportControllable> auto_loop_controllable;
478 boost::shared_ptr<TransportControllable> play_selection_controllable;
479 boost::shared_ptr<TransportControllable> rec_controllable;
481 void toggle_follow_edits ();
483 void set_transport_controllable_state (const XMLNode&);
484 XMLNode& get_transport_controllable_state ();
486 ArdourButton roll_button;
487 ArdourButton stop_button;
488 ArdourButton goto_start_button;
489 ArdourButton goto_end_button;
490 ArdourButton auto_loop_button;
491 ArdourButton play_selection_button;
492 ArdourButton rec_button;
494 void toggle_external_sync ();
495 void toggle_time_master ();
496 void toggle_video_sync ();
498 ShuttleControl* shuttle_box;
500 ArdourButton auto_return_button;
501 ArdourButton follow_edits_button;
502 ArdourButton auto_input_button;
503 ArdourButton click_button;
504 // NO NEED TO HAVE IT: ArdourButton sync_button;
506 ArdourButton auditioning_alert_button;
507 ArdourButton solo_alert_button;
508 ArdourButton feedback_alert_button;
512 LevelMeterHBox * editor_meter;
513 float editor_meter_max_peak;
514 ArdourButton editor_meter_peak_display;
515 bool editor_meter_peak_button_release (GdkEventButton*);
517 void solo_blink (bool);
518 void sync_blink (bool);
519 void audition_blink (bool);
520 void feedback_blink (bool);
522 void soloing_changed (bool);
523 void auditioning_changed (bool);
524 void _auditioning_changed (bool);
526 bool solo_alert_press (GdkEventButton* ev);
527 bool audition_alert_press (GdkEventButton* ev);
528 bool feedback_alert_press (GdkEventButton *);
530 void big_clock_value_changed ();
531 void primary_clock_value_changed ();
532 void secondary_clock_value_changed ();
534 /* called by Blink signal */
536 void transport_rec_enable_blink (bool onoff);
538 Gtk::Menu* session_popup_menu;
540 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
541 RecentSessionModelColumns() {
546 Gtk::TreeModelColumn<std::string> visible_name;
547 Gtk::TreeModelColumn<std::string> tip;
548 Gtk::TreeModelColumn<std::string> fullpath;
551 RecentSessionModelColumns recent_session_columns;
552 Gtk::TreeView recent_session_display;
553 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
555 ArdourDialog* session_selector_window;
556 Gtk::FileChooserDialog* open_session_selector;
558 void build_session_selector();
559 void redisplay_recent_sessions();
560 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
562 struct RecentSessionsSorter {
563 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
564 return ARDOUR::cmp_nocase(a.first, b.first) == -1;
568 /* menu bar and associated stuff */
570 Gtk::MenuBar* menu_bar;
572 void use_menubar_as_top_menubar ();
573 void build_menu_bar ();
575 void update_disk_space ();
576 void update_disk_usage ();
578 void update_cpu_load ();
580 gint every_second ();
581 gint every_point_one_seconds ();
582 gint every_point_zero_something_seconds ();
585 sigc::connection second_connection;
586 sigc::connection point_one_second_connection;
587 sigc::connection point_zero_something_second_connection;
588 sigc::connection fps_connection;
590 void set_fps_timeout_connection ();
592 void open_session ();
593 void open_recent_session ();
594 void save_template ();
596 void edit_metadata ();
597 void import_metadata ();
599 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
600 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
602 void set_transport_sensitivity (bool);
604 //stuff for ProTools-style numpad
605 void transport_numpad_event (int num);
606 void transport_numpad_decimal ();
607 bool _numpad_locate_happening;
608 int _pending_locate_num;
609 gint transport_numpad_timeout ();
610 sigc::connection _numpad_timeout_connection;
612 void transport_goto_nth_marker (int nth);
613 void transport_goto_zero ();
614 void transport_goto_start ();
615 void transport_goto_end ();
616 void transport_goto_wallclock ();
617 void transport_stop ();
618 void transport_record (bool roll);
619 void transport_roll ();
620 void transport_play_selection();
621 void transport_play_preroll();
622 void transport_forward (int option);
623 void transport_rewind (int option);
624 void transport_loop ();
625 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
626 bool trx_record_enable_all_tracks ();
628 bool _session_is_new;
629 void set_session (ARDOUR::Session *);
630 void connect_dependents_to_session (ARDOUR::Session *);
631 void we_have_dependents ();
633 void setup_session_options ();
635 guint32 last_key_press_time;
637 void snapshot_session (bool switch_to_it);
638 void rename_session ();
639 void setup_order_hint ();
644 PublicEditor *editor;
645 int create_editor ();
647 //Meterbridge *meterbridge;
648 int create_meterbridge ();
649 /* Dialogs that can be created via new<T> */
651 WM::Proxy<SpeakerDialog> speaker_config_window;
652 WM::Proxy<ThemeManager> theme_manager;
653 WM::Proxy<KeyEditor> key_editor;
654 WM::Proxy<RCOptionEditor> rc_option_editor;
655 boost::shared_ptr<AddTracksDialog> _add_tracks_dialog;
656 WM::Proxy<About> about;
657 WM::Proxy<LocationUIWindow> location_ui;
658 WM::Proxy<RouteParams_UI> route_params;
659 WM::Proxy<TracksControlPanel> tracks_control_panel;
660 WM::Proxy<SessionLockDialog> session_lock_dialog;
662 /* Windows/Dialogs that require a creator method */
664 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
665 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
666 WM::ProxyWithConstructor<BundleManager> bundle_manager;
667 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
668 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
669 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
671 /* creator methods */
673 SessionOptionEditor* create_session_option_editor ();
674 BundleManager* create_bundle_manager ();
675 AddVideoDialog* create_add_video_dialog ();
676 BigClockWindow* create_big_clock_window();
677 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
679 static UIConfiguration *ui_config;
681 ARDOUR::SystemExec *video_server_process;
683 void handle_locations_change (ARDOUR::Location*);
685 /* Keyboard Handling */
687 ArdourKeyboard* keyboard;
689 /* Keymap handling */
691 void install_actions ();
693 void toggle_record_enable (uint32_t);
695 uint32_t rec_enabled_streams;
696 void count_recenabled_streams (ARDOUR::Route&);
700 void pop_back_splash (Gtk::Window&);
704 Gtk::MenuItem *cleanup_item;
706 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
710 bool have_configure_timeout;
711 ARDOUR::microseconds_t last_configure_time;
712 gint configure_timeout ();
714 ARDOUR::microseconds_t last_peak_grab;
715 ARDOUR::microseconds_t last_shuttle_request;
717 bool have_disk_speed_dialog_displayed;
718 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
719 void disk_overrun_handler ();
720 void disk_underrun_handler ();
721 void gui_idle_handler ();
723 void cancel_plugin_scan ();
724 void cancel_plugin_timeout ();
725 void plugin_scan_dialog (std::string type, std::string plugin, bool);
726 void plugin_scan_timeout (int);
728 void session_format_mismatch (std::string, std::string);
730 void session_dialog (std::string);
731 int pending_state_dialog ();
732 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
734 Gtk::MenuItem* jack_disconnect_item;
735 Gtk::MenuItem* jack_reconnect_item;
736 Gtk::Menu* jack_bufsize_menu;
738 Glib::RefPtr<Gtk::ActionGroup> common_actions;
740 void editor_realized ();
742 std::vector<std::string> positional_sync_strings;
744 void toggle_send_midi_feedback ();
745 void toggle_use_mmc ();
746 void toggle_send_mmc ();
747 void toggle_send_mtc ();
748 void toggle_send_midi_clock ();
750 void toggle_use_osc ();
752 void parameter_changed (std::string);
753 void session_parameter_changed (const std::string& param);
757 void check_memory_locking ();
759 bool check_audioengine();
760 void audioengine_setup ();
762 void loading_message (const std::string& msg);
764 PBD::ScopedConnectionList forever_connections;
765 PBD::ScopedConnection halt_connection;
767 void step_edit_status_change (bool);
769 void platform_specific ();
770 void platform_setup ();
772 /* these are used only in response to a platform-specific "ShouldQuit" signal
775 void queue_finish ();
776 void fontconfig_dialog ();
778 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
779 int ambiguous_file (std::string file, std::vector<std::string> hits);
781 bool click_button_clicked (GdkEventButton *);
783 Gtk::Adjustment* _dsp_load_adjustment;
784 Gtk::Adjustment* _hd_load_adjustment;
785 Gtk::Label* _dsp_load_label;
786 Gtk::Label* _hd_load_label;
787 Gtk::Label* _hd_remained_time_label;
789 /** A ProcessThread so that we have some thread-local buffers for use by
790 * PluginEqGui::impulse_analysis ().
792 ARDOUR::ProcessThread* _process_thread;
794 void feedback_detected ();
796 ArdourButton midi_panic_button;
799 void successful_graph_sort ();
800 bool _feedback_exists;
802 std::string _announce_string;
803 void check_announcements ();
805 int do_engine_setup(ARDOUR::framecnt_t desired_sample_rate);
807 ARDOUR::SampleFormat _sample_format;
808 ARDOUR::HeaderFormat _header_format;
809 Timecode::TimecodeFormat _timecode_format;
811 PBD::ScopedConnection connection_with_session_config;
814 #endif /* __ardour_gui_h__ */