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_dialog.h"
71 #include "ardour_button.h"
74 #include "ui_config.h"
75 #include "window_proxy.h"
77 #include "visibility_group.h"
89 class ConnectionEditor;
91 class LocationUIWindow;
97 class SessionOptionEditor;
104 class WindowProxyBase;
105 class GlobalPortMatrixWindow;
106 class GUIObjectState;
108 namespace Gtkmm2ext {
113 class ControlProtocolInfo;
122 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
125 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
128 bool run_startup (bool should_be_new, std::string load_template);
134 void launch_manual ();
135 void launch_reference ();
139 void idle_load (const std::string& path);
142 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
144 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
145 bool session_is_new() const { return _session_is_new; }
147 ARDOUR::Session* the_session() { return _session; }
149 bool get_smart_mode () const;
151 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
152 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
153 bool ask_about_loading_existing_session (const std::string& session_path);
155 /// @return true if session was successfully unloaded.
156 int unload_session (bool hide_stuff = false);
157 void close_session();
159 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
160 void save_state (const std::string & state_name = "", bool switch_to_it = false);
162 static ARDOUR_UI *instance () { return theArdourUI; }
163 static UIConfiguration *config () { return ui_config; }
165 PublicEditor& the_editor(){return *editor;}
166 Mixer_UI* the_mixer() { return mixer; }
168 void toggle_key_editor ();
169 void toggle_location_window ();
170 void toggle_theme_manager ();
171 void toggle_bundle_manager ();
172 void toggle_big_clock_window ();
173 void toggle_speaker_config_window ();
174 void new_midi_tracer_window ();
175 void toggle_route_params_window ();
176 void toggle_editing_space();
177 void toggle_keep_tearoffs();
179 Gtk::Tooltips& tooltips() { return _tooltips; }
181 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
183 static PublicEditor* _instance;
184 static sigc::signal<void,bool> Blink;
185 static sigc::signal<void> RapidScreenUpdate;
186 static sigc::signal<void> SuperRapidScreenUpdate;
187 /** Emitted frequently with the audible frame, false, and the edit point as
188 * parameters respectively.
190 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
192 XMLNode* editor_settings() const;
193 XMLNode* mixer_settings () const;
194 XMLNode* keyboard_settings () const;
195 XMLNode* tearoff_settings (const char*) const;
197 void save_ardour_state ();
198 gboolean configure_handler (GdkEventConfigure* conf);
200 void halt_on_xrun_message ();
201 void xrun_handler (framepos_t);
202 void create_xrun_marker (framepos_t);
204 GUIObjectState* gui_object_state;
206 MainClock* primary_clock;
207 MainClock* secondary_clock;
208 void focus_on_clock ();
210 TimeInfoBox* time_info_box;
212 VideoTimeLine *video_timeline;
214 void store_clock_modes ();
215 void restore_clock_modes ();
216 void reset_main_clocks ();
218 void synchronize_sync_source_and_video_pullup ();
220 void add_route (Gtk::Window* float_window);
221 void add_routes_part_two ();
222 void add_routes_thread ();
224 void add_video (Gtk::Window* float_window);
225 void remove_video ();
226 void start_video_server_menu (Gtk::Window* float_window);
227 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
228 void stop_video_server (bool ask_confirm=false);
229 void flush_videotimeline_cache (bool localcacheonly=false);
231 void session_add_audio_track (
233 int32_t output_channels,
234 ARDOUR::TrackMode mode,
235 ARDOUR::RouteGroup* route_group,
237 std::string const & name_template
240 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
243 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
244 uint32_t how_many, std::string const & name_template) {
245 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
248 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
249 ARDOUR::PluginInfoPtr instrument) {
250 session_add_midi_route (true, route_group, how_many, name_template, instrument);
253 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,
254 ARDOUR::PluginInfoPtr instrument);
256 /*void session_add_midi_bus () {
257 session_add_midi_route (false);
260 int create_engine ();
263 gint exit_on_main_window_close (GdkEventAny *);
265 void maximise_editing_space ();
266 void restore_editing_space ();
268 void update_tearoff_visibility ();
270 void setup_profile ();
271 void setup_tooltips ();
273 void set_shuttle_fract (double);
275 void add_window_proxy (WindowProxyBase *);
276 void remove_window_proxy (WindowProxyBase *);
278 void get_process_buffers ();
279 void drop_process_buffers ();
281 const std::string& announce_string() const { return _announce_string; }
284 friend class PublicEditor;
286 void toggle_auto_play ();
287 void toggle_auto_input ();
288 void toggle_punch ();
289 void unset_dual_punch ();
290 bool ignore_dual_punch;
291 void toggle_punch_in ();
292 void toggle_punch_out ();
293 void show_loop_punch_ruler_and_disallow_hide ();
294 void reenable_hide_loop_punch_ruler_if_appropriate ();
295 void toggle_auto_return ();
296 void toggle_click ();
298 void toggle_session_auto_loop ();
300 void toggle_rc_options_window ();
301 void toggle_session_options_window ();
304 ArdourStartup* _startup;
305 ARDOUR::AudioEngine *engine;
306 Gtk::Tooltips _tooltips;
310 void goto_editor_window ();
311 void goto_mixer_window ();
312 void toggle_mixer_window ();
313 void toggle_mixer_on_top ();
315 int setup_windows ();
316 void setup_transport ();
319 static ARDOUR_UI *theArdourUI;
324 int ask_about_saving_session (const std::vector<std::string>& actions);
326 /* periodic safety backup, to be precise */
327 gint autosave_session();
328 void update_autosave();
329 sigc::connection _autosave_connection;
331 void map_transport_state ();
332 int32_t do_engine_start ();
334 void engine_halted (const char* reason, bool free_reason);
335 void engine_stopped ();
336 void engine_running ();
340 static gint _blink (void *);
342 gint blink_timeout_tag;
344 void start_blinking ();
345 void stop_blinking ();
347 void about_signal_response(int response);
349 Gtk::VBox top_packer;
351 sigc::connection clock_signal_connection;
352 void update_clocks ();
353 void start_clocking ();
354 void stop_clocking ();
356 void manage_window (Gtk::Window&);
358 AudioClock* big_clock;
359 ActionWindowProxy<Gtk::Window>* big_clock_window;
360 int original_big_clock_width;
361 int original_big_clock_height;
362 double original_big_clock_font_size;
364 void big_clock_size_allocate (Gtk::Allocation&);
365 bool idle_big_clock_text_resizer (int width, int height);
366 void big_clock_realized ();
367 bool big_clock_resize_in_progress;
368 int big_clock_height;
369 void big_clock_catch_focus ();
370 void big_clock_reset_aspect_ratio ();
372 void float_big_clock (Gtk::Window* parent);
373 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
375 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
377 void update_transport_clocks (framepos_t pos);
378 void record_state_changed ();
380 std::list<MidiTracer*> _midi_tracer_windows;
382 /* Transport Control */
384 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
385 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
387 Gtkmm2ext::TearOff* transport_tearoff;
388 Gtk::Frame transport_frame;
389 Gtk::HBox transport_tearoff_hbox;
390 Gtk::HBox _editor_transport_box;
391 Gtk::HBox transport_hbox;
392 Gtk::Fixed transport_base;
393 Gtk::Fixed transport_button_base;
394 Gtk::Frame transport_button_frame;
395 Gtk::HBox transport_button_hbox;
396 Gtk::VBox transport_button_vbox;
397 Gtk::HBox transport_option_button_hbox;
398 Gtk::VBox transport_option_button_vbox;
399 Gtk::HBox transport_clock_hbox;
400 Gtk::VBox transport_clock_vbox;
401 Gtk::HBox primary_clock_hbox;
402 Gtk::HBox secondary_clock_hbox;
404 struct TransportControllable : public PBD::Controllable {
415 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
416 void set_value (double);
417 double get_value (void) const;
423 boost::shared_ptr<TransportControllable> roll_controllable;
424 boost::shared_ptr<TransportControllable> stop_controllable;
425 boost::shared_ptr<TransportControllable> goto_start_controllable;
426 boost::shared_ptr<TransportControllable> goto_end_controllable;
427 boost::shared_ptr<TransportControllable> auto_loop_controllable;
428 boost::shared_ptr<TransportControllable> play_selection_controllable;
429 boost::shared_ptr<TransportControllable> rec_controllable;
431 void toggle_always_play_range ();
433 void set_transport_controllable_state (const XMLNode&);
434 XMLNode& get_transport_controllable_state ();
436 ArdourButton roll_button;
437 ArdourButton stop_button;
438 ArdourButton goto_start_button;
439 ArdourButton goto_end_button;
440 ArdourButton auto_loop_button;
441 ArdourButton play_selection_button;
442 ArdourButton rec_button;
444 void toggle_external_sync ();
445 void toggle_time_master ();
446 void toggle_video_sync ();
448 ShuttleControl* shuttle_box;
450 ArdourButton auto_return_button;
451 ArdourButton follow_edits_button;
452 ArdourButton auto_input_button;
453 ArdourButton click_button;
454 ArdourButton sync_button;
456 ArdourButton auditioning_alert_button;
457 ArdourButton solo_alert_button;
458 ArdourButton feedback_alert_button;
462 void solo_blink (bool);
463 void sync_blink (bool);
464 void audition_blink (bool);
465 void feedback_blink (bool);
467 void soloing_changed (bool);
468 void auditioning_changed (bool);
469 void _auditioning_changed (bool);
471 bool solo_alert_press (GdkEventButton* ev);
472 bool audition_alert_press (GdkEventButton* ev);
473 bool feedback_alert_press (GdkEventButton *);
475 void big_clock_value_changed ();
476 void primary_clock_value_changed ();
477 void secondary_clock_value_changed ();
479 /* called by Blink signal */
481 void transport_rec_enable_blink (bool onoff);
483 Gtk::Menu* session_popup_menu;
485 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
486 RecentSessionModelColumns() {
491 Gtk::TreeModelColumn<std::string> visible_name;
492 Gtk::TreeModelColumn<std::string> tip;
493 Gtk::TreeModelColumn<std::string> fullpath;
496 RecentSessionModelColumns recent_session_columns;
497 Gtk::TreeView recent_session_display;
498 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
500 ArdourDialog* session_selector_window;
501 Gtk::FileChooserDialog* open_session_selector;
503 void build_session_selector();
504 void redisplay_recent_sessions();
505 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
507 struct RecentSessionsSorter {
508 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
509 return cmp_nocase(a.first, b.first) == -1;
513 /* menu bar and associated stuff */
515 Gtk::MenuBar* menu_bar;
516 Gtk::EventBox menu_bar_base;
519 void use_menubar_as_top_menubar ();
520 void build_menu_bar ();
522 Gtk::Label wall_clock_label;
523 gint update_wall_clock ();
525 Gtk::Label disk_space_label;
526 void update_disk_space ();
528 Gtk::Label timecode_format_label;
529 void update_timecode_format ();
531 Gtk::Label cpu_load_label;
532 void update_cpu_load ();
534 Gtk::Label buffer_load_label;
535 void update_buffer_load ();
537 Gtk::Label sample_rate_label;
538 void update_sample_rate (ARDOUR::framecnt_t);
540 Gtk::Label format_label;
541 void update_format ();
543 gint every_second ();
544 gint every_point_one_seconds ();
545 gint every_point_zero_one_seconds ();
547 sigc::connection second_connection;
548 sigc::connection point_one_second_connection;
549 sigc::connection point_oh_five_second_connection;
550 sigc::connection point_zero_one_second_connection;
552 void open_session ();
553 void open_recent_session ();
554 void save_template ();
556 void edit_metadata ();
557 void import_metadata ();
559 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
560 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
562 void set_transport_sensitivity (bool);
564 void transport_goto_zero ();
565 void transport_goto_start ();
566 void transport_goto_end ();
567 void transport_goto_wallclock ();
568 void transport_stop ();
569 void transport_record (bool roll);
570 void transport_roll ();
571 void transport_play_selection();
572 void transport_play_preroll();
573 void transport_forward (int option);
574 void transport_rewind (int option);
575 void transport_loop ();
576 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
578 bool _session_is_new;
579 void set_session (ARDOUR::Session *);
580 void connect_dependents_to_session (ARDOUR::Session *);
581 void we_have_dependents ();
583 void setup_session_options ();
585 guint32 last_key_press_time;
587 void snapshot_session (bool switch_to_it);
588 void rename_session ();
593 PublicEditor *editor;
594 int create_editor ();
596 RouteParams_UI *route_params;
597 int create_route_params ();
599 BundleManager *bundle_manager;
600 void create_bundle_manager ();
602 ActionWindowProxy<LocationUIWindow>* location_ui;
603 int create_location_ui ();
604 void handle_locations_change (ARDOUR::Location*);
606 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
607 void toggle_global_port_matrix (ARDOUR::DataType);
609 static UIConfiguration *ui_config;
610 ThemeManager *theme_manager;
612 /* Key bindings editor */
614 KeyEditor *key_editor;
616 /* RC Options window */
618 RCOptionEditor *rc_option_editor;
620 SessionOptionEditor *session_option_editor;
624 AddRouteDialog *add_route_dialog;
628 AddVideoDialog *add_video_dialog;
629 SystemExec *video_server_process;
631 /* Keyboard Handling */
633 ArdourKeyboard* keyboard;
635 /* Keymap handling */
637 void install_actions ();
639 void toggle_record_enable (uint32_t);
641 uint32_t rec_enabled_streams;
642 void count_recenabled_streams (ARDOUR::Route&);
647 void pop_back_splash (Gtk::Window&);
651 Gtk::MenuItem *cleanup_item;
653 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
657 bool have_configure_timeout;
658 ARDOUR::microseconds_t last_configure_time;
659 gint configure_timeout ();
661 ARDOUR::microseconds_t last_peak_grab;
662 ARDOUR::microseconds_t last_shuttle_request;
664 bool have_disk_speed_dialog_displayed;
665 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
666 void disk_overrun_handler ();
667 void disk_underrun_handler ();
669 void session_format_mismatch (std::string, std::string);
671 void session_dialog (std::string);
672 int pending_state_dialog ();
673 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
675 void disconnect_from_jack ();
676 void reconnect_to_jack ();
677 void set_jack_buffer_size (ARDOUR::pframes_t);
679 Gtk::MenuItem* jack_disconnect_item;
680 Gtk::MenuItem* jack_reconnect_item;
681 Gtk::Menu* jack_bufsize_menu;
683 Glib::RefPtr<Gtk::ActionGroup> common_actions;
685 void editor_realized ();
687 std::vector<std::string> positional_sync_strings;
689 void toggle_send_midi_feedback ();
690 void toggle_use_mmc ();
691 void toggle_send_mmc ();
692 void toggle_send_mtc ();
693 void toggle_send_midi_clock ();
695 void toggle_use_osc ();
697 void parameter_changed (std::string);
698 void session_parameter_changed (std::string);
702 void no_memory_warning ();
703 void check_memory_locking ();
705 bool check_audioengine();
706 void audioengine_setup ();
708 void display_message (const char *prefix, gint prefix_len,
709 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
711 Gtk::Label status_bar_label;
712 bool status_bar_button_press (GdkEventButton*);
713 Gtk::ToggleButton error_log_button;
715 void loading_message (const std::string& msg);
717 PBD::ScopedConnectionList forever_connections;
719 void step_edit_status_change (bool);
721 void platform_specific ();
722 void platform_setup ();
724 /* these are used only in response to a platform-specific "ShouldQuit" signal
727 void queue_finish ();
728 void fontconfig_dialog ();
730 std::list<WindowProxyBase*> _window_proxies;
732 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
733 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
735 bool click_button_clicked (GdkEventButton *);
737 VisibilityGroup _status_bar_visibility;
739 /** A ProcessThread so that we have some thread-local buffers for use by
740 * PluginEqGui::impulse_analysis ().
742 ARDOUR::ProcessThread* _process_thread;
744 void feedback_detected ();
746 ArdourButton midi_panic_button;
749 void successful_graph_sort ();
750 bool _feedback_exists;
752 void resize_text_widgets ();
754 std::string _announce_string;
755 void check_announcements ();
758 #endif /* __ardour_gui_h__ */