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 */
39 #include "pbd/xml++.h"
40 #include "pbd/controllable.h"
41 #include <gtkmm/box.h>
42 #include <gtkmm/frame.h>
43 #include <gtkmm/label.h>
44 #include <gtkmm/table.h>
45 #include <gtkmm/fixed.h>
46 #include <gtkmm/drawingarea.h>
47 #include <gtkmm/eventbox.h>
48 #include <gtkmm/menu.h>
49 #include <gtkmm/menuitem.h>
50 #include <gtkmm/button.h>
51 #include <gtkmm/togglebutton.h>
52 #include <gtkmm/treeview.h>
53 #include <gtkmm/menubar.h>
54 #include <gtkmm/textbuffer.h>
55 #include <gtkmm/adjustment.h>
56 #include <gtkmm2ext/gtk_ui.h>
57 #include <gtkmm2ext/click_box.h>
58 #include <gtkmm2ext/stateful_button.h>
59 #include <gtkmm2ext/bindable_button.h>
61 #include "ardour/ardour.h"
62 #include "ardour/types.h"
63 #include "ardour/utils.h"
64 #include "ardour/plugin.h"
65 #include "ardour/session_handle.h"
67 #include "video_timeline.h"
69 #include "ardour_button.h"
70 #include "ardour_dialog.h"
71 #include "ardour_window.h"
73 #include "meterbridge.h"
75 #include "ui_config.h"
77 #include "visibility_group.h"
78 #include "window_manager.h"
91 class ConnectionEditor;
93 class LocationUIWindow;
99 class SessionOptionEditor;
100 class ShuttleControl;
106 class GlobalPortMatrixWindow;
107 class GUIObjectState;
109 namespace Gtkmm2ext {
114 class ControlProtocolInfo;
123 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
126 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
129 bool run_startup (bool should_be_new, std::string load_template);
135 void launch_manual ();
136 void launch_reference ();
140 void idle_load (const std::string& path);
143 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
145 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
146 bool session_is_new() const { return _session_is_new; }
148 ARDOUR::Session* the_session() { return _session; }
150 bool get_smart_mode () const;
152 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
153 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
154 bool ask_about_loading_existing_session (const std::string& session_path);
156 /// @return true if session was successfully unloaded.
157 int unload_session (bool hide_stuff = false);
158 void close_session();
160 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
161 void save_state (const std::string & state_name = "", bool switch_to_it = false);
163 static ARDOUR_UI *instance () { return theArdourUI; }
164 static UIConfiguration *config () { return ui_config; }
166 PublicEditor& the_editor(){return *editor;}
167 Mixer_UI* the_mixer() { return mixer; }
169 void new_midi_tracer_window ();
170 void toggle_editing_space();
171 void toggle_keep_tearoffs();
173 Gtk::Tooltips& tooltips() { return _tooltips; }
175 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
177 static PublicEditor* _instance;
178 static sigc::signal<void,bool> Blink;
179 static sigc::signal<void> RapidScreenUpdate;
180 static sigc::signal<void> SuperRapidScreenUpdate;
181 /** Emitted frequently with the audible frame, false, and the edit point as
182 * parameters respectively.
184 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
186 static void close_all_dialogs () { CloseAllDialogs(); }
187 static sigc::signal<void> CloseAllDialogs;
189 XMLNode* editor_settings() const;
190 XMLNode* mixer_settings () const;
191 XMLNode* keyboard_settings () const;
192 XMLNode* tearoff_settings (const char*) const;
194 void save_ardour_state ();
195 gboolean configure_handler (GdkEventConfigure* conf);
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 MainClock* primary_clock;
204 MainClock* secondary_clock;
205 void focus_on_clock ();
206 AudioClock* big_clock;
208 TimeInfoBox* time_info_box;
210 VideoTimeLine *video_timeline;
212 void store_clock_modes ();
213 void restore_clock_modes ();
214 void reset_main_clocks ();
216 void synchronize_sync_source_and_video_pullup ();
218 void add_route (Gtk::Window* float_window);
219 void add_routes_part_two ();
220 void add_routes_thread ();
222 void add_video (Gtk::Window* float_window);
223 void remove_video ();
224 void start_video_server_menu (Gtk::Window* float_window);
225 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
226 void stop_video_server (bool ask_confirm=false);
227 void flush_videotimeline_cache (bool localcacheonly=false);
229 void session_add_audio_track (
231 int32_t output_channels,
232 ARDOUR::TrackMode mode,
233 ARDOUR::RouteGroup* route_group,
235 std::string const & name_template
238 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
241 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
242 uint32_t how_many, std::string const & name_template) {
243 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
246 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
247 ARDOUR::PluginInfoPtr instrument) {
248 session_add_midi_route (true, route_group, how_many, name_template, instrument);
251 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,
252 ARDOUR::PluginInfoPtr instrument);
254 /*void session_add_midi_bus () {
255 session_add_midi_route (false);
258 int create_engine ();
261 gint exit_on_main_window_close (GdkEventAny *);
263 void maximise_editing_space ();
264 void restore_editing_space ();
266 void update_tearoff_visibility ();
268 void setup_profile ();
269 void setup_tooltips ();
271 void set_shuttle_fract (double);
273 void get_process_buffers ();
274 void drop_process_buffers ();
276 const std::string& announce_string() const { return _announce_string; }
279 friend class PublicEditor;
281 void toggle_auto_play ();
282 void toggle_auto_input ();
283 void toggle_punch ();
284 void unset_dual_punch ();
285 bool ignore_dual_punch;
286 void toggle_punch_in ();
287 void toggle_punch_out ();
288 void show_loop_punch_ruler_and_disallow_hide ();
289 void reenable_hide_loop_punch_ruler_if_appropriate ();
290 void toggle_auto_return ();
291 void toggle_click ();
293 void toggle_session_auto_loop ();
295 void toggle_rc_options_window ();
296 void toggle_session_options_window ();
299 ArdourStartup* _startup;
300 ARDOUR::AudioEngine *engine;
301 Gtk::Tooltips _tooltips;
306 void goto_editor_window ();
307 void goto_mixer_window ();
308 void toggle_mixer_window ();
309 void toggle_meterbridge ();
310 void toggle_editor_mixer ();
312 int setup_windows ();
313 void setup_transport ();
316 static ARDOUR_UI *theArdourUI;
321 int ask_about_saving_session (const std::vector<std::string>& actions);
323 /* periodic safety backup, to be precise */
324 gint autosave_session();
325 void update_autosave();
326 sigc::connection _autosave_connection;
328 void map_transport_state ();
329 int32_t do_engine_start ();
331 void engine_halted (const char* reason, bool free_reason);
332 void engine_stopped ();
333 void engine_running ();
337 static gint _blink (void *);
339 gint blink_timeout_tag;
341 void start_blinking ();
342 void stop_blinking ();
344 void about_signal_response(int response);
346 Gtk::VBox top_packer;
348 sigc::connection clock_signal_connection;
349 void update_clocks ();
350 void start_clocking ();
351 void stop_clocking ();
353 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
355 void update_transport_clocks (framepos_t pos);
356 void record_state_changed ();
358 std::list<MidiTracer*> _midi_tracer_windows;
360 /* Transport Control */
362 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
363 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
365 Gtkmm2ext::TearOff* transport_tearoff;
366 Gtk::Frame transport_frame;
367 Gtk::HBox transport_tearoff_hbox;
368 Gtk::HBox _editor_transport_box;
369 Gtk::HBox transport_hbox;
370 Gtk::Fixed transport_base;
371 Gtk::Fixed transport_button_base;
372 Gtk::Frame transport_button_frame;
373 Gtk::HBox transport_button_hbox;
374 Gtk::VBox transport_button_vbox;
375 Gtk::HBox transport_option_button_hbox;
376 Gtk::VBox transport_option_button_vbox;
377 Gtk::HBox transport_clock_hbox;
378 Gtk::VBox transport_clock_vbox;
379 Gtk::HBox primary_clock_hbox;
380 Gtk::HBox secondary_clock_hbox;
382 struct TransportControllable : public PBD::Controllable {
393 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
394 void set_value (double);
395 double get_value (void) const;
401 boost::shared_ptr<TransportControllable> roll_controllable;
402 boost::shared_ptr<TransportControllable> stop_controllable;
403 boost::shared_ptr<TransportControllable> goto_start_controllable;
404 boost::shared_ptr<TransportControllable> goto_end_controllable;
405 boost::shared_ptr<TransportControllable> auto_loop_controllable;
406 boost::shared_ptr<TransportControllable> play_selection_controllable;
407 boost::shared_ptr<TransportControllable> rec_controllable;
409 void toggle_always_play_range ();
411 void set_transport_controllable_state (const XMLNode&);
412 XMLNode& get_transport_controllable_state ();
414 ArdourButton roll_button;
415 ArdourButton stop_button;
416 ArdourButton goto_start_button;
417 ArdourButton goto_end_button;
418 ArdourButton auto_loop_button;
419 ArdourButton play_selection_button;
420 ArdourButton rec_button;
422 void toggle_external_sync ();
423 void toggle_time_master ();
424 void toggle_video_sync ();
426 ShuttleControl* shuttle_box;
428 ArdourButton auto_return_button;
429 ArdourButton follow_edits_button;
430 ArdourButton auto_input_button;
431 ArdourButton click_button;
432 ArdourButton sync_button;
434 ArdourButton auditioning_alert_button;
435 ArdourButton solo_alert_button;
436 ArdourButton feedback_alert_button;
440 void solo_blink (bool);
441 void sync_blink (bool);
442 void audition_blink (bool);
443 void feedback_blink (bool);
445 void soloing_changed (bool);
446 void auditioning_changed (bool);
447 void _auditioning_changed (bool);
449 bool solo_alert_press (GdkEventButton* ev);
450 bool audition_alert_press (GdkEventButton* ev);
451 bool feedback_alert_press (GdkEventButton *);
453 void big_clock_value_changed ();
454 void primary_clock_value_changed ();
455 void secondary_clock_value_changed ();
457 /* called by Blink signal */
459 void transport_rec_enable_blink (bool onoff);
461 Gtk::Menu* session_popup_menu;
463 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
464 RecentSessionModelColumns() {
469 Gtk::TreeModelColumn<std::string> visible_name;
470 Gtk::TreeModelColumn<std::string> tip;
471 Gtk::TreeModelColumn<std::string> fullpath;
474 RecentSessionModelColumns recent_session_columns;
475 Gtk::TreeView recent_session_display;
476 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
478 ArdourDialog* session_selector_window;
479 Gtk::FileChooserDialog* open_session_selector;
481 void build_session_selector();
482 void redisplay_recent_sessions();
483 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
485 struct RecentSessionsSorter {
486 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
487 return cmp_nocase(a.first, b.first) == -1;
491 /* menu bar and associated stuff */
493 Gtk::MenuBar* menu_bar;
494 Gtk::EventBox menu_bar_base;
497 void use_menubar_as_top_menubar ();
498 void build_menu_bar ();
500 Gtk::Label wall_clock_label;
501 gint update_wall_clock ();
503 Gtk::Label disk_space_label;
504 void update_disk_space ();
506 Gtk::Label timecode_format_label;
507 void update_timecode_format ();
509 Gtk::Label cpu_load_label;
510 void update_cpu_load ();
512 Gtk::Label buffer_load_label;
513 void update_buffer_load ();
515 Gtk::Label sample_rate_label;
516 void update_sample_rate (ARDOUR::framecnt_t);
518 Gtk::Label format_label;
519 void update_format ();
521 gint every_second ();
522 gint every_point_one_seconds ();
523 gint every_point_zero_one_seconds ();
525 sigc::connection second_connection;
526 sigc::connection point_one_second_connection;
527 sigc::connection point_oh_five_second_connection;
528 sigc::connection point_zero_one_second_connection;
530 void open_session ();
531 void open_recent_session ();
532 void save_template ();
534 void edit_metadata ();
535 void import_metadata ();
537 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
538 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
540 void set_transport_sensitivity (bool);
542 void transport_goto_zero ();
543 void transport_goto_start ();
544 void transport_goto_end ();
545 void transport_goto_wallclock ();
546 void transport_stop ();
547 void transport_record (bool roll);
548 void transport_roll ();
549 void transport_play_selection();
550 void transport_play_preroll();
551 void transport_forward (int option);
552 void transport_rewind (int option);
553 void transport_loop ();
554 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
556 bool _session_is_new;
557 void set_session (ARDOUR::Session *);
558 void connect_dependents_to_session (ARDOUR::Session *);
559 void we_have_dependents ();
561 void setup_session_options ();
563 guint32 last_key_press_time;
565 void snapshot_session (bool switch_to_it);
566 void rename_session ();
571 PublicEditor *editor;
572 int create_editor ();
574 Meterbridge *meterbridge;
575 int create_meterbridge ();
576 /* Dialogs that can be created via new<T> */
578 WM::Proxy<SpeakerDialog> speaker_config_window;
579 WM::Proxy<ThemeManager> theme_manager;
580 WM::Proxy<KeyEditor> key_editor;
581 WM::Proxy<RCOptionEditor> rc_option_editor;
582 WM::Proxy<AddRouteDialog> add_route_dialog;
583 WM::Proxy<About> about;
584 WM::Proxy<LocationUIWindow> location_ui;
585 WM::Proxy<RouteParams_UI> route_params;
587 /* Windows/Dialogs that require a creator method */
589 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
590 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
591 WM::ProxyWithConstructor<BundleManager> bundle_manager;
592 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
593 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
594 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
596 /* creator methods */
598 SessionOptionEditor* create_session_option_editor ();
599 BundleManager* create_bundle_manager ();
600 AddVideoDialog* create_add_video_dialog ();
601 BigClockWindow* create_big_clock_window();
602 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
604 static UIConfiguration *ui_config;
606 SystemExec *video_server_process;
608 void handle_locations_change (ARDOUR::Location*);
610 /* Keyboard Handling */
612 ArdourKeyboard* keyboard;
614 /* Keymap handling */
616 void install_actions ();
618 void toggle_record_enable (uint32_t);
620 uint32_t rec_enabled_streams;
621 void count_recenabled_streams (ARDOUR::Route&);
625 void pop_back_splash (Gtk::Window&);
629 Gtk::MenuItem *cleanup_item;
631 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
635 bool have_configure_timeout;
636 ARDOUR::microseconds_t last_configure_time;
637 gint configure_timeout ();
639 ARDOUR::microseconds_t last_peak_grab;
640 ARDOUR::microseconds_t last_shuttle_request;
642 bool have_disk_speed_dialog_displayed;
643 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
644 void disk_overrun_handler ();
645 void disk_underrun_handler ();
647 void session_format_mismatch (std::string, std::string);
649 void session_dialog (std::string);
650 int pending_state_dialog ();
651 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
653 void disconnect_from_jack ();
654 void reconnect_to_jack ();
655 void set_jack_buffer_size (ARDOUR::pframes_t);
657 Gtk::MenuItem* jack_disconnect_item;
658 Gtk::MenuItem* jack_reconnect_item;
659 Gtk::Menu* jack_bufsize_menu;
661 Glib::RefPtr<Gtk::ActionGroup> common_actions;
663 void editor_realized ();
665 std::vector<std::string> positional_sync_strings;
667 void toggle_send_midi_feedback ();
668 void toggle_use_mmc ();
669 void toggle_send_mmc ();
670 void toggle_send_mtc ();
671 void toggle_send_midi_clock ();
673 void toggle_use_osc ();
675 void parameter_changed (std::string);
676 void session_parameter_changed (std::string);
680 void no_memory_warning ();
681 void check_memory_locking ();
683 bool check_audioengine();
684 void audioengine_setup ();
686 void display_message (const char *prefix, gint prefix_len,
687 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
689 Gtk::Label status_bar_label;
690 bool status_bar_button_press (GdkEventButton*);
691 Gtk::ToggleButton error_log_button;
693 void loading_message (const std::string& msg);
695 PBD::ScopedConnectionList forever_connections;
697 void step_edit_status_change (bool);
699 void platform_specific ();
700 void platform_setup ();
702 /* these are used only in response to a platform-specific "ShouldQuit" signal
705 void queue_finish ();
706 void fontconfig_dialog ();
708 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
709 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
711 bool click_button_clicked (GdkEventButton *);
713 VisibilityGroup _status_bar_visibility;
715 /** A ProcessThread so that we have some thread-local buffers for use by
716 * PluginEqGui::impulse_analysis ().
718 ARDOUR::ProcessThread* _process_thread;
720 void feedback_detected ();
722 ArdourButton midi_panic_button;
725 void successful_graph_sort ();
726 bool _feedback_exists;
728 void resize_text_widgets ();
730 std::string _announce_string;
731 void check_announcements ();
734 #endif /* __ardour_gui_h__ */