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 "video_timeline.h"
70 #include "ardour_button.h"
71 #include "ardour_dialog.h"
72 #include "ardour_window.h"
74 #include "meterbridge.h"
76 #include "ui_config.h"
78 #include "visibility_group.h"
79 #include "window_manager.h"
92 class ConnectionEditor;
94 class LocationUIWindow;
100 class SessionOptionEditor;
101 class ShuttleControl;
107 class LevelMeterHBox;
108 class GlobalPortMatrixWindow;
109 class GUIObjectState;
111 namespace Gtkmm2ext {
116 class ControlProtocolInfo;
125 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
128 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
131 bool run_startup (bool should_be_new, std::string load_template);
137 void launch_manual ();
138 void launch_reference ();
142 void idle_load (const std::string& path);
145 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
147 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
148 bool session_is_new() const { return _session_is_new; }
150 ARDOUR::Session* the_session() { return _session; }
152 bool get_smart_mode () const;
154 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
155 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
156 bool ask_about_loading_existing_session (const std::string& session_path);
158 /// @return true if session was successfully unloaded.
159 int unload_session (bool hide_stuff = false);
160 void close_session();
162 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
163 void save_state (const std::string & state_name = "", bool switch_to_it = false);
165 static ARDOUR_UI *instance () { return theArdourUI; }
166 static UIConfiguration *config () { return ui_config; }
168 PublicEditor& the_editor(){return *editor;}
169 Mixer_UI* the_mixer() { return mixer; }
171 void new_midi_tracer_window ();
172 void toggle_editing_space();
173 void toggle_keep_tearoffs();
175 Gtk::Tooltips& tooltips() { return _tooltips; }
177 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
179 static PublicEditor* _instance;
180 static sigc::signal<void,bool> Blink;
182 /** point_zero_one_seconds -- 10Hz ^= 100ms */
183 static sigc::signal<void> RapidScreenUpdate;
185 /** point_zero_something_seconds -- currently 25Hz ^= 40ms */
186 static sigc::signal<void> SuperRapidScreenUpdate;
188 /** Emitted frequently with the audible frame, false, and the edit point as
189 * parameters respectively.
191 * (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
193 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
195 static void close_all_dialogs () { CloseAllDialogs(); }
196 static sigc::signal<void> CloseAllDialogs;
198 XMLNode* editor_settings() const;
199 XMLNode* mixer_settings () const;
200 XMLNode* keyboard_settings () const;
201 XMLNode* tearoff_settings (const char*) const;
203 void save_ardour_state ();
204 gboolean configure_handler (GdkEventConfigure* conf);
206 void halt_on_xrun_message ();
207 void xrun_handler (framepos_t);
208 void create_xrun_marker (framepos_t);
210 GUIObjectState* gui_object_state;
212 MainClock* primary_clock;
213 MainClock* secondary_clock;
214 void focus_on_clock ();
215 AudioClock* big_clock;
217 TimeInfoBox* time_info_box;
219 VideoTimeLine *video_timeline;
221 void store_clock_modes ();
222 void restore_clock_modes ();
223 void reset_main_clocks ();
225 void synchronize_sync_source_and_video_pullup ();
227 void add_route (Gtk::Window* float_window);
228 void add_routes_part_two ();
229 void add_routes_thread ();
231 void add_video (Gtk::Window* float_window);
232 void remove_video ();
233 void start_video_server_menu (Gtk::Window* float_window);
234 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
235 void stop_video_server (bool ask_confirm=false);
236 void flush_videotimeline_cache (bool localcacheonly=false);
238 void session_add_audio_track (
240 int32_t output_channels,
241 ARDOUR::TrackMode mode,
242 ARDOUR::RouteGroup* route_group,
244 std::string const & name_template
247 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
250 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
251 uint32_t how_many, std::string const & name_template) {
252 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
255 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
256 ARDOUR::PluginInfoPtr instrument) {
257 session_add_midi_route (true, route_group, how_many, name_template, instrument);
260 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,
261 ARDOUR::PluginInfoPtr instrument);
263 /*void session_add_midi_bus () {
264 session_add_midi_route (false);
267 void attach_to_engine ();
270 gint exit_on_main_window_close (GdkEventAny *);
272 void maximise_editing_space ();
273 void restore_editing_space ();
275 void update_tearoff_visibility ();
277 void setup_profile ();
278 void setup_tooltips ();
280 void set_shuttle_fract (double);
282 void get_process_buffers ();
283 void drop_process_buffers ();
285 void reset_peak_display ();
286 void reset_route_peak_display (ARDOUR::Route*);
287 void reset_group_peak_display (ARDOUR::RouteGroup*);
289 const std::string& announce_string() const { return _announce_string; }
292 friend class PublicEditor;
294 void toggle_auto_play ();
295 void toggle_auto_input ();
296 void toggle_punch ();
297 void unset_dual_punch ();
298 bool ignore_dual_punch;
299 void toggle_punch_in ();
300 void toggle_punch_out ();
301 void show_loop_punch_ruler_and_disallow_hide ();
302 void reenable_hide_loop_punch_ruler_if_appropriate ();
303 void toggle_auto_return ();
304 void toggle_click ();
306 void toggle_session_auto_loop ();
308 void toggle_rc_options_window ();
309 void toggle_session_options_window ();
312 ArdourStartup* _startup;
313 ARDOUR::AudioEngine *engine;
314 Gtk::Tooltips _tooltips;
318 bool first_time_engine_run;
320 void goto_editor_window ();
321 void goto_mixer_window ();
322 void toggle_mixer_window ();
323 void toggle_meterbridge ();
324 void toggle_editor_mixer ();
326 int setup_windows ();
327 void setup_transport ();
330 static ARDOUR_UI *theArdourUI;
335 int ask_about_saving_session (const std::vector<std::string>& actions);
337 /* periodic safety backup, to be precise */
338 gint autosave_session();
339 void update_autosave();
340 sigc::connection _autosave_connection;
342 void map_transport_state ();
343 int32_t do_engine_start ();
345 void engine_halted (const char* reason, bool free_reason);
346 void engine_stopped ();
347 void engine_running ();
351 static gint _blink (void *);
353 gint blink_timeout_tag;
355 void start_blinking ();
356 void stop_blinking ();
358 void about_signal_response(int response);
360 Gtk::VBox top_packer;
362 sigc::connection clock_signal_connection;
363 void update_clocks ();
364 void start_clocking ();
365 void stop_clocking ();
367 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
369 void update_transport_clocks (framepos_t pos);
370 void record_state_changed ();
372 std::list<MidiTracer*> _midi_tracer_windows;
374 /* Transport Control */
376 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
377 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
379 Gtkmm2ext::TearOff* transport_tearoff;
380 Gtk::Frame transport_frame;
381 Gtk::HBox transport_tearoff_hbox;
382 Gtk::HBox _editor_transport_box;
383 Gtk::HBox transport_hbox;
384 Gtk::Fixed transport_base;
385 Gtk::Fixed transport_button_base;
386 Gtk::Frame transport_button_frame;
387 Gtk::HBox transport_button_hbox;
388 Gtk::VBox transport_button_vbox;
389 Gtk::HBox transport_option_button_hbox;
390 Gtk::VBox transport_option_button_vbox;
391 Gtk::HBox transport_clock_hbox;
392 Gtk::VBox transport_clock_vbox;
393 Gtk::HBox primary_clock_hbox;
394 Gtk::HBox secondary_clock_hbox;
396 struct TransportControllable : public PBD::Controllable {
407 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
408 void set_value (double);
409 double get_value (void) const;
415 boost::shared_ptr<TransportControllable> roll_controllable;
416 boost::shared_ptr<TransportControllable> stop_controllable;
417 boost::shared_ptr<TransportControllable> goto_start_controllable;
418 boost::shared_ptr<TransportControllable> goto_end_controllable;
419 boost::shared_ptr<TransportControllable> auto_loop_controllable;
420 boost::shared_ptr<TransportControllable> play_selection_controllable;
421 boost::shared_ptr<TransportControllable> rec_controllable;
423 void toggle_always_play_range ();
425 void set_transport_controllable_state (const XMLNode&);
426 XMLNode& get_transport_controllable_state ();
428 ArdourButton roll_button;
429 ArdourButton stop_button;
430 ArdourButton goto_start_button;
431 ArdourButton goto_end_button;
432 ArdourButton auto_loop_button;
433 ArdourButton play_selection_button;
434 ArdourButton rec_button;
436 void toggle_external_sync ();
437 void toggle_time_master ();
438 void toggle_video_sync ();
440 ShuttleControl* shuttle_box;
442 ArdourButton auto_return_button;
443 ArdourButton follow_edits_button;
444 ArdourButton auto_input_button;
445 ArdourButton click_button;
446 ArdourButton sync_button;
448 ArdourButton auditioning_alert_button;
449 ArdourButton solo_alert_button;
450 ArdourButton feedback_alert_button;
454 LevelMeterHBox * editor_meter;
455 float editor_meter_max_peak;
456 ArdourButton editor_meter_peak_display;
457 bool editor_meter_peak_button_release (GdkEventButton*);
459 void solo_blink (bool);
460 void sync_blink (bool);
461 void audition_blink (bool);
462 void feedback_blink (bool);
464 void soloing_changed (bool);
465 void auditioning_changed (bool);
466 void _auditioning_changed (bool);
468 bool solo_alert_press (GdkEventButton* ev);
469 bool audition_alert_press (GdkEventButton* ev);
470 bool feedback_alert_press (GdkEventButton *);
472 void big_clock_value_changed ();
473 void primary_clock_value_changed ();
474 void secondary_clock_value_changed ();
476 /* called by Blink signal */
478 void transport_rec_enable_blink (bool onoff);
480 Gtk::Menu* session_popup_menu;
482 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
483 RecentSessionModelColumns() {
488 Gtk::TreeModelColumn<std::string> visible_name;
489 Gtk::TreeModelColumn<std::string> tip;
490 Gtk::TreeModelColumn<std::string> fullpath;
493 RecentSessionModelColumns recent_session_columns;
494 Gtk::TreeView recent_session_display;
495 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
497 ArdourDialog* session_selector_window;
498 Gtk::FileChooserDialog* open_session_selector;
500 void build_session_selector();
501 void redisplay_recent_sessions();
502 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
504 struct RecentSessionsSorter {
505 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
506 return cmp_nocase(a.first, b.first) == -1;
510 /* menu bar and associated stuff */
512 Gtk::MenuBar* menu_bar;
513 Gtk::EventBox menu_bar_base;
516 void use_menubar_as_top_menubar ();
517 void build_menu_bar ();
519 Gtk::Label wall_clock_label;
520 gint update_wall_clock ();
522 Gtk::Label disk_space_label;
523 void update_disk_space ();
525 Gtk::Label timecode_format_label;
526 void update_timecode_format ();
528 Gtk::Label cpu_load_label;
529 void update_cpu_load ();
531 Gtk::Label buffer_load_label;
532 void update_buffer_load ();
534 Gtk::Label sample_rate_label;
535 void update_sample_rate (ARDOUR::framecnt_t);
537 Gtk::Label format_label;
538 void update_format ();
540 gint every_second ();
541 gint every_point_one_seconds ();
542 gint every_point_zero_something_seconds ();
544 sigc::connection second_connection;
545 sigc::connection point_one_second_connection;
546 sigc::connection point_zero_something_second_connection;
548 void open_session ();
549 void open_recent_session ();
550 void save_template ();
552 void edit_metadata ();
553 void import_metadata ();
555 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
556 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
558 void set_transport_sensitivity (bool);
560 void transport_goto_zero ();
561 void transport_goto_start ();
562 void transport_goto_end ();
563 void transport_goto_wallclock ();
564 void transport_stop ();
565 void transport_record (bool roll);
566 void transport_roll ();
567 void transport_play_selection();
568 void transport_play_preroll();
569 void transport_forward (int option);
570 void transport_rewind (int option);
571 void transport_loop ();
572 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
574 bool _session_is_new;
575 void set_session (ARDOUR::Session *);
576 void connect_dependents_to_session (ARDOUR::Session *);
577 void we_have_dependents ();
579 void setup_session_options ();
581 guint32 last_key_press_time;
583 void snapshot_session (bool switch_to_it);
584 void rename_session ();
589 PublicEditor *editor;
590 int create_editor ();
592 Meterbridge *meterbridge;
593 int create_meterbridge ();
594 /* Dialogs that can be created via new<T> */
596 WM::Proxy<SpeakerDialog> speaker_config_window;
597 WM::Proxy<ThemeManager> theme_manager;
598 WM::Proxy<KeyEditor> key_editor;
599 WM::Proxy<RCOptionEditor> rc_option_editor;
600 WM::Proxy<AddRouteDialog> add_route_dialog;
601 WM::Proxy<About> about;
602 WM::Proxy<LocationUIWindow> location_ui;
603 WM::Proxy<RouteParams_UI> route_params;
605 /* Windows/Dialogs that require a creator method */
607 WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
608 WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
609 WM::ProxyWithConstructor<BundleManager> bundle_manager;
610 WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
611 WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
612 WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
614 /* creator methods */
616 SessionOptionEditor* create_session_option_editor ();
617 BundleManager* create_bundle_manager ();
618 AddVideoDialog* create_add_video_dialog ();
619 BigClockWindow* create_big_clock_window();
620 GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
622 static UIConfiguration *ui_config;
624 SystemExec *video_server_process;
626 void handle_locations_change (ARDOUR::Location*);
628 /* Keyboard Handling */
630 ArdourKeyboard* keyboard;
632 /* Keymap handling */
634 void install_actions ();
636 void toggle_record_enable (uint32_t);
638 uint32_t rec_enabled_streams;
639 void count_recenabled_streams (ARDOUR::Route&);
643 void pop_back_splash (Gtk::Window&);
647 Gtk::MenuItem *cleanup_item;
649 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
653 bool have_configure_timeout;
654 ARDOUR::microseconds_t last_configure_time;
655 gint configure_timeout ();
657 ARDOUR::microseconds_t last_peak_grab;
658 ARDOUR::microseconds_t last_shuttle_request;
660 bool have_disk_speed_dialog_displayed;
661 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
662 void disk_overrun_handler ();
663 void disk_underrun_handler ();
665 void session_format_mismatch (std::string, std::string);
667 void session_dialog (std::string);
668 int pending_state_dialog ();
669 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
671 void disconnect_from_jack ();
672 void reconnect_to_jack ();
673 void set_jack_buffer_size (ARDOUR::pframes_t);
675 Gtk::MenuItem* jack_disconnect_item;
676 Gtk::MenuItem* jack_reconnect_item;
677 Gtk::Menu* jack_bufsize_menu;
679 Glib::RefPtr<Gtk::ActionGroup> common_actions;
681 void editor_realized ();
683 std::vector<std::string> positional_sync_strings;
685 void toggle_send_midi_feedback ();
686 void toggle_use_mmc ();
687 void toggle_send_mmc ();
688 void toggle_send_mtc ();
689 void toggle_send_midi_clock ();
691 void toggle_use_osc ();
693 void parameter_changed (std::string);
694 void session_parameter_changed (std::string);
698 void no_memory_warning ();
699 void check_memory_locking ();
701 bool check_audioengine();
702 void audioengine_setup ();
704 void display_message (const char *prefix, gint prefix_len,
705 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
707 Gtk::Label status_bar_label;
708 bool status_bar_button_press (GdkEventButton*);
709 Gtk::ToggleButton error_log_button;
711 void loading_message (const std::string& msg);
713 PBD::ScopedConnectionList forever_connections;
715 void step_edit_status_change (bool);
717 void platform_specific ();
718 void platform_setup ();
720 /* these are used only in response to a platform-specific "ShouldQuit" signal
723 void queue_finish ();
724 void fontconfig_dialog ();
726 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
727 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
729 bool click_button_clicked (GdkEventButton *);
731 VisibilityGroup _status_bar_visibility;
733 /** A ProcessThread so that we have some thread-local buffers for use by
734 * PluginEqGui::impulse_analysis ().
736 ARDOUR::ProcessThread* _process_thread;
738 void feedback_detected ();
740 ArdourButton midi_panic_button;
743 void successful_graph_sort ();
744 bool _feedback_exists;
746 void resize_text_widgets ();
748 std::string _announce_string;
749 void check_announcements ();
752 #endif /* __ardour_gui_h__ */