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
; }
121 void idle_load (const Glib::ustring
& path
);
124 int load_session (const Glib::ustring
& path
, const Glib::ustring
& snapshot
, Glib::ustring mix_template
= Glib::ustring());
126 int build_session (const Glib::ustring
& path
, const Glib::ustring
& snapshot
,
128 uint32_t master_chns
,
129 ARDOUR::AutoConnectOption input_connect
,
130 ARDOUR::AutoConnectOption output_connect
,
133 nframes_t initial_length
);
134 bool session_is_new() const { return _session_is_new
; }
136 ARDOUR::Session
* the_session() { return session
; }
138 bool will_create_new_session_automatically() const {
139 return _will_create_new_session_automatically
;
142 void set_will_create_new_session_automatically (bool yn
) {
143 _will_create_new_session_automatically
= yn
;
146 bool get_session_parameters (bool have_engine
= false, bool should_be_new
= false);
147 void parse_cmdline_path (const Glib::ustring
& cmdline_path
, Glib::ustring
& session_name
, Glib::ustring
& session_path
, bool& existing_session
);
148 int load_cmdline_session (const Glib::ustring
& session_name
, const Glib::ustring
& session_path
, bool& existing_session
);
149 int build_session_from_nsd (const Glib::ustring
& session_name
, const Glib::ustring
& session_path
);
150 bool ask_about_loading_existing_session (const Glib::ustring
& session_path
);
151 int unload_session (bool hide_stuff
= false);
152 void close_session();
154 int save_state_canfail (string state_name
= "", bool switch_to_it
= false);
155 void save_state (const string
& state_name
= "", bool switch_to_it
= false);
157 static double gain_to_slider_position (ARDOUR::gain_t g
);
158 static ARDOUR::gain_t
slider_position_to_gain (double pos
);
160 static ARDOUR_UI
*instance () { return theArdourUI
; }
161 static UIConfiguration
*config () { return ui_config
; }
163 PublicEditor
& the_editor(){return *editor
;}
164 Mixer_UI
* the_mixer() { return mixer
; }
166 ARDOUR::AudioEngine
& the_engine() const { return *engine
; }
168 void toggle_key_editor ();
169 void toggle_location_window ();
170 void toggle_theme_manager ();
171 void toggle_big_clock_window ();
172 void toggle_connection_editor ();
173 void toggle_route_params_window ();
174 void toggle_editing_space();
176 Gtk::Tooltips
& tooltips() { return _tooltips
; }
178 static sigc::signal
<void,bool> Blink
;
179 static sigc::signal
<void> RapidScreenUpdate
;
180 static sigc::signal
<void> SuperRapidScreenUpdate
;
181 static sigc::signal
<void,nframes_t
, bool, nframes_t
> Clock
;
183 void name_io_setup (ARDOUR::AudioEngine
&, string
&, ARDOUR::IO
& io
, bool in
);
185 XMLNode
* editor_settings() const;
186 XMLNode
* mixer_settings () const;
187 XMLNode
* keyboard_settings () const;
189 void save_ardour_state ();
190 gboolean
configure_handler (GdkEventConfigure
* conf
);
192 void do_transport_locate (nframes_t position
);
193 void halt_on_xrun_message ();
194 void xrun_handler (nframes_t
);
195 void create_xrun_marker (nframes_t
);
197 AudioClock primary_clock
;
198 AudioClock secondary_clock
;
199 AudioClock preroll_clock
;
200 AudioClock postroll_clock
;
202 void store_clock_modes ();
203 void restore_clock_modes ();
205 void add_route (Gtk::Window
* float_window
);
207 void session_add_audio_track (int input_channels
, int32_t output_channels
, ARDOUR::TrackMode mode
, uint32_t how_many
) {
208 session_add_audio_route (true, input_channels
, output_channels
, mode
, how_many
);
211 void session_add_audio_bus (int input_channels
, int32_t output_channels
, uint32_t how_many
) {
212 session_add_audio_route (false, input_channels
, output_channels
, ARDOUR::Normal
, how_many
);
215 void session_add_midi_track ();
217 int create_engine ();
220 gint
exit_on_main_window_close (GdkEventAny
*);
222 void maximise_editing_space ();
223 void restore_editing_space ();
225 void set_native_file_header_format (ARDOUR::HeaderFormat sf
);
226 void set_native_file_data_format (ARDOUR::SampleFormat sf
);
228 void setup_profile ();
231 void set_shuttle_fract (double);
234 friend class PublicEditor
;
236 void toggle_clocking ();
237 void toggle_auto_play ();
238 void toggle_auto_input ();
239 void toggle_punch ();
240 void unset_dual_punch ();
241 bool ignore_dual_punch
;
242 void toggle_punch_in ();
243 void toggle_punch_out ();
244 void show_loop_punch_ruler_and_disallow_hide ();
245 void reenable_hide_loop_punch_ruler_if_appropriate ();
246 void toggle_auto_return ();
247 void toggle_click ();
249 void toggle_session_auto_loop ();
251 void toggle_options_window ();
254 struct GlobalClickBox
: public Gtk::VBox
{
255 Gtkmm2ext::ClickBox
*box
;
258 vector
<string
> &strings
;
259 Gtk::Adjustment adjustment
;
261 static void printer (char buf
[32], Gtk::Adjustment
&adj
, void *arg
);
263 GlobalClickBox (const string
&str
, vector
<string
> &vs
)
265 adjustment (0, 0, vs
.size() - 1, 1, 1, 0) {
266 box
= new Gtkmm2ext::ClickBox (&adjustment
, "ClickButton");
267 label
.set_text (str
);
268 label
.set_name ("GlobalButtonLabel");
270 frame
.set_shadow_type (Gtk::SHADOW_IN
);
273 box
->set_print_func (printer
, this);
274 box
->set_wrap (true);
278 ARDOUR::AudioEngine
*engine
;
279 ARDOUR::Session
*session
;
281 Gtk::Tooltips _tooltips
;
283 void goto_editor_window ();
284 void goto_mixer_window ();
285 void toggle_editor_mixer_on_top ();
288 GlobalClickBox
*online_control_button
;
289 vector
<string
> online_control_strings
;
291 GlobalClickBox
*crossfade_time_button
;
292 vector
<string
> crossfade_time_strings
;
294 Gtk::ToggleButton preroll_button
;
295 Gtk::ToggleButton postroll_button
;
297 int setup_windows ();
298 void setup_transport ();
301 static ARDOUR_UI
*theArdourUI
;
303 void backend_audio_error (bool we_set_params
, Gtk::Window
* toplevel
= 0);
307 int ask_about_saving_session (const string
& why
);
309 /* periodic safety backup, to be precise */
310 gint
autosave_session();
311 void update_autosave();
312 sigc::connection _autosave_connection
;
314 void queue_transport_change ();
315 void map_transport_state ();
316 int32_t do_engine_start ();
318 void engine_halted (const char* reason
, bool free_reason
);
319 void engine_stopped ();
320 void engine_running ();
324 static gint
_blink (void *);
326 gint blink_timeout_tag
;
328 void start_blinking ();
329 void stop_blinking ();
331 void about_signal_response(int response
);
335 Gtk::VBox top_packer
;
337 sigc::connection clock_signal_connection
;
338 void update_clocks ();
339 void start_clocking ();
340 void stop_clocking ();
342 void manage_window (Gtk::Window
&);
344 AudioClock big_clock
;
345 Gtk::Window
* big_clock_window
;
347 void float_big_clock (Gtk::Window
* parent
);
348 bool main_window_state_event_handler (GdkEventWindowState
*, bool window_was_editor
);
350 void update_transport_clocks (nframes_t pos
);
351 void record_state_changed ();
353 /* Transport Control */
355 void detach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
);
356 void reattach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
, int32_t order
);
358 Gtkmm2ext::TearOff
* transport_tearoff
;
359 Gtk::Frame transport_frame
;
360 Gtk::HBox transport_tearoff_hbox
;
361 Gtk::HBox transport_hbox
;
362 Gtk::Fixed transport_base
;
363 Gtk::Fixed transport_button_base
;
364 Gtk::Frame transport_button_frame
;
365 Gtk::HBox transport_button_hbox
;
366 Gtk::VBox transport_button_vbox
;
367 Gtk::HBox transport_option_button_hbox
;
368 Gtk::VBox transport_option_button_vbox
;
369 Gtk::HBox transport_clock_hbox
;
370 Gtk::VBox transport_clock_vbox
;
371 Gtk::HBox primary_clock_hbox
;
372 Gtk::HBox secondary_clock_hbox
;
375 struct TransportControllable
: public PBD::Controllable
{
388 TransportControllable (std::string name
, ARDOUR_UI
&, ToggleType
);
389 void set_value (float);
390 float get_value (void) const;
392 void set_id (const std::string
&);
398 TransportControllable roll_controllable
;
399 TransportControllable stop_controllable
;
400 TransportControllable goto_start_controllable
;
401 TransportControllable goto_end_controllable
;
402 TransportControllable auto_loop_controllable
;
403 TransportControllable play_selection_controllable
;
404 TransportControllable rec_controllable
;
405 TransportControllable shuttle_controllable
;
406 BindingProxy shuttle_controller_binding_proxy
;
408 void set_transport_controllable_state (const XMLNode
&);
409 XMLNode
& get_transport_controllable_state ();
411 BindableButton roll_button
;
412 BindableButton stop_button
;
413 BindableButton goto_start_button
;
414 BindableButton goto_end_button
;
415 BindableButton auto_loop_button
;
416 BindableButton play_selection_button
;
417 BindableButton rec_button
;
419 Gtk::ComboBoxText sync_option_combo
;
421 void sync_option_changed ();
422 void toggle_time_master ();
423 void toggle_video_sync ();
425 Gtk::DrawingArea shuttle_box
;
426 Gtk::EventBox speed_display_box
;
427 Gtk::Label speed_display_label
;
428 Gtk::Button shuttle_units_button
;
429 Gtk::ComboBoxText shuttle_style_button
;
430 Gtk::Menu
* shuttle_unit_menu
;
431 Gtk::Menu
* shuttle_style_menu
;
432 float shuttle_max_speed
;
433 Gtk::Menu
* shuttle_context_menu
;
435 void build_shuttle_context_menu ();
436 void show_shuttle_context_menu ();
437 void shuttle_style_changed();
438 void shuttle_unit_clicked ();
439 void set_shuttle_max_speed (float);
440 void update_speed_display ();
441 float last_speed_displayed
;
443 gint
shuttle_box_button_press (GdkEventButton
*);
444 gint
shuttle_box_button_release (GdkEventButton
*);
445 gint
shuttle_box_scroll (GdkEventScroll
*);
446 gint
shuttle_box_motion (GdkEventMotion
*);
447 gint
shuttle_box_expose (GdkEventExpose
*);
448 gint
mouse_shuttle (double x
, bool force
);
449 void use_shuttle_fract (bool force
);
451 bool shuttle_grabbed
;
452 double shuttle_fract
;
454 Gtkmm2ext::StatefulToggleButton punch_in_button
;
455 Gtkmm2ext::StatefulToggleButton punch_out_button
;
456 Gtkmm2ext::StatefulToggleButton auto_return_button
;
457 Gtkmm2ext::StatefulToggleButton auto_play_button
;
458 Gtkmm2ext::StatefulToggleButton auto_input_button
;
459 Gtkmm2ext::StatefulToggleButton click_button
;
460 Gtkmm2ext::StatefulToggleButton time_master_button
;
462 Gtk::ToggleButton auditioning_alert_button
;
463 Gtk::ToggleButton solo_alert_button
;
467 void solo_blink (bool);
468 void audition_blink (bool);
470 void soloing_changed (bool);
471 void auditioning_changed (bool);
472 void _auditioning_changed (bool);
474 void solo_alert_toggle ();
475 void audition_alert_toggle ();
477 void big_clock_value_changed ();
478 void primary_clock_value_changed ();
479 void secondary_clock_value_changed ();
481 /* called by Blink signal */
483 void transport_rec_enable_blink (bool onoff
);
485 Gtk::Menu
* session_popup_menu
;
487 struct RecentSessionModelColumns
: public Gtk::TreeModel::ColumnRecord
{
488 RecentSessionModelColumns() {
492 Gtk::TreeModelColumn
<Glib::ustring
> visible_name
;
493 Gtk::TreeModelColumn
<Glib::ustring
> fullpath
;
496 RecentSessionModelColumns recent_session_columns
;
497 Gtk::TreeView recent_session_display
;
498 Glib::RefPtr
<Gtk::TreeStore
> recent_session_model
;
500 ArdourDialog
* session_selector_window
;
501 Gtk::FileChooserDialog
* open_session_selector
;
503 void build_session_selector();
504 void redisplay_recent_sessions();
505 void recent_session_row_activated (const Gtk::TreePath
& path
, Gtk::TreeViewColumn
* col
);
507 struct RecentSessionsSorter
{
508 bool operator() (std::pair
<string
,string
> a
, std::pair
<string
,string
> b
) const {
509 return cmp_nocase(a
.first
, b
.first
) == -1;
513 /* menu bar and associated stuff */
515 Gtk::MenuBar
* menu_bar
;
516 Gtk::EventBox menu_bar_base
;
519 void use_menubar_as_top_menubar ();
521 void build_menu_bar ();
522 void build_control_surface_menu ();
524 Gtk::Label wall_clock_label
;
525 Gtk::EventBox wall_clock_box
;
526 gint
update_wall_clock ();
528 Gtk::Label disk_space_label
;
529 Gtk::EventBox disk_space_box
;
530 void update_disk_space ();
532 Gtk::Label cpu_load_label
;
533 Gtk::EventBox cpu_load_box
;
534 void update_cpu_load ();
536 Gtk::Label buffer_load_label
;
537 Gtk::EventBox buffer_load_box
;
538 void update_buffer_load ();
540 Gtk::Label sample_rate_label
;
541 Gtk::EventBox sample_rate_box
;
542 void update_sample_rate (nframes_t
);
544 gint
every_second ();
545 gint
every_point_one_seconds ();
546 gint
every_point_zero_one_seconds ();
548 sigc::connection second_connection
;
549 sigc::connection point_one_second_connection
;
550 sigc::connection point_oh_five_second_connection
;
551 sigc::connection point_zero_one_second_connection
;
553 gint
session_menu (GdkEventButton
*);
555 bool _will_create_new_session_automatically
;
557 NewSessionDialog
* new_session_dialog
;
559 void open_session ();
560 void open_recent_session ();
561 void save_template ();
563 void session_add_audio_route (bool disk
, int32_t input_channels
, int32_t output_channels
, ARDOUR::TrackMode mode
, uint32_t how_many
);
565 void set_transport_sensitivity (bool);
567 void remove_last_capture ();
569 void transport_goto_zero ();
570 void transport_goto_start ();
571 void transport_goto_end ();
572 void transport_goto_wallclock ();
573 void transport_stop ();
574 void transport_stop_and_forget_capture ();
575 void transport_record (bool roll
);
576 void transport_roll ();
577 void transport_play_selection();
578 void transport_forward (int option
);
579 void transport_rewind (int option
);
580 void transport_loop ();
581 void toggle_roll (bool with_abort
, bool roll_out_of_bounded_mode
);
583 bool _session_is_new
;
584 void connect_to_session (ARDOUR::Session
*);
585 void connect_dependents_to_session (ARDOUR::Session
*);
586 void we_have_dependents ();
588 void setup_session_options ();
590 guint32 last_key_press_time
;
592 void snapshot_session (bool switch_to_it
);
597 PublicEditor
*editor
;
598 int create_editor ();
600 RouteParams_UI
*route_params
;
601 int create_route_params ();
603 ConnectionEditor
*connection_editor
;
604 int create_connection_editor ();
606 LocationUI
*location_ui
;
607 int create_location_ui ();
608 void handle_locations_change (ARDOUR::Location
*);
610 static UIConfiguration
*ui_config
;
611 ThemeManager
*theme_manager
;
613 /* Key bindings editor */
615 KeyEditor
*key_editor
;
619 OptionEditor
*option_editor
;
623 AddRouteDialog
*add_route_dialog
;
625 /* Keyboard Handling */
629 /* Keymap handling */
631 void install_actions ();
633 void toggle_record_enable (uint32_t);
635 uint32_t rec_enabled_streams
;
636 void count_recenabled_streams (ARDOUR::Route
&);
640 void pop_back_splash ();
645 Gtk::MenuItem
*cleanup_item
;
647 void display_cleanup_results (ARDOUR::Session::cleanup_report
& rep
, const gchar
* list_title
,
648 const string
& plural_msg
, const string
& singular_msg
);
652 bool have_configure_timeout
;
653 ARDOUR::microseconds_t last_configure_time
;
654 gint
configure_timeout ();
656 ARDOUR::microseconds_t last_peak_grab
;
657 ARDOUR::microseconds_t last_shuttle_request
;
659 struct DiskBufferStat
{
664 DiskBufferStat (time_t w
, uint32_t c
, uint32_t p
)
665 : when (w
), capture (c
), playback (p
) {}
668 std::list
<DiskBufferStat
> disk_buffer_stats
;
669 void push_buffer_stats (uint32_t, uint32_t);
670 void write_buffer_stats ();
672 bool have_disk_speed_dialog_displayed
;
673 void disk_speed_dialog_gone (int ignored_response
, Gtk::MessageDialog
*);
674 void disk_overrun_handler ();
675 void disk_underrun_handler ();
677 bool preset_file_exists_handler ();
679 void session_dialog (std::string
);
680 int pending_state_dialog ();
681 int sr_mismatch_dialog (nframes_t
, nframes_t
);
683 void disconnect_from_jack ();
684 void reconnect_to_jack ();
685 void set_jack_buffer_size (nframes_t
);
687 Gtk::MenuItem
* jack_disconnect_item
;
688 Gtk::MenuItem
* jack_reconnect_item
;
689 Gtk::Menu
* jack_bufsize_menu
;
691 Glib::RefPtr
<Gtk::ActionGroup
> common_actions
;
693 void editor_realized ();
695 std::vector
<std::string
> positional_sync_strings
;
697 void toggle_send_midi_feedback ();
698 void toggle_use_mmc ();
699 void toggle_send_mmc ();
700 void toggle_send_mtc ();
702 void toggle_use_osc ();
704 void toggle_denormal_protection ();
706 void set_input_auto_connect (ARDOUR::AutoConnectOption
);
707 void set_output_auto_connect (ARDOUR::AutoConnectOption
);
708 void set_solo_model (ARDOUR::SoloModel
);
709 void set_monitor_model (ARDOUR::MonitorModel
);
710 void set_remote_model (ARDOUR::RemoteModel
);
711 void set_denormal_model (ARDOUR::DenormalModel
);
713 void toggle_seamless_loop ();
714 void toggle_sync_order_keys ();
715 void toggle_new_plugins_active();
716 void toggle_StopPluginsWithTransport();
717 void toggle_DoNotRunPluginsWhileRecording();
718 void toggle_VerifyRemoveLastCapture();
719 void toggle_PeriodicSafetyBackups();
720 void toggle_StopRecordingOnXrun();
721 void toggle_CreateXrunMarker();
722 void toggle_StopTransportAtEndOfSession();
723 void toggle_GainReduceFastTransport();
724 void toggle_LatchedSolo();
725 void toggle_ShowSoloMutes();
726 void toggle_SoloMuteOverride();
727 void toggle_LatchedRecordEnable ();
728 void toggle_RegionEquivalentsOverlap ();
729 void toggle_PrimaryClockDeltaEditCursor ();
730 void toggle_SecondaryClockDeltaEditCursor ();
731 void toggle_only_copy_imported_files ();
732 void toggle_ShowTrackMeters ();
733 void toggle_use_narrow_ms();
734 void toggle_NameNewMarkers ();
735 void toggle_rubberbanding_snaps_to_grid ();
736 void toggle_auto_analyse_audio ();
737 void toggle_TapeMachineMode();
739 void mtc_port_changed ();
740 void map_solo_model ();
741 void map_monitor_model ();
742 void map_denormal_model ();
743 void map_denormal_protection ();
744 void map_remote_model ();
745 void map_file_header_format ();
746 void map_file_data_format ();
747 void map_input_auto_connect ();
748 void map_output_auto_connect ();
749 void map_only_copy_imported_files ();
750 void parameter_changed (const char*);
752 void set_meter_hold (ARDOUR::MeterHold
);
753 void set_meter_falloff (ARDOUR::MeterFalloff
);
754 void map_meter_hold ();
755 void map_meter_falloff ();
757 void toggle_control_protocol (ARDOUR::ControlProtocolInfo
*);
758 void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo
*, const char* group_name
, std::string action_name
);
762 void no_memory_warning ();
763 void check_memory_locking ();
765 bool check_audioengine();
766 void audioengine_setup ();
768 void display_message (const char *prefix
, gint prefix_len
,
769 Glib::RefPtr
<Gtk::TextBuffer::Tag
> ptag
, Glib::RefPtr
<Gtk::TextBuffer::Tag
> mtag
, const char *msg
);
770 Gtk::Label status_bar_label
;
771 bool status_bar_button_press (GdkEventButton
*);
772 Gtk::ToggleButton error_log_button
;
774 void loading_message (const std::string
& msg
);
775 void end_loading_messages ();
777 void platform_specific ();
778 void platform_setup ();
779 void fontconfig_dialog ();
780 void toggle_translations ();
782 /* these are used only in response to a platform-specific "ShouldQuit" signal
785 void queue_finish ();
788 #endif /* __ardour_gui_h__ */