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/session.h"
63 #include "ardour/types.h"
65 #include "audio_clock.h"
66 #include "ardour_dialog.h"
68 #include "ui_config.h"
74 class SessionOptionEditor;
77 class ConnectionEditor;
95 class ControlProtocolInfo;
98 extern sigc::signal<void> ColorsChanged;
99 extern sigc::signal<void> DPIReset;
101 class ARDOUR_UI : public Gtkmm2ext::UI
104 ARDOUR_UI (int *argcp, char **argvp[]);
107 void run_startup (bool should_be_new);
110 bool shown() { return shown_flag; }
120 int load_session (const Glib::ustring& path, const Glib::ustring& snapshot, Glib::ustring mix_template = Glib::ustring());
122 int build_session (const Glib::ustring& path, const Glib::ustring& snapshot,
124 uint32_t master_chns,
125 ARDOUR::AutoConnectOption input_connect,
126 ARDOUR::AutoConnectOption output_connect,
129 nframes_t initial_length);
130 bool session_is_new() const { return _session_is_new; }
132 ARDOUR::Session* the_session() { return session; }
134 bool will_create_new_session_automatically() const {
135 return _will_create_new_session_automatically;
138 void set_will_create_new_session_automatically (bool yn) {
139 _will_create_new_session_automatically = yn;
142 int get_session_parameters (bool should_be_new = false);
143 void parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session);
144 int load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session);
145 int build_session_from_nsd (const Glib::ustring& session_name, const Glib::ustring& session_path);
146 bool ask_about_loading_existing_session (const Glib::ustring& session_path);
148 /// @return true if session was successfully unloaded.
149 int unload_session (bool hide_stuff = false);
150 void close_session();
152 int save_state_canfail (std::string state_name = "");
153 void save_state (const std::string & state_name = "");
155 static double gain_to_slider_position (ARDOUR::gain_t g);
156 static ARDOUR::gain_t slider_position_to_gain (double pos);
158 static ARDOUR_UI *instance () { return theArdourUI; }
159 static UIConfiguration *config () { return ui_config; }
161 PublicEditor& the_editor(){return *editor;}
162 Mixer_UI* the_mixer() { return mixer; }
164 void toggle_key_editor ();
165 void toggle_location_window ();
166 void toggle_theme_manager ();
167 void toggle_bundle_manager ();
168 void toggle_big_clock_window ();
169 void toggle_route_params_window ();
170 void toggle_editing_space();
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 static sigc::signal<void,nframes_t, bool, nframes_t> Clock;
179 XMLNode* editor_settings() const;
180 XMLNode* mixer_settings () const;
181 XMLNode* keyboard_settings () const;
183 void save_ardour_state ();
184 gboolean configure_handler (GdkEventConfigure* conf);
186 void do_transport_locate (nframes_t position);
187 void halt_on_xrun_message ();
188 void xrun_handler (nframes_t);
189 void create_xrun_marker (nframes_t);
191 AudioClock primary_clock;
192 AudioClock secondary_clock;
193 AudioClock preroll_clock;
194 AudioClock postroll_clock;
196 void store_clock_modes ();
197 void restore_clock_modes ();
199 void add_route (Gtk::Window* float_window);
201 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many) {
202 session_add_audio_route (true, input_channels, output_channels, mode, how_many);
205 void session_add_audio_bus (int input_channels, int32_t output_channels, uint32_t how_many) {
206 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, how_many);
209 void session_add_midi_track (uint32_t how_many) {
210 session_add_midi_route (true, how_many);
213 /*void session_add_midi_bus () {
214 session_add_midi_route (false);
217 int create_engine ();
220 gint exit_on_main_window_close (GdkEventAny *);
222 void maximise_editing_space ();
223 void restore_editing_space ();
225 void setup_profile ();
228 void set_shuttle_fract (double);
231 friend class PublicEditor;
233 void toggle_clocking ();
234 void toggle_auto_play ();
235 void toggle_auto_input ();
236 void toggle_punch ();
237 void unset_dual_punch ();
238 bool ignore_dual_punch;
239 void toggle_punch_in ();
240 void toggle_punch_out ();
241 void toggle_auto_return ();
242 void toggle_click ();
244 void toggle_session_auto_loop ();
246 void toggle_rc_options_window ();
247 void toggle_session_options_window ();
250 ArdourStartup* _startup;
251 ARDOUR::AudioEngine *engine;
252 ARDOUR::Session *session;
253 Gtk::Tooltips _tooltips;
255 void goto_editor_window ();
256 void goto_mixer_window ();
257 void toggle_editor_mixer_on_top ();
260 Gtk::ToggleButton preroll_button;
261 Gtk::ToggleButton postroll_button;
263 int setup_windows ();
264 void setup_transport ();
267 static ARDOUR_UI *theArdourUI;
269 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
273 int ask_about_saving_session (const std::string & why);
275 /* periodic safety backup, to be precise */
276 gint autosave_session();
277 void update_autosave();
278 sigc::connection _autosave_connection;
280 void queue_transport_change ();
281 void map_transport_state ();
282 int32_t do_engine_start ();
284 void engine_halted ();
285 void engine_stopped ();
286 void engine_running ();
290 static gint _blink (void *);
292 gint blink_timeout_tag;
294 void start_blinking ();
295 void stop_blinking ();
297 void about_signal_response(int response);
300 Gtk::VBox top_packer;
302 sigc::connection clock_signal_connection;
303 void update_clocks ();
304 void start_clocking ();
305 void stop_clocking ();
307 void manage_window (Gtk::Window&);
309 AudioClock big_clock;
310 Gtk::Window* big_clock_window;
312 void float_big_clock (Gtk::Window* parent);
313 bool main_window_state_event_handler (GdkEventWindowState*, bool window_was_editor);
315 void update_transport_clocks (nframes_t pos);
316 void record_state_changed ();
318 /* Transport Control */
320 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
321 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
323 Gtkmm2ext::TearOff* transport_tearoff;
324 Gtk::Frame transport_frame;
325 Gtk::HBox transport_tearoff_hbox;
326 Gtk::HBox transport_hbox;
327 Gtk::Fixed transport_base;
328 Gtk::Fixed transport_button_base;
329 Gtk::Frame transport_button_frame;
330 Gtk::HBox transport_button_hbox;
331 Gtk::VBox transport_button_vbox;
332 Gtk::HBox transport_option_button_hbox;
333 Gtk::VBox transport_option_button_vbox;
334 Gtk::HBox transport_clock_hbox;
335 Gtk::VBox transport_clock_vbox;
336 Gtk::HBox primary_clock_hbox;
337 Gtk::HBox secondary_clock_hbox;
340 struct TransportControllable : public PBD::Controllable {
353 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
354 void set_value (float);
355 float get_value (void) const;
357 void set_id (const std::string&);
363 boost::shared_ptr<TransportControllable> roll_controllable;
364 boost::shared_ptr<TransportControllable> stop_controllable;
365 boost::shared_ptr<TransportControllable> goto_start_controllable;
366 boost::shared_ptr<TransportControllable> goto_end_controllable;
367 boost::shared_ptr<TransportControllable> auto_loop_controllable;
368 boost::shared_ptr<TransportControllable> play_selection_controllable;
369 boost::shared_ptr<TransportControllable> rec_controllable;
370 boost::shared_ptr<TransportControllable> shuttle_controllable;
371 BindingProxy shuttle_controller_binding_proxy;
373 void set_transport_controllable_state (const XMLNode&);
374 XMLNode& get_transport_controllable_state ();
376 BindableButton roll_button;
377 BindableButton stop_button;
378 BindableButton goto_start_button;
379 BindableButton goto_end_button;
380 BindableButton auto_loop_button;
381 BindableButton play_selection_button;
382 BindableButton rec_button;
384 Gtk::ComboBoxText sync_option_combo;
386 void sync_option_changed ();
387 void toggle_time_master ();
388 void toggle_video_sync ();
390 Gtk::DrawingArea shuttle_box;
391 Gtk::EventBox speed_display_box;
392 Gtk::Label speed_display_label;
393 Gtk::Button shuttle_units_button;
394 Gtk::ComboBoxText shuttle_style_button;
395 Gtk::Menu* shuttle_unit_menu;
396 Gtk::Menu* shuttle_style_menu;
397 float shuttle_max_speed;
398 Gtk::Menu* shuttle_context_menu;
400 void build_shuttle_context_menu ();
401 void show_shuttle_context_menu ();
402 void shuttle_style_changed();
403 void shuttle_unit_clicked ();
404 void set_shuttle_max_speed (float);
405 void update_speed_display ();
406 float last_speed_displayed;
408 gint shuttle_box_button_press (GdkEventButton*);
409 gint shuttle_box_button_release (GdkEventButton*);
410 gint shuttle_box_scroll (GdkEventScroll*);
411 gint shuttle_box_motion (GdkEventMotion*);
412 gint shuttle_box_expose (GdkEventExpose*);
413 gint mouse_shuttle (double x, bool force);
414 void use_shuttle_fract (bool force);
416 bool shuttle_grabbed;
417 double shuttle_fract;
419 Gtkmm2ext::StatefulToggleButton punch_in_button;
420 Gtkmm2ext::StatefulToggleButton punch_out_button;
421 Gtkmm2ext::StatefulToggleButton auto_return_button;
422 Gtkmm2ext::StatefulToggleButton auto_play_button;
423 Gtkmm2ext::StatefulToggleButton auto_input_button;
424 Gtkmm2ext::StatefulToggleButton click_button;
425 Gtkmm2ext::StatefulToggleButton time_master_button;
427 Gtk::ToggleButton auditioning_alert_button;
428 Gtk::ToggleButton solo_alert_button;
432 void solo_blink (bool);
433 void audition_blink (bool);
435 void soloing_changed (bool);
436 void auditioning_changed (bool);
437 void _auditioning_changed (bool);
439 void solo_alert_toggle ();
440 void audition_alert_toggle ();
442 void big_clock_value_changed ();
443 void primary_clock_value_changed ();
444 void secondary_clock_value_changed ();
446 /* called by Blink signal */
448 void transport_rec_enable_blink (bool onoff);
450 Gtk::Menu* session_popup_menu;
452 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
453 RecentSessionModelColumns() {
457 Gtk::TreeModelColumn<Glib::ustring> visible_name;
458 Gtk::TreeModelColumn<Glib::ustring> fullpath;
461 RecentSessionModelColumns recent_session_columns;
462 Gtk::TreeView recent_session_display;
463 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
465 ArdourDialog* session_selector_window;
466 Gtk::FileChooserDialog* open_session_selector;
468 void build_session_selector();
469 void redisplay_recent_sessions();
470 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
472 struct RecentSessionsSorter {
473 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
474 return cmp_nocase(a.first, b.first) == -1;
478 /* menu bar and associated stuff */
480 Gtk::MenuBar* menu_bar;
481 Gtk::EventBox menu_bar_base;
484 void use_menubar_as_top_menubar ();
485 void build_menu_bar ();
487 Gtk::Label wall_clock_label;
488 Gtk::EventBox wall_clock_box;
489 gint update_wall_clock ();
491 Gtk::Label disk_space_label;
492 Gtk::EventBox disk_space_box;
493 void update_disk_space ();
495 Gtk::Label cpu_load_label;
496 Gtk::EventBox cpu_load_box;
497 void update_cpu_load ();
499 Gtk::Label buffer_load_label;
500 Gtk::EventBox buffer_load_box;
501 void update_buffer_load ();
503 Gtk::Label sample_rate_label;
504 Gtk::EventBox sample_rate_box;
505 void update_sample_rate (nframes_t);
507 gint every_second ();
508 gint every_point_one_seconds ();
509 gint every_point_zero_one_seconds ();
511 sigc::connection second_connection;
512 sigc::connection point_one_second_connection;
513 sigc::connection point_oh_five_second_connection;
514 sigc::connection point_zero_one_second_connection;
516 gint session_menu (GdkEventButton *);
518 bool _will_create_new_session_automatically;
520 void open_session ();
521 void open_recent_session ();
522 void save_template ();
524 void edit_metadata ();
525 void import_metadata ();
527 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many);
528 void session_add_midi_route (bool disk, uint32_t how_many);
530 void set_transport_sensitivity (bool);
532 void remove_last_capture ();
534 void transport_goto_zero ();
535 void transport_goto_start ();
536 void transport_goto_end ();
537 void transport_goto_wallclock ();
538 void transport_stop ();
539 void transport_stop_and_forget_capture ();
540 void transport_record (bool roll);
541 void transport_roll ();
542 void transport_play_selection();
543 void transport_forward (int option);
544 void transport_rewind (int option);
545 void transport_loop ();
547 void transport_rolling ();
548 void transport_rewinding ();
549 void transport_forwarding ();
550 void transport_stopped ();
552 bool _session_is_new;
553 void connect_to_session (ARDOUR::Session *);
554 void connect_dependents_to_session (ARDOUR::Session *);
555 void we_have_dependents ();
557 void setup_session_options ();
559 guint32 last_key_press_time;
561 void snapshot_session ();
566 PublicEditor *editor;
567 int create_editor ();
569 RouteParams_UI *route_params;
570 int create_route_params ();
572 BundleManager *bundle_manager;
573 void create_bundle_manager ();
575 LocationUI *location_ui;
576 int create_location_ui ();
577 void handle_locations_change (ARDOUR::Location*);
579 static UIConfiguration *ui_config;
580 ThemeManager *theme_manager;
582 /* Key bindings editor */
584 KeyEditor *key_editor;
586 /* RC Options window */
588 RCOptionEditor *rc_option_editor;
590 SessionOptionEditor *session_option_editor;
594 AddRouteDialog *add_route_dialog;
596 /* Keyboard Handling */
600 /* Keymap handling */
602 void install_actions ();
604 void toggle_record_enable (uint32_t);
606 uint32_t rec_enabled_streams;
607 void count_recenabled_streams (ARDOUR::Route&);
611 void pop_back_splash ();
616 Gtk::MenuItem *cleanup_item;
618 void display_cleanup_results (ARDOUR::Session::cleanup_report& rep, const gchar* list_title, const std::string & msg);
622 bool have_configure_timeout;
623 ARDOUR::microseconds_t last_configure_time;
624 gint configure_timeout ();
626 ARDOUR::microseconds_t last_peak_grab;
627 ARDOUR::microseconds_t last_shuttle_request;
629 struct DiskBufferStat {
634 DiskBufferStat (time_t w, uint32_t c, uint32_t p)
635 : when (w), capture (c), playback (p) {}
638 std::list<DiskBufferStat> disk_buffer_stats;
639 void push_buffer_stats (uint32_t, uint32_t);
640 void write_buffer_stats ();
642 bool have_disk_speed_dialog_displayed;
643 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
644 void disk_overrun_handler ();
645 void disk_underrun_handler ();
647 void session_dialog (std::string);
648 int pending_state_dialog ();
649 int sr_mismatch_dialog (nframes_t, nframes_t);
651 void disconnect_from_jack ();
652 void reconnect_to_jack ();
653 void set_jack_buffer_size (nframes_t);
655 Gtk::MenuItem* jack_disconnect_item;
656 Gtk::MenuItem* jack_reconnect_item;
657 Gtk::Menu* jack_bufsize_menu;
659 Glib::RefPtr<Gtk::ActionGroup> common_actions;
661 void editor_realized ();
663 std::vector<std::string> positional_sync_strings;
665 void toggle_send_midi_feedback ();
666 void toggle_use_mmc ();
667 void toggle_send_mmc ();
668 void toggle_send_mtc ();
669 void toggle_send_midi_clock ();
671 void toggle_use_osc ();
673 void mtc_port_changed ();
674 void parameter_changed (std::string);
678 void no_memory_warning ();
679 void check_memory_locking ();
681 bool check_audioengine();
682 void audioengine_setup ();
684 void display_message (const char *prefix, gint prefix_len,
685 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, const char *msg);
686 Gtk::Label status_bar_label;
687 Gtk::ToggleButton error_log_button;
689 void loading_message (const std::string& msg);
690 void end_loading_messages ();
692 void platform_specific ();
693 void platform_setup ();
694 void fontconfig_dialog ();
697 #endif /* __ardour_gui_h__ */