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>
61 #include "ardour/ardour.h"
62 #include "ardour/types.h"
63 #include "ardour/utils.h"
64 #include "ardour/session_handle.h"
66 #include "ardour_dialog.h"
67 #include "ardour_button.h"
69 #include "ui_config.h"
70 #include "window_proxy.h"
72 #include "visibility_group.h"
80 class ConnectionEditor;
82 class LocationUIWindow;
87 class SessionOptionEditor;
94 class WindowProxyBase;
95 class GlobalPortMatrixWindow;
103 class ControlProtocolInfo;
112 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
115 ARDOUR_UI (int *argcp, char **argvp[]);
118 bool run_startup (bool should_be_new, std::string load_template);
124 void launch_manual ();
125 void launch_reference ();
129 void idle_load (const std::string& path);
132 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
134 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
135 bool session_is_new() const { return _session_is_new; }
137 ARDOUR::Session* the_session() { return _session; }
139 bool will_create_new_session_automatically() const {
140 return _will_create_new_session_automatically;
143 void set_will_create_new_session_automatically (bool yn) {
144 _will_create_new_session_automatically = yn;
147 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
148 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
149 bool ask_about_loading_existing_session (const std::string& session_path);
151 /// @return true if session was successfully unloaded.
152 int unload_session (bool hide_stuff = false);
153 void close_session();
155 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
156 void save_state (const std::string & state_name = "", bool switch_to_it = false);
158 static ARDOUR_UI *instance () { return theArdourUI; }
159 static UIConfiguration *config () { return ui_config; }
161 PublicEditor& the_editor(){return *editor;}
162 Mixer_UI* the_mixer() { return mixer; }
164 void toggle_key_editor ();
165 void toggle_location_window ();
166 void toggle_theme_manager ();
167 void toggle_bundle_manager ();
168 void toggle_big_clock_window ();
169 void toggle_speaker_config_window ();
170 void new_midi_tracer_window ();
171 void toggle_route_params_window ();
172 void toggle_editing_space();
173 void toggle_keep_tearoffs();
175 Gtk::Tooltips& tooltips() { return _tooltips; }
177 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
179 static PublicEditor* _instance;
180 static sigc::signal<void,bool> Blink;
181 static sigc::signal<void> RapidScreenUpdate;
182 static sigc::signal<void> SuperRapidScreenUpdate;
183 /** Emitted frequently with the audible frame, false, and the edit point as
184 * parameters respectively.
186 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
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 do_transport_locate (framepos_t, bool);
197 void halt_on_xrun_message ();
198 void xrun_handler (framepos_t);
199 void create_xrun_marker (framepos_t);
201 GUIObjectState* gui_object_state;
203 AudioClock* primary_clock;
204 AudioClock* secondary_clock;
205 void focus_on_clock ();
207 TimeInfoBox* time_info_box;
209 void store_clock_modes ();
210 void restore_clock_modes ();
211 void reset_main_clocks ();
213 void synchronize_sync_source_and_video_pullup ();
215 void add_route (Gtk::Window* float_window);
217 void session_add_audio_track (
219 int32_t output_channels,
220 ARDOUR::TrackMode mode,
221 ARDOUR::RouteGroup* route_group,
223 std::string const & name_template
226 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
229 void session_add_audio_bus (
231 int32_t output_channels,
232 ARDOUR::RouteGroup* route_group,
234 std::string const & name_template
237 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
240 void session_add_midi_track (
241 ARDOUR::RouteGroup* route_group,
243 std::string const & name_template
246 session_add_midi_route (true, route_group, how_many, name_template);
249 /*void session_add_midi_bus () {
250 session_add_midi_route (false);
253 int create_engine ();
256 gint exit_on_main_window_close (GdkEventAny *);
258 void maximise_editing_space ();
259 void restore_editing_space ();
261 void setup_profile ();
263 void setup_tooltips ();
265 void set_shuttle_fract (double);
267 void add_window_proxy (WindowProxyBase *);
268 void remove_window_proxy (WindowProxyBase *);
270 void get_process_buffers ();
271 void drop_process_buffers ();
274 friend class PublicEditor;
276 void toggle_clocking ();
277 void toggle_auto_play ();
278 void toggle_auto_input ();
279 void toggle_punch ();
280 void unset_dual_punch ();
281 bool ignore_dual_punch;
282 void toggle_punch_in ();
283 void toggle_punch_out ();
284 void show_loop_punch_ruler_and_disallow_hide ();
285 void reenable_hide_loop_punch_ruler_if_appropriate ();
286 void toggle_auto_return ();
287 void toggle_click ();
289 void toggle_session_auto_loop ();
291 void toggle_rc_options_window ();
292 void toggle_session_options_window ();
295 ArdourStartup* _startup;
296 ARDOUR::AudioEngine *engine;
297 Gtk::Tooltips _tooltips;
299 void goto_editor_window ();
300 void goto_mixer_window ();
301 void toggle_mixer_window ();
302 void toggle_mixer_on_top ();
304 int setup_windows ();
305 void setup_transport ();
308 static ARDOUR_UI *theArdourUI;
310 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
314 int ask_about_saving_session (const std::vector<std::string>& actions);
316 /* periodic safety backup, to be precise */
317 gint autosave_session();
318 void update_autosave();
319 sigc::connection _autosave_connection;
321 void map_transport_state ();
322 int32_t do_engine_start ();
324 void engine_halted (const char* reason, bool free_reason);
325 void engine_stopped ();
326 void engine_running ();
330 static gint _blink (void *);
332 gint blink_timeout_tag;
334 void start_blinking ();
335 void stop_blinking ();
337 void about_signal_response(int response);
339 Gtk::VBox top_packer;
341 sigc::connection clock_signal_connection;
342 void update_clocks ();
343 void start_clocking ();
344 void stop_clocking ();
346 void manage_window (Gtk::Window&);
348 AudioClock* big_clock;
349 ActionWindowProxy<Gtk::Window>* big_clock_window;
350 int original_big_clock_width;
351 int original_big_clock_height;
352 double original_big_clock_font_size;
354 void big_clock_size_allocate (Gtk::Allocation&);
355 bool idle_big_clock_text_resizer (int width, int height);
356 void big_clock_realized ();
357 bool big_clock_resize_in_progress;
358 int big_clock_height;
359 void big_clock_catch_focus ();
360 void big_clock_reset_aspect_ratio ();
362 void float_big_clock (Gtk::Window* parent);
363 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
365 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
367 void update_transport_clocks (framepos_t pos);
368 void record_state_changed ();
370 std::list<MidiTracer*> _midi_tracer_windows;
372 /* Transport Control */
374 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
375 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
377 Gtkmm2ext::TearOff* transport_tearoff;
378 Gtk::Frame transport_frame;
379 Gtk::HBox transport_tearoff_hbox;
380 Gtk::HBox _editor_transport_box;
381 Gtk::HBox transport_hbox;
382 Gtk::Fixed transport_base;
383 Gtk::Fixed transport_button_base;
384 Gtk::Frame transport_button_frame;
385 Gtk::HBox transport_button_hbox;
386 Gtk::VBox transport_button_vbox;
387 Gtk::HBox transport_option_button_hbox;
388 Gtk::VBox transport_option_button_vbox;
389 Gtk::HBox transport_clock_hbox;
390 Gtk::VBox transport_clock_vbox;
391 Gtk::HBox primary_clock_hbox;
392 Gtk::HBox secondary_clock_hbox;
394 struct TransportControllable : public PBD::Controllable {
405 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
406 void set_value (double);
407 double get_value (void) const;
413 boost::shared_ptr<TransportControllable> roll_controllable;
414 boost::shared_ptr<TransportControllable> stop_controllable;
415 boost::shared_ptr<TransportControllable> goto_start_controllable;
416 boost::shared_ptr<TransportControllable> goto_end_controllable;
417 boost::shared_ptr<TransportControllable> auto_loop_controllable;
418 boost::shared_ptr<TransportControllable> play_selection_controllable;
419 boost::shared_ptr<TransportControllable> rec_controllable;
421 void join_play_range_clicked ();
423 void set_transport_controllable_state (const XMLNode&);
424 XMLNode& get_transport_controllable_state ();
426 ArdourButton roll_button;
427 ArdourButton stop_button;
428 ArdourButton goto_start_button;
429 ArdourButton goto_end_button;
430 ArdourButton auto_loop_button;
431 ArdourButton play_selection_button;
432 ArdourButton rec_button;
433 ArdourButton join_play_range_button;
435 void toggle_external_sync ();
436 void toggle_time_master ();
437 void toggle_video_sync ();
439 ShuttleControl* shuttle_box;
441 ArdourButton auto_return_button;
442 ArdourButton auto_play_button;
443 ArdourButton auto_input_button;
444 ArdourButton click_button;
445 ArdourButton sync_button;
447 ArdourButton auditioning_alert_button;
448 ArdourButton solo_alert_button;
449 ArdourButton feedback_alert_button;
453 void solo_blink (bool);
454 void sync_blink (bool);
455 void audition_blink (bool);
456 void feedback_blink (bool);
458 void soloing_changed (bool);
459 void auditioning_changed (bool);
460 void _auditioning_changed (bool);
462 bool solo_alert_press (GdkEventButton* ev);
463 bool audition_alert_press (GdkEventButton* ev);
464 bool feedback_alert_press (GdkEventButton *);
466 void big_clock_value_changed ();
467 void primary_clock_value_changed ();
468 void secondary_clock_value_changed ();
470 /* called by Blink signal */
472 void transport_rec_enable_blink (bool onoff);
474 Gtk::Menu* session_popup_menu;
476 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
477 RecentSessionModelColumns() {
481 Gtk::TreeModelColumn<std::string> visible_name;
482 Gtk::TreeModelColumn<std::string> fullpath;
485 RecentSessionModelColumns recent_session_columns;
486 Gtk::TreeView recent_session_display;
487 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
489 ArdourDialog* session_selector_window;
490 Gtk::FileChooserDialog* open_session_selector;
492 void build_session_selector();
493 void redisplay_recent_sessions();
494 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
496 struct RecentSessionsSorter {
497 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
498 return cmp_nocase(a.first, b.first) == -1;
502 /* menu bar and associated stuff */
504 Gtk::MenuBar* menu_bar;
505 Gtk::EventBox menu_bar_base;
508 void use_menubar_as_top_menubar ();
509 void build_menu_bar ();
511 Gtk::Label wall_clock_label;
512 gint update_wall_clock ();
514 Gtk::Label disk_space_label;
515 void update_disk_space ();
517 Gtk::Label cpu_load_label;
518 void update_cpu_load ();
520 Gtk::Label buffer_load_label;
521 void update_buffer_load ();
523 Gtk::Label sample_rate_label;
524 void update_sample_rate (ARDOUR::framecnt_t);
526 Gtk::Label format_label;
527 void update_format ();
529 gint every_second ();
530 gint every_point_one_seconds ();
531 gint every_point_zero_one_seconds ();
533 sigc::connection second_connection;
534 sigc::connection point_one_second_connection;
535 sigc::connection point_oh_five_second_connection;
536 sigc::connection point_zero_one_second_connection;
538 gint session_menu (GdkEventButton *);
540 bool _will_create_new_session_automatically;
542 void open_session ();
543 void open_recent_session ();
544 void save_template ();
546 void edit_metadata ();
547 void import_metadata ();
549 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
550 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &);
552 void set_transport_sensitivity (bool);
554 void remove_last_capture ();
556 void transport_goto_zero ();
557 void transport_goto_start ();
558 void transport_goto_end ();
559 void transport_goto_wallclock ();
560 void transport_stop ();
561 void transport_stop_and_forget_capture ();
562 void transport_record (bool roll);
563 void transport_roll ();
564 void transport_play_selection();
565 void transport_forward (int option);
566 void transport_rewind (int option);
567 void transport_loop ();
568 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
570 bool _session_is_new;
571 void set_session (ARDOUR::Session *);
572 void connect_dependents_to_session (ARDOUR::Session *);
573 void we_have_dependents ();
575 void setup_session_options ();
577 guint32 last_key_press_time;
579 void snapshot_session (bool switch_to_it);
580 void rename_session ();
585 PublicEditor *editor;
586 int create_editor ();
588 RouteParams_UI *route_params;
589 int create_route_params ();
591 BundleManager *bundle_manager;
592 void create_bundle_manager ();
594 ActionWindowProxy<LocationUIWindow>* location_ui;
595 int create_location_ui ();
596 void handle_locations_change (ARDOUR::Location*);
598 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
599 void toggle_global_port_matrix (ARDOUR::DataType);
601 static UIConfiguration *ui_config;
602 ThemeManager *theme_manager;
604 /* Key bindings editor */
606 KeyEditor *key_editor;
608 /* RC Options window */
610 RCOptionEditor *rc_option_editor;
612 SessionOptionEditor *session_option_editor;
616 AddRouteDialog *add_route_dialog;
618 /* Keyboard Handling */
620 ArdourKeyboard* keyboard;
622 /* Keymap handling */
624 void install_actions ();
626 void toggle_record_enable (uint32_t);
628 uint32_t rec_enabled_streams;
629 void count_recenabled_streams (ARDOUR::Route&);
633 void pop_back_splash ();
637 Gtk::MenuItem *cleanup_item;
639 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
640 const std::string& plural_msg, const std::string& singular_msg);
644 bool have_configure_timeout;
645 ARDOUR::microseconds_t last_configure_time;
646 gint configure_timeout ();
648 ARDOUR::microseconds_t last_peak_grab;
649 ARDOUR::microseconds_t last_shuttle_request;
651 bool have_disk_speed_dialog_displayed;
652 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
653 void disk_overrun_handler ();
654 void disk_underrun_handler ();
656 void session_dialog (std::string);
657 int pending_state_dialog ();
658 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
660 void disconnect_from_jack ();
661 void reconnect_to_jack ();
662 void set_jack_buffer_size (ARDOUR::pframes_t);
664 Gtk::MenuItem* jack_disconnect_item;
665 Gtk::MenuItem* jack_reconnect_item;
666 Gtk::Menu* jack_bufsize_menu;
668 Glib::RefPtr<Gtk::ActionGroup> common_actions;
670 void editor_realized ();
672 std::vector<std::string> positional_sync_strings;
674 void toggle_send_midi_feedback ();
675 void toggle_use_mmc ();
676 void toggle_send_mmc ();
677 void toggle_send_mtc ();
678 void toggle_send_midi_clock ();
680 void toggle_use_osc ();
682 void parameter_changed (std::string);
683 void session_parameter_changed (std::string);
687 void no_memory_warning ();
688 void check_memory_locking ();
690 bool check_audioengine();
691 void audioengine_setup ();
693 void display_message (const char *prefix, gint prefix_len,
694 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
696 Gtk::Label status_bar_label;
697 bool status_bar_button_press (GdkEventButton*);
698 Gtk::ToggleButton error_log_button;
700 void loading_message (const std::string& msg);
701 void end_loading_messages ();
703 void toggle_translations ();
705 PBD::ScopedConnectionList forever_connections;
707 void step_edit_status_change (bool);
709 void platform_specific ();
710 void platform_setup ();
712 /* these are used only in response to a platform-specific "ShouldQuit" signal
715 void queue_finish ();
716 void fontconfig_dialog ();
718 std::list<WindowProxyBase*> _window_proxies;
720 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
721 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
723 bool click_button_clicked (GdkEventButton *);
725 VisibilityGroup _status_bar_visibility;
727 /** A ProcessThread so that we have some thread-local buffers for use by
728 * PluginEqGui::impulse_analysis ().
730 ARDOUR::ProcessThread* _process_thread;
732 void feedback_detected ();
734 ArdourButton midi_panic_button;
737 void successful_graph_sort ();
738 bool _feedback_exists;
740 void resize_text_widgets ();
743 #endif /* __ardour_gui_h__ */