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"
77 class ConnectionEditor
;
79 class LocationUIWindow
;
84 class SessionOptionEditor
;
94 class ControlProtocolInfo
;
102 extern sigc::signal
<void> ColorsChanged
;
103 extern sigc::signal
<void> DPIReset
;
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
);
114 bool shown() { return shown_flag
; }
123 void idle_load (const Glib::ustring
& path
);
126 int load_session (const Glib::ustring
& path
, const Glib::ustring
& snapshot
, Glib::ustring mix_template
= Glib::ustring());
128 int build_session (const Glib::ustring
& path
, const Glib::ustring
& 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 Glib::ustring
& cmdline_path
, Glib::ustring
& session_name
, Glib::ustring
& session_path
, bool& existing_session
);
143 int load_cmdline_session (const Glib::ustring
& session_name
, const Glib::ustring
& session_path
, bool& existing_session
);
144 int build_session_from_nsd (const Glib::ustring
& session_name
, const Glib::ustring
& session_path
);
145 bool ask_about_loading_existing_session (const Glib::ustring
& 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 double gain_to_slider_position (ARDOUR::gain_t g
);
155 static ARDOUR::gain_t
slider_position_to_gain (double pos
);
157 static ARDOUR_UI
*instance () { return theArdourUI
; }
158 static UIConfiguration
*config () { return ui_config
; }
160 PublicEditor
& the_editor(){return *editor
;}
161 Mixer_UI
* the_mixer() { return mixer
; }
163 void toggle_key_editor ();
164 void toggle_location_window ();
165 void toggle_theme_manager ();
166 void toggle_bundle_manager ();
167 void toggle_big_clock_window ();
168 void new_midi_tracer_window ();
169 void toggle_route_params_window ();
170 void toggle_editing_space();
171 void toggle_keep_tearoffs();
173 Gtk::Tooltips
& tooltips() { return _tooltips
; }
175 static sigc::signal
<void,bool> Blink
;
176 static sigc::signal
<void> RapidScreenUpdate
;
177 static sigc::signal
<void> SuperRapidScreenUpdate
;
178 static sigc::signal
<void,nframes_t
, bool, nframes_t
> Clock
;
180 XMLNode
* editor_settings() const;
181 XMLNode
* mixer_settings () const;
182 XMLNode
* keyboard_settings () const;
183 XMLNode
* tearoff_settings (const char*) const;
185 void save_ardour_state ();
186 gboolean
configure_handler (GdkEventConfigure
* conf
);
188 void do_transport_locate (nframes_t position
);
189 void halt_on_xrun_message ();
190 void xrun_handler (nframes_t
);
191 void create_xrun_marker (nframes_t
);
193 AudioClock primary_clock
;
194 AudioClock secondary_clock
;
195 AudioClock preroll_clock
;
196 AudioClock postroll_clock
;
198 void store_clock_modes ();
199 void restore_clock_modes ();
200 void reset_main_clocks ();
202 void add_route (Gtk::Window
* float_window
);
204 void session_add_audio_track (int input_channels
, int32_t output_channels
, ARDOUR::TrackMode mode
, ARDOUR::RouteGroup
* route_group
, uint32_t how_many
) {
205 session_add_audio_route (true, false, input_channels
, output_channels
, mode
, route_group
, how_many
);
208 void session_add_audio_bus (bool aux
, int input_channels
, int32_t output_channels
, ARDOUR::RouteGroup
* route_group
, uint32_t how_many
) {
209 session_add_audio_route (false, aux
, input_channels
, output_channels
, ARDOUR::Normal
, route_group
, how_many
);
212 void session_add_midi_track (ARDOUR::RouteGroup
* route_group
, uint32_t how_many
) {
213 session_add_midi_route (true, route_group
, how_many
);
216 /*void session_add_midi_bus () {
217 session_add_midi_route (false);
220 int create_engine ();
223 gint
exit_on_main_window_close (GdkEventAny
*);
225 void maximise_editing_space ();
226 void restore_editing_space ();
228 void setup_profile ();
230 void setup_tooltips ();
232 void set_shuttle_fract (double);
235 friend class PublicEditor
;
237 void toggle_clocking ();
238 void toggle_auto_play ();
239 void toggle_auto_input ();
240 void toggle_punch ();
241 void unset_dual_punch ();
242 bool ignore_dual_punch
;
243 void toggle_punch_in ();
244 void toggle_punch_out ();
245 void show_loop_punch_ruler_and_disallow_hide ();
246 void reenable_hide_loop_punch_ruler_if_appropriate ();
247 void toggle_auto_return ();
248 void toggle_click ();
250 void toggle_session_auto_loop ();
252 void toggle_rc_options_window ();
253 void toggle_session_options_window ();
256 ArdourStartup
* _startup
;
257 ARDOUR::AudioEngine
*engine
;
258 Gtk::Tooltips _tooltips
;
260 void goto_editor_window ();
261 void goto_mixer_window ();
262 void toggle_editor_mixer_on_top ();
265 Gtk::ToggleButton preroll_button
;
266 Gtk::ToggleButton postroll_button
;
268 int setup_windows ();
269 void setup_transport ();
272 static ARDOUR_UI
*theArdourUI
;
274 void backend_audio_error (bool we_set_params
, Gtk::Window
* toplevel
= 0);
278 int ask_about_saving_session (const std::string
& why
);
280 /* periodic safety backup, to be precise */
281 gint
autosave_session();
282 void update_autosave();
283 sigc::connection _autosave_connection
;
285 void map_transport_state ();
286 int32_t do_engine_start ();
288 void engine_halted (const char* reason
, bool free_reason
);
289 void engine_stopped ();
290 void engine_running ();
294 static gint
_blink (void *);
296 gint blink_timeout_tag
;
298 void start_blinking ();
299 void stop_blinking ();
301 void about_signal_response(int response
);
304 Gtk::VBox top_packer
;
306 sigc::connection clock_signal_connection
;
307 void update_clocks ();
308 void start_clocking ();
309 void stop_clocking ();
311 void manage_window (Gtk::Window
&);
313 AudioClock big_clock
;
314 Gtk::Window
* big_clock_window
;
315 int original_big_clock_width
;
316 int original_big_clock_height
;
317 double original_big_clock_font_size
;
319 void big_clock_size_allocate (Gtk::Allocation
&);
320 bool idle_big_clock_text_resizer (int width
, int height
);
321 void big_clock_realized ();
322 bool big_clock_resize_in_progress
;
323 int big_clock_height
;
325 void float_big_clock (Gtk::Window
* parent
);
326 bool main_window_state_event_handler (GdkEventWindowState
*, bool window_was_editor
);
328 void update_transport_clocks (nframes_t pos
);
329 void record_state_changed ();
331 std::list
<MidiTracer
*> _midi_tracer_windows
;
333 /* Transport Control */
335 void detach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
);
336 void reattach_tearoff (Gtk::Box
* parent
, Gtk::Widget
* contents
, int32_t order
);
338 Gtkmm2ext::TearOff
* transport_tearoff
;
339 Gtk::Frame transport_frame
;
340 Gtk::HBox transport_tearoff_hbox
;
341 Gtk::HBox play_range_hbox
;
342 Gtk::VBox play_range_vbox
;
343 Gtk::HBox transport_hbox
;
344 Gtk::Fixed transport_base
;
345 Gtk::Fixed transport_button_base
;
346 Gtk::Frame transport_button_frame
;
347 Gtk::HBox transport_button_hbox
;
348 Gtk::VBox transport_button_vbox
;
349 Gtk::HBox transport_option_button_hbox
;
350 Gtk::VBox transport_option_button_vbox
;
351 Gtk::HBox transport_clock_hbox
;
352 Gtk::VBox transport_clock_vbox
;
353 Gtk::HBox primary_clock_hbox
;
354 Gtk::HBox secondary_clock_hbox
;
357 struct TransportControllable
: public PBD::Controllable
{
370 TransportControllable (std::string name
, ARDOUR_UI
&, ToggleType
);
371 void set_value (double);
372 double get_value (void) const;
374 void set_id (const std::string
&);
380 boost::shared_ptr
<TransportControllable
> roll_controllable
;
381 boost::shared_ptr
<TransportControllable
> stop_controllable
;
382 boost::shared_ptr
<TransportControllable
> goto_start_controllable
;
383 boost::shared_ptr
<TransportControllable
> goto_end_controllable
;
384 boost::shared_ptr
<TransportControllable
> auto_loop_controllable
;
385 boost::shared_ptr
<TransportControllable
> play_selection_controllable
;
386 boost::shared_ptr
<TransportControllable
> rec_controllable
;
387 boost::shared_ptr
<TransportControllable
> shuttle_controllable
;
388 BindingProxy shuttle_controller_binding_proxy
;
390 void set_transport_controllable_state (const XMLNode
&);
391 XMLNode
& get_transport_controllable_state ();
393 BindableButton roll_button
;
394 BindableButton stop_button
;
395 BindableButton goto_start_button
;
396 BindableButton goto_end_button
;
397 BindableButton auto_loop_button
;
398 BindableButton play_selection_button
;
399 BindableButton rec_button
;
400 Gtk::ToggleButton join_play_range_button
;
402 void toggle_external_sync ();
403 void toggle_time_master ();
404 void toggle_video_sync ();
406 Gtk::DrawingArea shuttle_box
;
407 Gtk::EventBox speed_display_box
;
408 Gtk::Label speed_display_label
;
409 Gtk::Button shuttle_units_button
;
410 Gtk::ComboBoxText shuttle_style_button
;
411 Gtk::Menu
* shuttle_unit_menu
;
412 Gtk::Menu
* shuttle_style_menu
;
413 float shuttle_max_speed
;
414 Gtk::Menu
* shuttle_context_menu
;
416 void build_shuttle_context_menu ();
417 void show_shuttle_context_menu ();
418 void shuttle_style_changed();
419 void shuttle_unit_clicked ();
420 void set_shuttle_max_speed (float);
421 void update_speed_display ();
422 float last_speed_displayed
;
424 gint
shuttle_box_button_press (GdkEventButton
*);
425 gint
shuttle_box_button_release (GdkEventButton
*);
426 gint
shuttle_box_scroll (GdkEventScroll
*);
427 gint
shuttle_box_motion (GdkEventMotion
*);
428 gint
shuttle_box_expose (GdkEventExpose
*);
429 gint
mouse_shuttle (double x
, bool force
);
430 void use_shuttle_fract (bool force
);
432 bool shuttle_grabbed
;
433 double shuttle_fract
;
435 Gtkmm2ext::StatefulToggleButton punch_in_button
;
436 Gtkmm2ext::StatefulToggleButton punch_out_button
;
437 Gtkmm2ext::StatefulToggleButton auto_return_button
;
438 Gtkmm2ext::StatefulToggleButton auto_play_button
;
439 Gtkmm2ext::StatefulToggleButton auto_input_button
;
440 Gtkmm2ext::StatefulToggleButton click_button
;
441 Gtkmm2ext::StatefulToggleButton time_master_button
;
442 Gtkmm2ext::StatefulToggleButton sync_button
;
444 Gtk::ToggleButton auditioning_alert_button
;
445 Gtk::ToggleButton solo_alert_button
;
449 void solo_blink (bool);
450 void sync_blink (bool);
451 void audition_blink (bool);
453 void soloing_changed (bool);
454 void auditioning_changed (bool);
455 void _auditioning_changed (bool);
457 bool solo_alert_press (GdkEventButton
* ev
);
458 bool audition_alert_press (GdkEventButton
* ev
);
460 void big_clock_value_changed ();
461 void primary_clock_value_changed ();
462 void secondary_clock_value_changed ();
464 /* called by Blink signal */
466 void transport_rec_enable_blink (bool onoff
);
468 Gtk::Menu
* session_popup_menu
;
470 struct RecentSessionModelColumns
: public Gtk::TreeModel::ColumnRecord
{
471 RecentSessionModelColumns() {
475 Gtk::TreeModelColumn
<Glib::ustring
> visible_name
;
476 Gtk::TreeModelColumn
<Glib::ustring
> fullpath
;
479 RecentSessionModelColumns recent_session_columns
;
480 Gtk::TreeView recent_session_display
;
481 Glib::RefPtr
<Gtk::TreeStore
> recent_session_model
;
483 ArdourDialog
* session_selector_window
;
484 Gtk::FileChooserDialog
* open_session_selector
;
486 void build_session_selector();
487 void redisplay_recent_sessions();
488 void recent_session_row_activated (const Gtk::TreePath
& path
, Gtk::TreeViewColumn
* col
);
490 struct RecentSessionsSorter
{
491 bool operator() (std::pair
<std::string
,std::string
> a
, std::pair
<std::string
,std::string
> b
) const {
492 return cmp_nocase(a
.first
, b
.first
) == -1;
496 /* menu bar and associated stuff */
498 Gtk::MenuBar
* menu_bar
;
499 Gtk::EventBox menu_bar_base
;
502 void use_menubar_as_top_menubar ();
503 void build_menu_bar ();
505 Gtk::Label wall_clock_label
;
506 Gtk::EventBox wall_clock_box
;
507 gint
update_wall_clock ();
509 Gtk::Label disk_space_label
;
510 Gtk::EventBox disk_space_box
;
511 void update_disk_space ();
513 Gtk::Label cpu_load_label
;
514 Gtk::EventBox cpu_load_box
;
515 void update_cpu_load ();
517 Gtk::Label buffer_load_label
;
518 Gtk::EventBox buffer_load_box
;
519 void update_buffer_load ();
521 Gtk::Label sample_rate_label
;
522 Gtk::EventBox sample_rate_box
;
523 void update_sample_rate (nframes_t
);
525 gint
every_second ();
526 gint
every_point_one_seconds ();
527 gint
every_point_zero_one_seconds ();
529 sigc::connection second_connection
;
530 sigc::connection point_one_second_connection
;
531 sigc::connection point_oh_five_second_connection
;
532 sigc::connection point_zero_one_second_connection
;
534 gint
session_menu (GdkEventButton
*);
536 bool _will_create_new_session_automatically
;
538 void open_session ();
539 void open_recent_session ();
540 void save_template ();
542 void edit_metadata ();
543 void import_metadata ();
545 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
);
546 void session_add_midi_route (bool disk
, ARDOUR::RouteGroup
*, uint32_t how_many
);
548 void set_transport_sensitivity (bool);
550 void remove_last_capture ();
552 void transport_goto_zero ();
553 void transport_goto_start ();
554 void transport_goto_end ();
555 void transport_goto_wallclock ();
556 void transport_stop ();
557 void transport_stop_and_forget_capture ();
558 void transport_record (bool roll
);
559 void transport_roll ();
560 void transport_play_selection();
561 void transport_forward (int option
);
562 void transport_rewind (int option
);
563 void transport_loop ();
564 void toggle_roll (bool with_abort
, bool roll_out_of_bounded_mode
);
566 bool _session_is_new
;
567 void set_session (ARDOUR::Session
*);
568 void connect_dependents_to_session (ARDOUR::Session
*);
569 void we_have_dependents ();
571 void setup_session_options ();
573 guint32 last_key_press_time
;
575 void snapshot_session (bool switch_to_it
);
580 PublicEditor
*editor
;
581 int create_editor ();
583 RouteParams_UI
*route_params
;
584 int create_route_params ();
586 BundleManager
*bundle_manager
;
587 void create_bundle_manager ();
589 LocationUIWindow
*location_ui
;
590 int create_location_ui ();
591 void handle_locations_change (ARDOUR::Location
*);
593 static UIConfiguration
*ui_config
;
594 ThemeManager
*theme_manager
;
596 /* Key bindings editor */
598 KeyEditor
*key_editor
;
600 /* RC Options window */
602 RCOptionEditor
*rc_option_editor
;
604 SessionOptionEditor
*session_option_editor
;
608 AddRouteDialog
*add_route_dialog
;
610 /* Keyboard Handling */
612 ArdourKeyboard
* keyboard
;
614 /* Keymap handling */
616 void install_actions ();
618 void toggle_record_enable (uint32_t);
620 uint32_t rec_enabled_streams
;
621 void count_recenabled_streams (ARDOUR::Route
&);
625 void pop_back_splash ();
630 Gtk::MenuItem
*cleanup_item
;
632 void display_cleanup_results (ARDOUR::CleanupReport
& rep
, const gchar
* list_title
,
633 const std::string
& plural_msg
, const std::string
& singular_msg
);
637 bool have_configure_timeout
;
638 ARDOUR::microseconds_t last_configure_time
;
639 gint
configure_timeout ();
641 ARDOUR::microseconds_t last_peak_grab
;
642 ARDOUR::microseconds_t last_shuttle_request
;
644 bool have_disk_speed_dialog_displayed
;
645 void disk_speed_dialog_gone (int ignored_response
, Gtk::MessageDialog
*);
646 void disk_overrun_handler ();
647 void disk_underrun_handler ();
649 void session_dialog (std::string
);
650 int pending_state_dialog ();
651 int sr_mismatch_dialog (nframes_t
, nframes_t
);
653 void disconnect_from_jack ();
654 void reconnect_to_jack ();
655 void set_jack_buffer_size (nframes_t
);
657 Gtk::MenuItem
* jack_disconnect_item
;
658 Gtk::MenuItem
* jack_reconnect_item
;
659 Gtk::Menu
* jack_bufsize_menu
;
661 Glib::RefPtr
<Gtk::ActionGroup
> common_actions
;
663 void editor_realized ();
665 std::vector
<std::string
> positional_sync_strings
;
667 void toggle_send_midi_feedback ();
668 void toggle_use_mmc ();
669 void toggle_send_mmc ();
670 void toggle_send_mtc ();
671 void toggle_send_midi_clock ();
673 void toggle_use_osc ();
675 void parameter_changed (std::string
);
679 void no_memory_warning ();
680 void check_memory_locking ();
682 bool check_audioengine();
683 void audioengine_setup ();
685 void display_message (const char *prefix
, gint prefix_len
,
686 Glib::RefPtr
<Gtk::TextBuffer::Tag
> ptag
, Glib::RefPtr
<Gtk::TextBuffer::Tag
> mtag
,
688 Gtk::Label status_bar_label
;
689 bool status_bar_button_press (GdkEventButton
*);
690 Gtk::ToggleButton error_log_button
;
692 void loading_message (const std::string
& msg
);
693 void end_loading_messages ();
695 void platform_specific ();
696 void platform_setup ();
697 void fontconfig_dialog ();
699 PBD::ScopedConnectionList forever_connections
;
701 void step_edit_status_change (bool);
704 #endif /* __ardour_gui_h__ */