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;
180 /** point_zero_one_seconds -- 10Hz ^= 100ms */
181 static sigc::signal<void> RapidScreenUpdate;
183 /** point_zero_something_seconds -- currently 25Hz ^= 40ms */
184 static sigc::signal<void> SuperRapidScreenUpdate;
186 /** Emitted frequently with the audible frame, false, and the edit point as
187 * parameters respectively.
189 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
191 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
193 static void close_all_dialogs () { CloseAllDialogs(); }
194 static sigc::signal<void> CloseAllDialogs;
196 XMLNode* editor_settings() const;
197 XMLNode* mixer_settings () const;
198 XMLNode* keyboard_settings () const;
199 XMLNode* tearoff_settings (const char*) const;
201 void save_ardour_state ();
202 gboolean configure_handler (GdkEventConfigure* conf);
204 void halt_on_xrun_message ();
205 void xrun_handler (framepos_t);
206 void create_xrun_marker (framepos_t);
208 GUIObjectState* gui_object_state;
210 MainClock* primary_clock;
211 MainClock* secondary_clock;
212 void focus_on_clock ();
213 AudioClock* big_clock;
215 TimeInfoBox* time_info_box;
217 VideoTimeLine *video_timeline;
219 void store_clock_modes ();
220 void restore_clock_modes ();
221 void reset_main_clocks ();
223 void synchronize_sync_source_and_video_pullup ();
225 void add_route (Gtk::Window* float_window);
226 void add_routes_part_two ();
227 void add_routes_thread ();
229 void add_video (Gtk::Window* float_window);
230 void remove_video ();
231 void start_video_server_menu (Gtk::Window* float_window);
232 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
233 void stop_video_server (bool ask_confirm=false);
234 void flush_videotimeline_cache (bool localcacheonly=false);
236 void session_add_audio_track (
238 int32_t output_channels,
239 ARDOUR::TrackMode mode,
240 ARDOUR::RouteGroup* route_group,
242 std::string const & name_template
245 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
248 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
249 uint32_t how_many, std::string const & name_template) {
250 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
253 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
254 ARDOUR::PluginInfoPtr instrument) {
255 session_add_midi_route (true, route_group, how_many, name_template, instrument);
258 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,
259 ARDOUR::PluginInfoPtr instrument);
261 /*void session_add_midi_bus () {
262 session_add_midi_route (false);
265 int create_engine ();
268 gint exit_on_main_window_close (GdkEventAny *);
270 void maximise_editing_space ();
271 void restore_editing_space ();
273 void update_tearoff_visibility ();
275 void setup_profile ();
276 void setup_tooltips ();
278 void set_shuttle_fract (double);
280 void get_process_buffers ();
281 void drop_process_buffers ();
283 const std::string& announce_string() const { return _announce_string; }
286 friend class PublicEditor;
288 void toggle_auto_play ();
289 void toggle_auto_input ();
290 void toggle_punch ();
291 void unset_dual_punch ();
292 bool ignore_dual_punch;
293 void toggle_punch_in ();
294 void toggle_punch_out ();
295 void show_loop_punch_ruler_and_disallow_hide ();
296 void reenable_hide_loop_punch_ruler_if_appropriate ();
297 void toggle_auto_return ();
298 void toggle_click ();
300 void toggle_session_auto_loop ();
302 void toggle_rc_options_window ();
303 void toggle_session_options_window ();
306 ArdourStartup* _startup;
307 ARDOUR::AudioEngine *engine;
308 Gtk::Tooltips _tooltips;
313 void goto_editor_window ();
314 void goto_mixer_window ();
315 void toggle_mixer_window ();
316 void toggle_meterbridge ();
317 void toggle_editor_mixer ();
319 int setup_windows ();
320 void setup_transport ();
323 static ARDOUR_UI *theArdourUI;
328 int ask_about_saving_session (const std::vector<std::string>& actions);
330 /* periodic safety backup, to be precise */
331 gint autosave_session();
332 void update_autosave();
333 sigc::connection _autosave_connection;
335 void map_transport_state ();
336 int32_t do_engine_start ();
338 void engine_halted (const char* reason, bool free_reason);
339 void engine_stopped ();
340 void engine_running ();
344 static gint _blink (void *);
346 gint blink_timeout_tag;
348 void start_blinking ();
349 void stop_blinking ();
351 void about_signal_response(int response);
353 Gtk::VBox top_packer;
355 sigc::connection clock_signal_connection;
356 void update_clocks ();
357 void start_clocking ();
358 void stop_clocking ();
360 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
362 void update_transport_clocks (framepos_t pos);
363 void record_state_changed ();
365 std::list<MidiTracer*> _midi_tracer_windows;
367 /* Transport Control */
369 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
370 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
372 Gtkmm2ext::TearOff* transport_tearoff;
373 Gtk::Frame transport_frame;
374 Gtk::HBox transport_tearoff_hbox;
375 Gtk::HBox _editor_transport_box;
376 Gtk::HBox transport_hbox;
377 Gtk::Fixed transport_base;
378 Gtk::Fixed transport_button_base;
379 Gtk::Frame transport_button_frame;
380 Gtk::HBox transport_button_hbox;
381 Gtk::VBox transport_button_vbox;
382 Gtk::HBox transport_option_button_hbox;
383 Gtk::VBox transport_option_button_vbox;
384 Gtk::HBox transport_clock_hbox;
385 Gtk::VBox transport_clock_vbox;
386 Gtk::HBox primary_clock_hbox;
387 Gtk::HBox secondary_clock_hbox;
389 struct TransportControllable : public PBD::Controllable {
400 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
401 void set_value (double);
402 double get_value (void) const;
408 boost::shared_ptr<TransportControllable> roll_controllable;
409 boost::shared_ptr<TransportControllable> stop_controllable;
410 boost::shared_ptr<TransportControllable> goto_start_controllable;
411 boost::shared_ptr<TransportControllable> goto_end_controllable;
412 boost::shared_ptr<TransportControllable> auto_loop_controllable;
413 boost::shared_ptr<TransportControllable> play_selection_controllable;
414 boost::shared_ptr<TransportControllable> rec_controllable;
416 void toggle_always_play_range ();
418 void set_transport_controllable_state (const XMLNode&);
419 XMLNode& get_transport_controllable_state ();
421 ArdourButton roll_button;
422 ArdourButton stop_button;
423 ArdourButton goto_start_button;
424 ArdourButton goto_end_button;
425 ArdourButton auto_loop_button;
426 ArdourButton play_selection_button;
427 ArdourButton rec_button;
429 void toggle_external_sync ();
430 void toggle_time_master ();
431 void toggle_video_sync ();
433 ShuttleControl* shuttle_box;
435 ArdourButton auto_return_button;
436 ArdourButton follow_edits_button;
437 ArdourButton auto_input_button;
438 ArdourButton click_button;
439 ArdourButton sync_button;
441 ArdourButton auditioning_alert_button;
442 ArdourButton solo_alert_button;
443 ArdourButton feedback_alert_button;
447 void solo_blink (bool);
448 void sync_blink (bool);
449 void audition_blink (bool);
450 void feedback_blink (bool);
452 void soloing_changed (bool);
453 void auditioning_changed (bool);
454 void _auditioning_changed (bool);
456 bool solo_alert_press (GdkEventButton* ev);
457 bool audition_alert_press (GdkEventButton* ev);
458 bool feedback_alert_press (GdkEventButton *);
460 void big_clock_value_changed ();
461 void primary_clock_value_changed ();
462 void secondary_clock_value_changed ();
464 /* called by Blink signal */
466 void transport_rec_enable_blink (bool onoff);
468 Gtk::Menu* session_popup_menu;
470 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
471 RecentSessionModelColumns() {
476 Gtk::TreeModelColumn<std::string> visible_name;
477 Gtk::TreeModelColumn<std::string> tip;
478 Gtk::TreeModelColumn<std::string> fullpath;
481 RecentSessionModelColumns recent_session_columns;
482 Gtk::TreeView recent_session_display;
483 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
485 ArdourDialog* session_selector_window;
486 Gtk::FileChooserDialog* open_session_selector;
488 void build_session_selector();
489 void redisplay_recent_sessions();
490 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
492 struct RecentSessionsSorter {
493 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
494 return cmp_nocase(a.first, b.first) == -1;
498 /* menu bar and associated stuff */
500 Gtk::MenuBar* menu_bar;
501 Gtk::EventBox menu_bar_base;
504 void use_menubar_as_top_menubar ();
505 void build_menu_bar ();
507 Gtk::Label wall_clock_label;
508 gint update_wall_clock ();
510 Gtk::Label disk_space_label;
511 void update_disk_space ();
513 Gtk::Label timecode_format_label;
514 void update_timecode_format ();
516 Gtk::Label cpu_load_label;
517 void update_cpu_load ();
519 Gtk::Label buffer_load_label;
520 void update_buffer_load ();
522 Gtk::Label sample_rate_label;
523 void update_sample_rate (ARDOUR::framecnt_t);
525 Gtk::Label format_label;
526 void update_format ();
528 gint every_second ();
529 gint every_point_one_seconds ();
530 gint every_point_zero_something_seconds ();
532 sigc::connection second_connection;
533 sigc::connection point_one_second_connection;
534 sigc::connection point_zero_something_second_connection;
536 void open_session ();
537 void open_recent_session ();
538 void save_template ();
540 void edit_metadata ();
541 void import_metadata ();
543 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
544 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
546 void set_transport_sensitivity (bool);
548 void transport_goto_zero ();
549 void transport_goto_start ();
550 void transport_goto_end ();
551 void transport_goto_wallclock ();
552 void transport_stop ();
553 void transport_record (bool roll);
554 void transport_roll ();
555 void transport_play_selection();
556 void transport_play_preroll();
557 void transport_forward (int option);
558 void transport_rewind (int option);
559 void transport_loop ();
560 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
562 bool _session_is_new;
563 void set_session (ARDOUR::Session *);
564 void connect_dependents_to_session (ARDOUR::Session *);
565 void we_have_dependents ();
567 void setup_session_options ();
569 guint32 last_key_press_time;
571 void snapshot_session (bool switch_to_it);
572 void rename_session ();
577 PublicEditor *editor;
578 int create_editor ();
580 Meterbridge *meterbridge;
581 int create_meterbridge ();
582 /* Dialogs that can be created via new<T> */
584 WM::Proxy<SpeakerDialog> speaker_config_window;
585 WM::Proxy<ThemeManager> theme_manager;
586 WM::Proxy<KeyEditor> key_editor;
587 WM::Proxy<RCOptionEditor> rc_option_editor;
588 WM::Proxy<AddRouteDialog> add_route_dialog;
589 WM::Proxy<About> about;
590 WM::Proxy<LocationUIWindow> location_ui;
591 WM::Proxy<RouteParams_UI> route_params;
593 /* Windows/Dialogs that require a creator method */
595 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
596 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
597 WM::ProxyWithConstructor<BundleManager> bundle_manager;
598 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
599 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
600 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
602 /* creator methods */
604 SessionOptionEditor* create_session_option_editor ();
605 BundleManager* create_bundle_manager ();
606 AddVideoDialog* create_add_video_dialog ();
607 BigClockWindow* create_big_clock_window();
608 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
610 static UIConfiguration *ui_config;
612 SystemExec *video_server_process;
614 void handle_locations_change (ARDOUR::Location*);
616 /* Keyboard Handling */
618 ArdourKeyboard* keyboard;
620 /* Keymap handling */
622 void install_actions ();
624 void toggle_record_enable (uint32_t);
626 uint32_t rec_enabled_streams;
627 void count_recenabled_streams (ARDOUR::Route&);
631 void pop_back_splash (Gtk::Window&);
635 Gtk::MenuItem *cleanup_item;
637 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
641 bool have_configure_timeout;
642 ARDOUR::microseconds_t last_configure_time;
643 gint configure_timeout ();
645 ARDOUR::microseconds_t last_peak_grab;
646 ARDOUR::microseconds_t last_shuttle_request;
648 bool have_disk_speed_dialog_displayed;
649 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
650 void disk_overrun_handler ();
651 void disk_underrun_handler ();
653 void session_format_mismatch (std::string, std::string);
655 void session_dialog (std::string);
656 int pending_state_dialog ();
657 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
659 void disconnect_from_jack ();
660 void reconnect_to_jack ();
661 void set_jack_buffer_size (ARDOUR::pframes_t);
663 Gtk::MenuItem* jack_disconnect_item;
664 Gtk::MenuItem* jack_reconnect_item;
665 Gtk::Menu* jack_bufsize_menu;
667 Glib::RefPtr<Gtk::ActionGroup> common_actions;
669 void editor_realized ();
671 std::vector<std::string> positional_sync_strings;
673 void toggle_send_midi_feedback ();
674 void toggle_use_mmc ();
675 void toggle_send_mmc ();
676 void toggle_send_mtc ();
677 void toggle_send_midi_clock ();
679 void toggle_use_osc ();
681 void parameter_changed (std::string);
682 void session_parameter_changed (std::string);
686 void no_memory_warning ();
687 void check_memory_locking ();
689 bool check_audioengine();
690 void audioengine_setup ();
692 void display_message (const char *prefix, gint prefix_len,
693 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
695 Gtk::Label status_bar_label;
696 bool status_bar_button_press (GdkEventButton*);
697 Gtk::ToggleButton error_log_button;
699 void loading_message (const std::string& msg);
701 PBD::ScopedConnectionList forever_connections;
703 void step_edit_status_change (bool);
705 void platform_specific ();
706 void platform_setup ();
708 /* these are used only in response to a platform-specific "ShouldQuit" signal
711 void queue_finish ();
712 void fontconfig_dialog ();
714 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
715 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
717 bool click_button_clicked (GdkEventButton *);
719 VisibilityGroup _status_bar_visibility;
721 /** A ProcessThread so that we have some thread-local buffers for use by
722 * PluginEqGui::impulse_analysis ().
724 ARDOUR::ProcessThread* _process_thread;
726 void feedback_detected ();
728 ArdourButton midi_panic_button;
731 void successful_graph_sort ();
732 bool _feedback_exists;
734 void resize_text_widgets ();
736 std::string _announce_string;
737 void check_announcements ();
740 #endif /* __ardour_gui_h__ */