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 "audio_clock.h"
67 #include "ardour_dialog.h"
69 #include "ui_config.h"
70 #include "window_proxy.h"
78 class ConnectionEditor;
80 class LocationUIWindow;
85 class SessionOptionEditor;
90 class WindowProxyBase;
91 class GlobalPortMatrixWindow;
98 class ControlProtocolInfo;
106 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
109 ARDOUR_UI (int *argcp, char **argvp[]);
112 bool run_startup (bool should_be_new, std::string load_template);
118 void launch_manual ();
119 void launch_reference ();
123 void idle_load (const std::string& path);
126 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
128 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
129 bool session_is_new() const { return _session_is_new; }
131 ARDOUR::Session* the_session() { return _session; }
133 bool will_create_new_session_automatically() const {
134 return _will_create_new_session_automatically;
137 void set_will_create_new_session_automatically (bool yn) {
138 _will_create_new_session_automatically = yn;
141 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
142 void parse_cmdline_path (const std::string& cmdline_path, std::string& session_name, std::string& session_path, bool& existing_session);
143 int load_cmdline_session (const std::string& session_name, const std::string& session_path, bool& existing_session);
144 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
145 bool ask_about_loading_existing_session (const std::string& session_path);
147 /// @return true if session was successfully unloaded.
148 int unload_session (bool hide_stuff = false);
149 void close_session();
151 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
152 void save_state (const std::string & state_name = "", bool switch_to_it = false);
154 static ARDOUR_UI *instance () { return theArdourUI; }
155 static UIConfiguration *config () { return ui_config; }
157 PublicEditor& the_editor(){return *editor;}
158 Mixer_UI* the_mixer() { return mixer; }
160 void toggle_key_editor ();
161 void toggle_location_window ();
162 void toggle_theme_manager ();
163 void toggle_bundle_manager ();
164 void toggle_big_clock_window ();
165 void toggle_speaker_config_window ();
166 void new_midi_tracer_window ();
167 void toggle_route_params_window ();
168 void toggle_editing_space();
169 void toggle_keep_tearoffs();
171 Gtk::Tooltips& tooltips() { return _tooltips; }
173 static sigc::signal<void,bool> Blink;
174 static sigc::signal<void> RapidScreenUpdate;
175 static sigc::signal<void> SuperRapidScreenUpdate;
176 /** Emitted frequently with the audible frame, false, and the edit point as
177 * parameters respectively.
179 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
181 XMLNode* editor_settings() const;
182 XMLNode* mixer_settings () const;
183 XMLNode* keyboard_settings () const;
184 XMLNode* tearoff_settings (const char*) const;
186 void save_ardour_state ();
187 gboolean configure_handler (GdkEventConfigure* conf);
189 void do_transport_locate (framepos_t, bool);
190 void halt_on_xrun_message ();
191 void xrun_handler (framepos_t);
192 void create_xrun_marker (framepos_t);
194 AudioClock primary_clock;
195 AudioClock secondary_clock;
196 AudioClock preroll_clock;
197 AudioClock postroll_clock;
199 void store_clock_modes ();
200 void restore_clock_modes ();
201 void reset_main_clocks ();
203 void synchronize_sync_source_and_video_pullup ();
205 void add_route (Gtk::Window* float_window);
207 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
208 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many);
211 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
212 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many);
215 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many) {
216 session_add_midi_route (true, route_group, how_many);
219 /*void session_add_midi_bus () {
220 session_add_midi_route (false);
223 int create_engine ();
226 gint exit_on_main_window_close (GdkEventAny *);
228 void maximise_editing_space ();
229 void restore_editing_space ();
231 void setup_profile ();
233 void setup_tooltips ();
235 void set_shuttle_fract (double);
237 void add_window_proxy (WindowProxyBase *);
238 void remove_window_proxy (WindowProxyBase *);
241 friend class PublicEditor;
243 void toggle_clocking ();
244 void toggle_auto_play ();
245 void toggle_auto_input ();
246 void toggle_punch ();
247 void unset_dual_punch ();
248 bool ignore_dual_punch;
249 void toggle_punch_in ();
250 void toggle_punch_out ();
251 void show_loop_punch_ruler_and_disallow_hide ();
252 void reenable_hide_loop_punch_ruler_if_appropriate ();
253 void toggle_auto_return ();
254 void toggle_click ();
256 void toggle_session_auto_loop ();
258 void toggle_rc_options_window ();
259 void toggle_session_options_window ();
262 ArdourStartup* _startup;
263 ARDOUR::AudioEngine *engine;
264 Gtk::Tooltips _tooltips;
266 void goto_editor_window ();
267 void goto_mixer_window ();
268 void toggle_mixer_window ();
269 void toggle_mixer_on_top ();
271 Gtk::ToggleButton preroll_button;
272 Gtk::ToggleButton postroll_button;
274 int setup_windows ();
275 void setup_transport ();
278 static ARDOUR_UI *theArdourUI;
280 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
284 int ask_about_saving_session (const std::string & why);
286 /* periodic safety backup, to be precise */
287 gint autosave_session();
288 void update_autosave();
289 sigc::connection _autosave_connection;
291 void map_transport_state ();
292 int32_t do_engine_start ();
294 void engine_halted (const char* reason, bool free_reason);
295 void engine_stopped ();
296 void engine_running ();
300 static gint _blink (void *);
302 gint blink_timeout_tag;
304 void start_blinking ();
305 void stop_blinking ();
307 void about_signal_response(int response);
309 Gtk::VBox top_packer;
311 sigc::connection clock_signal_connection;
312 void update_clocks ();
313 void start_clocking ();
314 void stop_clocking ();
316 void manage_window (Gtk::Window&);
318 AudioClock big_clock;
319 ActionWindowProxy<Gtk::Window>* big_clock_window;
320 int original_big_clock_width;
321 int original_big_clock_height;
322 double original_big_clock_font_size;
324 void big_clock_size_allocate (Gtk::Allocation&);
325 bool idle_big_clock_text_resizer (int width, int height);
326 void big_clock_realized ();
327 bool big_clock_resize_in_progress;
328 int big_clock_height;
330 void float_big_clock (Gtk::Window* parent);
331 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
333 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
335 void update_transport_clocks (framepos_t pos);
336 void record_state_changed ();
338 std::list<MidiTracer*> _midi_tracer_windows;
340 /* Transport Control */
342 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
343 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
345 Gtkmm2ext::TearOff* transport_tearoff;
346 Gtk::Frame transport_frame;
347 Gtk::HBox transport_tearoff_hbox;
348 Gtk::HBox play_range_hbox;
349 Gtk::VBox play_range_vbox;
350 Gtk::HBox transport_hbox;
351 Gtk::Fixed transport_base;
352 Gtk::Fixed transport_button_base;
353 Gtk::Frame transport_button_frame;
354 Gtk::HBox transport_button_hbox;
355 Gtk::VBox transport_button_vbox;
356 Gtk::HBox transport_option_button_hbox;
357 Gtk::VBox transport_option_button_vbox;
358 Gtk::HBox transport_clock_hbox;
359 Gtk::VBox transport_clock_vbox;
360 Gtk::HBox primary_clock_hbox;
361 Gtk::HBox secondary_clock_hbox;
364 struct TransportControllable : public PBD::Controllable {
377 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
378 void set_value (double);
379 double get_value (void) const;
381 void set_id (const std::string&);
387 boost::shared_ptr<TransportControllable> roll_controllable;
388 boost::shared_ptr<TransportControllable> stop_controllable;
389 boost::shared_ptr<TransportControllable> goto_start_controllable;
390 boost::shared_ptr<TransportControllable> goto_end_controllable;
391 boost::shared_ptr<TransportControllable> auto_loop_controllable;
392 boost::shared_ptr<TransportControllable> play_selection_controllable;
393 boost::shared_ptr<TransportControllable> rec_controllable;
394 boost::shared_ptr<TransportControllable> shuttle_controllable;
395 BindingProxy shuttle_controller_binding_proxy;
397 void set_transport_controllable_state (const XMLNode&);
398 XMLNode& get_transport_controllable_state ();
400 BindableButton roll_button;
401 BindableButton stop_button;
402 BindableButton goto_start_button;
403 BindableButton goto_end_button;
404 BindableButton auto_loop_button;
405 BindableButton play_selection_button;
406 BindableButton rec_button;
407 Gtk::ToggleButton join_play_range_button;
409 void toggle_external_sync ();
410 void toggle_time_master ();
411 void toggle_video_sync ();
413 Gtk::DrawingArea shuttle_box;
414 Gtk::EventBox speed_display_box;
415 Gtk::Label speed_display_label;
416 Gtk::Button shuttle_units_button;
417 Gtk::ComboBoxText shuttle_style_button;
418 Gtk::Menu* shuttle_unit_menu;
419 Gtk::Menu* shuttle_style_menu;
420 float shuttle_max_speed;
421 Gtk::Menu* shuttle_context_menu;
423 void build_shuttle_context_menu ();
424 void show_shuttle_context_menu ();
425 void shuttle_style_changed();
426 void shuttle_unit_clicked ();
427 void set_shuttle_max_speed (float);
428 void update_speed_display ();
429 float last_speed_displayed;
431 gint shuttle_box_button_press (GdkEventButton*);
432 gint shuttle_box_button_release (GdkEventButton*);
433 gint shuttle_box_scroll (GdkEventScroll*);
434 gint shuttle_box_motion (GdkEventMotion*);
435 gint shuttle_box_expose (GdkEventExpose*);
436 gint mouse_shuttle (double x, bool force);
437 void use_shuttle_fract (bool force);
439 bool shuttle_grabbed;
440 double shuttle_fract;
442 Gtkmm2ext::StatefulToggleButton punch_in_button;
443 Gtkmm2ext::StatefulToggleButton punch_out_button;
444 Gtkmm2ext::StatefulToggleButton auto_return_button;
445 Gtkmm2ext::StatefulToggleButton auto_play_button;
446 Gtkmm2ext::StatefulToggleButton auto_input_button;
447 Gtkmm2ext::StatefulToggleButton click_button;
448 Gtkmm2ext::StatefulToggleButton time_master_button;
449 Gtkmm2ext::StatefulToggleButton sync_button;
451 Gtk::ToggleButton auditioning_alert_button;
452 Gtk::ToggleButton solo_alert_button;
456 void solo_blink (bool);
457 void sync_blink (bool);
458 void audition_blink (bool);
460 void soloing_changed (bool);
461 void auditioning_changed (bool);
462 void _auditioning_changed (bool);
464 bool solo_alert_press (GdkEventButton* ev);
465 bool audition_alert_press (GdkEventButton* ev);
467 void big_clock_value_changed ();
468 void primary_clock_value_changed ();
469 void secondary_clock_value_changed ();
471 /* called by Blink signal */
473 void transport_rec_enable_blink (bool onoff);
475 Gtk::Menu* session_popup_menu;
477 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
478 RecentSessionModelColumns() {
482 Gtk::TreeModelColumn<std::string> visible_name;
483 Gtk::TreeModelColumn<std::string> fullpath;
486 RecentSessionModelColumns recent_session_columns;
487 Gtk::TreeView recent_session_display;
488 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
490 ArdourDialog* session_selector_window;
491 Gtk::FileChooserDialog* open_session_selector;
493 void build_session_selector();
494 void redisplay_recent_sessions();
495 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
497 struct RecentSessionsSorter {
498 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
499 return cmp_nocase(a.first, b.first) == -1;
503 /* menu bar and associated stuff */
505 Gtk::MenuBar* menu_bar;
506 Gtk::EventBox menu_bar_base;
509 void use_menubar_as_top_menubar ();
510 void build_menu_bar ();
512 Gtk::Label wall_clock_label;
513 Gtk::EventBox wall_clock_box;
514 gint update_wall_clock ();
516 Gtk::Label disk_space_label;
517 Gtk::EventBox disk_space_box;
518 void update_disk_space ();
520 Gtk::Label cpu_load_label;
521 Gtk::EventBox cpu_load_box;
522 void update_cpu_load ();
524 Gtk::Label buffer_load_label;
525 Gtk::EventBox buffer_load_box;
526 void update_buffer_load ();
528 Gtk::Label sample_rate_label;
529 Gtk::EventBox sample_rate_box;
530 void update_sample_rate (ARDOUR::framecnt_t);
532 gint every_second ();
533 gint every_point_one_seconds ();
534 gint every_point_zero_one_seconds ();
536 sigc::connection second_connection;
537 sigc::connection point_one_second_connection;
538 sigc::connection point_oh_five_second_connection;
539 sigc::connection point_zero_one_second_connection;
541 gint session_menu (GdkEventButton *);
543 bool _will_create_new_session_automatically;
545 void open_session ();
546 void open_recent_session ();
547 void save_template ();
549 void edit_metadata ();
550 void import_metadata ();
552 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup *, uint32_t how_many);
553 void session_add_midi_route (bool disk, ARDOUR::RouteGroup *, uint32_t how_many);
555 void set_transport_sensitivity (bool);
557 void remove_last_capture ();
559 void transport_goto_zero ();
560 void transport_goto_start ();
561 void transport_goto_end ();
562 void transport_goto_wallclock ();
563 void transport_stop ();
564 void transport_stop_and_forget_capture ();
565 void transport_record (bool roll);
566 void transport_roll ();
567 void transport_play_selection();
568 void transport_forward (int option);
569 void transport_rewind (int option);
570 void transport_loop ();
571 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
573 bool _session_is_new;
574 void set_session (ARDOUR::Session *);
575 void connect_dependents_to_session (ARDOUR::Session *);
576 void we_have_dependents ();
578 void setup_session_options ();
580 guint32 last_key_press_time;
582 void snapshot_session (bool switch_to_it);
587 PublicEditor *editor;
588 int create_editor ();
590 RouteParams_UI *route_params;
591 int create_route_params ();
593 BundleManager *bundle_manager;
594 void create_bundle_manager ();
596 ActionWindowProxy<LocationUIWindow>* location_ui;
597 int create_location_ui ();
598 void handle_locations_change (ARDOUR::Location*);
600 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
601 void toggle_global_port_matrix (ARDOUR::DataType);
603 static UIConfiguration *ui_config;
604 ThemeManager *theme_manager;
606 /* Key bindings editor */
608 KeyEditor *key_editor;
610 /* RC Options window */
612 RCOptionEditor *rc_option_editor;
614 SessionOptionEditor *session_option_editor;
618 AddRouteDialog *add_route_dialog;
620 /* Keyboard Handling */
622 ArdourKeyboard* keyboard;
624 /* Keymap handling */
626 void install_actions ();
628 void toggle_record_enable (uint32_t);
630 uint32_t rec_enabled_streams;
631 void count_recenabled_streams (ARDOUR::Route&);
635 void pop_back_splash ();
639 Gtk::MenuItem *cleanup_item;
641 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
642 const std::string& plural_msg, const std::string& singular_msg);
646 bool have_configure_timeout;
647 ARDOUR::microseconds_t last_configure_time;
648 gint configure_timeout ();
650 ARDOUR::microseconds_t last_peak_grab;
651 ARDOUR::microseconds_t last_shuttle_request;
653 bool have_disk_speed_dialog_displayed;
654 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
655 void disk_overrun_handler ();
656 void disk_underrun_handler ();
658 void session_dialog (std::string);
659 int pending_state_dialog ();
660 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
662 void disconnect_from_jack ();
663 void reconnect_to_jack ();
664 void set_jack_buffer_size (ARDOUR::pframes_t);
666 Gtk::MenuItem* jack_disconnect_item;
667 Gtk::MenuItem* jack_reconnect_item;
668 Gtk::Menu* jack_bufsize_menu;
670 Glib::RefPtr<Gtk::ActionGroup> common_actions;
672 void editor_realized ();
674 std::vector<std::string> positional_sync_strings;
676 void toggle_send_midi_feedback ();
677 void toggle_use_mmc ();
678 void toggle_send_mmc ();
679 void toggle_send_mtc ();
680 void toggle_send_midi_clock ();
682 void toggle_use_osc ();
684 void parameter_changed (std::string);
688 void no_memory_warning ();
689 void check_memory_locking ();
691 bool check_audioengine();
692 void audioengine_setup ();
694 void display_message (const char *prefix, gint prefix_len,
695 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
697 Gtk::Label status_bar_label;
698 bool status_bar_button_press (GdkEventButton*);
699 Gtk::ToggleButton error_log_button;
701 void loading_message (const std::string& msg);
702 void end_loading_messages ();
704 void platform_specific ();
705 void platform_setup ();
706 void fontconfig_dialog ();
707 void toggle_translations ();
709 PBD::ScopedConnectionList forever_connections;
711 void step_edit_status_change (bool);
713 /* these are used only in response to a platform-specific "ShouldQuit" signal
716 void queue_finish ();
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 *);
726 #endif /* __ardour_gui_h__ */