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>
61 #include "ardour/ardour.h"
62 #include "ardour/types.h"
63 #include "ardour/utils.h"
64 #include "ardour/session_handle.h"
66 #include "audio_clock.h"
67 #include "ardour_dialog.h"
69 #include "ui_config.h"
70 #include "window_proxy.h"
78 class ConnectionEditor;
80 class LocationUIWindow;
85 class SessionOptionEditor;
89 class WindowProxyBase;
90 class GlobalPortMatrixWindow;
97 class ControlProtocolInfo;
105 extern sigc::signal<void> ColorsChanged;
106 extern sigc::signal<void> DPIReset;
108 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
111 ARDOUR_UI (int *argcp, char **argvp[]);
114 bool run_startup (bool should_be_new, std::string load_template);
120 void launch_manual ();
121 void launch_reference ();
125 void idle_load (const Glib::ustring& path);
128 int load_session (const Glib::ustring& path, const Glib::ustring& snapshot, Glib::ustring mix_template = Glib::ustring());
130 int build_session (const Glib::ustring& path, const Glib::ustring& snapshot, ARDOUR::BusProfile&);
131 bool session_is_new() const { return _session_is_new; }
133 ARDOUR::Session* the_session() { return _session; }
135 bool will_create_new_session_automatically() const {
136 return _will_create_new_session_automatically;
139 void set_will_create_new_session_automatically (bool yn) {
140 _will_create_new_session_automatically = yn;
143 int get_session_parameters (bool quit_on_cancel, bool should_be_new = false, std::string load_template = "");
144 void parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session);
145 int load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session);
146 int build_session_from_nsd (const Glib::ustring& session_name, const Glib::ustring& session_path);
147 bool ask_about_loading_existing_session (const Glib::ustring& session_path);
149 /// @return true if session was successfully unloaded.
150 int unload_session (bool hide_stuff = false);
151 void close_session();
153 int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
154 void save_state (const std::string & state_name = "", bool switch_to_it = false);
156 static double gain_to_slider_position (ARDOUR::gain_t g);
157 static ARDOUR::gain_t slider_position_to_gain (double pos);
159 static ARDOUR_UI *instance () { return theArdourUI; }
160 static UIConfiguration *config () { return ui_config; }
162 PublicEditor& the_editor(){return *editor;}
163 Mixer_UI* the_mixer() { return mixer; }
165 void toggle_key_editor ();
166 void toggle_location_window ();
167 void toggle_theme_manager ();
168 void toggle_bundle_manager ();
169 void toggle_big_clock_window ();
170 void new_midi_tracer_window ();
171 void toggle_route_params_window ();
172 void toggle_editing_space();
173 void toggle_keep_tearoffs();
175 Gtk::Tooltips& tooltips() { return _tooltips; }
177 static sigc::signal<void,bool> Blink;
178 static sigc::signal<void> RapidScreenUpdate;
179 static sigc::signal<void> SuperRapidScreenUpdate;
180 static sigc::signal<void,nframes_t, bool, nframes_t> Clock;
182 XMLNode* editor_settings() const;
183 XMLNode* mixer_settings () const;
184 XMLNode* keyboard_settings () const;
185 XMLNode* tearoff_settings (const char*) const;
187 void save_ardour_state ();
188 gboolean configure_handler (GdkEventConfigure* conf);
190 void do_transport_locate (nframes_t position);
191 void halt_on_xrun_message ();
192 void xrun_handler (nframes_t);
193 void create_xrun_marker (nframes_t);
195 AudioClock primary_clock;
196 AudioClock secondary_clock;
197 AudioClock preroll_clock;
198 AudioClock postroll_clock;
200 void store_clock_modes ();
201 void restore_clock_modes ();
202 void reset_main_clocks ();
204 void add_route (Gtk::Window* float_window);
206 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
207 session_add_audio_route (true, false, input_channels, output_channels, mode, route_group, how_many);
210 void session_add_audio_bus (bool aux, int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
211 session_add_audio_route (false, aux, input_channels, output_channels, ARDOUR::Normal, route_group, how_many);
214 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many) {
215 session_add_midi_route (true, route_group, how_many);
218 /*void session_add_midi_bus () {
219 session_add_midi_route (false);
222 int create_engine ();
225 gint exit_on_main_window_close (GdkEventAny *);
227 void maximise_editing_space ();
228 void restore_editing_space ();
230 void setup_profile ();
232 void setup_tooltips ();
234 void set_shuttle_fract (double);
236 void add_window_proxy (WindowProxyBase *);
237 void remove_window_proxy (WindowProxyBase *);
240 friend class PublicEditor;
242 void toggle_clocking ();
243 void toggle_auto_play ();
244 void toggle_auto_input ();
245 void toggle_punch ();
246 void unset_dual_punch ();
247 bool ignore_dual_punch;
248 void toggle_punch_in ();
249 void toggle_punch_out ();
250 void show_loop_punch_ruler_and_disallow_hide ();
251 void reenable_hide_loop_punch_ruler_if_appropriate ();
252 void toggle_auto_return ();
253 void toggle_click ();
255 void toggle_session_auto_loop ();
257 void toggle_rc_options_window ();
258 void toggle_session_options_window ();
261 ArdourStartup* _startup;
262 ARDOUR::AudioEngine *engine;
263 Gtk::Tooltips _tooltips;
265 void goto_editor_window ();
266 void goto_mixer_window ();
267 void toggle_editor_mixer_on_top ();
270 Gtk::ToggleButton preroll_button;
271 Gtk::ToggleButton postroll_button;
273 int setup_windows ();
274 void setup_transport ();
277 static ARDOUR_UI *theArdourUI;
279 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
283 int ask_about_saving_session (const std::string & why);
285 /* periodic safety backup, to be precise */
286 gint autosave_session();
287 void update_autosave();
288 sigc::connection _autosave_connection;
290 void map_transport_state ();
291 int32_t do_engine_start ();
293 void engine_halted (const char* reason, bool free_reason);
294 void engine_stopped ();
295 void engine_running ();
299 static gint _blink (void *);
301 gint blink_timeout_tag;
303 void start_blinking ();
304 void stop_blinking ();
306 void about_signal_response(int response);
309 Gtk::VBox top_packer;
311 sigc::connection clock_signal_connection;
312 void update_clocks ();
313 void start_clocking ();
314 void stop_clocking ();
316 void manage_window (Gtk::Window&);
318 AudioClock big_clock;
319 ActionWindowProxy<Gtk::Window>* big_clock_window;
320 int original_big_clock_width;
321 int original_big_clock_height;
322 double original_big_clock_font_size;
324 void big_clock_size_allocate (Gtk::Allocation&);
325 bool idle_big_clock_text_resizer (int width, int height);
326 void big_clock_realized ();
327 bool big_clock_resize_in_progress;
328 int big_clock_height;
330 void float_big_clock (Gtk::Window* parent);
331 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
333 void update_transport_clocks (nframes_t pos);
334 void record_state_changed ();
336 std::list<MidiTracer*> _midi_tracer_windows;
338 /* Transport Control */
340 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
341 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
343 Gtkmm2ext::TearOff* transport_tearoff;
344 Gtk::Frame transport_frame;
345 Gtk::HBox transport_tearoff_hbox;
346 Gtk::HBox play_range_hbox;
347 Gtk::VBox play_range_vbox;
348 Gtk::HBox transport_hbox;
349 Gtk::Fixed transport_base;
350 Gtk::Fixed transport_button_base;
351 Gtk::Frame transport_button_frame;
352 Gtk::HBox transport_button_hbox;
353 Gtk::VBox transport_button_vbox;
354 Gtk::HBox transport_option_button_hbox;
355 Gtk::VBox transport_option_button_vbox;
356 Gtk::HBox transport_clock_hbox;
357 Gtk::VBox transport_clock_vbox;
358 Gtk::HBox primary_clock_hbox;
359 Gtk::HBox secondary_clock_hbox;
362 struct TransportControllable : public PBD::Controllable {
375 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
376 void set_value (double);
377 double get_value (void) const;
379 void set_id (const std::string&);
385 boost::shared_ptr<TransportControllable> roll_controllable;
386 boost::shared_ptr<TransportControllable> stop_controllable;
387 boost::shared_ptr<TransportControllable> goto_start_controllable;
388 boost::shared_ptr<TransportControllable> goto_end_controllable;
389 boost::shared_ptr<TransportControllable> auto_loop_controllable;
390 boost::shared_ptr<TransportControllable> play_selection_controllable;
391 boost::shared_ptr<TransportControllable> rec_controllable;
392 boost::shared_ptr<TransportControllable> shuttle_controllable;
393 BindingProxy shuttle_controller_binding_proxy;
395 void set_transport_controllable_state (const XMLNode&);
396 XMLNode& get_transport_controllable_state ();
398 BindableButton roll_button;
399 BindableButton stop_button;
400 BindableButton goto_start_button;
401 BindableButton goto_end_button;
402 BindableButton auto_loop_button;
403 BindableButton play_selection_button;
404 BindableButton rec_button;
405 Gtk::ToggleButton join_play_range_button;
407 void toggle_external_sync ();
408 void toggle_time_master ();
409 void toggle_video_sync ();
411 Gtk::DrawingArea shuttle_box;
412 Gtk::EventBox speed_display_box;
413 Gtk::Label speed_display_label;
414 Gtk::Button shuttle_units_button;
415 Gtk::ComboBoxText shuttle_style_button;
416 Gtk::Menu* shuttle_unit_menu;
417 Gtk::Menu* shuttle_style_menu;
418 float shuttle_max_speed;
419 Gtk::Menu* shuttle_context_menu;
421 void build_shuttle_context_menu ();
422 void show_shuttle_context_menu ();
423 void shuttle_style_changed();
424 void shuttle_unit_clicked ();
425 void set_shuttle_max_speed (float);
426 void update_speed_display ();
427 float last_speed_displayed;
429 gint shuttle_box_button_press (GdkEventButton*);
430 gint shuttle_box_button_release (GdkEventButton*);
431 gint shuttle_box_scroll (GdkEventScroll*);
432 gint shuttle_box_motion (GdkEventMotion*);
433 gint shuttle_box_expose (GdkEventExpose*);
434 gint mouse_shuttle (double x, bool force);
435 void use_shuttle_fract (bool force);
437 bool shuttle_grabbed;
438 double shuttle_fract;
440 Gtkmm2ext::StatefulToggleButton punch_in_button;
441 Gtkmm2ext::StatefulToggleButton punch_out_button;
442 Gtkmm2ext::StatefulToggleButton auto_return_button;
443 Gtkmm2ext::StatefulToggleButton auto_play_button;
444 Gtkmm2ext::StatefulToggleButton auto_input_button;
445 Gtkmm2ext::StatefulToggleButton click_button;
446 Gtkmm2ext::StatefulToggleButton time_master_button;
447 Gtkmm2ext::StatefulToggleButton sync_button;
449 Gtk::ToggleButton auditioning_alert_button;
450 Gtk::ToggleButton solo_alert_button;
454 void solo_blink (bool);
455 void sync_blink (bool);
456 void audition_blink (bool);
458 void soloing_changed (bool);
459 void auditioning_changed (bool);
460 void _auditioning_changed (bool);
462 bool solo_alert_press (GdkEventButton* ev);
463 bool audition_alert_press (GdkEventButton* ev);
465 void big_clock_value_changed ();
466 void primary_clock_value_changed ();
467 void secondary_clock_value_changed ();
469 /* called by Blink signal */
471 void transport_rec_enable_blink (bool onoff);
473 Gtk::Menu* session_popup_menu;
475 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
476 RecentSessionModelColumns() {
480 Gtk::TreeModelColumn<Glib::ustring> visible_name;
481 Gtk::TreeModelColumn<Glib::ustring> fullpath;
484 RecentSessionModelColumns recent_session_columns;
485 Gtk::TreeView recent_session_display;
486 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
488 ArdourDialog* session_selector_window;
489 Gtk::FileChooserDialog* open_session_selector;
491 void build_session_selector();
492 void redisplay_recent_sessions();
493 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
495 struct RecentSessionsSorter {
496 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
497 return cmp_nocase(a.first, b.first) == -1;
501 /* menu bar and associated stuff */
503 Gtk::MenuBar* menu_bar;
504 Gtk::EventBox menu_bar_base;
507 void use_menubar_as_top_menubar ();
508 void build_menu_bar ();
510 Gtk::Label wall_clock_label;
511 Gtk::EventBox wall_clock_box;
512 gint update_wall_clock ();
514 Gtk::Label disk_space_label;
515 Gtk::EventBox disk_space_box;
516 void update_disk_space ();
518 Gtk::Label cpu_load_label;
519 Gtk::EventBox cpu_load_box;
520 void update_cpu_load ();
522 Gtk::Label buffer_load_label;
523 Gtk::EventBox buffer_load_box;
524 void update_buffer_load ();
526 Gtk::Label sample_rate_label;
527 Gtk::EventBox sample_rate_box;
528 void update_sample_rate (nframes_t);
530 gint every_second ();
531 gint every_point_one_seconds ();
532 gint every_point_zero_one_seconds ();
534 sigc::connection second_connection;
535 sigc::connection point_one_second_connection;
536 sigc::connection point_oh_five_second_connection;
537 sigc::connection point_zero_one_second_connection;
539 gint session_menu (GdkEventButton *);
541 bool _will_create_new_session_automatically;
543 void open_session ();
544 void open_recent_session ();
545 void save_template ();
547 void edit_metadata ();
548 void import_metadata ();
550 void session_add_audio_route (bool disk, bool aux, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup *, uint32_t how_many);
551 void session_add_midi_route (bool disk, ARDOUR::RouteGroup *, uint32_t how_many);
553 void set_transport_sensitivity (bool);
555 void remove_last_capture ();
557 void transport_goto_zero ();
558 void transport_goto_start ();
559 void transport_goto_end ();
560 void transport_goto_wallclock ();
561 void transport_stop ();
562 void transport_stop_and_forget_capture ();
563 void transport_record (bool roll);
564 void transport_roll ();
565 void transport_play_selection();
566 void transport_forward (int option);
567 void transport_rewind (int option);
568 void transport_loop ();
569 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
571 bool _session_is_new;
572 void set_session (ARDOUR::Session *);
573 void connect_dependents_to_session (ARDOUR::Session *);
574 void we_have_dependents ();
576 void setup_session_options ();
578 guint32 last_key_press_time;
580 void snapshot_session (bool switch_to_it);
585 PublicEditor *editor;
586 int create_editor ();
588 RouteParams_UI *route_params;
589 int create_route_params ();
591 BundleManager *bundle_manager;
592 void create_bundle_manager ();
594 ActionWindowProxy<LocationUIWindow>* location_ui;
595 int create_location_ui ();
596 void handle_locations_change (ARDOUR::Location*);
598 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
599 void toggle_global_port_matrix (ARDOUR::DataType);
601 static UIConfiguration *ui_config;
602 ThemeManager *theme_manager;
604 /* Key bindings editor */
606 KeyEditor *key_editor;
608 /* RC Options window */
610 RCOptionEditor *rc_option_editor;
612 SessionOptionEditor *session_option_editor;
616 AddRouteDialog *add_route_dialog;
618 /* Keyboard Handling */
620 ArdourKeyboard* keyboard;
622 /* Keymap handling */
624 void install_actions ();
626 void toggle_record_enable (uint32_t);
628 uint32_t rec_enabled_streams;
629 void count_recenabled_streams (ARDOUR::Route&);
633 void pop_back_splash ();
637 Gtk::MenuItem *cleanup_item;
639 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
640 const std::string& plural_msg, const std::string& singular_msg);
644 bool have_configure_timeout;
645 ARDOUR::microseconds_t last_configure_time;
646 gint configure_timeout ();
648 ARDOUR::microseconds_t last_peak_grab;
649 ARDOUR::microseconds_t last_shuttle_request;
651 bool have_disk_speed_dialog_displayed;
652 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
653 void disk_overrun_handler ();
654 void disk_underrun_handler ();
656 void session_dialog (std::string);
657 int pending_state_dialog ();
658 int sr_mismatch_dialog (nframes_t, nframes_t);
660 void disconnect_from_jack ();
661 void reconnect_to_jack ();
662 void set_jack_buffer_size (nframes_t);
664 Gtk::MenuItem* jack_disconnect_item;
665 Gtk::MenuItem* jack_reconnect_item;
666 Gtk::Menu* jack_bufsize_menu;
668 Glib::RefPtr<Gtk::ActionGroup> common_actions;
670 void editor_realized ();
672 std::vector<std::string> positional_sync_strings;
674 void toggle_send_midi_feedback ();
675 void toggle_use_mmc ();
676 void toggle_send_mmc ();
677 void toggle_send_mtc ();
678 void toggle_send_midi_clock ();
680 void toggle_use_osc ();
682 void parameter_changed (std::string);
686 void no_memory_warning ();
687 void check_memory_locking ();
689 bool check_audioengine();
690 void audioengine_setup ();
692 void display_message (const char *prefix, gint prefix_len,
693 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
695 Gtk::Label status_bar_label;
696 bool status_bar_button_press (GdkEventButton*);
697 Gtk::ToggleButton error_log_button;
699 void loading_message (const std::string& msg);
700 void end_loading_messages ();
702 void platform_specific ();
703 void platform_setup ();
704 void fontconfig_dialog ();
705 void toggle_translations ();
707 PBD::ScopedConnectionList forever_connections;
709 void step_edit_status_change (bool);
711 /* these are used only in response to a platform-specific "ShouldQuit" signal
714 void queue_finish ();
716 std::list<WindowProxyBase*> _window_proxies;
719 #endif /* __ardour_gui_h__ */