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 #ifdef WITH_VIDEOTIMELINE
68 #include "video_timeline.h"
71 #include "ardour_dialog.h"
72 #include "ardour_button.h"
75 #include "ui_config.h"
76 #include "window_proxy.h"
78 #include "visibility_group.h"
82 #ifdef WITH_VIDEOTIMELINE
92 class ConnectionEditor;
94 class LocationUIWindow;
100 class SessionOptionEditor;
101 class ShuttleControl;
107 class WindowProxyBase;
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 toggle_key_editor ();
172 void toggle_location_window ();
173 void toggle_theme_manager ();
174 void toggle_bundle_manager ();
175 void toggle_big_clock_window ();
176 void toggle_speaker_config_window ();
177 void new_midi_tracer_window ();
178 void toggle_route_params_window ();
179 void toggle_editing_space();
180 void toggle_keep_tearoffs();
182 Gtk::Tooltips& tooltips() { return _tooltips; }
184 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
186 static PublicEditor* _instance;
187 static sigc::signal<void,bool> Blink;
188 static sigc::signal<void> RapidScreenUpdate;
189 static sigc::signal<void> SuperRapidScreenUpdate;
190 /** Emitted frequently with the audible frame, false, and the edit point as
191 * parameters respectively.
193 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
195 XMLNode* editor_settings() const;
196 XMLNode* mixer_settings () const;
197 XMLNode* keyboard_settings () const;
198 XMLNode* tearoff_settings (const char*) const;
200 void save_ardour_state ();
201 gboolean configure_handler (GdkEventConfigure* conf);
203 void halt_on_xrun_message ();
204 void xrun_handler (framepos_t);
205 void create_xrun_marker (framepos_t);
207 GUIObjectState* gui_object_state;
209 MainClock* primary_clock;
210 MainClock* secondary_clock;
211 void focus_on_clock ();
213 TimeInfoBox* time_info_box;
215 #ifdef WITH_VIDEOTIMELINE
216 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 ();
228 #ifdef WITH_VIDEOTIMELINE
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);
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 add_window_proxy (WindowProxyBase *);
282 void remove_window_proxy (WindowProxyBase *);
284 void get_process_buffers ();
285 void drop_process_buffers ();
287 const std::string& announce_string() const { return _announce_string; }
290 friend class PublicEditor;
292 void toggle_auto_play ();
293 void toggle_auto_input ();
294 void toggle_punch ();
295 void unset_dual_punch ();
296 bool ignore_dual_punch;
297 void toggle_punch_in ();
298 void toggle_punch_out ();
299 void show_loop_punch_ruler_and_disallow_hide ();
300 void reenable_hide_loop_punch_ruler_if_appropriate ();
301 void toggle_auto_return ();
302 void toggle_click ();
304 void toggle_session_auto_loop ();
306 void toggle_rc_options_window ();
307 void toggle_session_options_window ();
310 ArdourStartup* _startup;
311 ARDOUR::AudioEngine *engine;
312 Gtk::Tooltips _tooltips;
316 void goto_editor_window ();
317 void goto_mixer_window ();
318 void toggle_mixer_window ();
319 void toggle_mixer_on_top ();
321 int setup_windows ();
322 void setup_transport ();
325 static ARDOUR_UI *theArdourUI;
330 int ask_about_saving_session (const std::vector<std::string>& actions);
332 /* periodic safety backup, to be precise */
333 gint autosave_session();
334 void update_autosave();
335 sigc::connection _autosave_connection;
337 void map_transport_state ();
338 int32_t do_engine_start ();
340 void engine_halted (const char* reason, bool free_reason);
341 void engine_stopped ();
342 void engine_running ();
346 static gint _blink (void *);
348 gint blink_timeout_tag;
350 void start_blinking ();
351 void stop_blinking ();
353 void about_signal_response(int response);
355 Gtk::VBox top_packer;
357 sigc::connection clock_signal_connection;
358 void update_clocks ();
359 void start_clocking ();
360 void stop_clocking ();
362 void manage_window (Gtk::Window&);
364 AudioClock* big_clock;
365 ActionWindowProxy<Gtk::Window>* big_clock_window;
366 int original_big_clock_width;
367 int original_big_clock_height;
368 double original_big_clock_font_size;
370 void big_clock_size_allocate (Gtk::Allocation&);
371 bool idle_big_clock_text_resizer (int width, int height);
372 void big_clock_realized ();
373 bool big_clock_resize_in_progress;
374 int big_clock_height;
375 void big_clock_catch_focus ();
376 void big_clock_reset_aspect_ratio ();
378 void float_big_clock (Gtk::Window* parent);
379 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
381 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
383 void update_transport_clocks (framepos_t pos);
384 void record_state_changed ();
386 std::list<MidiTracer*> _midi_tracer_windows;
388 /* Transport Control */
390 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
391 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
393 Gtkmm2ext::TearOff* transport_tearoff;
394 Gtk::Frame transport_frame;
395 Gtk::HBox transport_tearoff_hbox;
396 Gtk::HBox _editor_transport_box;
397 Gtk::HBox transport_hbox;
398 Gtk::Fixed transport_base;
399 Gtk::Fixed transport_button_base;
400 Gtk::Frame transport_button_frame;
401 Gtk::HBox transport_button_hbox;
402 Gtk::VBox transport_button_vbox;
403 Gtk::HBox transport_option_button_hbox;
404 Gtk::VBox transport_option_button_vbox;
405 Gtk::HBox transport_clock_hbox;
406 Gtk::VBox transport_clock_vbox;
407 Gtk::HBox primary_clock_hbox;
408 Gtk::HBox secondary_clock_hbox;
410 struct TransportControllable : public PBD::Controllable {
421 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
422 void set_value (double);
423 double get_value (void) const;
429 boost::shared_ptr<TransportControllable> roll_controllable;
430 boost::shared_ptr<TransportControllable> stop_controllable;
431 boost::shared_ptr<TransportControllable> goto_start_controllable;
432 boost::shared_ptr<TransportControllable> goto_end_controllable;
433 boost::shared_ptr<TransportControllable> auto_loop_controllable;
434 boost::shared_ptr<TransportControllable> play_selection_controllable;
435 boost::shared_ptr<TransportControllable> rec_controllable;
437 void toggle_always_play_range ();
439 void set_transport_controllable_state (const XMLNode&);
440 XMLNode& get_transport_controllable_state ();
442 ArdourButton roll_button;
443 ArdourButton stop_button;
444 ArdourButton goto_start_button;
445 ArdourButton goto_end_button;
446 ArdourButton auto_loop_button;
447 ArdourButton play_selection_button;
448 ArdourButton rec_button;
450 void toggle_external_sync ();
451 void toggle_time_master ();
452 void toggle_video_sync ();
454 ShuttleControl* shuttle_box;
456 ArdourButton auto_return_button;
457 ArdourButton follow_edits_button;
458 ArdourButton auto_input_button;
459 ArdourButton click_button;
460 ArdourButton sync_button;
462 ArdourButton auditioning_alert_button;
463 ArdourButton solo_alert_button;
464 ArdourButton feedback_alert_button;
468 void solo_blink (bool);
469 void sync_blink (bool);
470 void audition_blink (bool);
471 void feedback_blink (bool);
473 void soloing_changed (bool);
474 void auditioning_changed (bool);
475 void _auditioning_changed (bool);
477 bool solo_alert_press (GdkEventButton* ev);
478 bool audition_alert_press (GdkEventButton* ev);
479 bool feedback_alert_press (GdkEventButton *);
481 void big_clock_value_changed ();
482 void primary_clock_value_changed ();
483 void secondary_clock_value_changed ();
485 /* called by Blink signal */
487 void transport_rec_enable_blink (bool onoff);
489 Gtk::Menu* session_popup_menu;
491 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
492 RecentSessionModelColumns() {
497 Gtk::TreeModelColumn<std::string> visible_name;
498 Gtk::TreeModelColumn<std::string> tip;
499 Gtk::TreeModelColumn<std::string> fullpath;
502 RecentSessionModelColumns recent_session_columns;
503 Gtk::TreeView recent_session_display;
504 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
506 ArdourDialog* session_selector_window;
507 Gtk::FileChooserDialog* open_session_selector;
509 void build_session_selector();
510 void redisplay_recent_sessions();
511 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
513 struct RecentSessionsSorter {
514 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
515 return cmp_nocase(a.first, b.first) == -1;
519 /* menu bar and associated stuff */
521 Gtk::MenuBar* menu_bar;
522 Gtk::EventBox menu_bar_base;
525 void use_menubar_as_top_menubar ();
526 void build_menu_bar ();
528 Gtk::Label wall_clock_label;
529 gint update_wall_clock ();
531 Gtk::Label disk_space_label;
532 void update_disk_space ();
534 Gtk::Label timecode_format_label;
535 void update_timecode_format ();
537 Gtk::Label cpu_load_label;
538 void update_cpu_load ();
540 Gtk::Label buffer_load_label;
541 void update_buffer_load ();
543 Gtk::Label sample_rate_label;
544 void update_sample_rate (ARDOUR::framecnt_t);
546 Gtk::Label format_label;
547 void update_format ();
549 gint every_second ();
550 gint every_point_one_seconds ();
551 gint every_point_zero_one_seconds ();
553 sigc::connection second_connection;
554 sigc::connection point_one_second_connection;
555 sigc::connection point_oh_five_second_connection;
556 sigc::connection point_zero_one_second_connection;
558 void open_session ();
559 void open_recent_session ();
560 void save_template ();
562 void edit_metadata ();
563 void import_metadata ();
565 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
566 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
568 void set_transport_sensitivity (bool);
570 void transport_goto_zero ();
571 void transport_goto_start ();
572 void transport_goto_end ();
573 void transport_goto_wallclock ();
574 void transport_stop ();
575 void transport_record (bool roll);
576 void transport_roll ();
577 void transport_play_selection();
578 void transport_play_preroll();
579 void transport_forward (int option);
580 void transport_rewind (int option);
581 void transport_loop ();
582 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
584 bool _session_is_new;
585 void set_session (ARDOUR::Session *);
586 void connect_dependents_to_session (ARDOUR::Session *);
587 void we_have_dependents ();
589 void setup_session_options ();
591 guint32 last_key_press_time;
593 void snapshot_session (bool switch_to_it);
594 void rename_session ();
599 PublicEditor *editor;
600 int create_editor ();
602 RouteParams_UI *route_params;
603 int create_route_params ();
605 BundleManager *bundle_manager;
606 void create_bundle_manager ();
608 ActionWindowProxy<LocationUIWindow>* location_ui;
609 int create_location_ui ();
610 void handle_locations_change (ARDOUR::Location*);
612 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
613 void toggle_global_port_matrix (ARDOUR::DataType);
615 static UIConfiguration *ui_config;
616 ThemeManager *theme_manager;
618 /* Key bindings editor */
620 KeyEditor *key_editor;
622 /* RC Options window */
624 RCOptionEditor *rc_option_editor;
626 SessionOptionEditor *session_option_editor;
630 AddRouteDialog *add_route_dialog;
632 #ifdef WITH_VIDEOTIMELINE
634 AddVideoDialog *add_video_dialog;
635 SystemExec *video_server_process;
638 /* Keyboard Handling */
640 ArdourKeyboard* keyboard;
642 /* Keymap handling */
644 void install_actions ();
646 void toggle_record_enable (uint32_t);
648 uint32_t rec_enabled_streams;
649 void count_recenabled_streams (ARDOUR::Route&);
654 void pop_back_splash (Gtk::Window&);
658 Gtk::MenuItem *cleanup_item;
660 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
664 bool have_configure_timeout;
665 ARDOUR::microseconds_t last_configure_time;
666 gint configure_timeout ();
668 ARDOUR::microseconds_t last_peak_grab;
669 ARDOUR::microseconds_t last_shuttle_request;
671 bool have_disk_speed_dialog_displayed;
672 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
673 void disk_overrun_handler ();
674 void disk_underrun_handler ();
676 void session_format_mismatch (std::string, std::string);
678 void session_dialog (std::string);
679 int pending_state_dialog ();
680 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
682 void disconnect_from_jack ();
683 void reconnect_to_jack ();
684 void set_jack_buffer_size (ARDOUR::pframes_t);
686 Gtk::MenuItem* jack_disconnect_item;
687 Gtk::MenuItem* jack_reconnect_item;
688 Gtk::Menu* jack_bufsize_menu;
690 Glib::RefPtr<Gtk::ActionGroup> common_actions;
692 void editor_realized ();
694 std::vector<std::string> positional_sync_strings;
696 void toggle_send_midi_feedback ();
697 void toggle_use_mmc ();
698 void toggle_send_mmc ();
699 void toggle_send_mtc ();
700 void toggle_send_midi_clock ();
702 void toggle_use_osc ();
704 void parameter_changed (std::string);
705 void session_parameter_changed (std::string);
709 void no_memory_warning ();
710 void check_memory_locking ();
712 bool check_audioengine();
713 void audioengine_setup ();
715 void display_message (const char *prefix, gint prefix_len,
716 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
718 Gtk::Label status_bar_label;
719 bool status_bar_button_press (GdkEventButton*);
720 Gtk::ToggleButton error_log_button;
722 void loading_message (const std::string& msg);
724 PBD::ScopedConnectionList forever_connections;
726 void step_edit_status_change (bool);
728 void platform_specific ();
729 void platform_setup ();
731 /* these are used only in response to a platform-specific "ShouldQuit" signal
734 void queue_finish ();
735 void fontconfig_dialog ();
737 std::list<WindowProxyBase*> _window_proxies;
739 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
740 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
742 bool click_button_clicked (GdkEventButton *);
744 VisibilityGroup _status_bar_visibility;
746 /** A ProcessThread so that we have some thread-local buffers for use by
747 * PluginEqGui::impulse_analysis ().
749 ARDOUR::ProcessThread* _process_thread;
751 void feedback_detected ();
753 ArdourButton midi_panic_button;
756 void successful_graph_sort ();
757 bool _feedback_exists;
759 void resize_text_widgets ();
761 std::string _announce_string;
762 void check_announcements ();
765 #endif /* __ardour_gui_h__ */