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;
93 class ControlProtocolInfo;
101 extern sigc::signal<void> ColorsChanged;
102 extern sigc::signal<void> DPIReset;
104 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
107 ARDOUR_UI (int *argcp, char **argvp[]);
110 bool run_startup (bool should_be_new);
113 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 int get_session_parameters (bool quit_on_cancel, 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);
152 /// @return true if session was successfully unloaded.
153 int unload_session (bool hide_stuff = false);
154 void close_session();
156 int save_state_canfail (std::string state_name = "");
157 void save_state (const std::string & state_name = "");
159 static double gain_to_slider_position (ARDOUR::gain_t g);
160 static ARDOUR::gain_t slider_position_to_gain (double pos);
162 static ARDOUR_UI *instance () { return theArdourUI; }
163 static UIConfiguration *config () { return ui_config; }
165 PublicEditor& the_editor(){return *editor;}
166 Mixer_UI* the_mixer() { return mixer; }
168 void toggle_key_editor ();
169 void toggle_location_window ();
170 void toggle_theme_manager ();
171 void toggle_bundle_manager ();
172 void toggle_big_clock_window ();
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 XMLNode* editor_settings() const;
184 XMLNode* mixer_settings () const;
185 XMLNode* keyboard_settings () const;
187 void save_ardour_state ();
188 gboolean configure_handler (GdkEventConfigure* conf);
190 void do_transport_locate (nframes_t position);
191 void halt_on_xrun_message ();
192 void xrun_handler (nframes_t);
193 void create_xrun_marker (nframes_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 add_route (Gtk::Window* float_window);
206 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
207 session_add_audio_route (true, false, input_channels, output_channels, mode, route_group, how_many);
210 void session_add_audio_bus (bool aux, int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
211 session_add_audio_route (false, aux, input_channels, output_channels, ARDOUR::Normal, route_group, how_many);
214 void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many) {
215 session_add_midi_route (true, route_group, how_many);
218 /*void session_add_midi_bus () {
219 session_add_midi_route (false);
222 int create_engine ();
225 gint exit_on_main_window_close (GdkEventAny *);
227 void maximise_editing_space ();
228 void restore_editing_space ();
230 void setup_profile ();
232 void setup_tooltips ();
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_rc_options_window ();
255 void toggle_session_options_window ();
258 ArdourStartup* _startup;
259 ARDOUR::AudioEngine *engine;
260 Gtk::Tooltips _tooltips;
262 void goto_editor_window ();
263 void goto_mixer_window ();
264 void toggle_editor_mixer_on_top ();
267 Gtk::ToggleButton preroll_button;
268 Gtk::ToggleButton postroll_button;
270 int setup_windows ();
271 void setup_transport ();
274 static ARDOUR_UI *theArdourUI;
276 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
280 int ask_about_saving_session (const std::string & why);
282 /* periodic safety backup, to be precise */
283 gint autosave_session();
284 void update_autosave();
285 sigc::connection _autosave_connection;
287 void map_transport_state ();
288 int32_t do_engine_start ();
290 void engine_halted ();
291 void engine_stopped ();
292 void engine_running ();
296 static gint _blink (void *);
298 gint blink_timeout_tag;
300 void start_blinking ();
301 void stop_blinking ();
303 void about_signal_response(int response);
306 Gtk::VBox top_packer;
308 sigc::connection clock_signal_connection;
309 void update_clocks ();
310 void start_clocking ();
311 void stop_clocking ();
313 void manage_window (Gtk::Window&);
315 AudioClock big_clock;
316 Gtk::Window* big_clock_window;
317 void big_clock_size_allocate (Gtk::Allocation&);
318 bool idle_big_clock_text_resizer (int width, int height);
319 void big_clock_realized ();
320 bool big_clock_resize_in_progress;
321 int big_clock_height;
323 void float_big_clock (Gtk::Window* parent);
324 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
326 void update_transport_clocks (nframes_t pos);
327 void record_state_changed ();
329 /* Transport Control */
331 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
332 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
334 Gtkmm2ext::TearOff* transport_tearoff;
335 Gtk::Frame transport_frame;
336 Gtk::HBox transport_tearoff_hbox;
337 Gtk::HBox play_range_hbox;
338 Gtk::VBox play_range_vbox;
339 Gtk::HBox transport_hbox;
340 Gtk::Fixed transport_base;
341 Gtk::Fixed transport_button_base;
342 Gtk::Frame transport_button_frame;
343 Gtk::HBox transport_button_hbox;
344 Gtk::VBox transport_button_vbox;
345 Gtk::HBox transport_option_button_hbox;
346 Gtk::VBox transport_option_button_vbox;
347 Gtk::HBox transport_clock_hbox;
348 Gtk::VBox transport_clock_vbox;
349 Gtk::HBox primary_clock_hbox;
350 Gtk::HBox secondary_clock_hbox;
353 struct TransportControllable : public PBD::Controllable {
366 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
367 void set_value (float);
368 float get_value (void) const;
370 void set_id (const std::string&);
376 boost::shared_ptr<TransportControllable> roll_controllable;
377 boost::shared_ptr<TransportControllable> stop_controllable;
378 boost::shared_ptr<TransportControllable> goto_start_controllable;
379 boost::shared_ptr<TransportControllable> goto_end_controllable;
380 boost::shared_ptr<TransportControllable> auto_loop_controllable;
381 boost::shared_ptr<TransportControllable> play_selection_controllable;
382 boost::shared_ptr<TransportControllable> rec_controllable;
383 boost::shared_ptr<TransportControllable> shuttle_controllable;
384 BindingProxy shuttle_controller_binding_proxy;
386 void set_transport_controllable_state (const XMLNode&);
387 XMLNode& get_transport_controllable_state ();
389 BindableButton roll_button;
390 BindableButton stop_button;
391 BindableButton goto_start_button;
392 BindableButton goto_end_button;
393 BindableButton auto_loop_button;
394 BindableButton play_selection_button;
395 BindableButton rec_button;
396 Gtk::ToggleButton join_play_range_button;
398 void toggle_external_sync ();
399 void toggle_time_master ();
400 void toggle_video_sync ();
402 Gtk::DrawingArea shuttle_box;
403 Gtk::EventBox speed_display_box;
404 Gtk::Label speed_display_label;
405 Gtk::Button shuttle_units_button;
406 Gtk::ComboBoxText shuttle_style_button;
407 Gtk::Menu* shuttle_unit_menu;
408 Gtk::Menu* shuttle_style_menu;
409 float shuttle_max_speed;
410 Gtk::Menu* shuttle_context_menu;
412 void build_shuttle_context_menu ();
413 void show_shuttle_context_menu ();
414 void shuttle_style_changed();
415 void shuttle_unit_clicked ();
416 void set_shuttle_max_speed (float);
417 void update_speed_display ();
418 float last_speed_displayed;
420 gint shuttle_box_button_press (GdkEventButton*);
421 gint shuttle_box_button_release (GdkEventButton*);
422 gint shuttle_box_scroll (GdkEventScroll*);
423 gint shuttle_box_motion (GdkEventMotion*);
424 gint shuttle_box_expose (GdkEventExpose*);
425 gint mouse_shuttle (double x, bool force);
426 void use_shuttle_fract (bool force);
428 bool shuttle_grabbed;
429 double shuttle_fract;
431 Gtkmm2ext::StatefulToggleButton punch_in_button;
432 Gtkmm2ext::StatefulToggleButton punch_out_button;
433 Gtkmm2ext::StatefulToggleButton auto_return_button;
434 Gtkmm2ext::StatefulToggleButton auto_play_button;
435 Gtkmm2ext::StatefulToggleButton auto_input_button;
436 Gtkmm2ext::StatefulToggleButton click_button;
437 Gtkmm2ext::StatefulToggleButton time_master_button;
438 Gtkmm2ext::StatefulToggleButton sync_button;
440 Gtk::ToggleButton auditioning_alert_button;
441 Gtk::ToggleButton solo_alert_button;
445 void solo_blink (bool);
446 void sync_blink (bool);
447 void audition_blink (bool);
449 void soloing_changed (bool);
450 void auditioning_changed (bool);
451 void _auditioning_changed (bool);
453 void solo_alert_toggle ();
454 void audition_alert_toggle ();
456 void big_clock_value_changed ();
457 void primary_clock_value_changed ();
458 void secondary_clock_value_changed ();
460 /* called by Blink signal */
462 void transport_rec_enable_blink (bool onoff);
464 Gtk::Menu* session_popup_menu;
466 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
467 RecentSessionModelColumns() {
471 Gtk::TreeModelColumn<Glib::ustring> visible_name;
472 Gtk::TreeModelColumn<Glib::ustring> fullpath;
475 RecentSessionModelColumns recent_session_columns;
476 Gtk::TreeView recent_session_display;
477 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
479 ArdourDialog* session_selector_window;
480 Gtk::FileChooserDialog* open_session_selector;
482 void build_session_selector();
483 void redisplay_recent_sessions();
484 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
486 struct RecentSessionsSorter {
487 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
488 return cmp_nocase(a.first, b.first) == -1;
492 /* menu bar and associated stuff */
494 Gtk::MenuBar* menu_bar;
495 Gtk::EventBox menu_bar_base;
498 void use_menubar_as_top_menubar ();
499 void build_menu_bar ();
501 Gtk::Label wall_clock_label;
502 Gtk::EventBox wall_clock_box;
503 gint update_wall_clock ();
505 Gtk::Label disk_space_label;
506 Gtk::EventBox disk_space_box;
507 void update_disk_space ();
509 Gtk::Label cpu_load_label;
510 Gtk::EventBox cpu_load_box;
511 void update_cpu_load ();
513 Gtk::Label buffer_load_label;
514 Gtk::EventBox buffer_load_box;
515 void update_buffer_load ();
517 Gtk::Label sample_rate_label;
518 Gtk::EventBox sample_rate_box;
519 void update_sample_rate (nframes_t);
521 gint every_second ();
522 gint every_point_one_seconds ();
523 gint every_point_zero_one_seconds ();
525 sigc::connection second_connection;
526 sigc::connection point_one_second_connection;
527 sigc::connection point_oh_five_second_connection;
528 sigc::connection point_zero_one_second_connection;
530 gint session_menu (GdkEventButton *);
532 bool _will_create_new_session_automatically;
534 void open_session ();
535 void open_recent_session ();
536 void save_template ();
538 void edit_metadata ();
539 void import_metadata ();
541 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);
542 void session_add_midi_route (bool disk, ARDOUR::RouteGroup *, uint32_t how_many);
544 void set_transport_sensitivity (bool);
546 void remove_last_capture ();
548 void transport_goto_zero ();
549 void transport_goto_start ();
550 void transport_goto_end ();
551 void transport_goto_wallclock ();
552 void transport_stop ();
553 void transport_stop_and_forget_capture ();
554 void transport_record (bool roll);
555 void transport_roll ();
556 void transport_play_selection();
557 void transport_forward (int option);
558 void transport_rewind (int option);
559 void transport_loop ();
560 void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
562 bool _session_is_new;
563 void set_session (ARDOUR::Session *);
564 void connect_dependents_to_session (ARDOUR::Session *);
565 void we_have_dependents ();
567 void setup_session_options ();
569 guint32 last_key_press_time;
571 void snapshot_session ();
576 PublicEditor *editor;
577 int create_editor ();
579 RouteParams_UI *route_params;
580 int create_route_params ();
582 BundleManager *bundle_manager;
583 void create_bundle_manager ();
585 LocationUIWindow *location_ui;
586 int create_location_ui ();
587 void handle_locations_change (ARDOUR::Location*);
589 static UIConfiguration *ui_config;
590 ThemeManager *theme_manager;
592 /* Key bindings editor */
594 KeyEditor *key_editor;
596 /* RC Options window */
598 RCOptionEditor *rc_option_editor;
600 SessionOptionEditor *session_option_editor;
604 AddRouteDialog *add_route_dialog;
606 /* Keyboard Handling */
608 ArdourKeyboard* keyboard;
610 /* Keymap handling */
612 void install_actions ();
614 void toggle_record_enable (uint32_t);
616 uint32_t rec_enabled_streams;
617 void count_recenabled_streams (ARDOUR::Route&);
621 void pop_back_splash ();
626 Gtk::MenuItem *cleanup_item;
628 void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
629 const std::string& plural_msg, const std::string& singular_msg);
633 bool have_configure_timeout;
634 ARDOUR::microseconds_t last_configure_time;
635 gint configure_timeout ();
637 ARDOUR::microseconds_t last_peak_grab;
638 ARDOUR::microseconds_t last_shuttle_request;
640 struct DiskBufferStat {
645 DiskBufferStat (time_t w, uint32_t c, uint32_t p)
646 : when (w), capture (c), playback (p) {}
649 std::list<DiskBufferStat> disk_buffer_stats;
650 void push_buffer_stats (uint32_t, uint32_t);
651 void write_buffer_stats ();
653 bool have_disk_speed_dialog_displayed;
654 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
655 void disk_overrun_handler ();
656 void disk_underrun_handler ();
658 void session_dialog (std::string);
659 int pending_state_dialog ();
660 int sr_mismatch_dialog (nframes_t, nframes_t);
662 void disconnect_from_jack ();
663 void reconnect_to_jack ();
664 void set_jack_buffer_size (nframes_t);
666 Gtk::MenuItem* jack_disconnect_item;
667 Gtk::MenuItem* jack_reconnect_item;
668 Gtk::Menu* jack_bufsize_menu;
670 Glib::RefPtr<Gtk::ActionGroup> common_actions;
672 void editor_realized ();
674 std::vector<std::string> positional_sync_strings;
676 void toggle_send_midi_feedback ();
677 void toggle_use_mmc ();
678 void toggle_send_mmc ();
679 void toggle_send_mtc ();
680 void toggle_send_midi_clock ();
682 void toggle_use_osc ();
684 void parameter_changed (std::string);
688 void no_memory_warning ();
689 void check_memory_locking ();
691 bool check_audioengine();
692 void audioengine_setup ();
694 void display_message (const char *prefix, gint prefix_len,
695 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
697 Gtk::Label status_bar_label;
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 ();
707 PBD::ScopedConnectionList forever_connections;
710 #endif /* __ardour_gui_h__ */