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 class ARDOUR_UI
: public Gtkmm2ext::UI
, public ARDOUR::SessionHandlePtr
108 ARDOUR_UI (int *argcp
, char **argvp
[]);
111 bool run_startup (bool should_be_new
, std::string load_template
);
117 void launch_manual ();
118 void launch_reference ();
122 void idle_load (const std::string
& path
);
125 int load_session (const std::string
& path
, const std::string
& snapshot
, std::string mix_template
= std::string());
127 int build_session (const std::string
& path
, const std::string
& snapshot
, ARDOUR::BusProfile
&);
128 bool session_is_new() const { return _session_is_new
; }
130 ARDOUR::Session
* the_session() { return _session
; }
132 bool will_create_new_session_automatically() const {
133 return _will_create_new_session_automatically
;
136 void set_will_create_new_session_automatically (bool yn
) {
137 _will_create_new_session_automatically
= yn
;
140 int get_session_parameters (bool quit_on_cancel
, bool should_be_new
= false, std::string load_template
= "");
141 void parse_cmdline_path (const std::string
& cmdline_path
, std::string
& session_name
, std::string
& session_path
, bool& existing_session
);
142 int load_cmdline_session (const std::string
& session_name
, const std::string
& session_path
, bool& existing_session
);
143 int build_session_from_nsd (const std::string
& session_name
, const std::string
& session_path
);
144 bool ask_about_loading_existing_session (const std::string
& session_path
);
146 /// @return true if session was successfully unloaded.
147 int unload_session (bool hide_stuff
= false);
148 void close_session();
150 int save_state_canfail (std::string state_name
= "", bool switch_to_it
= false);
151 void save_state (const std::string
& state_name
= "", bool switch_to_it
= false);
153 static double gain_to_slider_position (ARDOUR::gain_t g
);
154 static ARDOUR::gain_t
slider_position_to_gain (double pos
);
156 static ARDOUR_UI
*instance () { return theArdourUI
; }
157 static UIConfiguration
*config () { return ui_config
; }
159 PublicEditor
& the_editor(){return *editor
;}
160 Mixer_UI
* the_mixer() { return mixer
; }
162 void toggle_key_editor ();
163 void toggle_location_window ();
164 void toggle_theme_manager ();
165 void toggle_bundle_manager ();
166 void toggle_big_clock_window ();
167 void new_midi_tracer_window ();
168 void toggle_route_params_window ();
169 void toggle_editing_space();
170 void toggle_keep_tearoffs();
172 Gtk::Tooltips
& tooltips() { return _tooltips
; }
174 static sigc::signal
<void,bool> Blink
;
175 static sigc::signal
<void> RapidScreenUpdate
;
176 static sigc::signal
<void> SuperRapidScreenUpdate
;
177 /** Emitted frequently with the audible frame, false, and the edit point as
178 * parameters respectively.
180 static sigc::signal
<void, framepos_t
, bool, framepos_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 (framepos_t
, bool);
191 void halt_on_xrun_message ();
192 void xrun_handler (framepos_t
);
193 void create_xrun_marker (framepos_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, input_channels
, output_channels
, mode
, route_group
, how_many
);
212 void session_add_audio_bus (int input_channels
, int32_t output_channels
, ARDOUR::RouteGroup
* route_group
, uint32_t how_many
) {
213 session_add_audio_route (false, 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_mixer_window ();
270 void toggle_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
);
310 Gtk::VBox top_packer
;
312 sigc::connection clock_signal_connection
;
313 void update_clocks ();
314 void start_clocking ();
315 void stop_clocking ();
317 void manage_window (Gtk::Window
&);
319 AudioClock big_clock
;
320 ActionWindowProxy
<Gtk::Window
>* big_clock_window
;
321 int original_big_clock_width
;
322 int original_big_clock_height
;
323 double original_big_clock_font_size
;
325 void big_clock_size_allocate (Gtk::Allocation
&);
326 bool idle_big_clock_text_resizer (int width
, int height
);
327 void big_clock_realized ();
328 bool big_clock_resize_in_progress
;
329 int big_clock_height
;
331 void float_big_clock (Gtk::Window
* parent
);
332 bool main_window_state_event_handler (GdkEventWindowState
*, bool window_was_editor
);
334 void update_transport_clocks (framepos_t pos
);
335 void record_state_changed ();
337 std::list
<MidiTracer
*> _midi_tracer_windows
;
339 /* Transport Control */
341 void detach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
);
342 void reattach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
, int32_t order
);
344 Gtkmm2ext::TearOff
* transport_tearoff
;
345 Gtk::Frame transport_frame
;
346 Gtk::HBox transport_tearoff_hbox
;
347 Gtk::HBox play_range_hbox
;
348 Gtk::VBox play_range_vbox
;
349 Gtk::HBox transport_hbox
;
350 Gtk::Fixed transport_base
;
351 Gtk::Fixed transport_button_base
;
352 Gtk::Frame transport_button_frame
;
353 Gtk::HBox transport_button_hbox
;
354 Gtk::VBox transport_button_vbox
;
355 Gtk::HBox transport_option_button_hbox
;
356 Gtk::VBox transport_option_button_vbox
;
357 Gtk::HBox transport_clock_hbox
;
358 Gtk::VBox transport_clock_vbox
;
359 Gtk::HBox primary_clock_hbox
;
360 Gtk::HBox secondary_clock_hbox
;
363 struct TransportControllable
: public PBD::Controllable
{
376 TransportControllable (std::string name
, ARDOUR_UI
&, ToggleType
);
377 void set_value (double);
378 double get_value (void) const;
380 void set_id (const std::string
&);
386 boost::shared_ptr
<TransportControllable
> roll_controllable
;
387 boost::shared_ptr
<TransportControllable
> stop_controllable
;
388 boost::shared_ptr
<TransportControllable
> goto_start_controllable
;
389 boost::shared_ptr
<TransportControllable
> goto_end_controllable
;
390 boost::shared_ptr
<TransportControllable
> auto_loop_controllable
;
391 boost::shared_ptr
<TransportControllable
> play_selection_controllable
;
392 boost::shared_ptr
<TransportControllable
> rec_controllable
;
393 boost::shared_ptr
<TransportControllable
> shuttle_controllable
;
394 BindingProxy shuttle_controller_binding_proxy
;
396 void set_transport_controllable_state (const XMLNode
&);
397 XMLNode
& get_transport_controllable_state ();
399 BindableButton roll_button
;
400 BindableButton stop_button
;
401 BindableButton goto_start_button
;
402 BindableButton goto_end_button
;
403 BindableButton auto_loop_button
;
404 BindableButton play_selection_button
;
405 BindableButton rec_button
;
406 Gtk::ToggleButton join_play_range_button
;
408 void toggle_external_sync ();
409 void toggle_time_master ();
410 void toggle_video_sync ();
412 Gtk::DrawingArea shuttle_box
;
413 Gtk::EventBox speed_display_box
;
414 Gtk::Label speed_display_label
;
415 Gtk::Button shuttle_units_button
;
416 Gtk::ComboBoxText shuttle_style_button
;
417 Gtk::Menu
* shuttle_unit_menu
;
418 Gtk::Menu
* shuttle_style_menu
;
419 float shuttle_max_speed
;
420 Gtk::Menu
* shuttle_context_menu
;
422 void build_shuttle_context_menu ();
423 void show_shuttle_context_menu ();
424 void shuttle_style_changed();
425 void shuttle_unit_clicked ();
426 void set_shuttle_max_speed (float);
427 void update_speed_display ();
428 float last_speed_displayed
;
430 gint
shuttle_box_button_press (GdkEventButton
*);
431 gint
shuttle_box_button_release (GdkEventButton
*);
432 gint
shuttle_box_scroll (GdkEventScroll
*);
433 gint
shuttle_box_motion (GdkEventMotion
*);
434 gint
shuttle_box_expose (GdkEventExpose
*);
435 gint
mouse_shuttle (double x
, bool force
);
436 void use_shuttle_fract (bool force
);
438 bool shuttle_grabbed
;
439 double shuttle_fract
;
441 Gtkmm2ext::StatefulToggleButton punch_in_button
;
442 Gtkmm2ext::StatefulToggleButton punch_out_button
;
443 Gtkmm2ext::StatefulToggleButton auto_return_button
;
444 Gtkmm2ext::StatefulToggleButton auto_play_button
;
445 Gtkmm2ext::StatefulToggleButton auto_input_button
;
446 Gtkmm2ext::StatefulToggleButton click_button
;
447 Gtkmm2ext::StatefulToggleButton time_master_button
;
448 Gtkmm2ext::StatefulToggleButton sync_button
;
450 Gtk::ToggleButton auditioning_alert_button
;
451 Gtk::ToggleButton solo_alert_button
;
455 void solo_blink (bool);
456 void sync_blink (bool);
457 void audition_blink (bool);
459 void soloing_changed (bool);
460 void auditioning_changed (bool);
461 void _auditioning_changed (bool);
463 bool solo_alert_press (GdkEventButton
* ev
);
464 bool audition_alert_press (GdkEventButton
* ev
);
466 void big_clock_value_changed ();
467 void primary_clock_value_changed ();
468 void secondary_clock_value_changed ();
470 /* called by Blink signal */
472 void transport_rec_enable_blink (bool onoff
);
474 Gtk::Menu
* session_popup_menu
;
476 struct RecentSessionModelColumns
: public Gtk::TreeModel::ColumnRecord
{
477 RecentSessionModelColumns() {
481 Gtk::TreeModelColumn
<std::string
> visible_name
;
482 Gtk::TreeModelColumn
<std::string
> fullpath
;
485 RecentSessionModelColumns recent_session_columns
;
486 Gtk::TreeView recent_session_display
;
487 Glib::RefPtr
<Gtk::TreeStore
> recent_session_model
;
489 ArdourDialog
* session_selector_window
;
490 Gtk::FileChooserDialog
* open_session_selector
;
492 void build_session_selector();
493 void redisplay_recent_sessions();
494 void recent_session_row_activated (const Gtk::TreePath
& path
, Gtk::TreeViewColumn
* col
);
496 struct RecentSessionsSorter
{
497 bool operator() (std::pair
<std::string
,std::string
> a
, std::pair
<std::string
,std::string
> b
) const {
498 return cmp_nocase(a
.first
, b
.first
) == -1;
502 /* menu bar and associated stuff */
504 Gtk::MenuBar
* menu_bar
;
505 Gtk::EventBox menu_bar_base
;
508 void use_menubar_as_top_menubar ();
509 void build_menu_bar ();
511 Gtk::Label wall_clock_label
;
512 Gtk::EventBox wall_clock_box
;
513 gint
update_wall_clock ();
515 Gtk::Label disk_space_label
;
516 Gtk::EventBox disk_space_box
;
517 void update_disk_space ();
519 Gtk::Label cpu_load_label
;
520 Gtk::EventBox cpu_load_box
;
521 void update_cpu_load ();
523 Gtk::Label buffer_load_label
;
524 Gtk::EventBox buffer_load_box
;
525 void update_buffer_load ();
527 Gtk::Label sample_rate_label
;
528 Gtk::EventBox sample_rate_box
;
529 void update_sample_rate (ARDOUR::framecnt_t
);
531 gint
every_second ();
532 gint
every_point_one_seconds ();
533 gint
every_point_zero_one_seconds ();
535 sigc::connection second_connection
;
536 sigc::connection point_one_second_connection
;
537 sigc::connection point_oh_five_second_connection
;
538 sigc::connection point_zero_one_second_connection
;
540 gint
session_menu (GdkEventButton
*);
542 bool _will_create_new_session_automatically
;
544 void open_session ();
545 void open_recent_session ();
546 void save_template ();
548 void edit_metadata ();
549 void import_metadata ();
551 void session_add_audio_route (bool disk
, int32_t input_channels
, int32_t output_channels
, ARDOUR::TrackMode mode
, ARDOUR::RouteGroup
*, uint32_t how_many
);
552 void session_add_midi_route (bool disk
, ARDOUR::RouteGroup
*, uint32_t how_many
);
554 void set_transport_sensitivity (bool);
556 void remove_last_capture ();
558 void transport_goto_zero ();
559 void transport_goto_start ();
560 void transport_goto_end ();
561 void transport_goto_wallclock ();
562 void transport_stop ();
563 void transport_stop_and_forget_capture ();
564 void transport_record (bool roll
);
565 void transport_roll ();
566 void transport_play_selection();
567 void transport_forward (int option
);
568 void transport_rewind (int option
);
569 void transport_loop ();
570 void toggle_roll (bool with_abort
, bool roll_out_of_bounded_mode
);
572 bool _session_is_new
;
573 void set_session (ARDOUR::Session
*);
574 void connect_dependents_to_session (ARDOUR::Session
*);
575 void we_have_dependents ();
577 void setup_session_options ();
579 guint32 last_key_press_time
;
581 void snapshot_session (bool switch_to_it
);
586 PublicEditor
*editor
;
587 int create_editor ();
589 RouteParams_UI
*route_params
;
590 int create_route_params ();
592 BundleManager
*bundle_manager
;
593 void create_bundle_manager ();
595 ActionWindowProxy
<LocationUIWindow
>* location_ui
;
596 int create_location_ui ();
597 void handle_locations_change (ARDOUR::Location
*);
599 ActionWindowProxy
<GlobalPortMatrixWindow
>* _global_port_matrix
[ARDOUR::DataType::num_types
];
600 void toggle_global_port_matrix (ARDOUR::DataType
);
602 static UIConfiguration
*ui_config
;
603 ThemeManager
*theme_manager
;
605 /* Key bindings editor */
607 KeyEditor
*key_editor
;
609 /* RC Options window */
611 RCOptionEditor
*rc_option_editor
;
613 SessionOptionEditor
*session_option_editor
;
617 AddRouteDialog
*add_route_dialog
;
619 /* Keyboard Handling */
621 ArdourKeyboard
* keyboard
;
623 /* Keymap handling */
625 void install_actions ();
627 void toggle_record_enable (uint32_t);
629 uint32_t rec_enabled_streams
;
630 void count_recenabled_streams (ARDOUR::Route
&);
634 void pop_back_splash ();
638 Gtk::MenuItem
*cleanup_item
;
640 void display_cleanup_results (ARDOUR::CleanupReport
& rep
, const gchar
* list_title
,
641 const std::string
& plural_msg
, const std::string
& singular_msg
);
645 bool have_configure_timeout
;
646 ARDOUR::microseconds_t last_configure_time
;
647 gint
configure_timeout ();
649 ARDOUR::microseconds_t last_peak_grab
;
650 ARDOUR::microseconds_t last_shuttle_request
;
652 bool have_disk_speed_dialog_displayed
;
653 void disk_speed_dialog_gone (int ignored_response
, Gtk::MessageDialog
*);
654 void disk_overrun_handler ();
655 void disk_underrun_handler ();
657 void session_dialog (std::string
);
658 int pending_state_dialog ();
659 int sr_mismatch_dialog (ARDOUR::framecnt_t
, ARDOUR::framecnt_t
);
661 void disconnect_from_jack ();
662 void reconnect_to_jack ();
663 void set_jack_buffer_size (ARDOUR::pframes_t
);
665 Gtk::MenuItem
* jack_disconnect_item
;
666 Gtk::MenuItem
* jack_reconnect_item
;
667 Gtk::Menu
* jack_bufsize_menu
;
669 Glib::RefPtr
<Gtk::ActionGroup
> common_actions
;
671 void editor_realized ();
673 std::vector
<std::string
> positional_sync_strings
;
675 void toggle_send_midi_feedback ();
676 void toggle_use_mmc ();
677 void toggle_send_mmc ();
678 void toggle_send_mtc ();
679 void toggle_send_midi_clock ();
681 void toggle_use_osc ();
683 void parameter_changed (std::string
);
687 void no_memory_warning ();
688 void check_memory_locking ();
690 bool check_audioengine();
691 void audioengine_setup ();
693 void display_message (const char *prefix
, gint prefix_len
,
694 Glib::RefPtr
<Gtk::TextBuffer::Tag
> ptag
, Glib::RefPtr
<Gtk::TextBuffer::Tag
> mtag
,
696 Gtk::Label status_bar_label
;
697 bool status_bar_button_press (GdkEventButton
*);
698 Gtk::ToggleButton error_log_button
;
700 void loading_message (const std::string
& msg
);
701 void end_loading_messages ();
703 void platform_specific ();
704 void platform_setup ();
705 void fontconfig_dialog ();
706 void toggle_translations ();
708 PBD::ScopedConnectionList forever_connections
;
710 void step_edit_status_change (bool);
712 /* these are used only in response to a platform-specific "ShouldQuit" signal
715 void queue_finish ();
717 std::list
<WindowProxyBase
*> _window_proxies
;
719 int missing_file (ARDOUR::Session
*s
, std::string str
, ARDOUR::DataType type
);
720 int ambiguous_file (std::string file
, std::string path
, std::vector
<std::string
> hits
);
723 #endif /* __ardour_gui_h__ */