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 #include "ardour_dialog.h"
69 #include "ardour_button.h"
71 #include "ui_config.h"
72 #include "window_proxy.h"
74 #include "visibility_group.h"
83 class ConnectionEditor;
85 class LocationUIWindow;
91 class SessionOptionEditor;
98 class WindowProxyBase;
99 class GlobalPortMatrixWindow;
100 class GUIObjectState;
102 namespace Gtkmm2ext {
107 class ControlProtocolInfo;
116 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
119 ARDOUR_UI (int *argcp, char **argvp[]);
122 bool run_startup (bool should_be_new, std::string load_template);
128 void launch_manual ();
129 void launch_reference ();
133 void idle_load (const std::string& path);
136 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
138 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
139 bool session_is_new() const { return _session_is_new; }
141 ARDOUR::Session* the_session() { return _session; }
143 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
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 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
175 static PublicEditor* _instance;
176 static sigc::signal<void,bool> Blink;
177 static sigc::signal<void> RapidScreenUpdate;
178 static sigc::signal<void> SuperRapidScreenUpdate;
179 /** Emitted frequently with the audible frame, false, and the edit point as
180 * parameters respectively.
182 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
184 XMLNode* editor_settings() const;
185 XMLNode* mixer_settings () const;
186 XMLNode* keyboard_settings () const;
187 XMLNode* tearoff_settings (const char*) const;
189 void save_ardour_state ();
190 gboolean configure_handler (GdkEventConfigure* conf);
192 void halt_on_xrun_message ();
193 void xrun_handler (framepos_t);
194 void create_xrun_marker (framepos_t);
196 GUIObjectState* gui_object_state;
198 MainClock* primary_clock;
199 MainClock* secondary_clock;
200 void focus_on_clock ();
202 TimeInfoBox* time_info_box;
204 void store_clock_modes ();
205 void restore_clock_modes ();
206 void reset_main_clocks ();
208 void synchronize_sync_source_and_video_pullup ();
210 void add_route (Gtk::Window* float_window);
212 void session_add_audio_track (
214 int32_t output_channels,
215 ARDOUR::TrackMode mode,
216 ARDOUR::RouteGroup* route_group,
218 std::string const & name_template
221 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
224 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
225 uint32_t how_many, std::string const & name_template) {
226 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
229 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
230 ARDOUR::PluginInfoPtr instrument) {
231 session_add_midi_route (true, route_group, how_many, name_template, instrument);
234 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,
235 ARDOUR::PluginInfoPtr instrument);
237 /*void session_add_midi_bus () {
238 session_add_midi_route (false);
241 int create_engine ();
244 gint exit_on_main_window_close (GdkEventAny *);
246 void maximise_editing_space ();
247 void restore_editing_space ();
249 void update_tearoff_visibility ();
251 void setup_profile ();
252 void setup_tooltips ();
254 void set_shuttle_fract (double);
256 void add_window_proxy (WindowProxyBase *);
257 void remove_window_proxy (WindowProxyBase *);
259 void get_process_buffers ();
260 void drop_process_buffers ();
263 friend class PublicEditor;
265 void toggle_auto_play ();
266 void toggle_auto_input ();
267 void toggle_punch ();
268 void unset_dual_punch ();
269 bool ignore_dual_punch;
270 void toggle_punch_in ();
271 void toggle_punch_out ();
272 void show_loop_punch_ruler_and_disallow_hide ();
273 void reenable_hide_loop_punch_ruler_if_appropriate ();
274 void toggle_auto_return ();
275 void toggle_click ();
277 void toggle_session_auto_loop ();
279 void toggle_rc_options_window ();
280 void toggle_session_options_window ();
283 ArdourStartup* _startup;
284 ARDOUR::AudioEngine *engine;
285 Gtk::Tooltips _tooltips;
287 void goto_editor_window ();
288 void goto_mixer_window ();
289 void toggle_mixer_window ();
290 void toggle_mixer_on_top ();
292 int setup_windows ();
293 void setup_transport ();
296 static ARDOUR_UI *theArdourUI;
301 int ask_about_saving_session (const std::vector<std::string>& actions);
303 /* periodic safety backup, to be precise */
304 gint autosave_session();
305 void update_autosave();
306 sigc::connection _autosave_connection;
308 void map_transport_state ();
309 int32_t do_engine_start ();
311 void engine_halted (const char* reason, bool free_reason);
312 void engine_stopped ();
313 void engine_running ();
317 static gint _blink (void *);
319 gint blink_timeout_tag;
321 void start_blinking ();
322 void stop_blinking ();
324 void about_signal_response(int response);
326 Gtk::VBox top_packer;
328 sigc::connection clock_signal_connection;
329 void update_clocks ();
330 void start_clocking ();
331 void stop_clocking ();
333 void manage_window (Gtk::Window&);
335 AudioClock* big_clock;
336 ActionWindowProxy<Gtk::Window>* big_clock_window;
337 int original_big_clock_width;
338 int original_big_clock_height;
339 double original_big_clock_font_size;
341 void big_clock_size_allocate (Gtk::Allocation&);
342 bool idle_big_clock_text_resizer (int width, int height);
343 void big_clock_realized ();
344 bool big_clock_resize_in_progress;
345 int big_clock_height;
346 void big_clock_catch_focus ();
347 void big_clock_reset_aspect_ratio ();
349 void float_big_clock (Gtk::Window* parent);
350 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
352 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
354 void update_transport_clocks (framepos_t pos);
355 void record_state_changed ();
357 std::list<MidiTracer*> _midi_tracer_windows;
359 /* Transport Control */
361 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
362 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
364 Gtkmm2ext::TearOff* transport_tearoff;
365 Gtk::Frame transport_frame;
366 Gtk::HBox transport_tearoff_hbox;
367 Gtk::HBox _editor_transport_box;
368 Gtk::HBox transport_hbox;
369 Gtk::Fixed transport_base;
370 Gtk::Fixed transport_button_base;
371 Gtk::Frame transport_button_frame;
372 Gtk::HBox transport_button_hbox;
373 Gtk::VBox transport_button_vbox;
374 Gtk::HBox transport_option_button_hbox;
375 Gtk::VBox transport_option_button_vbox;
376 Gtk::HBox transport_clock_hbox;
377 Gtk::VBox transport_clock_vbox;
378 Gtk::HBox primary_clock_hbox;
379 Gtk::HBox secondary_clock_hbox;
381 struct TransportControllable : public PBD::Controllable {
392 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
393 void set_value (double);
394 double get_value (void) const;
400 boost::shared_ptr<TransportControllable> roll_controllable;
401 boost::shared_ptr<TransportControllable> stop_controllable;
402 boost::shared_ptr<TransportControllable> goto_start_controllable;
403 boost::shared_ptr<TransportControllable> goto_end_controllable;
404 boost::shared_ptr<TransportControllable> auto_loop_controllable;
405 boost::shared_ptr<TransportControllable> play_selection_controllable;
406 boost::shared_ptr<TransportControllable> rec_controllable;
408 void toggle_always_play_range ();
410 void set_transport_controllable_state (const XMLNode&);
411 XMLNode& get_transport_controllable_state ();
413 ArdourButton roll_button;
414 ArdourButton stop_button;
415 ArdourButton goto_start_button;
416 ArdourButton goto_end_button;
417 ArdourButton auto_loop_button;
418 ArdourButton play_selection_button;
419 ArdourButton rec_button;
421 ButtonJoiner* transport_joiner;
423 void toggle_external_sync ();
424 void toggle_time_master ();
425 void toggle_video_sync ();
427 ShuttleControl* shuttle_box;
429 ArdourButton auto_return_button;
430 ArdourButton auto_play_button;
431 ArdourButton auto_input_button;
432 ArdourButton click_button;
433 ArdourButton sync_button;
435 ArdourButton auditioning_alert_button;
436 ArdourButton solo_alert_button;
437 ArdourButton feedback_alert_button;
441 void solo_blink (bool);
442 void sync_blink (bool);
443 void audition_blink (bool);
444 void feedback_blink (bool);
446 void soloing_changed (bool);
447 void auditioning_changed (bool);
448 void _auditioning_changed (bool);
450 bool solo_alert_press (GdkEventButton* ev);
451 bool audition_alert_press (GdkEventButton* ev);
452 bool feedback_alert_press (GdkEventButton *);
454 void big_clock_value_changed ();
455 void primary_clock_value_changed ();
456 void secondary_clock_value_changed ();
458 /* called by Blink signal */
460 void transport_rec_enable_blink (bool onoff);
462 Gtk::Menu* session_popup_menu;
464 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
465 RecentSessionModelColumns() {
469 Gtk::TreeModelColumn<std::string> visible_name;
470 Gtk::TreeModelColumn<std::string> fullpath;
473 RecentSessionModelColumns recent_session_columns;
474 Gtk::TreeView recent_session_display;
475 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
477 ArdourDialog* session_selector_window;
478 Gtk::FileChooserDialog* open_session_selector;
480 void build_session_selector();
481 void redisplay_recent_sessions();
482 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
484 struct RecentSessionsSorter {
485 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
486 return cmp_nocase(a.first, b.first) == -1;
490 /* menu bar and associated stuff */
492 Gtk::MenuBar* menu_bar;
493 Gtk::EventBox menu_bar_base;
496 void use_menubar_as_top_menubar ();
497 void build_menu_bar ();
499 Gtk::Label wall_clock_label;
500 gint update_wall_clock ();
502 Gtk::Label disk_space_label;
503 void update_disk_space ();
505 Gtk::Label timecode_format_label;
506 void update_timecode_format ();
508 Gtk::Label cpu_load_label;
509 void update_cpu_load ();
511 Gtk::Label buffer_load_label;
512 void update_buffer_load ();
514 Gtk::Label sample_rate_label;
515 void update_sample_rate (ARDOUR::framecnt_t);
517 Gtk::Label format_label;
518 void update_format ();
520 gint every_second ();
521 gint every_point_one_seconds ();
522 gint every_point_zero_one_seconds ();
524 sigc::connection second_connection;
525 sigc::connection point_one_second_connection;
526 sigc::connection point_oh_five_second_connection;
527 sigc::connection point_zero_one_second_connection;
529 void open_session ();
530 void open_recent_session ();
531 void save_template ();
533 void edit_metadata ();
534 void import_metadata ();
536 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
537 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
539 void set_transport_sensitivity (bool);
541 void transport_goto_zero ();
542 void transport_goto_start ();
543 void transport_goto_end ();
544 void transport_goto_wallclock ();
545 void transport_stop ();
546 void transport_record (bool roll);
547 void transport_roll ();
548 void transport_play_selection();
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 RouteParams_UI *route_params;
573 int create_route_params ();
575 BundleManager *bundle_manager;
576 void create_bundle_manager ();
578 ActionWindowProxy<LocationUIWindow>* location_ui;
579 int create_location_ui ();
580 void handle_locations_change (ARDOUR::Location*);
582 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
583 void toggle_global_port_matrix (ARDOUR::DataType);
585 static UIConfiguration *ui_config;
586 ThemeManager *theme_manager;
588 /* Key bindings editor */
590 KeyEditor *key_editor;
592 /* RC Options window */
594 RCOptionEditor *rc_option_editor;
596 SessionOptionEditor *session_option_editor;
600 AddRouteDialog *add_route_dialog;
602 /* Keyboard Handling */
604 ArdourKeyboard* keyboard;
606 /* Keymap handling */
608 void install_actions ();
610 void toggle_record_enable (uint32_t);
612 uint32_t rec_enabled_streams;
613 void count_recenabled_streams (ARDOUR::Route&);
618 void pop_back_splash (Gtk::Window&);
622 Gtk::MenuItem *cleanup_item;
624 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
625 const std::string& plural_msg, const std::string& singular_msg);
629 bool have_configure_timeout;
630 ARDOUR::microseconds_t last_configure_time;
631 gint configure_timeout ();
633 ARDOUR::microseconds_t last_peak_grab;
634 ARDOUR::microseconds_t last_shuttle_request;
636 bool have_disk_speed_dialog_displayed;
637 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
638 void disk_overrun_handler ();
639 void disk_underrun_handler ();
641 void session_dialog (std::string);
642 int pending_state_dialog ();
643 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
645 void disconnect_from_jack ();
646 void reconnect_to_jack ();
647 void set_jack_buffer_size (ARDOUR::pframes_t);
649 Gtk::MenuItem* jack_disconnect_item;
650 Gtk::MenuItem* jack_reconnect_item;
651 Gtk::Menu* jack_bufsize_menu;
653 Glib::RefPtr<Gtk::ActionGroup> common_actions;
655 void editor_realized ();
657 std::vector<std::string> positional_sync_strings;
659 void toggle_send_midi_feedback ();
660 void toggle_use_mmc ();
661 void toggle_send_mmc ();
662 void toggle_send_mtc ();
663 void toggle_send_midi_clock ();
665 void toggle_use_osc ();
667 void parameter_changed (std::string);
668 void session_parameter_changed (std::string);
672 void no_memory_warning ();
673 void check_memory_locking ();
675 bool check_audioengine();
676 void audioengine_setup ();
678 void display_message (const char *prefix, gint prefix_len,
679 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
681 Gtk::Label status_bar_label;
682 bool status_bar_button_press (GdkEventButton*);
683 Gtk::ToggleButton error_log_button;
685 void loading_message (const std::string& msg);
687 void toggle_translations ();
689 PBD::ScopedConnectionList forever_connections;
691 void step_edit_status_change (bool);
693 void platform_specific ();
694 void platform_setup ();
696 /* these are used only in response to a platform-specific "ShouldQuit" signal
699 void queue_finish ();
700 void fontconfig_dialog ();
702 std::list<WindowProxyBase*> _window_proxies;
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 ();
727 #endif /* __ardour_gui_h__ */