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 LevelMeterHBox;
107 class GlobalPortMatrixWindow;
108 class GUIObjectState;
110 namespace Gtkmm2ext {
115 class ControlProtocolInfo;
124 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
127 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
130 bool run_startup (bool should_be_new, std::string load_template);
136 void launch_manual ();
137 void launch_reference ();
141 void idle_load (const std::string& path);
144 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
146 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
147 bool session_is_new() const { return _session_is_new; }
149 ARDOUR::Session* the_session() { return _session; }
151 bool get_smart_mode () const;
153 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
154 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
155 bool ask_about_loading_existing_session (const std::string& session_path);
157 /// @return true if session was successfully unloaded.
158 int unload_session (bool hide_stuff = false);
159 void close_session();
161 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
162 void save_state (const std::string & state_name = "", bool switch_to_it = false);
164 static ARDOUR_UI *instance () { return theArdourUI; }
165 static UIConfiguration *config () { return ui_config; }
167 PublicEditor& the_editor(){return *editor;}
168 Mixer_UI* the_mixer() { return mixer; }
170 void new_midi_tracer_window ();
171 void toggle_editing_space();
172 void toggle_keep_tearoffs();
174 Gtk::Tooltips& tooltips() { return _tooltips; }
176 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
178 static PublicEditor* _instance;
179 static sigc::signal<void,bool> Blink;
181 /** point_zero_one_seconds -- 10Hz ^= 100ms */
182 static sigc::signal<void> RapidScreenUpdate;
184 /** point_zero_something_seconds -- currently 25Hz ^= 40ms */
185 static sigc::signal<void> SuperRapidScreenUpdate;
187 /** Emitted frequently with the audible frame, false, and the edit point as
188 * parameters respectively.
190 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
192 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
194 static void close_all_dialogs () { CloseAllDialogs(); }
195 static sigc::signal<void> CloseAllDialogs;
197 XMLNode* editor_settings() const;
198 XMLNode* mixer_settings () const;
199 XMLNode* keyboard_settings () const;
200 XMLNode* tearoff_settings (const char*) const;
202 void save_ardour_state ();
203 gboolean configure_handler (GdkEventConfigure* conf);
205 void halt_on_xrun_message ();
206 void xrun_handler (framepos_t);
207 void create_xrun_marker (framepos_t);
209 GUIObjectState* gui_object_state;
211 MainClock* primary_clock;
212 MainClock* secondary_clock;
213 void focus_on_clock ();
214 AudioClock* big_clock;
216 TimeInfoBox* time_info_box;
218 VideoTimeLine *video_timeline;
220 void store_clock_modes ();
221 void restore_clock_modes ();
222 void reset_main_clocks ();
224 void synchronize_sync_source_and_video_pullup ();
226 void add_route (Gtk::Window* float_window);
227 void add_routes_part_two ();
228 void add_routes_thread ();
230 void add_video (Gtk::Window* float_window);
231 void remove_video ();
232 void start_video_server_menu (Gtk::Window* float_window);
233 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
234 void stop_video_server (bool ask_confirm=false);
235 void flush_videotimeline_cache (bool localcacheonly=false);
237 void session_add_audio_track (
239 int32_t output_channels,
240 ARDOUR::TrackMode mode,
241 ARDOUR::RouteGroup* route_group,
243 std::string const & name_template
246 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
249 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
250 uint32_t how_many, std::string const & name_template) {
251 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
254 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
255 ARDOUR::PluginInfoPtr instrument) {
256 session_add_midi_route (true, route_group, how_many, name_template, instrument);
259 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,
260 ARDOUR::PluginInfoPtr instrument);
262 /*void session_add_midi_bus () {
263 session_add_midi_route (false);
266 int create_engine ();
269 gint exit_on_main_window_close (GdkEventAny *);
271 void maximise_editing_space ();
272 void restore_editing_space ();
274 void update_tearoff_visibility ();
276 void setup_profile ();
277 void setup_tooltips ();
279 void set_shuttle_fract (double);
281 void get_process_buffers ();
282 void drop_process_buffers ();
284 void reset_peak_display ();
285 void reset_route_peak_display (ARDOUR::Route*);
286 void reset_group_peak_display (ARDOUR::RouteGroup*);
288 const std::string& announce_string() const { return _announce_string; }
291 friend class PublicEditor;
293 void toggle_auto_play ();
294 void toggle_auto_input ();
295 void toggle_punch ();
296 void unset_dual_punch ();
297 bool ignore_dual_punch;
298 void toggle_punch_in ();
299 void toggle_punch_out ();
300 void show_loop_punch_ruler_and_disallow_hide ();
301 void reenable_hide_loop_punch_ruler_if_appropriate ();
302 void toggle_auto_return ();
303 void toggle_click ();
305 void toggle_session_auto_loop ();
307 void toggle_rc_options_window ();
308 void toggle_session_options_window ();
311 ArdourStartup* _startup;
312 ARDOUR::AudioEngine *engine;
313 Gtk::Tooltips _tooltips;
318 void goto_editor_window ();
319 void goto_mixer_window ();
320 void toggle_mixer_window ();
321 void toggle_meterbridge ();
322 void toggle_editor_mixer ();
324 int setup_windows ();
325 void setup_transport ();
328 static ARDOUR_UI *theArdourUI;
333 int ask_about_saving_session (const std::vector<std::string>& actions);
335 /* periodic safety backup, to be precise */
336 gint autosave_session();
337 void update_autosave();
338 sigc::connection _autosave_connection;
340 void map_transport_state ();
341 int32_t do_engine_start ();
343 void engine_halted (const char* reason, bool free_reason);
344 void engine_stopped ();
345 void engine_running ();
349 static gint _blink (void *);
351 gint blink_timeout_tag;
353 void start_blinking ();
354 void stop_blinking ();
356 void about_signal_response(int response);
358 Gtk::VBox top_packer;
360 sigc::connection clock_signal_connection;
361 void update_clocks ();
362 void start_clocking ();
363 void stop_clocking ();
365 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
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 toggle_always_play_range ();
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;
434 void toggle_external_sync ();
435 void toggle_time_master ();
436 void toggle_video_sync ();
438 ShuttleControl* shuttle_box;
440 ArdourButton auto_return_button;
441 ArdourButton follow_edits_button;
442 ArdourButton auto_input_button;
443 ArdourButton click_button;
444 ArdourButton sync_button;
446 ArdourButton auditioning_alert_button;
447 ArdourButton solo_alert_button;
448 ArdourButton feedback_alert_button;
452 LevelMeterHBox * editor_meter;
454 void solo_blink (bool);
455 void sync_blink (bool);
456 void audition_blink (bool);
457 void feedback_blink (bool);
459 void soloing_changed (bool);
460 void auditioning_changed (bool);
461 void _auditioning_changed (bool);
463 bool solo_alert_press (GdkEventButton* ev);
464 bool audition_alert_press (GdkEventButton* ev);
465 bool feedback_alert_press (GdkEventButton *);
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() {
483 Gtk::TreeModelColumn<std::string> visible_name;
484 Gtk::TreeModelColumn<std::string> tip;
485 Gtk::TreeModelColumn<std::string> fullpath;
488 RecentSessionModelColumns recent_session_columns;
489 Gtk::TreeView recent_session_display;
490 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
492 ArdourDialog* session_selector_window;
493 Gtk::FileChooserDialog* open_session_selector;
495 void build_session_selector();
496 void redisplay_recent_sessions();
497 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
499 struct RecentSessionsSorter {
500 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
501 return cmp_nocase(a.first, b.first) == -1;
505 /* menu bar and associated stuff */
507 Gtk::MenuBar* menu_bar;
508 Gtk::EventBox menu_bar_base;
511 void use_menubar_as_top_menubar ();
512 void build_menu_bar ();
514 Gtk::Label wall_clock_label;
515 gint update_wall_clock ();
517 Gtk::Label disk_space_label;
518 void update_disk_space ();
520 Gtk::Label timecode_format_label;
521 void update_timecode_format ();
523 Gtk::Label cpu_load_label;
524 void update_cpu_load ();
526 Gtk::Label buffer_load_label;
527 void update_buffer_load ();
529 Gtk::Label sample_rate_label;
530 void update_sample_rate (ARDOUR::framecnt_t);
532 Gtk::Label format_label;
533 void update_format ();
535 gint every_second ();
536 gint every_point_one_seconds ();
537 gint every_point_zero_something_seconds ();
539 sigc::connection second_connection;
540 sigc::connection point_one_second_connection;
541 sigc::connection point_zero_something_second_connection;
543 void open_session ();
544 void open_recent_session ();
545 void save_template ();
547 void edit_metadata ();
548 void import_metadata ();
550 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
551 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
553 void set_transport_sensitivity (bool);
555 void transport_goto_zero ();
556 void transport_goto_start ();
557 void transport_goto_end ();
558 void transport_goto_wallclock ();
559 void transport_stop ();
560 void transport_record (bool roll);
561 void transport_roll ();
562 void transport_play_selection();
563 void transport_play_preroll();
564 void transport_forward (int option);
565 void transport_rewind (int option);
566 void transport_loop ();
567 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
569 bool _session_is_new;
570 void set_session (ARDOUR::Session *);
571 void connect_dependents_to_session (ARDOUR::Session *);
572 void we_have_dependents ();
574 void setup_session_options ();
576 guint32 last_key_press_time;
578 void snapshot_session (bool switch_to_it);
579 void rename_session ();
584 PublicEditor *editor;
585 int create_editor ();
587 Meterbridge *meterbridge;
588 int create_meterbridge ();
589 /* Dialogs that can be created via new<T> */
591 WM::Proxy<SpeakerDialog> speaker_config_window;
592 WM::Proxy<ThemeManager> theme_manager;
593 WM::Proxy<KeyEditor> key_editor;
594 WM::Proxy<RCOptionEditor> rc_option_editor;
595 WM::Proxy<AddRouteDialog> add_route_dialog;
596 WM::Proxy<About> about;
597 WM::Proxy<LocationUIWindow> location_ui;
598 WM::Proxy<RouteParams_UI> route_params;
600 /* Windows/Dialogs that require a creator method */
602 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
603 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
604 WM::ProxyWithConstructor<BundleManager> bundle_manager;
605 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
606 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
607 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
609 /* creator methods */
611 SessionOptionEditor* create_session_option_editor ();
612 BundleManager* create_bundle_manager ();
613 AddVideoDialog* create_add_video_dialog ();
614 BigClockWindow* create_big_clock_window();
615 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
617 static UIConfiguration *ui_config;
619 SystemExec *video_server_process;
621 void handle_locations_change (ARDOUR::Location*);
623 /* Keyboard Handling */
625 ArdourKeyboard* keyboard;
627 /* Keymap handling */
629 void install_actions ();
631 void toggle_record_enable (uint32_t);
633 uint32_t rec_enabled_streams;
634 void count_recenabled_streams (ARDOUR::Route&);
638 void pop_back_splash (Gtk::Window&);
642 Gtk::MenuItem *cleanup_item;
644 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
648 bool have_configure_timeout;
649 ARDOUR::microseconds_t last_configure_time;
650 gint configure_timeout ();
652 ARDOUR::microseconds_t last_peak_grab;
653 ARDOUR::microseconds_t last_shuttle_request;
655 bool have_disk_speed_dialog_displayed;
656 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
657 void disk_overrun_handler ();
658 void disk_underrun_handler ();
660 void session_format_mismatch (std::string, std::string);
662 void session_dialog (std::string);
663 int pending_state_dialog ();
664 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
666 void disconnect_from_jack ();
667 void reconnect_to_jack ();
668 void set_jack_buffer_size (ARDOUR::pframes_t);
670 Gtk::MenuItem* jack_disconnect_item;
671 Gtk::MenuItem* jack_reconnect_item;
672 Gtk::Menu* jack_bufsize_menu;
674 Glib::RefPtr<Gtk::ActionGroup> common_actions;
676 void editor_realized ();
678 std::vector<std::string> positional_sync_strings;
680 void toggle_send_midi_feedback ();
681 void toggle_use_mmc ();
682 void toggle_send_mmc ();
683 void toggle_send_mtc ();
684 void toggle_send_midi_clock ();
686 void toggle_use_osc ();
688 void parameter_changed (std::string);
689 void session_parameter_changed (std::string);
693 void no_memory_warning ();
694 void check_memory_locking ();
696 bool check_audioengine();
697 void audioengine_setup ();
699 void display_message (const char *prefix, gint prefix_len,
700 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
702 Gtk::Label status_bar_label;
703 bool status_bar_button_press (GdkEventButton*);
704 Gtk::ToggleButton error_log_button;
706 void loading_message (const std::string& msg);
708 PBD::ScopedConnectionList forever_connections;
710 void step_edit_status_change (bool);
712 void platform_specific ();
713 void platform_setup ();
715 /* these are used only in response to a platform-specific "ShouldQuit" signal
718 void queue_finish ();
719 void fontconfig_dialog ();
721 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
722 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
724 bool click_button_clicked (GdkEventButton *);
726 VisibilityGroup _status_bar_visibility;
728 /** A ProcessThread so that we have some thread-local buffers for use by
729 * PluginEqGui::impulse_analysis ().
731 ARDOUR::ProcessThread* _process_thread;
733 void feedback_detected ();
735 ArdourButton midi_panic_button;
738 void successful_graph_sort ();
739 bool _feedback_exists;
741 void resize_text_widgets ();
743 std::string _announce_string;
744 void check_announcements ();
747 #endif /* __ardour_gui_h__ */