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 */
38 #include <libgnomecanvasmm/canvas.h>
40 #include "pbd/xml++.h"
41 #include "pbd/controllable.h"
42 #include <gtkmm/box.h>
43 #include <gtkmm/frame.h>
44 #include <gtkmm/label.h>
45 #include <gtkmm/table.h>
46 #include <gtkmm/fixed.h>
47 #include <gtkmm/drawingarea.h>
48 #include <gtkmm/eventbox.h>
49 #include <gtkmm/menu.h>
50 #include <gtkmm/menuitem.h>
51 #include <gtkmm/button.h>
52 #include <gtkmm/togglebutton.h>
53 #include <gtkmm/treeview.h>
54 #include <gtkmm/menubar.h>
55 #include <gtkmm/textbuffer.h>
56 #include <gtkmm/adjustment.h>
57 #include <gtkmm2ext/gtk_ui.h>
58 #include <gtkmm2ext/click_box.h>
59 #include <gtkmm2ext/stateful_button.h>
60 #include <gtkmm2ext/bindable_button.h>
62 #include "ardour/ardour.h"
63 #include "ardour/types.h"
64 #include "ardour/utils.h"
65 #include "ardour/plugin.h"
66 #include "ardour/session_handle.h"
68 #ifdef WITH_VIDEOTIMELINE
69 #include "video_timeline.h"
72 #include "ardour_dialog.h"
73 #include "ardour_button.h"
75 #include "ui_config.h"
76 #include "window_proxy.h"
78 #include "visibility_group.h"
82 #ifdef WITH_VIDEOTIMELINE
92 class ConnectionEditor;
94 class LocationUIWindow;
100 class SessionOptionEditor;
101 class ShuttleControl;
107 class WindowProxyBase;
108 class GlobalPortMatrixWindow;
109 class GUIObjectState;
111 namespace Gtkmm2ext {
116 class ControlProtocolInfo;
125 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
128 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
131 bool run_startup (bool should_be_new, std::string load_template);
137 void launch_manual ();
138 void launch_reference ();
142 void idle_load (const std::string& path);
145 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
147 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
148 bool session_is_new() const { return _session_is_new; }
150 ARDOUR::Session* the_session() { return _session; }
152 bool get_smart_mode () const;
154 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
155 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
156 bool ask_about_loading_existing_session (const std::string& session_path);
158 /// @return true if session was successfully unloaded.
159 int unload_session (bool hide_stuff = false);
160 void close_session();
162 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
163 void save_state (const std::string & state_name = "", bool switch_to_it = false);
165 static ARDOUR_UI *instance () { return theArdourUI; }
166 static UIConfiguration *config () { return ui_config; }
168 PublicEditor& the_editor(){return *editor;}
169 Mixer_UI* the_mixer() { return mixer; }
171 void toggle_key_editor ();
172 void toggle_location_window ();
173 void toggle_theme_manager ();
174 void toggle_bundle_manager ();
175 void toggle_big_clock_window ();
176 void toggle_speaker_config_window ();
177 void new_midi_tracer_window ();
178 void toggle_route_params_window ();
179 void toggle_editing_space();
180 void toggle_keep_tearoffs();
182 Gtk::Tooltips& tooltips() { return _tooltips; }
184 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
186 static PublicEditor* _instance;
187 static sigc::signal<void,bool> Blink;
188 static sigc::signal<void> RapidScreenUpdate;
189 static sigc::signal<void> SuperRapidScreenUpdate;
190 /** Emitted frequently with the audible frame, false, and the edit point as
191 * parameters respectively.
193 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
195 XMLNode* editor_settings() const;
196 XMLNode* mixer_settings () const;
197 XMLNode* keyboard_settings () const;
198 XMLNode* tearoff_settings (const char*) const;
200 void save_ardour_state ();
201 gboolean configure_handler (GdkEventConfigure* conf);
203 void halt_on_xrun_message ();
204 void xrun_handler (framepos_t);
205 void create_xrun_marker (framepos_t);
207 GUIObjectState* gui_object_state;
209 MainClock* primary_clock;
210 MainClock* secondary_clock;
211 void focus_on_clock ();
213 TimeInfoBox* time_info_box;
215 #ifdef WITH_VIDEOTIMELINE
216 VideoTimeLine *video_timeline;
219 void store_clock_modes ();
220 void restore_clock_modes ();
221 void reset_main_clocks ();
223 void synchronize_sync_source_and_video_pullup ();
225 void add_route (Gtk::Window* float_window);
226 void add_routes_part_two ();
227 void add_routes_thread ();
228 #ifdef WITH_VIDEOTIMELINE
229 void add_video (Gtk::Window* float_window);
230 void start_video_server_menu (Gtk::Window* float_window);
231 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
232 void stop_video_server (bool ask_confirm=false);
233 void flush_videotimeline_cache (bool localcacheonly=false);
236 void session_add_audio_track (
238 int32_t output_channels,
239 ARDOUR::TrackMode mode,
240 ARDOUR::RouteGroup* route_group,
242 std::string const & name_template
245 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
248 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
249 uint32_t how_many, std::string const & name_template) {
250 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
253 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
254 ARDOUR::PluginInfoPtr instrument) {
255 session_add_midi_route (true, route_group, how_many, name_template, instrument);
258 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,
259 ARDOUR::PluginInfoPtr instrument);
261 /*void session_add_midi_bus () {
262 session_add_midi_route (false);
265 int create_engine ();
268 gint exit_on_main_window_close (GdkEventAny *);
270 void maximise_editing_space ();
271 void restore_editing_space ();
273 void update_tearoff_visibility ();
275 void setup_profile ();
276 void setup_tooltips ();
278 void set_shuttle_fract (double);
280 void add_window_proxy (WindowProxyBase *);
281 void remove_window_proxy (WindowProxyBase *);
283 void get_process_buffers ();
284 void drop_process_buffers ();
286 const std::string& announce_string() const { return _announce_string; }
289 friend class PublicEditor;
291 void toggle_auto_play ();
292 void toggle_auto_input ();
293 void toggle_punch ();
294 void unset_dual_punch ();
295 bool ignore_dual_punch;
296 void toggle_punch_in ();
297 void toggle_punch_out ();
298 void show_loop_punch_ruler_and_disallow_hide ();
299 void reenable_hide_loop_punch_ruler_if_appropriate ();
300 void toggle_auto_return ();
301 void toggle_click ();
303 void toggle_session_auto_loop ();
305 void toggle_rc_options_window ();
306 void toggle_session_options_window ();
309 ArdourStartup* _startup;
310 ARDOUR::AudioEngine *engine;
311 Gtk::Tooltips _tooltips;
313 void goto_editor_window ();
314 void goto_mixer_window ();
315 void toggle_mixer_window ();
316 void toggle_mixer_on_top ();
318 int setup_windows ();
319 void setup_transport ();
322 static ARDOUR_UI *theArdourUI;
327 int ask_about_saving_session (const std::vector<std::string>& actions);
329 /* periodic safety backup, to be precise */
330 gint autosave_session();
331 void update_autosave();
332 sigc::connection _autosave_connection;
334 void map_transport_state ();
335 int32_t do_engine_start ();
337 void engine_halted (const char* reason, bool free_reason);
338 void engine_stopped ();
339 void engine_running ();
343 static gint _blink (void *);
345 gint blink_timeout_tag;
347 void start_blinking ();
348 void stop_blinking ();
350 void about_signal_response(int response);
352 Gtk::VBox top_packer;
354 sigc::connection clock_signal_connection;
355 void update_clocks ();
356 void start_clocking ();
357 void stop_clocking ();
359 void manage_window (Gtk::Window&);
361 AudioClock* big_clock;
362 ActionWindowProxy<Gtk::Window>* big_clock_window;
363 int original_big_clock_width;
364 int original_big_clock_height;
365 double original_big_clock_font_size;
367 void big_clock_size_allocate (Gtk::Allocation&);
368 bool idle_big_clock_text_resizer (int width, int height);
369 void big_clock_realized ();
370 bool big_clock_resize_in_progress;
371 int big_clock_height;
372 void big_clock_catch_focus ();
373 void big_clock_reset_aspect_ratio ();
375 void float_big_clock (Gtk::Window* parent);
376 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
378 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
380 void update_transport_clocks (framepos_t pos);
381 void record_state_changed ();
383 std::list<MidiTracer*> _midi_tracer_windows;
385 /* Transport Control */
387 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
388 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
390 Gtkmm2ext::TearOff* transport_tearoff;
391 Gtk::Frame transport_frame;
392 Gtk::HBox transport_tearoff_hbox;
393 Gtk::HBox _editor_transport_box;
394 Gtk::HBox transport_hbox;
395 Gtk::Fixed transport_base;
396 Gtk::Fixed transport_button_base;
397 Gtk::Frame transport_button_frame;
398 Gtk::HBox transport_button_hbox;
399 Gtk::VBox transport_button_vbox;
400 Gtk::HBox transport_option_button_hbox;
401 Gtk::VBox transport_option_button_vbox;
402 Gtk::HBox transport_clock_hbox;
403 Gtk::VBox transport_clock_vbox;
404 Gtk::HBox primary_clock_hbox;
405 Gtk::HBox secondary_clock_hbox;
407 struct TransportControllable : public PBD::Controllable {
418 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
419 void set_value (double);
420 double get_value (void) const;
426 boost::shared_ptr<TransportControllable> roll_controllable;
427 boost::shared_ptr<TransportControllable> stop_controllable;
428 boost::shared_ptr<TransportControllable> goto_start_controllable;
429 boost::shared_ptr<TransportControllable> goto_end_controllable;
430 boost::shared_ptr<TransportControllable> auto_loop_controllable;
431 boost::shared_ptr<TransportControllable> play_selection_controllable;
432 boost::shared_ptr<TransportControllable> rec_controllable;
434 void toggle_always_play_range ();
436 void set_transport_controllable_state (const XMLNode&);
437 XMLNode& get_transport_controllable_state ();
439 ArdourButton roll_button;
440 ArdourButton stop_button;
441 ArdourButton goto_start_button;
442 ArdourButton goto_end_button;
443 ArdourButton auto_loop_button;
444 ArdourButton play_selection_button;
445 ArdourButton rec_button;
447 void toggle_external_sync ();
448 void toggle_time_master ();
449 void toggle_video_sync ();
451 ShuttleControl* shuttle_box;
453 ArdourButton auto_return_button;
454 ArdourButton follow_edits_button;
455 ArdourButton auto_input_button;
456 ArdourButton click_button;
457 ArdourButton sync_button;
459 ArdourButton auditioning_alert_button;
460 ArdourButton solo_alert_button;
461 ArdourButton feedback_alert_button;
465 void solo_blink (bool);
466 void sync_blink (bool);
467 void audition_blink (bool);
468 void feedback_blink (bool);
470 void soloing_changed (bool);
471 void auditioning_changed (bool);
472 void _auditioning_changed (bool);
474 bool solo_alert_press (GdkEventButton* ev);
475 bool audition_alert_press (GdkEventButton* ev);
476 bool feedback_alert_press (GdkEventButton *);
478 void big_clock_value_changed ();
479 void primary_clock_value_changed ();
480 void secondary_clock_value_changed ();
482 /* called by Blink signal */
484 void transport_rec_enable_blink (bool onoff);
486 Gtk::Menu* session_popup_menu;
488 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
489 RecentSessionModelColumns() {
494 Gtk::TreeModelColumn<std::string> visible_name;
495 Gtk::TreeModelColumn<std::string> tip;
496 Gtk::TreeModelColumn<std::string> fullpath;
499 RecentSessionModelColumns recent_session_columns;
500 Gtk::TreeView recent_session_display;
501 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
503 ArdourDialog* session_selector_window;
504 Gtk::FileChooserDialog* open_session_selector;
506 void build_session_selector();
507 void redisplay_recent_sessions();
508 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
510 struct RecentSessionsSorter {
511 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
512 return cmp_nocase(a.first, b.first) == -1;
516 /* menu bar and associated stuff */
518 Gtk::MenuBar* menu_bar;
519 Gtk::EventBox menu_bar_base;
522 void use_menubar_as_top_menubar ();
523 void build_menu_bar ();
525 Gtk::Label wall_clock_label;
526 gint update_wall_clock ();
528 Gtk::Label disk_space_label;
529 void update_disk_space ();
531 Gtk::Label timecode_format_label;
532 void update_timecode_format ();
534 Gtk::Label cpu_load_label;
535 void update_cpu_load ();
537 Gtk::Label buffer_load_label;
538 void update_buffer_load ();
540 Gtk::Label sample_rate_label;
541 void update_sample_rate (ARDOUR::framecnt_t);
543 Gtk::Label format_label;
544 void update_format ();
546 gint every_second ();
547 gint every_point_one_seconds ();
548 gint every_point_zero_one_seconds ();
550 sigc::connection second_connection;
551 sigc::connection point_one_second_connection;
552 sigc::connection point_oh_five_second_connection;
553 sigc::connection point_zero_one_second_connection;
555 void open_session ();
556 void open_recent_session ();
557 void save_template ();
559 void edit_metadata ();
560 void import_metadata ();
562 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
563 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
565 void set_transport_sensitivity (bool);
567 void transport_goto_zero ();
568 void transport_goto_start ();
569 void transport_goto_end ();
570 void transport_goto_wallclock ();
571 void transport_stop ();
572 void transport_record (bool roll);
573 void transport_roll ();
574 void transport_play_selection();
575 void transport_play_preroll();
576 void transport_forward (int option);
577 void transport_rewind (int option);
578 void transport_loop ();
579 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
581 bool _session_is_new;
582 void set_session (ARDOUR::Session *);
583 void connect_dependents_to_session (ARDOUR::Session *);
584 void we_have_dependents ();
586 void setup_session_options ();
588 guint32 last_key_press_time;
590 void snapshot_session (bool switch_to_it);
591 void rename_session ();
596 PublicEditor *editor;
597 int create_editor ();
599 RouteParams_UI *route_params;
600 int create_route_params ();
602 BundleManager *bundle_manager;
603 void create_bundle_manager ();
605 ActionWindowProxy<LocationUIWindow>* location_ui;
606 int create_location_ui ();
607 void handle_locations_change (ARDOUR::Location*);
609 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
610 void toggle_global_port_matrix (ARDOUR::DataType);
612 static UIConfiguration *ui_config;
613 ThemeManager *theme_manager;
615 /* Key bindings editor */
617 KeyEditor *key_editor;
619 /* RC Options window */
621 RCOptionEditor *rc_option_editor;
623 SessionOptionEditor *session_option_editor;
627 AddRouteDialog *add_route_dialog;
629 #ifdef WITH_VIDEOTIMELINE
631 AddVideoDialog *add_video_dialog;
632 SystemExec *video_server_process;
635 /* Keyboard Handling */
637 ArdourKeyboard* keyboard;
639 /* Keymap handling */
641 void install_actions ();
643 void toggle_record_enable (uint32_t);
645 uint32_t rec_enabled_streams;
646 void count_recenabled_streams (ARDOUR::Route&);
651 void pop_back_splash (Gtk::Window&);
655 Gtk::MenuItem *cleanup_item;
657 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
661 bool have_configure_timeout;
662 ARDOUR::microseconds_t last_configure_time;
663 gint configure_timeout ();
665 ARDOUR::microseconds_t last_peak_grab;
666 ARDOUR::microseconds_t last_shuttle_request;
668 bool have_disk_speed_dialog_displayed;
669 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
670 void disk_overrun_handler ();
671 void disk_underrun_handler ();
673 void session_format_mismatch (std::string, std::string);
675 void session_dialog (std::string);
676 int pending_state_dialog ();
677 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
679 void disconnect_from_jack ();
680 void reconnect_to_jack ();
681 void set_jack_buffer_size (ARDOUR::pframes_t);
683 Gtk::MenuItem* jack_disconnect_item;
684 Gtk::MenuItem* jack_reconnect_item;
685 Gtk::Menu* jack_bufsize_menu;
687 Glib::RefPtr<Gtk::ActionGroup> common_actions;
689 void editor_realized ();
691 std::vector<std::string> positional_sync_strings;
693 void toggle_send_midi_feedback ();
694 void toggle_use_mmc ();
695 void toggle_send_mmc ();
696 void toggle_send_mtc ();
697 void toggle_send_midi_clock ();
699 void toggle_use_osc ();
701 void parameter_changed (std::string);
702 void session_parameter_changed (std::string);
706 void no_memory_warning ();
707 void check_memory_locking ();
709 bool check_audioengine();
710 void audioengine_setup ();
712 void display_message (const char *prefix, gint prefix_len,
713 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
715 Gtk::Label status_bar_label;
716 bool status_bar_button_press (GdkEventButton*);
717 Gtk::ToggleButton error_log_button;
719 void loading_message (const std::string& msg);
721 PBD::ScopedConnectionList forever_connections;
723 void step_edit_status_change (bool);
725 void platform_specific ();
726 void platform_setup ();
728 /* these are used only in response to a platform-specific "ShouldQuit" signal
731 void queue_finish ();
732 void fontconfig_dialog ();
734 std::list<WindowProxyBase*> _window_proxies;
736 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
737 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
739 bool click_button_clicked (GdkEventButton *);
741 VisibilityGroup _status_bar_visibility;
743 /** A ProcessThread so that we have some thread-local buffers for use by
744 * PluginEqGui::impulse_analysis ().
746 ARDOUR::ProcessThread* _process_thread;
748 void feedback_detected ();
750 ArdourButton midi_panic_button;
753 void successful_graph_sort ();
754 bool _feedback_exists;
756 void resize_text_widgets ();
758 std::string _announce_string;
759 void check_announcements ();
762 #endif /* __ardour_gui_h__ */