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;
96 class ControlProtocolInfo;
100 class MultiChannelDevice;
103 #define FRAME_NAME "BaseFrame"
105 extern sigc::signal<void> ColorsChanged;
106 extern sigc::signal<void> DPIReset;
108 class ARDOUR_UI : public Gtkmm2ext::UI
111 ARDOUR_UI (int *argcp, char **argvp[]);
114 void run_startup (bool should_be_new);
117 bool shown() { return shown_flag; }
127 int load_session (const Glib::ustring& path, const Glib::ustring& snapshot, Glib::ustring mix_template = Glib::ustring());
129 int build_session (const Glib::ustring& path, const Glib::ustring& snapshot,
131 uint32_t master_chns,
132 ARDOUR::AutoConnectOption input_connect,
133 ARDOUR::AutoConnectOption output_connect,
136 nframes_t initial_length);
137 bool session_is_new() const { return _session_is_new; }
139 ARDOUR::Session* the_session() { return session; }
141 bool will_create_new_session_automatically() const {
142 return _will_create_new_session_automatically;
145 void set_will_create_new_session_automatically (bool yn) {
146 _will_create_new_session_automatically = yn;
149 int get_session_parameters (bool should_be_new = false);
150 void parse_cmdline_path (const Glib::ustring& cmdline_path, Glib::ustring& session_name, Glib::ustring& session_path, bool& existing_session);
151 int load_cmdline_session (const Glib::ustring& session_name, const Glib::ustring& session_path, bool& existing_session);
152 int build_session_from_nsd (const Glib::ustring& session_name, const Glib::ustring& session_path);
153 bool ask_about_loading_existing_session (const Glib::ustring& session_path);
155 /// @return true if session was successfully unloaded.
156 int unload_session (bool hide_stuff = false);
157 void close_session();
159 int save_state_canfail (std::string state_name = "");
160 void save_state (const std::string & state_name = "");
162 static double gain_to_slider_position (ARDOUR::gain_t g);
163 static ARDOUR::gain_t slider_position_to_gain (double pos);
165 static ARDOUR_UI *instance () { return theArdourUI; }
166 static UIConfiguration *config () { return ui_config; }
168 PublicEditor& the_editor(){return *editor;}
169 Mixer_UI* the_mixer() { return mixer; }
171 ARDOUR::AudioEngine& the_engine() const { return *engine; }
173 void toggle_key_editor ();
174 void toggle_location_window ();
175 void toggle_theme_manager ();
176 void toggle_bundle_manager ();
177 void toggle_big_clock_window ();
178 void toggle_route_params_window ();
179 void toggle_editing_space();
181 Gtk::Tooltips& tooltips() { return _tooltips; }
183 static sigc::signal<void,bool> Blink;
184 static sigc::signal<void> RapidScreenUpdate;
185 static sigc::signal<void> SuperRapidScreenUpdate;
186 static sigc::signal<void,nframes_t, bool, nframes_t> Clock;
188 void name_io_setup (ARDOUR::AudioEngine&, std::string&, ARDOUR::IO& io, bool in);
190 XMLNode* editor_settings() const;
191 XMLNode* mixer_settings () const;
192 XMLNode* keyboard_settings () const;
194 void save_ardour_state ();
195 gboolean configure_handler (GdkEventConfigure* conf);
197 void do_transport_locate (nframes_t position);
198 void halt_on_xrun_message ();
199 void xrun_handler (nframes_t);
200 void create_xrun_marker (nframes_t);
202 AudioClock primary_clock;
203 AudioClock secondary_clock;
204 AudioClock preroll_clock;
205 AudioClock postroll_clock;
207 void store_clock_modes ();
208 void restore_clock_modes ();
210 void add_route (Gtk::Window* float_window);
212 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many) {
213 session_add_audio_route (true, input_channels, output_channels, mode, how_many);
216 void session_add_audio_bus (int input_channels, int32_t output_channels, uint32_t how_many) {
217 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, how_many);
220 void session_add_midi_track (uint32_t how_many) {
221 session_add_midi_route (true, how_many);
224 /*void session_add_midi_bus () {
225 session_add_midi_route (false);
228 int create_engine ();
231 gint exit_on_main_window_close (GdkEventAny *);
233 void maximise_editing_space ();
234 void restore_editing_space ();
236 void setup_profile ();
239 void set_shuttle_fract (double);
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 toggle_auto_return ();
253 void toggle_click ();
255 void toggle_session_auto_loop ();
257 void toggle_rc_options_window ();
258 void toggle_session_options_window ();
261 ArdourStartup* _startup;
262 ARDOUR::AudioEngine *engine;
263 ARDOUR::Session *session;
264 Gtk::Tooltips _tooltips;
266 void goto_editor_window ();
267 void goto_mixer_window ();
268 void toggle_editor_mixer_on_top ();
271 Gtk::ToggleButton preroll_button;
272 Gtk::ToggleButton postroll_button;
274 int setup_windows ();
275 void setup_transport ();
278 static ARDOUR_UI *theArdourUI;
280 void backend_audio_error (bool we_set_params, Gtk::Window* toplevel = 0);
284 int ask_about_saving_session (const std::string & why);
286 /* periodic safety backup, to be precise */
287 gint autosave_session();
288 void update_autosave();
289 sigc::connection _autosave_connection;
291 void queue_transport_change ();
292 void map_transport_state ();
293 int32_t do_engine_start ();
295 void engine_halted ();
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);
311 Gtk::VBox top_packer;
313 sigc::connection clock_signal_connection;
314 void update_clocks ();
315 void start_clocking ();
316 void stop_clocking ();
318 void manage_window (Gtk::Window&);
320 AudioClock big_clock;
321 Gtk::Window* big_clock_window;
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 transport_hbox;
338 Gtk::Fixed transport_base;
339 Gtk::Fixed transport_button_base;
340 Gtk::Frame transport_button_frame;
341 Gtk::HBox transport_button_hbox;
342 Gtk::VBox transport_button_vbox;
343 Gtk::HBox transport_option_button_hbox;
344 Gtk::VBox transport_option_button_vbox;
345 Gtk::HBox transport_clock_hbox;
346 Gtk::VBox transport_clock_vbox;
347 Gtk::HBox primary_clock_hbox;
348 Gtk::HBox secondary_clock_hbox;
351 struct TransportControllable : public PBD::Controllable {
364 TransportControllable (std::string name, ARDOUR_UI&, ToggleType);
365 void set_value (float);
366 float get_value (void) const;
368 void set_id (const std::string&);
374 boost::shared_ptr<TransportControllable> roll_controllable;
375 boost::shared_ptr<TransportControllable> stop_controllable;
376 boost::shared_ptr<TransportControllable> goto_start_controllable;
377 boost::shared_ptr<TransportControllable> goto_end_controllable;
378 boost::shared_ptr<TransportControllable> auto_loop_controllable;
379 boost::shared_ptr<TransportControllable> play_selection_controllable;
380 boost::shared_ptr<TransportControllable> rec_controllable;
381 boost::shared_ptr<TransportControllable> shuttle_controllable;
382 BindingProxy shuttle_controller_binding_proxy;
384 void set_transport_controllable_state (const XMLNode&);
385 XMLNode& get_transport_controllable_state ();
387 BindableButton roll_button;
388 BindableButton stop_button;
389 BindableButton goto_start_button;
390 BindableButton goto_end_button;
391 BindableButton auto_loop_button;
392 BindableButton play_selection_button;
393 BindableButton rec_button;
395 Gtk::ComboBoxText sync_option_combo;
397 void sync_option_changed ();
398 void toggle_time_master ();
399 void toggle_video_sync ();
401 Gtk::DrawingArea shuttle_box;
402 Gtk::EventBox speed_display_box;
403 Gtk::Label speed_display_label;
404 Gtk::Button shuttle_units_button;
405 Gtk::ComboBoxText shuttle_style_button;
406 Gtk::Menu* shuttle_unit_menu;
407 Gtk::Menu* shuttle_style_menu;
408 float shuttle_max_speed;
409 Gtk::Menu* shuttle_context_menu;
411 void build_shuttle_context_menu ();
412 void show_shuttle_context_menu ();
413 void shuttle_style_changed();
414 void shuttle_unit_clicked ();
415 void set_shuttle_max_speed (float);
416 void update_speed_display ();
417 float last_speed_displayed;
419 gint shuttle_box_button_press (GdkEventButton*);
420 gint shuttle_box_button_release (GdkEventButton*);
421 gint shuttle_box_scroll (GdkEventScroll*);
422 gint shuttle_box_motion (GdkEventMotion*);
423 gint shuttle_box_expose (GdkEventExpose*);
424 gint mouse_shuttle (double x, bool force);
425 void use_shuttle_fract (bool force);
427 bool shuttle_grabbed;
428 double shuttle_fract;
430 Gtkmm2ext::StatefulToggleButton punch_in_button;
431 Gtkmm2ext::StatefulToggleButton punch_out_button;
432 Gtkmm2ext::StatefulToggleButton auto_return_button;
433 Gtkmm2ext::StatefulToggleButton auto_play_button;
434 Gtkmm2ext::StatefulToggleButton auto_input_button;
435 Gtkmm2ext::StatefulToggleButton click_button;
436 Gtkmm2ext::StatefulToggleButton time_master_button;
438 Gtk::ToggleButton auditioning_alert_button;
439 Gtk::ToggleButton solo_alert_button;
443 void solo_blink (bool);
444 void audition_blink (bool);
446 void soloing_changed (bool);
447 void auditioning_changed (bool);
448 void _auditioning_changed (bool);
450 void solo_alert_toggle ();
451 void audition_alert_toggle ();
453 void big_clock_value_changed ();
454 void primary_clock_value_changed ();
455 void secondary_clock_value_changed ();
457 /* called by Blink signal */
459 void transport_rec_enable_blink (bool onoff);
461 Gtk::Menu* session_popup_menu;
463 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
464 RecentSessionModelColumns() {
468 Gtk::TreeModelColumn<Glib::ustring> visible_name;
469 Gtk::TreeModelColumn<Glib::ustring> fullpath;
472 RecentSessionModelColumns recent_session_columns;
473 Gtk::TreeView recent_session_display;
474 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
476 ArdourDialog* session_selector_window;
477 Gtk::FileChooserDialog* open_session_selector;
479 void build_session_selector();
480 void redisplay_recent_sessions();
481 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
483 struct RecentSessionsSorter {
484 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
485 return cmp_nocase(a.first, b.first) == -1;
489 /* menu bar and associated stuff */
491 Gtk::MenuBar* menu_bar;
492 Gtk::EventBox menu_bar_base;
495 void use_menubar_as_top_menubar ();
496 void build_menu_bar ();
497 void build_control_surface_menu ();
499 Gtk::Label wall_clock_label;
500 Gtk::EventBox wall_clock_box;
501 gint update_wall_clock ();
503 Gtk::Label disk_space_label;
504 Gtk::EventBox disk_space_box;
505 void update_disk_space ();
507 Gtk::Label cpu_load_label;
508 Gtk::EventBox cpu_load_box;
509 void update_cpu_load ();
511 Gtk::Label buffer_load_label;
512 Gtk::EventBox buffer_load_box;
513 void update_buffer_load ();
515 Gtk::Label sample_rate_label;
516 Gtk::EventBox sample_rate_box;
517 void update_sample_rate (nframes_t);
519 gint every_second ();
520 gint every_point_one_seconds ();
521 gint every_point_zero_one_seconds ();
523 sigc::connection second_connection;
524 sigc::connection point_one_second_connection;
525 sigc::connection point_oh_five_second_connection;
526 sigc::connection point_zero_one_second_connection;
528 gint session_menu (GdkEventButton *);
530 bool _will_create_new_session_automatically;
532 void open_session ();
533 void open_recent_session ();
534 void save_template ();
536 void edit_metadata ();
537 void import_metadata ();
539 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many);
540 void session_add_midi_route (bool disk, uint32_t how_many);
542 void set_transport_sensitivity (bool);
544 void remove_last_capture ();
546 void transport_goto_zero ();
547 void transport_goto_start ();
548 void transport_goto_end ();
549 void transport_goto_wallclock ();
550 void transport_stop ();
551 void transport_stop_and_forget_capture ();
552 void transport_record (bool roll);
553 void transport_roll ();
554 void transport_play_selection();
555 void transport_forward (int option);
556 void transport_rewind (int option);
557 void transport_loop ();
559 void transport_rolling ();
560 void transport_rewinding ();
561 void transport_forwarding ();
562 void transport_stopped ();
564 bool _session_is_new;
565 void connect_to_session (ARDOUR::Session *);
566 void connect_dependents_to_session (ARDOUR::Session *);
567 void we_have_dependents ();
569 void setup_session_options ();
571 guint32 last_key_press_time;
573 void snapshot_session ();
578 PublicEditor *editor;
579 int create_editor ();
581 RouteParams_UI *route_params;
582 int create_route_params ();
584 BundleManager *bundle_manager;
585 void create_bundle_manager ();
587 LocationUI *location_ui;
588 int create_location_ui ();
589 void handle_locations_change (ARDOUR::Location*);
591 static UIConfiguration *ui_config;
592 ThemeManager *theme_manager;
594 /* Key bindings editor */
596 KeyEditor *key_editor;
598 /* RC Options window */
600 RCOptionEditor *rc_option_editor;
602 SessionOptionEditor *session_option_editor;
606 AddRouteDialog *add_route_dialog;
608 /* Keyboard Handling */
612 /* Keymap handling */
614 void install_actions ();
616 void toggle_record_enable (uint32_t);
618 uint32_t rec_enabled_streams;
619 void count_recenabled_streams (ARDOUR::Route&);
623 void pop_back_splash ();
628 Gtk::MenuItem *cleanup_item;
630 void display_cleanup_results (ARDOUR::Session::cleanup_report& rep, const gchar* list_title, const std::string & msg);
634 bool have_configure_timeout;
635 ARDOUR::microseconds_t last_configure_time;
636 gint configure_timeout ();
638 ARDOUR::microseconds_t last_peak_grab;
639 ARDOUR::microseconds_t last_shuttle_request;
641 struct DiskBufferStat {
646 DiskBufferStat (time_t w, uint32_t c, uint32_t p)
647 : when (w), capture (c), playback (p) {}
650 std::list<DiskBufferStat> disk_buffer_stats;
651 void push_buffer_stats (uint32_t, uint32_t);
652 void write_buffer_stats ();
654 bool have_disk_speed_dialog_displayed;
655 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
656 void disk_overrun_handler ();
657 void disk_underrun_handler ();
659 void session_dialog (std::string);
660 int pending_state_dialog ();
661 int sr_mismatch_dialog (nframes_t, nframes_t);
663 void disconnect_from_jack ();
664 void reconnect_to_jack ();
665 void set_jack_buffer_size (nframes_t);
667 Gtk::MenuItem* jack_disconnect_item;
668 Gtk::MenuItem* jack_reconnect_item;
669 Gtk::Menu* jack_bufsize_menu;
671 Glib::RefPtr<Gtk::ActionGroup> common_actions;
673 void editor_realized ();
675 std::vector<std::string> positional_sync_strings;
677 void toggle_send_midi_feedback ();
678 void toggle_use_mmc ();
679 void toggle_send_mmc ();
680 void toggle_send_mtc ();
681 void toggle_send_midi_clock ();
683 void toggle_use_osc ();
685 void mtc_port_changed ();
686 void parameter_changed (std::string);
688 void toggle_control_protocol (ARDOUR::ControlProtocolInfo*);
689 void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo*, const char* group_name, std::string action_name);
693 void no_memory_warning ();
694 void check_memory_locking ();
696 bool check_audioengine();
697 void audioengine_setup ();
699 void display_message (const char *prefix, gint prefix_len,
700 Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag, const char *msg);
701 Gtk::Label status_bar_label;
702 Gtk::ToggleButton error_log_button;
704 void loading_message (const std::string& msg);
705 void end_loading_messages ();
707 void platform_specific ();
708 void platform_setup ();
709 void fontconfig_dialog ();
712 #endif /* __ardour_gui_h__ */