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"
67 #include "video_timeline.h"
69 #include "ardour_button.h"
70 #include "ardour_dialog.h"
71 #include "ardour_window.h"
74 #include "ui_config.h"
76 #include "visibility_group.h"
77 #include "window_manager.h"
90 class ConnectionEditor;
92 class LocationUIWindow;
98 class SessionOptionEditor;
105 class GlobalPortMatrixWindow;
106 class GUIObjectState;
108 namespace Gtkmm2ext {
113 class ControlProtocolInfo;
122 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
125 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
128 bool run_startup (bool should_be_new, std::string load_template);
134 void launch_manual ();
135 void launch_reference ();
139 void idle_load (const std::string& path);
142 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
144 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
145 bool session_is_new() const { return _session_is_new; }
147 ARDOUR::Session* the_session() { return _session; }
149 bool get_smart_mode () const;
151 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
152 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
153 bool ask_about_loading_existing_session (const std::string& session_path);
155 /// @return true if session was successfully unloaded.
156 int unload_session (bool hide_stuff = false);
157 void close_session();
159 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
160 void save_state (const std::string & state_name = "", bool switch_to_it = false);
162 static ARDOUR_UI *instance () { return theArdourUI; }
163 static UIConfiguration *config () { return ui_config; }
165 PublicEditor& the_editor(){return *editor;}
166 Mixer_UI* the_mixer() { return mixer; }
168 void new_midi_tracer_window ();
169 void toggle_editing_space();
170 void toggle_keep_tearoffs();
172 Gtk::Tooltips& tooltips() { return _tooltips; }
174 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
176 static PublicEditor* _instance;
177 static sigc::signal<void,bool> Blink;
178 static sigc::signal<void> RapidScreenUpdate;
179 static sigc::signal<void> SuperRapidScreenUpdate;
180 /** Emitted frequently with the audible frame, false, and the edit point as
181 * parameters respectively.
183 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
185 static void close_all_dialogs () { CloseAllDialogs(); }
186 static sigc::signal<void> CloseAllDialogs;
188 XMLNode* editor_settings() const;
189 XMLNode* mixer_settings () const;
190 XMLNode* keyboard_settings () const;
191 XMLNode* tearoff_settings (const char*) const;
193 void save_ardour_state ();
194 gboolean configure_handler (GdkEventConfigure* conf);
196 void halt_on_xrun_message ();
197 void xrun_handler (framepos_t);
198 void create_xrun_marker (framepos_t);
200 GUIObjectState* gui_object_state;
202 MainClock* primary_clock;
203 MainClock* secondary_clock;
204 void focus_on_clock ();
205 AudioClock* big_clock;
207 TimeInfoBox* time_info_box;
209 VideoTimeLine *video_timeline;
211 void store_clock_modes ();
212 void restore_clock_modes ();
213 void reset_main_clocks ();
215 void synchronize_sync_source_and_video_pullup ();
217 void add_route (Gtk::Window* float_window);
218 void add_routes_part_two ();
219 void add_routes_thread ();
221 void add_video (Gtk::Window* float_window);
222 void remove_video ();
223 void start_video_server_menu (Gtk::Window* float_window);
224 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
225 void stop_video_server (bool ask_confirm=false);
226 void flush_videotimeline_cache (bool localcacheonly=false);
228 void session_add_audio_track (
230 int32_t output_channels,
231 ARDOUR::TrackMode mode,
232 ARDOUR::RouteGroup* route_group,
234 std::string const & name_template
237 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
240 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
241 uint32_t how_many, std::string const & name_template) {
242 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
245 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
246 ARDOUR::PluginInfoPtr instrument) {
247 session_add_midi_route (true, route_group, how_many, name_template, instrument);
250 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,
251 ARDOUR::PluginInfoPtr instrument);
253 /*void session_add_midi_bus () {
254 session_add_midi_route (false);
257 int create_engine ();
260 gint exit_on_main_window_close (GdkEventAny *);
262 void maximise_editing_space ();
263 void restore_editing_space ();
265 void update_tearoff_visibility ();
267 void setup_profile ();
268 void setup_tooltips ();
270 void set_shuttle_fract (double);
272 void get_process_buffers ();
273 void drop_process_buffers ();
275 const std::string& announce_string() const { return _announce_string; }
278 friend class PublicEditor;
280 void toggle_auto_play ();
281 void toggle_auto_input ();
282 void toggle_punch ();
283 void unset_dual_punch ();
284 bool ignore_dual_punch;
285 void toggle_punch_in ();
286 void toggle_punch_out ();
287 void show_loop_punch_ruler_and_disallow_hide ();
288 void reenable_hide_loop_punch_ruler_if_appropriate ();
289 void toggle_auto_return ();
290 void toggle_click ();
292 void toggle_session_auto_loop ();
294 void toggle_rc_options_window ();
295 void toggle_session_options_window ();
298 ArdourStartup* _startup;
299 ARDOUR::AudioEngine *engine;
300 Gtk::Tooltips _tooltips;
305 void goto_editor_window ();
306 void goto_mixer_window ();
307 void toggle_mixer_window ();
308 void toggle_editor_mixer ();
310 int setup_windows ();
311 void setup_transport ();
314 static ARDOUR_UI *theArdourUI;
319 int ask_about_saving_session (const std::vector<std::string>& actions);
321 /* periodic safety backup, to be precise */
322 gint autosave_session();
323 void update_autosave();
324 sigc::connection _autosave_connection;
326 void map_transport_state ();
327 int32_t do_engine_start ();
329 void engine_halted (const char* reason, bool free_reason);
330 void engine_stopped ();
331 void engine_running ();
335 static gint _blink (void *);
337 gint blink_timeout_tag;
339 void start_blinking ();
340 void stop_blinking ();
342 void about_signal_response(int response);
344 Gtk::VBox top_packer;
346 sigc::connection clock_signal_connection;
347 void update_clocks ();
348 void start_clocking ();
349 void stop_clocking ();
351 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
353 void update_transport_clocks (framepos_t pos);
354 void record_state_changed ();
356 std::list<MidiTracer*> _midi_tracer_windows;
358 /* Transport Control */
360 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
361 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
363 Gtkmm2ext::TearOff* transport_tearoff;
364 Gtk::Frame transport_frame;
365 Gtk::HBox transport_tearoff_hbox;
366 Gtk::HBox _editor_transport_box;
367 Gtk::HBox transport_hbox;
368 Gtk::Fixed transport_base;
369 Gtk::Fixed transport_button_base;
370 Gtk::Frame transport_button_frame;
371 Gtk::HBox transport_button_hbox;
372 Gtk::VBox transport_button_vbox;
373 Gtk::HBox transport_option_button_hbox;
374 Gtk::VBox transport_option_button_vbox;
375 Gtk::HBox transport_clock_hbox;
376 Gtk::VBox transport_clock_vbox;
377 Gtk::HBox primary_clock_hbox;
378 Gtk::HBox secondary_clock_hbox;
380 struct TransportControllable : public PBD::Controllable {
391 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
392 void set_value (double);
393 double get_value (void) const;
399 boost::shared_ptr<TransportControllable> roll_controllable;
400 boost::shared_ptr<TransportControllable> stop_controllable;
401 boost::shared_ptr<TransportControllable> goto_start_controllable;
402 boost::shared_ptr<TransportControllable> goto_end_controllable;
403 boost::shared_ptr<TransportControllable> auto_loop_controllable;
404 boost::shared_ptr<TransportControllable> play_selection_controllable;
405 boost::shared_ptr<TransportControllable> rec_controllable;
407 void toggle_always_play_range ();
409 void set_transport_controllable_state (const XMLNode&);
410 XMLNode& get_transport_controllable_state ();
412 ArdourButton roll_button;
413 ArdourButton stop_button;
414 ArdourButton goto_start_button;
415 ArdourButton goto_end_button;
416 ArdourButton auto_loop_button;
417 ArdourButton play_selection_button;
418 ArdourButton rec_button;
420 void toggle_external_sync ();
421 void toggle_time_master ();
422 void toggle_video_sync ();
424 ShuttleControl* shuttle_box;
426 ArdourButton auto_return_button;
427 ArdourButton follow_edits_button;
428 ArdourButton auto_input_button;
429 ArdourButton click_button;
430 ArdourButton sync_button;
432 ArdourButton auditioning_alert_button;
433 ArdourButton solo_alert_button;
434 ArdourButton feedback_alert_button;
438 void solo_blink (bool);
439 void sync_blink (bool);
440 void audition_blink (bool);
441 void feedback_blink (bool);
443 void soloing_changed (bool);
444 void auditioning_changed (bool);
445 void _auditioning_changed (bool);
447 bool solo_alert_press (GdkEventButton* ev);
448 bool audition_alert_press (GdkEventButton* ev);
449 bool feedback_alert_press (GdkEventButton *);
451 void big_clock_value_changed ();
452 void primary_clock_value_changed ();
453 void secondary_clock_value_changed ();
455 /* called by Blink signal */
457 void transport_rec_enable_blink (bool onoff);
459 Gtk::Menu* session_popup_menu;
461 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
462 RecentSessionModelColumns() {
467 Gtk::TreeModelColumn<std::string> visible_name;
468 Gtk::TreeModelColumn<std::string> tip;
469 Gtk::TreeModelColumn<std::string> fullpath;
472 RecentSessionModelColumns recent_session_columns;
473 Gtk::TreeView recent_session_display;
474 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
476 ArdourDialog* session_selector_window;
477 Gtk::FileChooserDialog* open_session_selector;
479 void build_session_selector();
480 void redisplay_recent_sessions();
481 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
483 struct RecentSessionsSorter {
484 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
485 return cmp_nocase(a.first, b.first) == -1;
489 /* menu bar and associated stuff */
491 Gtk::MenuBar* menu_bar;
492 Gtk::EventBox menu_bar_base;
495 void use_menubar_as_top_menubar ();
496 void build_menu_bar ();
498 Gtk::Label wall_clock_label;
499 gint update_wall_clock ();
501 Gtk::Label disk_space_label;
502 void update_disk_space ();
504 Gtk::Label timecode_format_label;
505 void update_timecode_format ();
507 Gtk::Label cpu_load_label;
508 void update_cpu_load ();
510 Gtk::Label buffer_load_label;
511 void update_buffer_load ();
513 Gtk::Label sample_rate_label;
514 void update_sample_rate (ARDOUR::framecnt_t);
516 Gtk::Label format_label;
517 void update_format ();
519 gint every_second ();
520 gint every_point_one_seconds ();
521 gint every_point_zero_one_seconds ();
523 sigc::connection second_connection;
524 sigc::connection point_one_second_connection;
525 sigc::connection point_oh_five_second_connection;
526 sigc::connection point_zero_one_second_connection;
528 void open_session ();
529 void open_recent_session ();
530 void save_template ();
532 void edit_metadata ();
533 void import_metadata ();
535 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
536 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
538 void set_transport_sensitivity (bool);
540 void transport_goto_zero ();
541 void transport_goto_start ();
542 void transport_goto_end ();
543 void transport_goto_wallclock ();
544 void transport_stop ();
545 void transport_record (bool roll);
546 void transport_roll ();
547 void transport_play_selection();
548 void transport_play_preroll();
549 void transport_forward (int option);
550 void transport_rewind (int option);
551 void transport_loop ();
552 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
554 bool _session_is_new;
555 void set_session (ARDOUR::Session *);
556 void connect_dependents_to_session (ARDOUR::Session *);
557 void we_have_dependents ();
559 void setup_session_options ();
561 guint32 last_key_press_time;
563 void snapshot_session (bool switch_to_it);
564 void rename_session ();
569 PublicEditor *editor;
570 int create_editor ();
572 /* Dialogs that can be created via new<T> */
574 WM::Proxy<SpeakerDialog> speaker_config_window;
575 WM::Proxy<ThemeManager> theme_manager;
576 WM::Proxy<KeyEditor> key_editor;
577 WM::Proxy<RCOptionEditor> rc_option_editor;
578 WM::Proxy<AddRouteDialog> add_route_dialog;
579 WM::Proxy<About> about;
580 WM::Proxy<LocationUIWindow> location_ui;
581 WM::Proxy<RouteParams_UI> route_params;
583 /* Windows/Dialogs that require a creator method */
585 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
586 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
587 WM::ProxyWithConstructor<BundleManager> bundle_manager;
588 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
589 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
590 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
592 /* creator methods */
594 SessionOptionEditor* create_session_option_editor ();
595 BundleManager* create_bundle_manager ();
596 AddVideoDialog* create_add_video_dialog ();
597 BigClockWindow* create_big_clock_window();
598 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
600 static UIConfiguration *ui_config;
602 SystemExec *video_server_process;
604 void handle_locations_change (ARDOUR::Location*);
606 /* Keyboard Handling */
608 ArdourKeyboard* keyboard;
610 /* Keymap handling */
612 void install_actions ();
614 void toggle_record_enable (uint32_t);
616 uint32_t rec_enabled_streams;
617 void count_recenabled_streams (ARDOUR::Route&);
621 void pop_back_splash (Gtk::Window&);
625 Gtk::MenuItem *cleanup_item;
627 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
631 bool have_configure_timeout;
632 ARDOUR::microseconds_t last_configure_time;
633 gint configure_timeout ();
635 ARDOUR::microseconds_t last_peak_grab;
636 ARDOUR::microseconds_t last_shuttle_request;
638 bool have_disk_speed_dialog_displayed;
639 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
640 void disk_overrun_handler ();
641 void disk_underrun_handler ();
643 void session_format_mismatch (std::string, std::string);
645 void session_dialog (std::string);
646 int pending_state_dialog ();
647 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
649 void disconnect_from_jack ();
650 void reconnect_to_jack ();
651 void set_jack_buffer_size (ARDOUR::pframes_t);
653 Gtk::MenuItem* jack_disconnect_item;
654 Gtk::MenuItem* jack_reconnect_item;
655 Gtk::Menu* jack_bufsize_menu;
657 Glib::RefPtr<Gtk::ActionGroup> common_actions;
659 void editor_realized ();
661 std::vector<std::string> positional_sync_strings;
663 void toggle_send_midi_feedback ();
664 void toggle_use_mmc ();
665 void toggle_send_mmc ();
666 void toggle_send_mtc ();
667 void toggle_send_midi_clock ();
669 void toggle_use_osc ();
671 void parameter_changed (std::string);
672 void session_parameter_changed (std::string);
676 void no_memory_warning ();
677 void check_memory_locking ();
679 bool check_audioengine();
680 void audioengine_setup ();
682 void display_message (const char *prefix, gint prefix_len,
683 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
685 Gtk::Label status_bar_label;
686 bool status_bar_button_press (GdkEventButton*);
687 Gtk::ToggleButton error_log_button;
689 void loading_message (const std::string& msg);
691 PBD::ScopedConnectionList forever_connections;
693 void step_edit_status_change (bool);
695 void platform_specific ();
696 void platform_setup ();
698 /* these are used only in response to a platform-specific "ShouldQuit" signal
701 void queue_finish ();
702 void fontconfig_dialog ();
704 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
705 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
707 bool click_button_clicked (GdkEventButton *);
709 VisibilityGroup _status_bar_visibility;
711 /** A ProcessThread so that we have some thread-local buffers for use by
712 * PluginEqGui::impulse_analysis ().
714 ARDOUR::ProcessThread* _process_thread;
716 void feedback_detected ();
718 ArdourButton midi_panic_button;
721 void successful_graph_sort ();
722 bool _feedback_exists;
724 void resize_text_widgets ();
726 std::string _announce_string;
727 void check_announcements ();
730 #endif /* __ardour_gui_h__ */