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 "meterbridge.h"
77 #include "ui_config.h"
79 #include "visibility_group.h"
80 #include "window_manager.h"
82 #include "add_route_dialog.h"
83 #include "add_video_dialog.h"
84 #include "big_clock_window.h"
85 #include "bundle_manager.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"
98 class ConnectionEditor;
102 class RCOptionEditor;
103 class RouteParams_UI;
105 class SessionOptionEditor;
106 class ShuttleControl;
111 class LevelMeterHBox;
112 class GUIObjectState;
115 class ControlProtocolInfo;
124 namespace Gtkmm2ext {
128 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
131 /* This must be the first data element because constructor ordering
134 UIConfiguration* ui_config;
137 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
140 bool run_startup (bool should_be_new, std::string load_template);
146 void launch_manual ();
147 void launch_reference ();
148 void launch_tracker ();
149 void launch_cheat_sheet ();
150 void launch_website ();
151 void launch_website_dev ();
152 void launch_forums ();
153 void launch_howto_report ();
157 void idle_load (const std::string& path);
160 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
162 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
163 bool session_is_new() const { return _session_is_new; }
165 ARDOUR::Session* the_session() { return _session; }
167 bool get_smart_mode () const;
169 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
170 int build_session_from_dialog (SessionDialog&, const std::string& session_name, const std::string& session_path);
171 bool ask_about_loading_existing_session (const std::string& session_path);
173 /// @return true if session was successfully unloaded.
174 int unload_session (bool hide_stuff = false);
175 void close_session();
177 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
178 void save_state (const std::string & state_name = "", bool switch_to_it = false);
180 static ARDOUR_UI *instance () { return theArdourUI; }
181 static UIConfiguration *config () { return theArdourUI->ui_config; }
183 PublicEditor& the_editor(){return *editor;}
184 Mixer_UI* the_mixer() { return mixer; }
186 void new_midi_tracer_window ();
187 void toggle_editing_space();
188 void toggle_mixer_space();
189 void toggle_keep_tearoffs();
191 Gtk::Tooltips& tooltips() { return _tooltips; }
193 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
195 static PublicEditor* _instance;
196 static sigc::signal<void,bool> Blink;
198 /** point_zero_one_seconds -- 10Hz ^= 100ms */
199 static sigc::signal<void> RapidScreenUpdate;
201 /** point_zero_something_seconds -- currently 25Hz ^= 40ms */
202 static sigc::signal<void> SuperRapidScreenUpdate;
204 /** every_fps -- see set_fps_timeout_connection() 25Hz < x < 120Hz */
205 static sigc::signal<void> FPSUpdate;
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);
257 void session_add_audio_track (
259 int32_t output_channels,
260 ARDOUR::TrackMode mode,
261 ARDOUR::RouteGroup* route_group,
263 std::string const & name_template
266 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
269 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
270 uint32_t how_many, std::string const & name_template) {
271 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
274 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
275 ARDOUR::PluginInfoPtr instrument) {
276 session_add_midi_route (true, route_group, how_many, name_template, instrument);
279 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,
280 ARDOUR::PluginInfoPtr instrument);
282 /*void session_add_midi_bus () {
283 session_add_midi_route (false);
286 void attach_to_engine ();
289 gint exit_on_main_window_close (GdkEventAny *);
291 void maximise_editing_space ();
292 void restore_editing_space ();
294 void show_ui_prefs ();
296 void update_tearoff_visibility ();
298 void setup_profile ();
299 void setup_tooltips ();
301 void set_shuttle_fract (double);
303 void get_process_buffers ();
304 void drop_process_buffers ();
306 void reset_peak_display ();
307 void reset_route_peak_display (ARDOUR::Route*);
308 void reset_group_peak_display (ARDOUR::RouteGroup*);
310 const std::string& announce_string() const { return _announce_string; }
312 int disconnect_from_engine ();
313 int reconnect_to_engine ();
316 friend class PublicEditor;
318 void toggle_auto_play ();
319 void toggle_auto_input ();
320 void toggle_punch ();
321 void unset_dual_punch ();
322 bool ignore_dual_punch;
323 void toggle_punch_in ();
324 void toggle_punch_out ();
325 void show_loop_punch_ruler_and_disallow_hide ();
326 void reenable_hide_loop_punch_ruler_if_appropriate ();
327 void toggle_auto_return ();
328 void toggle_click ();
329 void toggle_audio_midi_setup ();
330 void toggle_session_auto_loop ();
331 void toggle_rc_options_window ();
332 void toggle_session_options_window ();
335 PublicEditor* editor;
337 Gtk::Tooltips _tooltips;
341 bool first_time_engine_run;
343 void goto_editor_window ();
344 void goto_mixer_window ();
345 void toggle_mixer_window ();
346 void toggle_meterbridge ();
347 void toggle_editor_mixer ();
349 int setup_windows ();
350 void setup_transport ();
353 static ARDOUR_UI *theArdourUI;
357 int ask_about_saving_session (const std::vector<std::string>& actions);
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 static gint _blink (void *);
375 gint blink_timeout_tag;
377 void start_blinking ();
378 void stop_blinking ();
380 void about_signal_response(int response);
382 Gtk::VBox top_packer;
384 sigc::connection clock_signal_connection;
385 void update_clocks ();
386 void start_clocking ();
387 void stop_clocking ();
389 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
391 void update_transport_clocks (framepos_t pos);
392 void record_state_changed ();
394 std::list<MidiTracer*> _midi_tracer_windows;
396 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
397 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
398 void reattach_all_tearoffs ();
400 /* Transport Control */
402 Gtkmm2ext::TearOff* transport_tearoff;
403 Gtk::Frame transport_frame;
404 Gtk::HBox transport_tearoff_hbox;
405 Gtk::HBox _editor_transport_box;
406 Gtk::HBox transport_hbox;
407 Gtk::Fixed transport_base;
408 Gtk::Fixed transport_button_base;
409 Gtk::Frame transport_button_frame;
410 Gtk::HBox transport_button_hbox;
411 Gtk::VBox transport_button_vbox;
412 Gtk::HBox transport_option_button_hbox;
413 Gtk::VBox transport_option_button_vbox;
414 Gtk::HBox transport_clock_hbox;
415 Gtk::VBox transport_clock_vbox;
416 Gtk::HBox primary_clock_hbox;
417 Gtk::HBox secondary_clock_hbox;
419 struct TransportControllable : public PBD::Controllable {
430 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
431 void set_value (double);
432 double get_value (void) const;
438 boost::shared_ptr<TransportControllable> roll_controllable;
439 boost::shared_ptr<TransportControllable> stop_controllable;
440 boost::shared_ptr<TransportControllable> goto_start_controllable;
441 boost::shared_ptr<TransportControllable> goto_end_controllable;
442 boost::shared_ptr<TransportControllable> auto_loop_controllable;
443 boost::shared_ptr<TransportControllable> play_selection_controllable;
444 boost::shared_ptr<TransportControllable> rec_controllable;
446 void toggle_follow_edits ();
448 void set_transport_controllable_state (const XMLNode&);
449 XMLNode& get_transport_controllable_state ();
451 ArdourButton roll_button;
452 ArdourButton stop_button;
453 ArdourButton goto_start_button;
454 ArdourButton goto_end_button;
455 ArdourButton auto_loop_button;
456 ArdourButton play_selection_button;
457 ArdourButton rec_button;
459 void toggle_external_sync ();
460 void toggle_time_master ();
461 void toggle_video_sync ();
463 ShuttleControl* shuttle_box;
465 ArdourButton auto_return_button;
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;
477 LevelMeterHBox * editor_meter;
478 float editor_meter_max_peak;
479 ArdourButton editor_meter_peak_display;
480 bool editor_meter_peak_button_release (GdkEventButton*);
482 void solo_blink (bool);
483 void sync_blink (bool);
484 void audition_blink (bool);
485 void feedback_blink (bool);
487 void set_flat_buttons();
489 void soloing_changed (bool);
490 void auditioning_changed (bool);
491 void _auditioning_changed (bool);
493 bool solo_alert_press (GdkEventButton* ev);
494 bool audition_alert_press (GdkEventButton* ev);
495 bool feedback_alert_press (GdkEventButton *);
497 void big_clock_value_changed ();
498 void primary_clock_value_changed ();
499 void secondary_clock_value_changed ();
501 /* called by Blink signal */
503 void transport_rec_enable_blink (bool onoff);
505 Gtk::Menu* session_popup_menu;
507 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
508 RecentSessionModelColumns() {
513 Gtk::TreeModelColumn<std::string> visible_name;
514 Gtk::TreeModelColumn<std::string> tip;
515 Gtk::TreeModelColumn<std::string> fullpath;
518 RecentSessionModelColumns recent_session_columns;
519 Gtk::TreeView recent_session_display;
520 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
522 ArdourDialog* session_selector_window;
523 Gtk::FileChooserDialog* open_session_selector;
525 void build_session_selector();
526 void redisplay_recent_sessions();
527 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
529 struct RecentSessionsSorter {
530 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
531 return ARDOUR::cmp_nocase(a.first, b.first) == -1;
535 /* menu bar and associated stuff */
537 Gtk::MenuBar* menu_bar;
538 Gtk::EventBox menu_bar_base;
541 void use_menubar_as_top_menubar ();
542 void build_menu_bar ();
544 Gtk::Label wall_clock_label;
545 gint update_wall_clock ();
547 Gtk::Label disk_space_label;
548 void update_disk_space ();
550 Gtk::Label timecode_format_label;
551 void update_timecode_format ();
553 Gtk::Label cpu_load_label;
554 void update_cpu_load ();
556 Gtk::Label buffer_load_label;
557 void update_buffer_load ();
559 Gtk::Label sample_rate_label;
560 void update_sample_rate (ARDOUR::framecnt_t);
562 Gtk::Label format_label;
563 void update_format ();
565 gint every_second ();
566 gint every_point_one_seconds ();
567 gint every_point_zero_something_seconds ();
570 sigc::connection second_connection;
571 sigc::connection point_one_second_connection;
572 sigc::connection point_zero_something_second_connection;
573 sigc::connection fps_connection;
575 void set_fps_timeout_connection ();
577 void open_session ();
578 void open_recent_session ();
579 void save_template ();
581 void edit_metadata ();
582 void import_metadata ();
584 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
585 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
587 void set_transport_sensitivity (bool);
589 //stuff for ProTools-style numpad
590 void transport_numpad_event (int num);
591 void transport_numpad_decimal ();
592 bool _numpad_locate_happening;
593 int _pending_locate_num;
594 gint transport_numpad_timeout ();
595 sigc::connection _numpad_timeout_connection;
597 void transport_goto_nth_marker (int nth);
598 void transport_goto_zero ();
599 void transport_goto_start ();
600 void transport_goto_end ();
601 void transport_goto_wallclock ();
602 void transport_stop ();
603 void transport_record (bool roll);
604 void transport_roll ();
605 void transport_play_selection();
606 void transport_play_preroll();
607 void transport_forward (int option);
608 void transport_rewind (int option);
609 void transport_loop ();
610 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
611 bool trx_record_enable_all_tracks ();
613 bool _session_is_new;
614 void set_session (ARDOUR::Session *);
615 void connect_dependents_to_session (ARDOUR::Session *);
616 void we_have_dependents ();
618 void setup_session_options ();
620 guint32 last_key_press_time;
622 void snapshot_session (bool switch_to_it);
623 void rename_session ();
624 void setup_order_hint ();
627 int create_editor ();
629 Meterbridge *meterbridge;
630 int create_meterbridge ();
631 /* Dialogs that can be created via new<T> */
633 WM::Proxy<SpeakerDialog> speaker_config_window;
634 WM::Proxy<KeyEditor> key_editor;
635 WM::Proxy<RCOptionEditor> rc_option_editor;
636 WM::Proxy<AddRouteDialog> add_route_dialog;
637 WM::Proxy<About> about;
638 WM::Proxy<LocationUIWindow> location_ui;
639 WM::Proxy<RouteParams_UI> route_params;
640 WM::Proxy<EngineControl> audio_midi_setup;
642 /* Windows/Dialogs that require a creator method */
644 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
645 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
646 WM::ProxyWithConstructor<BundleManager> bundle_manager;
647 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
648 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
649 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
651 /* creator methods */
653 SessionOptionEditor* create_session_option_editor ();
654 BundleManager* create_bundle_manager ();
655 AddVideoDialog* create_add_video_dialog ();
656 BigClockWindow* create_big_clock_window();
657 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
659 ARDOUR::SystemExec *video_server_process;
661 void handle_locations_change (ARDOUR::Location*);
663 /* Keyboard Handling */
665 ArdourKeyboard* keyboard;
667 /* Keymap handling */
669 void install_actions ();
671 void toggle_record_enable (uint32_t);
673 uint32_t rec_enabled_streams;
674 void count_recenabled_streams (ARDOUR::Route&);
678 void pop_back_splash (Gtk::Window&);
682 Gtk::MenuItem *cleanup_item;
684 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
688 bool have_configure_timeout;
689 ARDOUR::microseconds_t last_configure_time;
690 gint configure_timeout ();
692 ARDOUR::microseconds_t last_peak_grab;
693 ARDOUR::microseconds_t last_shuttle_request;
695 bool have_disk_speed_dialog_displayed;
696 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
697 void disk_overrun_handler ();
698 void disk_underrun_handler ();
699 void gui_idle_handler ();
701 void cancel_plugin_scan ();
702 void cancel_plugin_timeout ();
703 void plugin_scan_dialog (std::string type, std::string plugin, bool);
704 void plugin_scan_timeout (int);
706 void session_format_mismatch (std::string, std::string);
708 void session_dialog (std::string);
709 int pending_state_dialog ();
710 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
712 Gtk::MenuItem* jack_disconnect_item;
713 Gtk::MenuItem* jack_reconnect_item;
714 Gtk::Menu* jack_bufsize_menu;
716 Glib::RefPtr<Gtk::ActionGroup> common_actions;
718 void editor_realized ();
720 std::vector<std::string> positional_sync_strings;
722 void toggle_send_midi_feedback ();
723 void toggle_use_mmc ();
724 void toggle_send_mmc ();
725 void toggle_send_mtc ();
726 void toggle_send_midi_clock ();
728 void toggle_use_osc ();
730 void parameter_changed (std::string);
731 void session_parameter_changed (std::string);
735 void check_memory_locking ();
737 bool check_audioengine();
738 void audioengine_setup ();
740 void display_message (const char *prefix, gint prefix_len,
741 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
743 Gtk::Label status_bar_label;
744 bool status_bar_button_press (GdkEventButton*);
745 Gtk::ToggleButton error_log_button;
747 void loading_message (const std::string& msg);
749 PBD::ScopedConnectionList forever_connections;
750 PBD::ScopedConnection halt_connection;
752 void step_edit_status_change (bool);
754 void platform_specific ();
755 void platform_setup ();
757 /* these are used only in response to a platform-specific "ShouldQuit" signal
760 void queue_finish ();
761 void fontconfig_dialog ();
763 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
764 int ambiguous_file (std::string file, std::vector<std::string> hits);
766 bool click_button_clicked (GdkEventButton *);
768 VisibilityGroup _status_bar_visibility;
770 /** A ProcessThread so that we have some thread-local buffers for use by
771 * PluginEqGui::impulse_analysis ().
773 ARDOUR::ProcessThread* _process_thread;
775 void feedback_detected ();
777 ArdourButton midi_panic_button;
780 void successful_graph_sort ();
781 bool _feedback_exists;
783 void resize_text_widgets ();
785 std::string _announce_string;
786 void check_announcements ();
788 int do_audio_midi_setup (uint32_t);
791 #endif /* __ardour_gui_h__ */