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 std::string& path);
128 int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
130 int build_session (const std::string& path, const std::string& 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 std::string& cmdline_path, std::string& session_name, std::string& session_path, bool& existing_session);
145 int load_cmdline_session (const std::string& session_name, const std::string& session_path, bool& existing_session);
146 int build_session_from_nsd (const std::string& session_name, const std::string& session_path);
147 bool ask_about_loading_existing_session (const std::string& 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 synchronize_sync_source_and_video_pullup ();
206 void add_route (Gtk::Window* float_window);
208 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
209 session_add_audio_route (true, false, input_channels, output_channels, mode, route_group, how_many);
212 void session_add_audio_bus (bool aux, int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
213 session_add_audio_route (false, aux, input_channels, output_channels, ARDOUR::Normal, route_group, how_many);
216 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many) {
217 session_add_midi_route (true, route_group, how_many);
220 /*void session_add_midi_bus () {
221 session_add_midi_route (false);
224 int create_engine ();
227 gint exit_on_main_window_close (GdkEventAny *);
229 void maximise_editing_space ();
230 void restore_editing_space ();
232 void setup_profile ();
234 void setup_tooltips ();
236 void set_shuttle_fract (double);
238 void add_window_proxy (WindowProxyBase *);
239 void remove_window_proxy (WindowProxyBase *);
242 friend class PublicEditor;
244 void toggle_clocking ();
245 void toggle_auto_play ();
246 void toggle_auto_input ();
247 void toggle_punch ();
248 void unset_dual_punch ();
249 bool ignore_dual_punch;
250 void toggle_punch_in ();
251 void toggle_punch_out ();
252 void show_loop_punch_ruler_and_disallow_hide ();
253 void reenable_hide_loop_punch_ruler_if_appropriate ();
254 void toggle_auto_return ();
255 void toggle_click ();
257 void toggle_session_auto_loop ();
259 void toggle_rc_options_window ();
260 void toggle_session_options_window ();
263 ArdourStartup* _startup;
264 ARDOUR::AudioEngine *engine;
265 Gtk::Tooltips _tooltips;
267 void goto_editor_window ();
268 void goto_mixer_window ();
269 void toggle_editor_mixer_on_top ();
272 Gtk::ToggleButton preroll_button;
273 Gtk::ToggleButton postroll_button;
275 int setup_windows ();
276 void setup_transport ();
279 static ARDOUR_UI *theArdourUI;
281 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
285 int ask_about_saving_session (const std::string & why);
287 /* periodic safety backup, to be precise */
288 gint autosave_session();
289 void update_autosave();
290 sigc::connection _autosave_connection;
292 void map_transport_state ();
293 int32_t do_engine_start ();
295 void engine_halted (const char* reason, bool free_reason);
296 void engine_stopped ();
297 void engine_running ();
301 static gint _blink (void *);
303 gint blink_timeout_tag;
305 void start_blinking ();
306 void stop_blinking ();
308 void about_signal_response(int response);
311 Gtk::VBox top_packer;
313 sigc::connection clock_signal_connection;
314 void update_clocks ();
315 void start_clocking ();
316 void stop_clocking ();
318 void manage_window (Gtk::Window&);
320 AudioClock big_clock;
321 ActionWindowProxy<Gtk::Window>* big_clock_window;
322 int original_big_clock_width;
323 int original_big_clock_height;
324 double original_big_clock_font_size;
326 void big_clock_size_allocate (Gtk::Allocation&);
327 bool idle_big_clock_text_resizer (int width, int height);
328 void big_clock_realized ();
329 bool big_clock_resize_in_progress;
330 int big_clock_height;
332 void float_big_clock (Gtk::Window* parent);
333 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
335 void update_transport_clocks (nframes_t pos);
336 void record_state_changed ();
338 std::list<MidiTracer*> _midi_tracer_windows;
340 /* Transport Control */
342 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
343 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
345 Gtkmm2ext::TearOff* transport_tearoff;
346 Gtk::Frame transport_frame;
347 Gtk::HBox transport_tearoff_hbox;
348 Gtk::HBox play_range_hbox;
349 Gtk::VBox play_range_vbox;
350 Gtk::HBox transport_hbox;
351 Gtk::Fixed transport_base;
352 Gtk::Fixed transport_button_base;
353 Gtk::Frame transport_button_frame;
354 Gtk::HBox transport_button_hbox;
355 Gtk::VBox transport_button_vbox;
356 Gtk::HBox transport_option_button_hbox;
357 Gtk::VBox transport_option_button_vbox;
358 Gtk::HBox transport_clock_hbox;
359 Gtk::VBox transport_clock_vbox;
360 Gtk::HBox primary_clock_hbox;
361 Gtk::HBox secondary_clock_hbox;
364 struct TransportControllable : public PBD::Controllable {
377 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
378 void set_value (double);
379 double get_value (void) const;
381 void set_id (const std::string&);
387 boost::shared_ptr<TransportControllable> roll_controllable;
388 boost::shared_ptr<TransportControllable> stop_controllable;
389 boost::shared_ptr<TransportControllable> goto_start_controllable;
390 boost::shared_ptr<TransportControllable> goto_end_controllable;
391 boost::shared_ptr<TransportControllable> auto_loop_controllable;
392 boost::shared_ptr<TransportControllable> play_selection_controllable;
393 boost::shared_ptr<TransportControllable> rec_controllable;
394 boost::shared_ptr<TransportControllable> shuttle_controllable;
395 BindingProxy shuttle_controller_binding_proxy;
397 void set_transport_controllable_state (const XMLNode&);
398 XMLNode& get_transport_controllable_state ();
400 BindableButton roll_button;
401 BindableButton stop_button;
402 BindableButton goto_start_button;
403 BindableButton goto_end_button;
404 BindableButton auto_loop_button;
405 BindableButton play_selection_button;
406 BindableButton rec_button;
407 Gtk::ToggleButton join_play_range_button;
409 void toggle_external_sync ();
410 void toggle_time_master ();
411 void toggle_video_sync ();
413 Gtk::DrawingArea shuttle_box;
414 Gtk::EventBox speed_display_box;
415 Gtk::Label speed_display_label;
416 Gtk::Button shuttle_units_button;
417 Gtk::ComboBoxText shuttle_style_button;
418 Gtk::Menu* shuttle_unit_menu;
419 Gtk::Menu* shuttle_style_menu;
420 float shuttle_max_speed;
421 Gtk::Menu* shuttle_context_menu;
423 void build_shuttle_context_menu ();
424 void show_shuttle_context_menu ();
425 void shuttle_style_changed();
426 void shuttle_unit_clicked ();
427 void set_shuttle_max_speed (float);
428 void update_speed_display ();
429 float last_speed_displayed;
431 gint shuttle_box_button_press (GdkEventButton*);
432 gint shuttle_box_button_release (GdkEventButton*);
433 gint shuttle_box_scroll (GdkEventScroll*);
434 gint shuttle_box_motion (GdkEventMotion*);
435 gint shuttle_box_expose (GdkEventExpose*);
436 gint mouse_shuttle (double x, bool force);
437 void use_shuttle_fract (bool force);
439 bool shuttle_grabbed;
440 double shuttle_fract;
442 Gtkmm2ext::StatefulToggleButton punch_in_button;
443 Gtkmm2ext::StatefulToggleButton punch_out_button;
444 Gtkmm2ext::StatefulToggleButton auto_return_button;
445 Gtkmm2ext::StatefulToggleButton auto_play_button;
446 Gtkmm2ext::StatefulToggleButton auto_input_button;
447 Gtkmm2ext::StatefulToggleButton click_button;
448 Gtkmm2ext::StatefulToggleButton time_master_button;
449 Gtkmm2ext::StatefulToggleButton sync_button;
451 Gtk::ToggleButton auditioning_alert_button;
452 Gtk::ToggleButton solo_alert_button;
456 void solo_blink (bool);
457 void sync_blink (bool);
458 void audition_blink (bool);
460 void soloing_changed (bool);
461 void auditioning_changed (bool);
462 void _auditioning_changed (bool);
464 bool solo_alert_press (GdkEventButton* ev);
465 bool audition_alert_press (GdkEventButton* ev);
467 void big_clock_value_changed ();
468 void primary_clock_value_changed ();
469 void secondary_clock_value_changed ();
471 /* called by Blink signal */
473 void transport_rec_enable_blink (bool onoff);
475 Gtk::Menu* session_popup_menu;
477 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
478 RecentSessionModelColumns() {
482 Gtk::TreeModelColumn<std::string> visible_name;
483 Gtk::TreeModelColumn<std::string> fullpath;
486 RecentSessionModelColumns recent_session_columns;
487 Gtk::TreeView recent_session_display;
488 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
490 ArdourDialog* session_selector_window;
491 Gtk::FileChooserDialog* open_session_selector;
493 void build_session_selector();
494 void redisplay_recent_sessions();
495 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
497 struct RecentSessionsSorter {
498 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
499 return cmp_nocase(a.first, b.first) == -1;
503 /* menu bar and associated stuff */
505 Gtk::MenuBar* menu_bar;
506 Gtk::EventBox menu_bar_base;
509 void use_menubar_as_top_menubar ();
510 void build_menu_bar ();
512 Gtk::Label wall_clock_label;
513 Gtk::EventBox wall_clock_box;
514 gint update_wall_clock ();
516 Gtk::Label disk_space_label;
517 Gtk::EventBox disk_space_box;
518 void update_disk_space ();
520 Gtk::Label cpu_load_label;
521 Gtk::EventBox cpu_load_box;
522 void update_cpu_load ();
524 Gtk::Label buffer_load_label;
525 Gtk::EventBox buffer_load_box;
526 void update_buffer_load ();
528 Gtk::Label sample_rate_label;
529 Gtk::EventBox sample_rate_box;
530 void update_sample_rate (nframes_t);
532 gint every_second ();
533 gint every_point_one_seconds ();
534 gint every_point_zero_one_seconds ();
536 sigc::connection second_connection;
537 sigc::connection point_one_second_connection;
538 sigc::connection point_oh_five_second_connection;
539 sigc::connection point_zero_one_second_connection;
541 gint session_menu (GdkEventButton *);
543 bool _will_create_new_session_automatically;
545 void open_session ();
546 void open_recent_session ();
547 void save_template ();
549 void edit_metadata ();
550 void import_metadata ();
552 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);
553 void session_add_midi_route (bool disk, ARDOUR::RouteGroup *, uint32_t how_many);
555 void set_transport_sensitivity (bool);
557 void remove_last_capture ();
559 void transport_goto_zero ();
560 void transport_goto_start ();
561 void transport_goto_end ();
562 void transport_goto_wallclock ();
563 void transport_stop ();
564 void transport_stop_and_forget_capture ();
565 void transport_record (bool roll);
566 void transport_roll ();
567 void transport_play_selection();
568 void transport_forward (int option);
569 void transport_rewind (int option);
570 void transport_loop ();
571 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
573 bool _session_is_new;
574 void set_session (ARDOUR::Session *);
575 void connect_dependents_to_session (ARDOUR::Session *);
576 void we_have_dependents ();
578 void setup_session_options ();
580 guint32 last_key_press_time;
582 void snapshot_session (bool switch_to_it);
587 PublicEditor *editor;
588 int create_editor ();
590 RouteParams_UI *route_params;
591 int create_route_params ();
593 BundleManager *bundle_manager;
594 void create_bundle_manager ();
596 ActionWindowProxy<LocationUIWindow>* location_ui;
597 int create_location_ui ();
598 void handle_locations_change (ARDOUR::Location*);
600 ActionWindowProxy<GlobalPortMatrixWindow>* _global_port_matrix[ARDOUR::DataType::num_types];
601 void toggle_global_port_matrix (ARDOUR::DataType);
603 static UIConfiguration *ui_config;
604 ThemeManager *theme_manager;
606 /* Key bindings editor */
608 KeyEditor *key_editor;
610 /* RC Options window */
612 RCOptionEditor *rc_option_editor;
614 SessionOptionEditor *session_option_editor;
618 AddRouteDialog *add_route_dialog;
620 /* Keyboard Handling */
622 ArdourKeyboard* keyboard;
624 /* Keymap handling */
626 void install_actions ();
628 void toggle_record_enable (uint32_t);
630 uint32_t rec_enabled_streams;
631 void count_recenabled_streams (ARDOUR::Route&);
635 void pop_back_splash ();
639 Gtk::MenuItem *cleanup_item;
641 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
642 const std::string& plural_msg, const std::string& singular_msg);
646 bool have_configure_timeout;
647 ARDOUR::microseconds_t last_configure_time;
648 gint configure_timeout ();
650 ARDOUR::microseconds_t last_peak_grab;
651 ARDOUR::microseconds_t last_shuttle_request;
653 bool have_disk_speed_dialog_displayed;
654 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
655 void disk_overrun_handler ();
656 void disk_underrun_handler ();
658 void session_dialog (std::string);
659 int pending_state_dialog ();
660 int sr_mismatch_dialog (nframes_t, nframes_t);
662 void disconnect_from_jack ();
663 void reconnect_to_jack ();
664 void set_jack_buffer_size (nframes_t);
666 Gtk::MenuItem* jack_disconnect_item;
667 Gtk::MenuItem* jack_reconnect_item;
668 Gtk::Menu* jack_bufsize_menu;
670 Glib::RefPtr<Gtk::ActionGroup> common_actions;
672 void editor_realized ();
674 std::vector<std::string> positional_sync_strings;
676 void toggle_send_midi_feedback ();
677 void toggle_use_mmc ();
678 void toggle_send_mmc ();
679 void toggle_send_mtc ();
680 void toggle_send_midi_clock ();
682 void toggle_use_osc ();
684 void parameter_changed (std::string);
688 void no_memory_warning ();
689 void check_memory_locking ();
691 bool check_audioengine();
692 void audioengine_setup ();
694 void display_message (const char *prefix, gint prefix_len,
695 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
697 Gtk::Label status_bar_label;
698 bool status_bar_button_press (GdkEventButton*);
699 Gtk::ToggleButton error_log_button;
701 void loading_message (const std::string& msg);
702 void end_loading_messages ();
704 void platform_specific ();
705 void platform_setup ();
706 void fontconfig_dialog ();
707 void toggle_translations ();
709 PBD::ScopedConnectionList forever_connections;
711 void step_edit_status_change (bool);
713 /* these are used only in response to a platform-specific "ShouldQuit" signal
716 void queue_finish ();
718 std::list<WindowProxyBase*> _window_proxies;
721 #endif /* __ardour_gui_h__ */