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
;
90 class WindowProxyBase
;
91 class GlobalPortMatrixWindow
;
98 class ControlProtocolInfo
;
106 class ARDOUR_UI
: public Gtkmm2ext::UI
, public ARDOUR::SessionHandlePtr
109 ARDOUR_UI (int *argcp
, char **argvp
[]);
112 bool run_startup (bool should_be_new
, std::string load_template
);
118 void launch_manual ();
119 void launch_reference ();
123 void idle_load (const std::string
& path
);
126 int load_session (const std::string
& path
, const std::string
& snapshot
, std::string mix_template
= std::string());
128 int build_session (const std::string
& path
, const std::string
& snapshot
, ARDOUR::BusProfile
&);
129 bool session_is_new() const { return _session_is_new
; }
131 ARDOUR::Session
* the_session() { return _session
; }
133 bool will_create_new_session_automatically() const {
134 return _will_create_new_session_automatically
;
137 void set_will_create_new_session_automatically (bool yn
) {
138 _will_create_new_session_automatically
= yn
;
141 int get_session_parameters (bool quit_on_cancel
, bool should_be_new
= false, std::string load_template
= "");
142 void parse_cmdline_path (const std::string
& cmdline_path
, std::string
& session_name
, std::string
& session_path
, bool& existing_session
);
143 int load_cmdline_session (const std::string
& session_name
, const std::string
& session_path
, bool& existing_session
);
144 int build_session_from_nsd (const std::string
& session_name
, const std::string
& session_path
);
145 bool ask_about_loading_existing_session (const std::string
& session_path
);
147 /// @return true if session was successfully unloaded.
148 int unload_session (bool hide_stuff
= false);
149 void close_session();
151 int save_state_canfail (std::string state_name
= "", bool switch_to_it
= false);
152 void save_state (const std::string
& state_name
= "", bool switch_to_it
= false);
154 static ARDOUR_UI
*instance () { return theArdourUI
; }
155 static UIConfiguration
*config () { return ui_config
; }
157 PublicEditor
& the_editor(){return *editor
;}
158 Mixer_UI
* the_mixer() { return mixer
; }
160 void toggle_key_editor ();
161 void toggle_location_window ();
162 void toggle_theme_manager ();
163 void toggle_bundle_manager ();
164 void toggle_big_clock_window ();
165 void toggle_speaker_config_window ();
166 void new_midi_tracer_window ();
167 void toggle_route_params_window ();
168 void toggle_editing_space();
169 void toggle_keep_tearoffs();
171 Gtk::Tooltips
& tooltips() { return _tooltips
; }
173 Gtk::HBox
& editor_transport_box() { return _editor_transport_box
; }
175 static PublicEditor
* _instance
;
176 static sigc::signal
<void,bool> Blink
;
177 static sigc::signal
<void> RapidScreenUpdate
;
178 static sigc::signal
<void> SuperRapidScreenUpdate
;
179 /** Emitted frequently with the audible frame, false, and the edit point as
180 * parameters respectively.
182 static sigc::signal
<void, framepos_t
, bool, framepos_t
> Clock
;
184 XMLNode
* editor_settings() const;
185 XMLNode
* mixer_settings () const;
186 XMLNode
* keyboard_settings () const;
187 XMLNode
* tearoff_settings (const char*) const;
189 void save_ardour_state ();
190 gboolean
configure_handler (GdkEventConfigure
* conf
);
192 void do_transport_locate (framepos_t
, bool);
193 void halt_on_xrun_message ();
194 void xrun_handler (framepos_t
);
195 void create_xrun_marker (framepos_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 ();
204 void reset_main_clocks ();
206 void synchronize_sync_source_and_video_pullup ();
208 void add_route (Gtk::Window
* float_window
);
210 void session_add_audio_track (
212 int32_t output_channels
,
213 ARDOUR::TrackMode mode
,
214 ARDOUR::RouteGroup
* route_group
,
216 std::string
const & name_template
219 session_add_audio_route (true, input_channels
, output_channels
, mode
, route_group
, how_many
, name_template
);
222 void session_add_audio_bus (
224 int32_t output_channels
,
225 ARDOUR::RouteGroup
* route_group
,
227 std::string
const & name_template
230 session_add_audio_route (false, input_channels
, output_channels
, ARDOUR::Normal
, route_group
, how_many
, name_template
);
233 void session_add_midi_track (
234 ARDOUR::RouteGroup
* route_group
,
236 std::string
const & name_template
239 session_add_midi_route (true, route_group
, how_many
, name_template
);
242 /*void session_add_midi_bus () {
243 session_add_midi_route (false);
246 int create_engine ();
249 gint
exit_on_main_window_close (GdkEventAny
*);
251 void maximise_editing_space ();
252 void restore_editing_space ();
254 void setup_profile ();
256 void setup_tooltips ();
258 void set_shuttle_fract (double);
260 void add_window_proxy (WindowProxyBase
*);
261 void remove_window_proxy (WindowProxyBase
*);
264 friend class PublicEditor
;
266 void toggle_clocking ();
267 void toggle_auto_play ();
268 void toggle_auto_input ();
269 void toggle_punch ();
270 void unset_dual_punch ();
271 bool ignore_dual_punch
;
272 void toggle_punch_in ();
273 void toggle_punch_out ();
274 void show_loop_punch_ruler_and_disallow_hide ();
275 void reenable_hide_loop_punch_ruler_if_appropriate ();
276 void toggle_auto_return ();
277 void toggle_click ();
279 void toggle_session_auto_loop ();
281 void toggle_rc_options_window ();
282 void toggle_session_options_window ();
285 ArdourStartup
* _startup
;
286 ARDOUR::AudioEngine
*engine
;
287 Gtk::Tooltips _tooltips
;
289 void goto_editor_window ();
290 void goto_mixer_window ();
291 void toggle_mixer_window ();
292 void toggle_mixer_on_top ();
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 std::string
& why
);
309 /* periodic safety backup, to be precise */
310 gint
autosave_session();
311 void update_autosave();
312 sigc::connection _autosave_connection
;
314 void map_transport_state ();
315 int32_t do_engine_start ();
317 void engine_halted (const char* reason
, bool free_reason
);
318 void engine_stopped ();
319 void engine_running ();
323 static gint
_blink (void *);
325 gint blink_timeout_tag
;
327 void start_blinking ();
328 void stop_blinking ();
330 void about_signal_response(int response
);
332 Gtk::VBox top_packer
;
334 sigc::connection clock_signal_connection
;
335 void update_clocks ();
336 void start_clocking ();
337 void stop_clocking ();
339 void manage_window (Gtk::Window
&);
341 AudioClock big_clock
;
342 ActionWindowProxy
<Gtk::Window
>* big_clock_window
;
343 int original_big_clock_width
;
344 int original_big_clock_height
;
345 double original_big_clock_font_size
;
347 void big_clock_size_allocate (Gtk::Allocation
&);
348 bool idle_big_clock_text_resizer (int width
, int height
);
349 void big_clock_realized ();
350 bool big_clock_resize_in_progress
;
351 int big_clock_height
;
353 void float_big_clock (Gtk::Window
* parent
);
354 bool main_window_state_event_handler (GdkEventWindowState
*, bool window_was_editor
);
356 ActionWindowProxy
<SpeakerDialog
>* speaker_config_window
;
358 void update_transport_clocks (framepos_t pos
);
359 void record_state_changed ();
361 std::list
<MidiTracer
*> _midi_tracer_windows
;
363 /* Transport Control */
365 void detach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
);
366 void reattach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
, int32_t order
);
368 Gtkmm2ext::TearOff
* transport_tearoff
;
369 Gtk::Frame transport_frame
;
370 Gtk::HBox transport_tearoff_hbox
;
371 Gtk::HBox play_range_hbox
;
372 Gtk::VBox play_range_vbox
;
373 Gtk::HBox _editor_transport_box
;
374 Gtk::HBox transport_hbox
;
375 Gtk::Fixed transport_base
;
376 Gtk::Fixed transport_button_base
;
377 Gtk::Frame transport_button_frame
;
378 Gtk::HBox transport_button_hbox
;
379 Gtk::VBox transport_button_vbox
;
380 Gtk::HBox transport_option_button_hbox
;
381 Gtk::VBox transport_option_button_vbox
;
382 Gtk::HBox transport_clock_hbox
;
383 Gtk::VBox transport_clock_vbox
;
384 Gtk::HBox primary_clock_hbox
;
385 Gtk::HBox secondary_clock_hbox
;
388 struct TransportControllable
: public PBD::Controllable
{
401 TransportControllable (std::string name
, ARDOUR_UI
&, ToggleType
);
402 void set_value (double);
403 double get_value (void) const;
405 void set_id (const std::string
&);
411 boost::shared_ptr
<TransportControllable
> roll_controllable
;
412 boost::shared_ptr
<TransportControllable
> stop_controllable
;
413 boost::shared_ptr
<TransportControllable
> goto_start_controllable
;
414 boost::shared_ptr
<TransportControllable
> goto_end_controllable
;
415 boost::shared_ptr
<TransportControllable
> auto_loop_controllable
;
416 boost::shared_ptr
<TransportControllable
> play_selection_controllable
;
417 boost::shared_ptr
<TransportControllable
> rec_controllable
;
418 boost::shared_ptr
<TransportControllable
> shuttle_controllable
;
419 BindingProxy shuttle_controller_binding_proxy
;
421 void set_transport_controllable_state (const XMLNode
&);
422 XMLNode
& get_transport_controllable_state ();
424 BindableButton roll_button
;
425 BindableButton stop_button
;
426 BindableButton goto_start_button
;
427 BindableButton goto_end_button
;
428 BindableButton auto_loop_button
;
429 BindableButton play_selection_button
;
430 BindableButton rec_button
;
431 Gtk::ToggleButton join_play_range_button
;
433 void toggle_external_sync ();
434 void toggle_time_master ();
435 void toggle_video_sync ();
437 Gtk::DrawingArea shuttle_box
;
438 Gtk::EventBox speed_display_box
;
439 Gtk::Label speed_display_label
;
440 Gtk::Button shuttle_units_button
;
441 Gtk::ComboBoxText shuttle_style_button
;
442 Gtk::Menu
* shuttle_unit_menu
;
443 Gtk::Menu
* shuttle_style_menu
;
444 float shuttle_max_speed
;
445 Gtk::Menu
* shuttle_context_menu
;
447 void build_shuttle_context_menu ();
448 void show_shuttle_context_menu ();
449 void shuttle_style_changed();
450 void shuttle_unit_clicked ();
451 void set_shuttle_max_speed (float);
452 void update_speed_display ();
453 float last_speed_displayed
;
455 gint
shuttle_box_button_press (GdkEventButton
*);
456 gint
shuttle_box_button_release (GdkEventButton
*);
457 gint
shuttle_box_scroll (GdkEventScroll
*);
458 gint
shuttle_box_motion (GdkEventMotion
*);
459 gint
shuttle_box_expose (GdkEventExpose
*);
460 gint
mouse_shuttle (double x
, bool force
);
461 void use_shuttle_fract (bool force
);
463 bool shuttle_grabbed
;
464 double shuttle_fract
;
466 Gtkmm2ext::StatefulToggleButton punch_in_button
;
467 Gtkmm2ext::StatefulToggleButton punch_out_button
;
468 Gtkmm2ext::StatefulToggleButton auto_return_button
;
469 Gtkmm2ext::StatefulToggleButton auto_play_button
;
470 Gtkmm2ext::StatefulToggleButton auto_input_button
;
471 Gtkmm2ext::StatefulToggleButton click_button
;
472 Gtkmm2ext::StatefulToggleButton time_master_button
;
473 Gtkmm2ext::StatefulToggleButton sync_button
;
475 Gtk::ToggleButton auditioning_alert_button
;
476 Gtk::ToggleButton solo_alert_button
;
480 void solo_blink (bool);
481 void sync_blink (bool);
482 void audition_blink (bool);
484 void soloing_changed (bool);
485 void auditioning_changed (bool);
486 void _auditioning_changed (bool);
488 bool solo_alert_press (GdkEventButton
* ev
);
489 bool audition_alert_press (GdkEventButton
* ev
);
491 void big_clock_value_changed ();
492 void primary_clock_value_changed ();
493 void secondary_clock_value_changed ();
495 /* called by Blink signal */
497 void transport_rec_enable_blink (bool onoff
);
499 Gtk::Menu
* session_popup_menu
;
501 struct RecentSessionModelColumns
: public Gtk::TreeModel::ColumnRecord
{
502 RecentSessionModelColumns() {
506 Gtk::TreeModelColumn
<std::string
> visible_name
;
507 Gtk::TreeModelColumn
<std::string
> fullpath
;
510 RecentSessionModelColumns recent_session_columns
;
511 Gtk::TreeView recent_session_display
;
512 Glib::RefPtr
<Gtk::TreeStore
> recent_session_model
;
514 ArdourDialog
* session_selector_window
;
515 Gtk::FileChooserDialog
* open_session_selector
;
517 void build_session_selector();
518 void redisplay_recent_sessions();
519 void recent_session_row_activated (const Gtk::TreePath
& path
, Gtk::TreeViewColumn
* col
);
521 struct RecentSessionsSorter
{
522 bool operator() (std::pair
<std::string
,std::string
> a
, std::pair
<std::string
,std::string
> b
) const {
523 return cmp_nocase(a
.first
, b
.first
) == -1;
527 /* menu bar and associated stuff */
529 Gtk::MenuBar
* menu_bar
;
530 Gtk::EventBox menu_bar_base
;
533 void use_menubar_as_top_menubar ();
534 void build_menu_bar ();
536 Gtk::Label wall_clock_label
;
537 Gtk::EventBox wall_clock_box
;
538 gint
update_wall_clock ();
540 Gtk::Label disk_space_label
;
541 Gtk::EventBox disk_space_box
;
542 void update_disk_space ();
544 Gtk::Label cpu_load_label
;
545 Gtk::EventBox cpu_load_box
;
546 void update_cpu_load ();
548 Gtk::Label buffer_load_label
;
549 Gtk::EventBox buffer_load_box
;
550 void update_buffer_load ();
552 Gtk::Label sample_rate_label
;
553 Gtk::EventBox sample_rate_box
;
554 void update_sample_rate (ARDOUR::framecnt_t
);
556 gint
every_second ();
557 gint
every_point_one_seconds ();
558 gint
every_point_zero_one_seconds ();
560 sigc::connection second_connection
;
561 sigc::connection point_one_second_connection
;
562 sigc::connection point_oh_five_second_connection
;
563 sigc::connection point_zero_one_second_connection
;
565 gint
session_menu (GdkEventButton
*);
567 bool _will_create_new_session_automatically
;
569 void open_session ();
570 void open_recent_session ();
571 void save_template ();
573 void edit_metadata ();
574 void import_metadata ();
576 void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode
, ARDOUR::RouteGroup
*, uint32_t, std::string
const &);
577 void session_add_midi_route (bool, ARDOUR::RouteGroup
*, uint32_t, std::string
const &);
579 void set_transport_sensitivity (bool);
581 void remove_last_capture ();
583 void transport_goto_zero ();
584 void transport_goto_start ();
585 void transport_goto_end ();
586 void transport_goto_wallclock ();
587 void transport_stop ();
588 void transport_stop_and_forget_capture ();
589 void transport_record (bool roll
);
590 void transport_roll ();
591 void transport_play_selection();
592 void transport_forward (int option
);
593 void transport_rewind (int option
);
594 void transport_loop ();
595 void toggle_roll (bool with_abort
, bool roll_out_of_bounded_mode
);
597 bool _session_is_new
;
598 void set_session (ARDOUR::Session
*);
599 void connect_dependents_to_session (ARDOUR::Session
*);
600 void we_have_dependents ();
602 void setup_session_options ();
604 guint32 last_key_press_time
;
606 void snapshot_session (bool switch_to_it
);
611 PublicEditor
*editor
;
612 int create_editor ();
614 RouteParams_UI
*route_params
;
615 int create_route_params ();
617 BundleManager
*bundle_manager
;
618 void create_bundle_manager ();
620 ActionWindowProxy
<LocationUIWindow
>* location_ui
;
621 int create_location_ui ();
622 void handle_locations_change (ARDOUR::Location
*);
624 ActionWindowProxy
<GlobalPortMatrixWindow
>* _global_port_matrix
[ARDOUR::DataType::num_types
];
625 void toggle_global_port_matrix (ARDOUR::DataType
);
627 static UIConfiguration
*ui_config
;
628 ThemeManager
*theme_manager
;
630 /* Key bindings editor */
632 KeyEditor
*key_editor
;
634 /* RC Options window */
636 RCOptionEditor
*rc_option_editor
;
638 SessionOptionEditor
*session_option_editor
;
642 AddRouteDialog
*add_route_dialog
;
644 /* Keyboard Handling */
646 ArdourKeyboard
* keyboard
;
648 /* Keymap handling */
650 void install_actions ();
652 void toggle_record_enable (uint32_t);
654 uint32_t rec_enabled_streams
;
655 void count_recenabled_streams (ARDOUR::Route
&);
659 void pop_back_splash ();
663 Gtk::MenuItem
*cleanup_item
;
665 void display_cleanup_results (ARDOUR::CleanupReport
& rep
, const gchar
* list_title
,
666 const std::string
& plural_msg
, const std::string
& singular_msg
);
670 bool have_configure_timeout
;
671 ARDOUR::microseconds_t last_configure_time
;
672 gint
configure_timeout ();
674 ARDOUR::microseconds_t last_peak_grab
;
675 ARDOUR::microseconds_t last_shuttle_request
;
677 bool have_disk_speed_dialog_displayed
;
678 void disk_speed_dialog_gone (int ignored_response
, Gtk::MessageDialog
*);
679 void disk_overrun_handler ();
680 void disk_underrun_handler ();
682 void session_dialog (std::string
);
683 int pending_state_dialog ();
684 int sr_mismatch_dialog (ARDOUR::framecnt_t
, ARDOUR::framecnt_t
);
686 void disconnect_from_jack ();
687 void reconnect_to_jack ();
688 void set_jack_buffer_size (ARDOUR::pframes_t
);
690 Gtk::MenuItem
* jack_disconnect_item
;
691 Gtk::MenuItem
* jack_reconnect_item
;
692 Gtk::Menu
* jack_bufsize_menu
;
694 Glib::RefPtr
<Gtk::ActionGroup
> common_actions
;
696 void editor_realized ();
698 std::vector
<std::string
> positional_sync_strings
;
700 void toggle_send_midi_feedback ();
701 void toggle_use_mmc ();
702 void toggle_send_mmc ();
703 void toggle_send_mtc ();
704 void toggle_send_midi_clock ();
706 void toggle_use_osc ();
708 void parameter_changed (std::string
);
712 void no_memory_warning ();
713 void check_memory_locking ();
715 bool check_audioengine();
716 void audioengine_setup ();
718 void display_message (const char *prefix
, gint prefix_len
,
719 Glib::RefPtr
<Gtk::TextBuffer::Tag
> ptag
, Glib::RefPtr
<Gtk::TextBuffer::Tag
> mtag
,
721 Gtk::Label status_bar_label
;
722 bool status_bar_button_press (GdkEventButton
*);
723 Gtk::ToggleButton error_log_button
;
725 void loading_message (const std::string
& msg
);
726 void end_loading_messages ();
728 void platform_specific ();
729 void platform_setup ();
730 void fontconfig_dialog ();
731 void toggle_translations ();
733 PBD::ScopedConnectionList forever_connections
;
735 void step_edit_status_change (bool);
737 /* these are used only in response to a platform-specific "ShouldQuit" signal
740 void queue_finish ();
742 std::list
<WindowProxyBase
*> _window_proxies
;
744 int missing_file (ARDOUR::Session
*s
, std::string str
, ARDOUR::DataType type
);
745 int ambiguous_file (std::string file
, std::string path
, std::vector
<std::string
> hits
);
747 bool click_button_clicked (GdkEventButton
*);
750 #endif /* __ardour_gui_h__ */