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 #ifdef WITH_VIDEOTIMELINE
69 #include "video_timeline.h"
72 #include "ardour_dialog.h"
73 #include "ardour_button.h"
76 #include "ui_config.h"
77 #include "window_proxy.h"
79 #include "visibility_group.h"
83 #ifdef WITH_VIDEOTIMELINE
93 class ConnectionEditor;
95 class LocationUIWindow;
100 class RouteParams_UI;
101 class SessionOptionEditor;
102 class ShuttleControl;
108 class WindowProxyBase;
109 class GlobalPortMatrixWindow;
110 class GUIObjectState;
112 namespace Gtkmm2ext {
117 class ControlProtocolInfo;
126 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
129 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
132 bool run_startup (bool should_be_new, std::string load_template);
138 void launch_manual ();
139 void launch_reference ();
143 void idle_load (const std::string& path);
146 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
148 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
149 bool session_is_new() const { return _session_is_new; }
151 ARDOUR::Session* the_session() { return _session; }
153 bool get_smart_mode () const;
155 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
156 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
157 bool ask_about_loading_existing_session (const std::string& session_path);
159 /// @return true if session was successfully unloaded.
160 int unload_session (bool hide_stuff = false);
161 void close_session();
163 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
164 void save_state (const std::string & state_name = "", bool switch_to_it = false);
166 static ARDOUR_UI *instance () { return theArdourUI; }
167 static UIConfiguration *config () { return ui_config; }
169 PublicEditor& the_editor(){return *editor;}
170 Mixer_UI* the_mixer() { return mixer; }
172 void toggle_key_editor ();
173 void toggle_location_window ();
174 void toggle_theme_manager ();
175 void toggle_bundle_manager ();
176 void toggle_big_clock_window ();
177 void toggle_speaker_config_window ();
178 void new_midi_tracer_window ();
179 void toggle_route_params_window ();
180 void toggle_editing_space();
181 void toggle_keep_tearoffs();
183 Gtk::Tooltips& tooltips() { return _tooltips; }
185 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
187 static PublicEditor* _instance;
188 static sigc::signal<void,bool> Blink;
189 static sigc::signal<void> RapidScreenUpdate;
190 static sigc::signal<void> SuperRapidScreenUpdate;
191 /** Emitted frequently with the audible frame, false, and the edit point as
192 * parameters respectively.
194 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
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 ();
214 TimeInfoBox* time_info_box;
216 #ifdef WITH_VIDEOTIMELINE
217 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 ();
229 #ifdef WITH_VIDEOTIMELINE
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);
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 int create_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 add_window_proxy (WindowProxyBase *);
283 void remove_window_proxy (WindowProxyBase *);
285 void get_process_buffers ();
286 void drop_process_buffers ();
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;
317 void goto_editor_window ();
318 void goto_mixer_window ();
319 void toggle_mixer_window ();
320 void toggle_mixer_on_top ();
322 int setup_windows ();
323 void setup_transport ();
326 static ARDOUR_UI *theArdourUI;
331 int ask_about_saving_session (const std::vector<std::string>& actions);
333 /* periodic safety backup, to be precise */
334 gint autosave_session();
335 void update_autosave();
336 sigc::connection _autosave_connection;
338 void map_transport_state ();
339 int32_t do_engine_start ();
341 void engine_halted (const char* reason, bool free_reason);
342 void engine_stopped ();
343 void engine_running ();
347 static gint _blink (void *);
349 gint blink_timeout_tag;
351 void start_blinking ();
352 void stop_blinking ();
354 void about_signal_response(int response);
356 Gtk::VBox top_packer;
358 sigc::connection clock_signal_connection;
359 void update_clocks ();
360 void start_clocking ();
361 void stop_clocking ();
363 void manage_window (Gtk::Window&);
365 AudioClock* big_clock;
366 ActionWindowProxy<Gtk::Window>* big_clock_window;
367 int original_big_clock_width;
368 int original_big_clock_height;
369 double original_big_clock_font_size;
371 void big_clock_size_allocate (Gtk::Allocation&);
372 bool idle_big_clock_text_resizer (int width, int height);
373 void big_clock_realized ();
374 bool big_clock_resize_in_progress;
375 int big_clock_height;
376 void big_clock_catch_focus ();
377 void big_clock_reset_aspect_ratio ();
379 void float_big_clock (Gtk::Window* parent);
380 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
382 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
384 void update_transport_clocks (framepos_t pos);
385 void record_state_changed ();
387 std::list<MidiTracer*> _midi_tracer_windows;
389 /* Transport Control */
391 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
392 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
394 Gtkmm2ext::TearOff* transport_tearoff;
395 Gtk::Frame transport_frame;
396 Gtk::HBox transport_tearoff_hbox;
397 Gtk::HBox _editor_transport_box;
398 Gtk::HBox transport_hbox;
399 Gtk::Fixed transport_base;
400 Gtk::Fixed transport_button_base;
401 Gtk::Frame transport_button_frame;
402 Gtk::HBox transport_button_hbox;
403 Gtk::VBox transport_button_vbox;
404 Gtk::HBox transport_option_button_hbox;
405 Gtk::VBox transport_option_button_vbox;
406 Gtk::HBox transport_clock_hbox;
407 Gtk::VBox transport_clock_vbox;
408 Gtk::HBox primary_clock_hbox;
409 Gtk::HBox secondary_clock_hbox;
411 struct TransportControllable : public PBD::Controllable {
422 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
423 void set_value (double);
424 double get_value (void) const;
430 boost::shared_ptr<TransportControllable> roll_controllable;
431 boost::shared_ptr<TransportControllable> stop_controllable;
432 boost::shared_ptr<TransportControllable> goto_start_controllable;
433 boost::shared_ptr<TransportControllable> goto_end_controllable;
434 boost::shared_ptr<TransportControllable> auto_loop_controllable;
435 boost::shared_ptr<TransportControllable> play_selection_controllable;
436 boost::shared_ptr<TransportControllable> rec_controllable;
438 void toggle_always_play_range ();
440 void set_transport_controllable_state (const XMLNode&);
441 XMLNode& get_transport_controllable_state ();
443 ArdourButton roll_button;
444 ArdourButton stop_button;
445 ArdourButton goto_start_button;
446 ArdourButton goto_end_button;
447 ArdourButton auto_loop_button;
448 ArdourButton play_selection_button;
449 ArdourButton rec_button;
451 void toggle_external_sync ();
452 void toggle_time_master ();
453 void toggle_video_sync ();
455 ShuttleControl* shuttle_box;
457 ArdourButton auto_return_button;
458 ArdourButton follow_edits_button;
459 ArdourButton auto_input_button;
460 ArdourButton click_button;
461 ArdourButton sync_button;
463 ArdourButton auditioning_alert_button;
464 ArdourButton solo_alert_button;
465 ArdourButton feedback_alert_button;
469 void solo_blink (bool);
470 void sync_blink (bool);
471 void audition_blink (bool);
472 void feedback_blink (bool);
474 void soloing_changed (bool);
475 void auditioning_changed (bool);
476 void _auditioning_changed (bool);
478 bool solo_alert_press (GdkEventButton* ev);
479 bool audition_alert_press (GdkEventButton* ev);
480 bool feedback_alert_press (GdkEventButton *);
482 void big_clock_value_changed ();
483 void primary_clock_value_changed ();
484 void secondary_clock_value_changed ();
486 /* called by Blink signal */
488 void transport_rec_enable_blink (bool onoff);
490 Gtk::Menu* session_popup_menu;
492 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
493 RecentSessionModelColumns() {
498 Gtk::TreeModelColumn<std::string> visible_name;
499 Gtk::TreeModelColumn<std::string> tip;
500 Gtk::TreeModelColumn<std::string> fullpath;
503 RecentSessionModelColumns recent_session_columns;
504 Gtk::TreeView recent_session_display;
505 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
507 ArdourDialog* session_selector_window;
508 Gtk::FileChooserDialog* open_session_selector;
510 void build_session_selector();
511 void redisplay_recent_sessions();
512 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
514 struct RecentSessionsSorter {
515 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
516 return cmp_nocase(a.first, b.first) == -1;
520 /* menu bar and associated stuff */
522 Gtk::MenuBar* menu_bar;
523 Gtk::EventBox menu_bar_base;
526 void use_menubar_as_top_menubar ();
527 void build_menu_bar ();
529 Gtk::Label wall_clock_label;
530 gint update_wall_clock ();
532 Gtk::Label disk_space_label;
533 void update_disk_space ();
535 Gtk::Label timecode_format_label;
536 void update_timecode_format ();
538 Gtk::Label cpu_load_label;
539 void update_cpu_load ();
541 Gtk::Label buffer_load_label;
542 void update_buffer_load ();
544 Gtk::Label sample_rate_label;
545 void update_sample_rate (ARDOUR::framecnt_t);
547 Gtk::Label format_label;
548 void update_format ();
550 gint every_second ();
551 gint every_point_one_seconds ();
552 gint every_point_zero_one_seconds ();
554 sigc::connection second_connection;
555 sigc::connection point_one_second_connection;
556 sigc::connection point_oh_five_second_connection;
557 sigc::connection point_zero_one_second_connection;
559 void open_session ();
560 void open_recent_session ();
561 void save_template ();
563 void edit_metadata ();
564 void import_metadata ();
566 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
567 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
569 void set_transport_sensitivity (bool);
571 void transport_goto_zero ();
572 void transport_goto_start ();
573 void transport_goto_end ();
574 void transport_goto_wallclock ();
575 void transport_stop ();
576 void transport_record (bool roll);
577 void transport_roll ();
578 void transport_play_selection();
579 void transport_play_preroll();
580 void transport_forward (int option);
581 void transport_rewind (int option);
582 void transport_loop ();
583 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
585 bool _session_is_new;
586 void set_session (ARDOUR::Session *);
587 void connect_dependents_to_session (ARDOUR::Session *);
588 void we_have_dependents ();
590 void setup_session_options ();
592 guint32 last_key_press_time;
594 void snapshot_session (bool switch_to_it);
595 void rename_session ();
600 PublicEditor *editor;
601 int create_editor ();
603 RouteParams_UI *route_params;
604 int create_route_params ();
606 BundleManager *bundle_manager;
607 void create_bundle_manager ();
609 ActionWindowProxy<LocationUIWindow>* location_ui;
610 int create_location_ui ();
611 void handle_locations_change (ARDOUR::Location*);
613 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
614 void toggle_global_port_matrix (ARDOUR::DataType);
616 static UIConfiguration *ui_config;
617 ThemeManager *theme_manager;
619 /* Key bindings editor */
621 KeyEditor *key_editor;
623 /* RC Options window */
625 RCOptionEditor *rc_option_editor;
627 SessionOptionEditor *session_option_editor;
631 AddRouteDialog *add_route_dialog;
633 #ifdef WITH_VIDEOTIMELINE
635 AddVideoDialog *add_video_dialog;
636 SystemExec *video_server_process;
639 /* Keyboard Handling */
641 ArdourKeyboard* keyboard;
643 /* Keymap handling */
645 void install_actions ();
647 void toggle_record_enable (uint32_t);
649 uint32_t rec_enabled_streams;
650 void count_recenabled_streams (ARDOUR::Route&);
655 void pop_back_splash (Gtk::Window&);
659 Gtk::MenuItem *cleanup_item;
661 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
665 bool have_configure_timeout;
666 ARDOUR::microseconds_t last_configure_time;
667 gint configure_timeout ();
669 ARDOUR::microseconds_t last_peak_grab;
670 ARDOUR::microseconds_t last_shuttle_request;
672 bool have_disk_speed_dialog_displayed;
673 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
674 void disk_overrun_handler ();
675 void disk_underrun_handler ();
677 void session_format_mismatch (std::string, std::string);
679 void session_dialog (std::string);
680 int pending_state_dialog ();
681 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
683 void disconnect_from_jack ();
684 void reconnect_to_jack ();
685 void set_jack_buffer_size (ARDOUR::pframes_t);
687 Gtk::MenuItem* jack_disconnect_item;
688 Gtk::MenuItem* jack_reconnect_item;
689 Gtk::Menu* jack_bufsize_menu;
691 Glib::RefPtr<Gtk::ActionGroup> common_actions;
693 void editor_realized ();
695 std::vector<std::string> positional_sync_strings;
697 void toggle_send_midi_feedback ();
698 void toggle_use_mmc ();
699 void toggle_send_mmc ();
700 void toggle_send_mtc ();
701 void toggle_send_midi_clock ();
703 void toggle_use_osc ();
705 void parameter_changed (std::string);
706 void session_parameter_changed (std::string);
710 void no_memory_warning ();
711 void check_memory_locking ();
713 bool check_audioengine();
714 void audioengine_setup ();
716 void display_message (const char *prefix, gint prefix_len,
717 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
719 Gtk::Label status_bar_label;
720 bool status_bar_button_press (GdkEventButton*);
721 Gtk::ToggleButton error_log_button;
723 void loading_message (const std::string& msg);
725 PBD::ScopedConnectionList forever_connections;
727 void step_edit_status_change (bool);
729 void platform_specific ();
730 void platform_setup ();
732 /* these are used only in response to a platform-specific "ShouldQuit" signal
735 void queue_finish ();
736 void fontconfig_dialog ();
738 std::list<WindowProxyBase*> _window_proxies;
740 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
741 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
743 bool click_button_clicked (GdkEventButton *);
745 VisibilityGroup _status_bar_visibility;
747 /** A ProcessThread so that we have some thread-local buffers for use by
748 * PluginEqGui::impulse_analysis ().
750 ARDOUR::ProcessThread* _process_thread;
752 void feedback_detected ();
754 ArdourButton midi_panic_button;
757 void successful_graph_sort ();
758 bool _feedback_exists;
760 void resize_text_widgets ();
762 std::string _announce_string;
763 void check_announcements ();
766 #endif /* __ardour_gui_h__ */