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;
90 class SessionOptionEditor;
97 class WindowProxyBase;
98 class GlobalPortMatrixWindow;
101 namespace Gtkmm2ext {
106 class ControlProtocolInfo;
115 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
118 ARDOUR_UI (int *argcp, char **argvp[]);
121 bool run_startup (bool should_be_new, std::string load_template);
127 void launch_manual ();
128 void launch_reference ();
132 void idle_load (const std::string& path);
135 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
137 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
138 bool session_is_new() const { return _session_is_new; }
140 ARDOUR::Session* the_session() { return _session; }
142 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
143 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
144 bool ask_about_loading_existing_session (const std::string& session_path);
146 /// @return true if session was successfully unloaded.
147 int unload_session (bool hide_stuff = false);
148 void close_session();
150 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
151 void save_state (const std::string & state_name = "", bool switch_to_it = false);
153 static ARDOUR_UI *instance () { return theArdourUI; }
154 static UIConfiguration *config () { return ui_config; }
156 PublicEditor& the_editor(){return *editor;}
157 Mixer_UI* the_mixer() { return mixer; }
159 void toggle_key_editor ();
160 void toggle_location_window ();
161 void toggle_theme_manager ();
162 void toggle_bundle_manager ();
163 void toggle_big_clock_window ();
164 void toggle_speaker_config_window ();
165 void new_midi_tracer_window ();
166 void toggle_route_params_window ();
167 void toggle_editing_space();
168 void toggle_keep_tearoffs();
170 Gtk::Tooltips& tooltips() { return _tooltips; }
172 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
174 static PublicEditor* _instance;
175 static sigc::signal<void,bool> Blink;
176 static sigc::signal<void> RapidScreenUpdate;
177 static sigc::signal<void> SuperRapidScreenUpdate;
178 /** Emitted frequently with the audible frame, false, and the edit point as
179 * parameters respectively.
181 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
183 XMLNode* editor_settings() const;
184 XMLNode* mixer_settings () const;
185 XMLNode* keyboard_settings () const;
186 XMLNode* tearoff_settings (const char*) const;
188 void save_ardour_state ();
189 gboolean configure_handler (GdkEventConfigure* conf);
191 void halt_on_xrun_message ();
192 void xrun_handler (framepos_t);
193 void create_xrun_marker (framepos_t);
195 GUIObjectState* gui_object_state;
197 AudioClock* primary_clock;
198 AudioClock* secondary_clock;
199 void focus_on_clock ();
201 TimeInfoBox* time_info_box;
203 void store_clock_modes ();
204 void restore_clock_modes ();
205 void reset_main_clocks ();
207 void synchronize_sync_source_and_video_pullup ();
209 void add_route (Gtk::Window* float_window);
211 void session_add_audio_track (
213 int32_t output_channels,
214 ARDOUR::TrackMode mode,
215 ARDOUR::RouteGroup* route_group,
217 std::string const & name_template
220 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
223 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
224 uint32_t how_many, std::string const & name_template) {
225 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
228 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
229 ARDOUR::PluginInfoPtr instrument) {
230 session_add_midi_route (true, route_group, how_many, name_template, instrument);
233 /*void session_add_midi_bus () {
234 session_add_midi_route (false);
237 int create_engine ();
240 gint exit_on_main_window_close (GdkEventAny *);
242 void maximise_editing_space ();
243 void restore_editing_space ();
245 void setup_profile ();
246 void setup_tooltips ();
248 void set_shuttle_fract (double);
250 void add_window_proxy (WindowProxyBase *);
251 void remove_window_proxy (WindowProxyBase *);
253 void get_process_buffers ();
254 void drop_process_buffers ();
257 friend class PublicEditor;
259 void toggle_auto_play ();
260 void toggle_auto_input ();
261 void toggle_punch ();
262 void unset_dual_punch ();
263 bool ignore_dual_punch;
264 void toggle_punch_in ();
265 void toggle_punch_out ();
266 void show_loop_punch_ruler_and_disallow_hide ();
267 void reenable_hide_loop_punch_ruler_if_appropriate ();
268 void toggle_auto_return ();
269 void toggle_click ();
271 void toggle_session_auto_loop ();
273 void toggle_rc_options_window ();
274 void toggle_session_options_window ();
277 ArdourStartup* _startup;
278 ARDOUR::AudioEngine *engine;
279 Gtk::Tooltips _tooltips;
281 void goto_editor_window ();
282 void goto_mixer_window ();
283 void toggle_mixer_window ();
284 void toggle_mixer_on_top ();
286 int setup_windows ();
287 void setup_transport ();
290 static ARDOUR_UI *theArdourUI;
295 int ask_about_saving_session (const std::vector<std::string>& actions);
297 /* periodic safety backup, to be precise */
298 gint autosave_session();
299 void update_autosave();
300 sigc::connection _autosave_connection;
302 void map_transport_state ();
303 int32_t do_engine_start ();
305 void engine_halted (const char* reason, bool free_reason);
306 void engine_stopped ();
307 void engine_running ();
311 static gint _blink (void *);
313 gint blink_timeout_tag;
315 void start_blinking ();
316 void stop_blinking ();
318 void about_signal_response(int response);
320 Gtk::VBox top_packer;
322 sigc::connection clock_signal_connection;
323 void update_clocks ();
324 void start_clocking ();
325 void stop_clocking ();
327 void manage_window (Gtk::Window&);
329 AudioClock* big_clock;
330 ActionWindowProxy<Gtk::Window>* big_clock_window;
331 int original_big_clock_width;
332 int original_big_clock_height;
333 double original_big_clock_font_size;
335 void big_clock_size_allocate (Gtk::Allocation&);
336 bool idle_big_clock_text_resizer (int width, int height);
337 void big_clock_realized ();
338 bool big_clock_resize_in_progress;
339 int big_clock_height;
340 void big_clock_catch_focus ();
341 void big_clock_reset_aspect_ratio ();
343 void float_big_clock (Gtk::Window* parent);
344 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
346 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
348 void update_transport_clocks (framepos_t pos);
349 void record_state_changed ();
351 std::list<MidiTracer*> _midi_tracer_windows;
353 /* Transport Control */
355 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
356 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
358 Gtkmm2ext::TearOff* transport_tearoff;
359 Gtk::Frame transport_frame;
360 Gtk::HBox transport_tearoff_hbox;
361 Gtk::HBox _editor_transport_box;
362 Gtk::HBox transport_hbox;
363 Gtk::Fixed transport_base;
364 Gtk::Fixed transport_button_base;
365 Gtk::Frame transport_button_frame;
366 Gtk::HBox transport_button_hbox;
367 Gtk::VBox transport_button_vbox;
368 Gtk::HBox transport_option_button_hbox;
369 Gtk::VBox transport_option_button_vbox;
370 Gtk::HBox transport_clock_hbox;
371 Gtk::VBox transport_clock_vbox;
372 Gtk::HBox primary_clock_hbox;
373 Gtk::HBox secondary_clock_hbox;
375 struct TransportControllable : public PBD::Controllable {
386 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
387 void set_value (double);
388 double get_value (void) const;
394 boost::shared_ptr<TransportControllable> roll_controllable;
395 boost::shared_ptr<TransportControllable> stop_controllable;
396 boost::shared_ptr<TransportControllable> goto_start_controllable;
397 boost::shared_ptr<TransportControllable> goto_end_controllable;
398 boost::shared_ptr<TransportControllable> auto_loop_controllable;
399 boost::shared_ptr<TransportControllable> play_selection_controllable;
400 boost::shared_ptr<TransportControllable> rec_controllable;
402 void toggle_always_play_range ();
404 void set_transport_controllable_state (const XMLNode&);
405 XMLNode& get_transport_controllable_state ();
407 ArdourButton roll_button;
408 ArdourButton stop_button;
409 ArdourButton goto_start_button;
410 ArdourButton goto_end_button;
411 ArdourButton auto_loop_button;
412 ArdourButton play_selection_button;
413 ArdourButton rec_button;
415 ButtonJoiner* transport_joiner;
417 void toggle_external_sync ();
418 void toggle_time_master ();
419 void toggle_video_sync ();
421 ShuttleControl* shuttle_box;
423 ArdourButton auto_return_button;
424 ArdourButton auto_play_button;
425 ArdourButton auto_input_button;
426 ArdourButton click_button;
427 ArdourButton sync_button;
429 ArdourButton auditioning_alert_button;
430 ArdourButton solo_alert_button;
431 ArdourButton feedback_alert_button;
435 void solo_blink (bool);
436 void sync_blink (bool);
437 void audition_blink (bool);
438 void feedback_blink (bool);
440 void soloing_changed (bool);
441 void auditioning_changed (bool);
442 void _auditioning_changed (bool);
444 bool solo_alert_press (GdkEventButton* ev);
445 bool audition_alert_press (GdkEventButton* ev);
446 bool feedback_alert_press (GdkEventButton *);
448 void big_clock_value_changed ();
449 void primary_clock_value_changed ();
450 void secondary_clock_value_changed ();
452 /* called by Blink signal */
454 void transport_rec_enable_blink (bool onoff);
456 Gtk::Menu* session_popup_menu;
458 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
459 RecentSessionModelColumns() {
463 Gtk::TreeModelColumn<std::string> visible_name;
464 Gtk::TreeModelColumn<std::string> fullpath;
467 RecentSessionModelColumns recent_session_columns;
468 Gtk::TreeView recent_session_display;
469 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
471 ArdourDialog* session_selector_window;
472 Gtk::FileChooserDialog* open_session_selector;
474 void build_session_selector();
475 void redisplay_recent_sessions();
476 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
478 struct RecentSessionsSorter {
479 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
480 return cmp_nocase(a.first, b.first) == -1;
484 /* menu bar and associated stuff */
486 Gtk::MenuBar* menu_bar;
487 Gtk::EventBox menu_bar_base;
490 void use_menubar_as_top_menubar ();
491 void build_menu_bar ();
493 Gtk::Label wall_clock_label;
494 gint update_wall_clock ();
496 Gtk::Label disk_space_label;
497 void update_disk_space ();
499 Gtk::Label cpu_load_label;
500 void update_cpu_load ();
502 Gtk::Label buffer_load_label;
503 void update_buffer_load ();
505 Gtk::Label sample_rate_label;
506 void update_sample_rate (ARDOUR::framecnt_t);
508 Gtk::Label format_label;
509 void update_format ();
511 gint every_second ();
512 gint every_point_one_seconds ();
513 gint every_point_zero_one_seconds ();
515 sigc::connection second_connection;
516 sigc::connection point_one_second_connection;
517 sigc::connection point_oh_five_second_connection;
518 sigc::connection point_zero_one_second_connection;
520 void open_session ();
521 void open_recent_session ();
522 void save_template ();
524 void edit_metadata ();
525 void import_metadata ();
527 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
528 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
530 void set_transport_sensitivity (bool);
532 void transport_goto_zero ();
533 void transport_goto_start ();
534 void transport_goto_end ();
535 void transport_goto_wallclock ();
536 void transport_stop ();
537 void transport_record (bool roll);
538 void transport_roll ();
539 void transport_play_selection();
540 void transport_forward (int option);
541 void transport_rewind (int option);
542 void transport_loop ();
543 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
545 bool _session_is_new;
546 void set_session (ARDOUR::Session *);
547 void connect_dependents_to_session (ARDOUR::Session *);
548 void we_have_dependents ();
550 void setup_session_options ();
552 guint32 last_key_press_time;
554 void snapshot_session (bool switch_to_it);
555 void rename_session ();
560 PublicEditor *editor;
561 int create_editor ();
563 RouteParams_UI *route_params;
564 int create_route_params ();
566 BundleManager *bundle_manager;
567 void create_bundle_manager ();
569 ActionWindowProxy<LocationUIWindow>* location_ui;
570 int create_location_ui ();
571 void handle_locations_change (ARDOUR::Location*);
573 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
574 void toggle_global_port_matrix (ARDOUR::DataType);
576 static UIConfiguration *ui_config;
577 ThemeManager *theme_manager;
579 /* Key bindings editor */
581 KeyEditor *key_editor;
583 /* RC Options window */
585 RCOptionEditor *rc_option_editor;
587 SessionOptionEditor *session_option_editor;
591 AddRouteDialog *add_route_dialog;
593 /* Keyboard Handling */
595 ArdourKeyboard* keyboard;
597 /* Keymap handling */
599 void install_actions ();
601 void toggle_record_enable (uint32_t);
603 uint32_t rec_enabled_streams;
604 void count_recenabled_streams (ARDOUR::Route&);
608 void pop_back_splash (Gtk::Window&);
612 Gtk::MenuItem *cleanup_item;
614 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
615 const std::string& plural_msg, const std::string& singular_msg);
619 bool have_configure_timeout;
620 ARDOUR::microseconds_t last_configure_time;
621 gint configure_timeout ();
623 ARDOUR::microseconds_t last_peak_grab;
624 ARDOUR::microseconds_t last_shuttle_request;
626 bool have_disk_speed_dialog_displayed;
627 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
628 void disk_overrun_handler ();
629 void disk_underrun_handler ();
631 void session_dialog (std::string);
632 int pending_state_dialog ();
633 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
635 void disconnect_from_jack ();
636 void reconnect_to_jack ();
637 void set_jack_buffer_size (ARDOUR::pframes_t);
639 Gtk::MenuItem* jack_disconnect_item;
640 Gtk::MenuItem* jack_reconnect_item;
641 Gtk::Menu* jack_bufsize_menu;
643 Glib::RefPtr<Gtk::ActionGroup> common_actions;
645 void editor_realized ();
647 std::vector<std::string> positional_sync_strings;
649 void toggle_send_midi_feedback ();
650 void toggle_use_mmc ();
651 void toggle_send_mmc ();
652 void toggle_send_mtc ();
653 void toggle_send_midi_clock ();
655 void toggle_use_osc ();
657 void parameter_changed (std::string);
658 void session_parameter_changed (std::string);
662 void no_memory_warning ();
663 void check_memory_locking ();
665 bool check_audioengine();
666 void audioengine_setup ();
668 void display_message (const char *prefix, gint prefix_len,
669 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
671 Gtk::Label status_bar_label;
672 bool status_bar_button_press (GdkEventButton*);
673 Gtk::ToggleButton error_log_button;
675 void loading_message (const std::string& msg);
677 void toggle_translations ();
679 PBD::ScopedConnectionList forever_connections;
681 void step_edit_status_change (bool);
683 void platform_specific ();
684 void platform_setup ();
686 /* these are used only in response to a platform-specific "ShouldQuit" signal
689 void queue_finish ();
690 void fontconfig_dialog ();
692 std::list<WindowProxyBase*> _window_proxies;
694 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
695 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
697 bool click_button_clicked (GdkEventButton *);
699 VisibilityGroup _status_bar_visibility;
701 /** A ProcessThread so that we have some thread-local buffers for use by
702 * PluginEqGui::impulse_analysis ().
704 ARDOUR::ProcessThread* _process_thread;
706 void feedback_detected ();
708 ArdourButton midi_panic_button;
711 void successful_graph_sort ();
712 bool _feedback_exists;
714 void resize_text_widgets ();
717 #endif /* __ardour_gui_h__ */