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_dialog.h"
70 #include "ardour_button.h"
73 #include "ui_config.h"
74 #include "window_proxy.h"
76 #include "visibility_group.h"
88 class ConnectionEditor;
90 class LocationUIWindow;
96 class SessionOptionEditor;
103 class WindowProxyBase;
104 class GlobalPortMatrixWindow;
105 class GUIObjectState;
107 namespace Gtkmm2ext {
112 class ControlProtocolInfo;
121 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
124 ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
127 bool run_startup (bool should_be_new, std::string load_template);
133 void launch_manual ();
134 void launch_reference ();
138 void idle_load (const std::string& path);
141 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
143 int build_session (const std::string& path, const std::string& snapshot, ARDOUR::BusProfile&);
144 bool session_is_new() const { return _session_is_new; }
146 ARDOUR::Session* the_session() { return _session; }
148 bool get_smart_mode () const;
150 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
151 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
152 bool ask_about_loading_existing_session (const std::string& session_path);
154 /// @return true if session was successfully unloaded.
155 int unload_session (bool hide_stuff = false);
156 void close_session();
158 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
159 void save_state (const std::string & state_name = "", bool switch_to_it = false);
161 static ARDOUR_UI *instance () { return theArdourUI; }
162 static UIConfiguration *config () { return ui_config; }
164 PublicEditor& the_editor(){return *editor;}
165 Mixer_UI* the_mixer() { return mixer; }
167 void toggle_key_editor ();
168 void toggle_location_window ();
169 void toggle_theme_manager ();
170 void toggle_bundle_manager ();
171 void toggle_big_clock_window ();
172 void toggle_speaker_config_window ();
173 void new_midi_tracer_window ();
174 void toggle_route_params_window ();
175 void toggle_editing_space();
176 void toggle_keep_tearoffs();
178 Gtk::Tooltips& tooltips() { return _tooltips; }
180 Gtk::HBox& editor_transport_box() { return _editor_transport_box; }
182 static PublicEditor* _instance;
183 static sigc::signal<void,bool> Blink;
184 static sigc::signal<void> RapidScreenUpdate;
185 static sigc::signal<void> SuperRapidScreenUpdate;
186 /** Emitted frequently with the audible frame, false, and the edit point as
187 * parameters respectively.
189 static sigc::signal<void, framepos_t, bool, framepos_t> Clock;
191 XMLNode* editor_settings() const;
192 XMLNode* mixer_settings () const;
193 XMLNode* keyboard_settings () const;
194 XMLNode* tearoff_settings (const char*) const;
196 void save_ardour_state ();
197 gboolean configure_handler (GdkEventConfigure* conf);
199 void halt_on_xrun_message ();
200 void xrun_handler (framepos_t);
201 void create_xrun_marker (framepos_t);
203 GUIObjectState* gui_object_state;
205 MainClock* primary_clock;
206 MainClock* secondary_clock;
207 void focus_on_clock ();
209 TimeInfoBox* time_info_box;
211 VideoTimeLine *video_timeline;
213 void store_clock_modes ();
214 void restore_clock_modes ();
215 void reset_main_clocks ();
217 void synchronize_sync_source_and_video_pullup ();
219 void add_route (Gtk::Window* float_window);
220 void add_routes_part_two ();
221 void add_routes_thread ();
223 void add_video (Gtk::Window* float_window);
224 void remove_video ();
225 void start_video_server_menu (Gtk::Window* float_window);
226 bool start_video_server (Gtk::Window* float_window, bool popup_msg);
227 void stop_video_server (bool ask_confirm=false);
228 void flush_videotimeline_cache (bool localcacheonly=false);
230 void session_add_audio_track (
232 int32_t output_channels,
233 ARDOUR::TrackMode mode,
234 ARDOUR::RouteGroup* route_group,
236 std::string const & name_template
239 session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
242 void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
243 uint32_t how_many, std::string const & name_template) {
244 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
247 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
248 ARDOUR::PluginInfoPtr instrument) {
249 session_add_midi_route (true, route_group, how_many, name_template, instrument);
252 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,
253 ARDOUR::PluginInfoPtr instrument);
255 /*void session_add_midi_bus () {
256 session_add_midi_route (false);
259 int create_engine ();
262 gint exit_on_main_window_close (GdkEventAny *);
264 void maximise_editing_space ();
265 void restore_editing_space ();
267 void update_tearoff_visibility ();
269 void setup_profile ();
270 void setup_tooltips ();
272 void set_shuttle_fract (double);
274 void add_window_proxy (WindowProxyBase *);
275 void remove_window_proxy (WindowProxyBase *);
277 void get_process_buffers ();
278 void drop_process_buffers ();
280 const std::string& announce_string() const { return _announce_string; }
283 friend class PublicEditor;
285 void toggle_auto_play ();
286 void toggle_auto_input ();
287 void toggle_punch ();
288 void unset_dual_punch ();
289 bool ignore_dual_punch;
290 void toggle_punch_in ();
291 void toggle_punch_out ();
292 void show_loop_punch_ruler_and_disallow_hide ();
293 void reenable_hide_loop_punch_ruler_if_appropriate ();
294 void toggle_auto_return ();
295 void toggle_click ();
297 void toggle_session_auto_loop ();
299 void toggle_rc_options_window ();
300 void toggle_session_options_window ();
303 ArdourStartup* _startup;
304 ARDOUR::AudioEngine *engine;
305 Gtk::Tooltips _tooltips;
309 void goto_editor_window ();
310 void goto_mixer_window ();
311 void toggle_mixer_window ();
312 void toggle_mixer_on_top ();
314 int setup_windows ();
315 void setup_transport ();
318 static ARDOUR_UI *theArdourUI;
323 int ask_about_saving_session (const std::vector<std::string>& actions);
325 /* periodic safety backup, to be precise */
326 gint autosave_session();
327 void update_autosave();
328 sigc::connection _autosave_connection;
330 void map_transport_state ();
331 int32_t do_engine_start ();
333 void engine_halted (const char* reason, bool free_reason);
334 void engine_stopped ();
335 void engine_running ();
339 static gint _blink (void *);
341 gint blink_timeout_tag;
343 void start_blinking ();
344 void stop_blinking ();
346 void about_signal_response(int response);
348 Gtk::VBox top_packer;
350 sigc::connection clock_signal_connection;
351 void update_clocks ();
352 void start_clocking ();
353 void stop_clocking ();
355 void manage_window (Gtk::Window&);
357 AudioClock* big_clock;
358 ActionWindowProxy<Gtk::Window>* big_clock_window;
359 int original_big_clock_width;
360 int original_big_clock_height;
361 double original_big_clock_font_size;
363 void big_clock_size_allocate (Gtk::Allocation&);
364 bool idle_big_clock_text_resizer (int width, int height);
365 void big_clock_realized ();
366 bool big_clock_resize_in_progress;
367 int big_clock_height;
368 void big_clock_catch_focus ();
369 void big_clock_reset_aspect_ratio ();
371 void float_big_clock (Gtk::Window* parent);
372 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
374 ActionWindowProxy<SpeakerDialog>* speaker_config_window;
376 void update_transport_clocks (framepos_t pos);
377 void record_state_changed ();
379 std::list<MidiTracer*> _midi_tracer_windows;
381 /* Transport Control */
383 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
384 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
386 Gtkmm2ext::TearOff* transport_tearoff;
387 Gtk::Frame transport_frame;
388 Gtk::HBox transport_tearoff_hbox;
389 Gtk::HBox _editor_transport_box;
390 Gtk::HBox transport_hbox;
391 Gtk::Fixed transport_base;
392 Gtk::Fixed transport_button_base;
393 Gtk::Frame transport_button_frame;
394 Gtk::HBox transport_button_hbox;
395 Gtk::VBox transport_button_vbox;
396 Gtk::HBox transport_option_button_hbox;
397 Gtk::VBox transport_option_button_vbox;
398 Gtk::HBox transport_clock_hbox;
399 Gtk::VBox transport_clock_vbox;
400 Gtk::HBox primary_clock_hbox;
401 Gtk::HBox secondary_clock_hbox;
403 struct TransportControllable : public PBD::Controllable {
414 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
415 void set_value (double);
416 double get_value (void) const;
422 boost::shared_ptr<TransportControllable> roll_controllable;
423 boost::shared_ptr<TransportControllable> stop_controllable;
424 boost::shared_ptr<TransportControllable> goto_start_controllable;
425 boost::shared_ptr<TransportControllable> goto_end_controllable;
426 boost::shared_ptr<TransportControllable> auto_loop_controllable;
427 boost::shared_ptr<TransportControllable> play_selection_controllable;
428 boost::shared_ptr<TransportControllable> rec_controllable;
430 void toggle_always_play_range ();
432 void set_transport_controllable_state (const XMLNode&);
433 XMLNode& get_transport_controllable_state ();
435 ArdourButton roll_button;
436 ArdourButton stop_button;
437 ArdourButton goto_start_button;
438 ArdourButton goto_end_button;
439 ArdourButton auto_loop_button;
440 ArdourButton play_selection_button;
441 ArdourButton rec_button;
443 void toggle_external_sync ();
444 void toggle_time_master ();
445 void toggle_video_sync ();
447 ShuttleControl* shuttle_box;
449 ArdourButton auto_return_button;
450 ArdourButton follow_edits_button;
451 ArdourButton auto_input_button;
452 ArdourButton click_button;
453 ArdourButton sync_button;
455 ArdourButton auditioning_alert_button;
456 ArdourButton solo_alert_button;
457 ArdourButton feedback_alert_button;
461 void solo_blink (bool);
462 void sync_blink (bool);
463 void audition_blink (bool);
464 void feedback_blink (bool);
466 void soloing_changed (bool);
467 void auditioning_changed (bool);
468 void _auditioning_changed (bool);
470 bool solo_alert_press (GdkEventButton* ev);
471 bool audition_alert_press (GdkEventButton* ev);
472 bool feedback_alert_press (GdkEventButton *);
474 void big_clock_value_changed ();
475 void primary_clock_value_changed ();
476 void secondary_clock_value_changed ();
478 /* called by Blink signal */
480 void transport_rec_enable_blink (bool onoff);
482 Gtk::Menu* session_popup_menu;
484 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
485 RecentSessionModelColumns() {
490 Gtk::TreeModelColumn<std::string> visible_name;
491 Gtk::TreeModelColumn<std::string> tip;
492 Gtk::TreeModelColumn<std::string> fullpath;
495 RecentSessionModelColumns recent_session_columns;
496 Gtk::TreeView recent_session_display;
497 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
499 ArdourDialog* session_selector_window;
500 Gtk::FileChooserDialog* open_session_selector;
502 void build_session_selector();
503 void redisplay_recent_sessions();
504 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
506 struct RecentSessionsSorter {
507 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
508 return cmp_nocase(a.first, b.first) == -1;
512 /* menu bar and associated stuff */
514 Gtk::MenuBar* menu_bar;
515 Gtk::EventBox menu_bar_base;
518 void use_menubar_as_top_menubar ();
519 void build_menu_bar ();
521 Gtk::Label wall_clock_label;
522 gint update_wall_clock ();
524 Gtk::Label disk_space_label;
525 void update_disk_space ();
527 Gtk::Label timecode_format_label;
528 void update_timecode_format ();
530 Gtk::Label cpu_load_label;
531 void update_cpu_load ();
533 Gtk::Label buffer_load_label;
534 void update_buffer_load ();
536 Gtk::Label sample_rate_label;
537 void update_sample_rate (ARDOUR::framecnt_t);
539 Gtk::Label format_label;
540 void update_format ();
542 gint every_second ();
543 gint every_point_one_seconds ();
544 gint every_point_zero_one_seconds ();
546 sigc::connection second_connection;
547 sigc::connection point_one_second_connection;
548 sigc::connection point_oh_five_second_connection;
549 sigc::connection point_zero_one_second_connection;
551 void open_session ();
552 void open_recent_session ();
553 void save_template ();
555 void edit_metadata ();
556 void import_metadata ();
558 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
559 void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
561 void set_transport_sensitivity (bool);
563 void transport_goto_zero ();
564 void transport_goto_start ();
565 void transport_goto_end ();
566 void transport_goto_wallclock ();
567 void transport_stop ();
568 void transport_record (bool roll);
569 void transport_roll ();
570 void transport_play_selection();
571 void transport_play_preroll();
572 void transport_forward (int option);
573 void transport_rewind (int option);
574 void transport_loop ();
575 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
577 bool _session_is_new;
578 void set_session (ARDOUR::Session *);
579 void connect_dependents_to_session (ARDOUR::Session *);
580 void we_have_dependents ();
582 void setup_session_options ();
584 guint32 last_key_press_time;
586 void snapshot_session (bool switch_to_it);
587 void rename_session ();
592 PublicEditor *editor;
593 int create_editor ();
595 RouteParams_UI *route_params;
596 int create_route_params ();
598 BundleManager *bundle_manager;
599 void create_bundle_manager ();
601 ActionWindowProxy<LocationUIWindow>* location_ui;
602 int create_location_ui ();
603 void handle_locations_change (ARDOUR::Location*);
605 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
606 void toggle_global_port_matrix (ARDOUR::DataType);
608 static UIConfiguration *ui_config;
609 ThemeManager *theme_manager;
611 /* Key bindings editor */
613 KeyEditor *key_editor;
615 /* RC Options window */
617 RCOptionEditor *rc_option_editor;
619 SessionOptionEditor *session_option_editor;
623 AddRouteDialog *add_route_dialog;
627 AddVideoDialog *add_video_dialog;
628 SystemExec *video_server_process;
630 /* Keyboard Handling */
632 ArdourKeyboard* keyboard;
634 /* Keymap handling */
636 void install_actions ();
638 void toggle_record_enable (uint32_t);
640 uint32_t rec_enabled_streams;
641 void count_recenabled_streams (ARDOUR::Route&);
646 void pop_back_splash (Gtk::Window&);
650 Gtk::MenuItem *cleanup_item;
652 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
656 bool have_configure_timeout;
657 ARDOUR::microseconds_t last_configure_time;
658 gint configure_timeout ();
660 ARDOUR::microseconds_t last_peak_grab;
661 ARDOUR::microseconds_t last_shuttle_request;
663 bool have_disk_speed_dialog_displayed;
664 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
665 void disk_overrun_handler ();
666 void disk_underrun_handler ();
668 void session_format_mismatch (std::string, std::string);
670 void session_dialog (std::string);
671 int pending_state_dialog ();
672 int sr_mismatch_dialog (ARDOUR::framecnt_t, ARDOUR::framecnt_t);
674 void disconnect_from_jack ();
675 void reconnect_to_jack ();
676 void set_jack_buffer_size (ARDOUR::pframes_t);
678 Gtk::MenuItem* jack_disconnect_item;
679 Gtk::MenuItem* jack_reconnect_item;
680 Gtk::Menu* jack_bufsize_menu;
682 Glib::RefPtr<Gtk::ActionGroup> common_actions;
684 void editor_realized ();
686 std::vector<std::string> positional_sync_strings;
688 void toggle_send_midi_feedback ();
689 void toggle_use_mmc ();
690 void toggle_send_mmc ();
691 void toggle_send_mtc ();
692 void toggle_send_midi_clock ();
694 void toggle_use_osc ();
696 void parameter_changed (std::string);
697 void session_parameter_changed (std::string);
701 void no_memory_warning ();
702 void check_memory_locking ();
704 bool check_audioengine();
705 void audioengine_setup ();
707 void display_message (const char *prefix, gint prefix_len,
708 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
710 Gtk::Label status_bar_label;
711 bool status_bar_button_press (GdkEventButton*);
712 Gtk::ToggleButton error_log_button;
714 void loading_message (const std::string& msg);
716 PBD::ScopedConnectionList forever_connections;
718 void step_edit_status_change (bool);
720 void platform_specific ();
721 void platform_setup ();
723 /* these are used only in response to a platform-specific "ShouldQuit" signal
726 void queue_finish ();
727 void fontconfig_dialog ();
729 std::list<WindowProxyBase*> _window_proxies;
731 int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
732 int ambiguous_file (std::string file, std::string path, std::vector<std::string> hits);
734 bool click_button_clicked (GdkEventButton *);
736 VisibilityGroup _status_bar_visibility;
738 /** A ProcessThread so that we have some thread-local buffers for use by
739 * PluginEqGui::impulse_analysis ().
741 ARDOUR::ProcessThread* _process_thread;
743 void feedback_detected ();
745 ArdourButton midi_panic_button;
748 void successful_graph_sort ();
749 bool _feedback_exists;
751 void resize_text_widgets ();
753 std::string _announce_string;
754 void check_announcements ();
757 #endif /* __ardour_gui_h__ */