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 <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>
60 #include <ardour/ardour.h>
61 #include <ardour/session.h>
62 #include <ardour/types.h>
64 #include "audio_clock.h"
65 #include "ardour_dialog.h"
67 #include "ui_config.h"
75 class ConnectionEditor
;
82 class NewSessionDialog
;
93 class ControlProtocolInfo
;
97 class MultiChannelDevice
;
100 #define FRAME_NAME "BaseFrame"
102 extern sigc::signal
<void> ColorsChanged
;
103 extern sigc::signal
<void> DPIReset
;
105 class ARDOUR_UI
: public Gtkmm2ext::UI
108 ARDOUR_UI (int *argcp
, char **argvp
[]);
112 bool shown() { return shown_flag
; }
118 void launch_manual ();
119 void launch_reference ();
124 void idle_load (const Glib::ustring
& path
);
127 int load_session (const Glib::ustring
& path
, const Glib::ustring
& snapshot
, Glib::ustring mix_template
= Glib::ustring());
129 int build_session (const Glib::ustring
& path
, const Glib::ustring
& snapshot
,
131 uint32_t master_chns
,
132 ARDOUR::AutoConnectOption input_connect
,
133 ARDOUR::AutoConnectOption output_connect
,
136 nframes_t initial_length
);
137 bool session_is_new() const { return _session_is_new
; }
139 ARDOUR::Session
* the_session() { return session
; }
141 bool will_create_new_session_automatically() const {
142 return _will_create_new_session_automatically
;
145 void set_will_create_new_session_automatically (bool yn
) {
146 _will_create_new_session_automatically
= yn
;
149 bool get_session_parameters (bool have_engine
= false, bool should_be_new
= false);
150 void parse_cmdline_path (const Glib::ustring
& cmdline_path
, Glib::ustring
& session_name
, Glib::ustring
& session_path
, bool& existing_session
);
151 int load_cmdline_session (const Glib::ustring
& session_name
, const Glib::ustring
& session_path
, bool& existing_session
);
152 int build_session_from_nsd (const Glib::ustring
& session_name
, const Glib::ustring
& session_path
);
153 bool ask_about_loading_existing_session (const Glib::ustring
& session_path
);
154 int unload_session (bool hide_stuff
= false);
155 void close_session();
157 int save_state_canfail (string state_name
= "", bool switch_to_it
= false);
158 void save_state (const string
& state_name
= "", bool switch_to_it
= false);
160 static double gain_to_slider_position (ARDOUR::gain_t g
);
161 static ARDOUR::gain_t
slider_position_to_gain (double pos
);
163 static ARDOUR_UI
*instance () { return theArdourUI
; }
164 static UIConfiguration
*config () { return ui_config
; }
166 PublicEditor
& the_editor(){return *editor
;}
167 Mixer_UI
* the_mixer() { return mixer
; }
169 ARDOUR::AudioEngine
& the_engine() const { return *engine
; }
171 void toggle_key_editor ();
172 void toggle_location_window ();
173 void toggle_theme_manager ();
174 void toggle_big_clock_window ();
175 void toggle_connection_editor ();
176 void toggle_route_params_window ();
177 void toggle_editing_space();
179 Gtk::Tooltips
& tooltips() { return _tooltips
; }
181 static sigc::signal
<void,bool> Blink
;
182 static sigc::signal
<void> RapidScreenUpdate
;
183 static sigc::signal
<void> SuperRapidScreenUpdate
;
184 static sigc::signal
<void,nframes_t
, bool, nframes_t
> Clock
;
186 void name_io_setup (ARDOUR::AudioEngine
&, string
&, ARDOUR::IO
& io
, bool in
);
188 XMLNode
* editor_settings() const;
189 XMLNode
* mixer_settings () const;
190 XMLNode
* keyboard_settings () const;
192 void save_ardour_state ();
193 gboolean
configure_handler (GdkEventConfigure
* conf
);
195 void do_transport_locate (nframes_t position
);
196 void halt_on_xrun_message ();
197 void xrun_handler (nframes_t
);
198 void create_xrun_marker (nframes_t
);
200 AudioClock primary_clock
;
201 AudioClock secondary_clock
;
202 AudioClock preroll_clock
;
203 AudioClock postroll_clock
;
205 void store_clock_modes ();
206 void restore_clock_modes ();
208 void add_route (Gtk::Window
* float_window
);
210 void session_add_audio_track (int input_channels
, int32_t output_channels
, ARDOUR::TrackMode mode
, uint32_t how_many
) {
211 session_add_audio_route (true, input_channels
, output_channels
, mode
, how_many
);
214 void session_add_audio_bus (int input_channels
, int32_t output_channels
, uint32_t how_many
) {
215 session_add_audio_route (false, input_channels
, output_channels
, ARDOUR::Normal
, how_many
);
218 void session_add_midi_track ();
220 int create_engine ();
223 gint
exit_on_main_window_close (GdkEventAny
*);
225 void maximise_editing_space ();
226 void restore_editing_space ();
228 void set_native_file_header_format (ARDOUR::HeaderFormat sf
);
229 void set_native_file_data_format (ARDOUR::SampleFormat sf
);
231 void setup_profile ();
234 void set_shuttle_fract (double);
237 friend class PublicEditor
;
239 void toggle_clocking ();
240 void toggle_auto_play ();
241 void toggle_auto_input ();
242 void toggle_punch ();
243 void unset_dual_punch ();
244 bool ignore_dual_punch
;
245 void toggle_punch_in ();
246 void toggle_punch_out ();
247 void show_loop_punch_ruler_and_disallow_hide ();
248 void reenable_hide_loop_punch_ruler_if_appropriate ();
249 void toggle_auto_return ();
250 void toggle_click ();
252 void toggle_session_auto_loop ();
254 void toggle_options_window ();
257 struct GlobalClickBox
: public Gtk::VBox
{
258 Gtkmm2ext::ClickBox
*box
;
261 vector
<string
> &strings
;
262 Gtk::Adjustment adjustment
;
264 static void printer (char buf
[32], Gtk::Adjustment
&adj
, void *arg
);
266 GlobalClickBox (const string
&str
, vector
<string
> &vs
)
268 adjustment (0, 0, vs
.size() - 1, 1, 1, 0) {
269 box
= new Gtkmm2ext::ClickBox (&adjustment
, "ClickButton");
270 label
.set_text (str
);
271 label
.set_name ("GlobalButtonLabel");
273 frame
.set_shadow_type (Gtk::SHADOW_IN
);
276 box
->set_print_func (printer
, this);
277 box
->set_wrap (true);
281 ARDOUR::AudioEngine
*engine
;
282 ARDOUR::Session
*session
;
284 Gtk::Tooltips _tooltips
;
286 void goto_editor_window ();
287 void goto_mixer_window ();
288 void toggle_editor_mixer_on_top ();
291 GlobalClickBox
*online_control_button
;
292 vector
<string
> online_control_strings
;
294 GlobalClickBox
*crossfade_time_button
;
295 vector
<string
> crossfade_time_strings
;
297 Gtk::ToggleButton preroll_button
;
298 Gtk::ToggleButton postroll_button
;
300 int setup_windows ();
301 void setup_transport ();
304 static ARDOUR_UI
*theArdourUI
;
306 void backend_audio_error (bool we_set_params
, Gtk::Window
* toplevel
= 0);
310 int ask_about_saving_session (const string
& why
);
312 /* periodic safety backup, to be precise */
313 gint
autosave_session();
314 void update_autosave();
315 sigc::connection _autosave_connection
;
317 void queue_transport_change ();
318 void map_transport_state ();
319 int32_t do_engine_start ();
321 void engine_halted (const char* reason
, bool free_reason
);
322 void engine_stopped ();
323 void engine_running ();
327 static gint
_blink (void *);
329 gint blink_timeout_tag
;
331 void start_blinking ();
332 void stop_blinking ();
334 void about_signal_response(int response
);
338 Gtk::VBox top_packer
;
340 sigc::connection clock_signal_connection
;
341 void update_clocks ();
342 void start_clocking ();
343 void stop_clocking ();
345 void manage_window (Gtk::Window
&);
347 AudioClock big_clock
;
348 Gtk::Window
* big_clock_window
;
350 void float_big_clock (Gtk::Window
* parent
);
351 bool main_window_state_event_handler (GdkEventWindowState
*, bool window_was_editor
);
353 void update_transport_clocks (nframes_t pos
);
354 void record_state_changed ();
356 /* Transport Control */
358 void detach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
);
359 void reattach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
, int32_t order
);
361 Gtkmm2ext::TearOff
* transport_tearoff
;
362 Gtk::Frame transport_frame
;
363 Gtk::HBox transport_tearoff_hbox
;
364 Gtk::HBox transport_hbox
;
365 Gtk::Fixed transport_base
;
366 Gtk::Fixed transport_button_base
;
367 Gtk::Frame transport_button_frame
;
368 Gtk::HBox transport_button_hbox
;
369 Gtk::VBox transport_button_vbox
;
370 Gtk::HBox transport_option_button_hbox
;
371 Gtk::VBox transport_option_button_vbox
;
372 Gtk::HBox transport_clock_hbox
;
373 Gtk::VBox transport_clock_vbox
;
374 Gtk::HBox primary_clock_hbox
;
375 Gtk::HBox secondary_clock_hbox
;
378 struct TransportControllable
: public PBD::Controllable
{
391 TransportControllable (std::string name
, ARDOUR_UI
&, ToggleType
);
392 void set_value (float);
393 float get_value (void) const;
395 void set_id (const std::string
&);
401 TransportControllable roll_controllable
;
402 TransportControllable stop_controllable
;
403 TransportControllable goto_start_controllable
;
404 TransportControllable goto_end_controllable
;
405 TransportControllable auto_loop_controllable
;
406 TransportControllable play_selection_controllable
;
407 TransportControllable rec_controllable
;
408 TransportControllable shuttle_controllable
;
409 BindingProxy shuttle_controller_binding_proxy
;
411 void set_transport_controllable_state (const XMLNode
&);
412 XMLNode
& get_transport_controllable_state ();
414 BindableButton roll_button
;
415 BindableButton stop_button
;
416 BindableButton goto_start_button
;
417 BindableButton goto_end_button
;
418 BindableButton auto_loop_button
;
419 BindableButton play_selection_button
;
420 BindableButton rec_button
;
422 Gtk::ComboBoxText sync_option_combo
;
424 void sync_option_changed ();
425 void toggle_time_master ();
426 void toggle_video_sync ();
428 Gtk::DrawingArea shuttle_box
;
429 Gtk::EventBox speed_display_box
;
430 Gtk::Label speed_display_label
;
431 Gtk::Button shuttle_units_button
;
432 Gtk::ComboBoxText shuttle_style_button
;
433 Gtk::Menu
* shuttle_unit_menu
;
434 Gtk::Menu
* shuttle_style_menu
;
435 float shuttle_max_speed
;
436 Gtk::Menu
* shuttle_context_menu
;
438 void build_shuttle_context_menu ();
439 void show_shuttle_context_menu ();
440 void shuttle_style_changed();
441 void shuttle_unit_clicked ();
442 void set_shuttle_max_speed (float);
443 void update_speed_display ();
444 float last_speed_displayed
;
446 gint
shuttle_box_button_press (GdkEventButton
*);
447 gint
shuttle_box_button_release (GdkEventButton
*);
448 gint
shuttle_box_scroll (GdkEventScroll
*);
449 gint
shuttle_box_motion (GdkEventMotion
*);
450 gint
shuttle_box_expose (GdkEventExpose
*);
451 gint
mouse_shuttle (double x
, bool force
);
452 void use_shuttle_fract (bool force
);
454 bool shuttle_grabbed
;
455 double shuttle_fract
;
457 Gtkmm2ext::StatefulToggleButton punch_in_button
;
458 Gtkmm2ext::StatefulToggleButton punch_out_button
;
459 Gtkmm2ext::StatefulToggleButton auto_return_button
;
460 Gtkmm2ext::StatefulToggleButton auto_play_button
;
461 Gtkmm2ext::StatefulToggleButton auto_input_button
;
462 Gtkmm2ext::StatefulToggleButton click_button
;
463 Gtkmm2ext::StatefulToggleButton time_master_button
;
465 Gtk::ToggleButton auditioning_alert_button
;
466 Gtk::ToggleButton solo_alert_button
;
470 void solo_blink (bool);
471 void audition_blink (bool);
473 void soloing_changed (bool);
474 void auditioning_changed (bool);
475 void _auditioning_changed (bool);
477 void solo_alert_toggle ();
478 void audition_alert_toggle ();
480 void big_clock_value_changed ();
481 void primary_clock_value_changed ();
482 void secondary_clock_value_changed ();
484 /* called by Blink signal */
486 void transport_rec_enable_blink (bool onoff
);
488 Gtk::Menu
* session_popup_menu
;
490 struct RecentSessionModelColumns
: public Gtk::TreeModel::ColumnRecord
{
491 RecentSessionModelColumns() {
495 Gtk::TreeModelColumn
<Glib::ustring
> visible_name
;
496 Gtk::TreeModelColumn
<Glib::ustring
> fullpath
;
499 RecentSessionModelColumns recent_session_columns
;
500 Gtk::TreeView recent_session_display
;
501 Glib::RefPtr
<Gtk::TreeStore
> recent_session_model
;
503 ArdourDialog
* session_selector_window
;
504 Gtk::FileChooserDialog
* open_session_selector
;
506 void build_session_selector();
507 void redisplay_recent_sessions();
508 void recent_session_row_activated (const Gtk::TreePath
& path
, Gtk::TreeViewColumn
* col
);
510 struct RecentSessionsSorter
{
511 bool operator() (std::pair
<string
,string
> a
, std::pair
<string
,string
> b
) const {
512 return cmp_nocase(a
.first
, b
.first
) == -1;
516 /* menu bar and associated stuff */
518 Gtk::MenuBar
* menu_bar
;
519 Gtk::EventBox menu_bar_base
;
522 void use_menubar_as_top_menubar ();
524 void build_menu_bar ();
525 void build_control_surface_menu ();
527 Gtk::Label wall_clock_label
;
528 Gtk::EventBox wall_clock_box
;
529 gint
update_wall_clock ();
531 Gtk::Label disk_space_label
;
532 Gtk::EventBox disk_space_box
;
533 void update_disk_space ();
535 Gtk::Label cpu_load_label
;
536 Gtk::EventBox cpu_load_box
;
537 void update_cpu_load ();
539 Gtk::Label buffer_load_label
;
540 Gtk::EventBox buffer_load_box
;
541 void update_buffer_load ();
543 Gtk::Label sample_rate_label
;
544 Gtk::EventBox sample_rate_box
;
545 void update_sample_rate (nframes_t
);
547 gint
every_second ();
548 gint
every_point_one_seconds ();
549 gint
every_point_zero_one_seconds ();
551 sigc::connection second_connection
;
552 sigc::connection point_one_second_connection
;
553 sigc::connection point_oh_five_second_connection
;
554 sigc::connection point_zero_one_second_connection
;
556 gint
session_menu (GdkEventButton
*);
558 bool _will_create_new_session_automatically
;
560 NewSessionDialog
* new_session_dialog
;
562 void open_session ();
563 void open_recent_session ();
564 void save_template ();
566 void session_add_audio_route (bool disk
, int32_t input_channels
, int32_t output_channels
, ARDOUR::TrackMode mode
, uint32_t how_many
);
568 void set_transport_sensitivity (bool);
570 void remove_last_capture ();
572 void transport_goto_zero ();
573 void transport_goto_start ();
574 void transport_goto_end ();
575 void transport_goto_wallclock ();
576 void transport_stop ();
577 void transport_stop_and_forget_capture ();
578 void transport_record (bool roll
);
579 void transport_roll ();
580 void transport_play_selection();
581 void transport_forward (int option
);
582 void transport_rewind (int option
);
583 void transport_loop ();
584 void toggle_roll (bool with_abort
, bool roll_out_of_bounded_mode
);
586 bool _session_is_new
;
587 void connect_to_session (ARDOUR::Session
*);
588 void connect_dependents_to_session (ARDOUR::Session
*);
589 void we_have_dependents ();
591 void setup_session_options ();
593 guint32 last_key_press_time
;
595 void snapshot_session (bool switch_to_it
);
600 PublicEditor
*editor
;
601 int create_editor ();
603 RouteParams_UI
*route_params
;
604 int create_route_params ();
606 ConnectionEditor
*connection_editor
;
607 int create_connection_editor ();
609 LocationUI
*location_ui
;
610 int create_location_ui ();
611 void handle_locations_change (ARDOUR::Location
*);
613 static UIConfiguration
*ui_config
;
614 ThemeManager
*theme_manager
;
616 /* Key bindings editor */
618 KeyEditor
*key_editor
;
622 OptionEditor
*option_editor
;
626 AddRouteDialog
*add_route_dialog
;
628 /* Keyboard Handling */
632 /* Keymap handling */
634 void install_actions ();
636 void toggle_record_enable (uint32_t);
638 uint32_t rec_enabled_streams
;
639 void count_recenabled_streams (ARDOUR::Route
&);
643 void pop_back_splash ();
648 Gtk::MenuItem
*cleanup_item
;
650 void display_cleanup_results (ARDOUR::Session::cleanup_report
& rep
, const gchar
* list_title
,
651 const string
& plural_msg
, const string
& singular_msg
);
655 bool have_configure_timeout
;
656 ARDOUR::microseconds_t last_configure_time
;
657 gint
configure_timeout ();
659 ARDOUR::microseconds_t last_peak_grab
;
660 ARDOUR::microseconds_t last_shuttle_request
;
662 bool have_disk_speed_dialog_displayed
;
663 void disk_speed_dialog_gone (int ignored_response
, Gtk::MessageDialog
*);
664 void disk_overrun_handler ();
665 void disk_underrun_handler ();
667 bool preset_file_exists_handler ();
669 void session_dialog (std::string
);
670 int pending_state_dialog ();
671 int sr_mismatch_dialog (nframes_t
, nframes_t
);
673 void disconnect_from_jack ();
674 void reconnect_to_jack ();
675 void set_jack_buffer_size (nframes_t
);
677 Gtk::MenuItem
* jack_disconnect_item
;
678 Gtk::MenuItem
* jack_reconnect_item
;
679 Gtk::Menu
* jack_bufsize_menu
;
681 Glib::RefPtr
<Gtk::ActionGroup
> common_actions
;
683 void editor_realized ();
685 std::vector
<std::string
> positional_sync_strings
;
687 void toggle_send_midi_feedback ();
688 void toggle_use_mmc ();
689 void toggle_send_mmc ();
690 void toggle_send_mtc ();
692 void toggle_use_osc ();
694 void toggle_denormal_protection ();
696 void set_input_auto_connect (ARDOUR::AutoConnectOption
);
697 void set_output_auto_connect (ARDOUR::AutoConnectOption
);
698 void set_solo_model (ARDOUR::SoloModel
);
699 void set_monitor_model (ARDOUR::MonitorModel
);
700 void set_remote_model (ARDOUR::RemoteModel
);
701 void set_denormal_model (ARDOUR::DenormalModel
);
703 void toggle_seamless_loop ();
704 void toggle_sync_order_keys ();
705 void toggle_new_plugins_active();
706 void toggle_StopPluginsWithTransport();
707 void toggle_DoNotRunPluginsWhileRecording();
708 void toggle_VerifyRemoveLastCapture();
709 void toggle_PeriodicSafetyBackups();
710 void toggle_StopRecordingOnXrun();
711 void toggle_CreateXrunMarker();
712 void toggle_StopTransportAtEndOfSession();
713 void toggle_GainReduceFastTransport();
714 void toggle_LatchedSolo();
715 void toggle_ShowSoloMutes();
716 void toggle_SoloMuteOverride();
717 void toggle_LatchedRecordEnable ();
718 void toggle_RegionEquivalentsOverlap ();
719 void toggle_PrimaryClockDeltaEditCursor ();
720 void toggle_SecondaryClockDeltaEditCursor ();
721 void toggle_only_copy_imported_files ();
722 void toggle_ShowTrackMeters ();
723 void toggle_use_narrow_ms();
724 void toggle_NameNewMarkers ();
725 void toggle_rubberbanding_snaps_to_grid ();
726 void toggle_auto_analyse_audio ();
727 void toggle_TapeMachineMode();
729 void mtc_port_changed ();
730 void map_solo_model ();
731 void map_monitor_model ();
732 void map_denormal_model ();
733 void map_denormal_protection ();
734 void map_remote_model ();
735 void map_file_header_format ();
736 void map_file_data_format ();
737 void map_input_auto_connect ();
738 void map_output_auto_connect ();
739 void map_only_copy_imported_files ();
740 void parameter_changed (const char*);
742 void set_meter_hold (ARDOUR::MeterHold
);
743 void set_meter_falloff (ARDOUR::MeterFalloff
);
744 void map_meter_hold ();
745 void map_meter_falloff ();
747 void toggle_control_protocol (ARDOUR::ControlProtocolInfo
*);
748 void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo
*, const char* group_name
, std::string action_name
);
752 void no_memory_warning ();
753 void check_memory_locking ();
755 bool check_audioengine();
756 void audioengine_setup ();
758 void display_message (const char *prefix
, gint prefix_len
,
759 Glib::RefPtr
<Gtk::TextBuffer::Tag
> ptag
, Glib::RefPtr
<Gtk::TextBuffer::Tag
> mtag
, const char *msg
);
760 Gtk::Label status_bar_label
;
761 bool status_bar_button_press (GdkEventButton
*);
762 Gtk::ToggleButton error_log_button
;
764 void loading_message (const std::string
& msg
);
765 void end_loading_messages ();
767 void platform_specific ();
768 void platform_setup ();
769 void fontconfig_dialog ();
770 void toggle_translations ();
772 /* these are used only in response to a platform-specific "ShouldQuit" signal
775 void queue_finish ();
778 #endif /* __ardour_gui_h__ */