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__
23 /* need _BSD_SOURCE to get timersub macros */
37 #include <libgnomecanvasmm/canvas.h>
39 #include <pbd/xml++.h>
40 #include <gtkmm/box.h>
41 #include <gtkmm/frame.h>
42 #include <gtkmm/label.h>
43 #include <gtkmm/table.h>
44 #include <gtkmm/fixed.h>
45 #include <gtkmm/drawingarea.h>
46 #include <gtkmm/eventbox.h>
47 #include <gtkmm/menu.h>
48 #include <gtkmm/menuitem.h>
49 #include <gtkmm/button.h>
50 #include <gtkmm/togglebutton.h>
51 #include <gtkmm/treeview.h>
52 #include <gtkmm/menubar.h>
53 #include <gtkmm/adjustment.h>
54 #include <gtkmm2ext/gtk_ui.h>
55 #include <gtkmm2ext/click_box.h>
56 #include <gtkmm2ext/stateful_button.h>
57 #include <gtkmm2ext/bindable_button.h>
58 #include <ardour/ardour.h>
59 #include <ardour/session.h>
61 #include "audio_clock.h"
62 #include "ardour_dialog.h"
70 class ConnectionEditor;
74 class NewSessionDialog;
87 class ControlProtocolInfo;
91 class MultiChannelDevice;
94 #define FRAME_NAME "BaseFrame"
96 class ARDOUR_UI : public Gtkmm2ext::UI
99 ARDOUR_UI (int *argcp, char **argvp[], string rcfile);
103 bool shown() { return shown_flag; }
108 int load_session (const string & path, const string & snapshot, string* mix_template = 0);
110 int build_session (const string & path, const string & snapshot,
112 uint32_t master_chns,
113 ARDOUR::AutoConnectOption input_connect,
114 ARDOUR::AutoConnectOption output_connect,
117 nframes_t initial_length);
118 bool session_is_new() const { return _session_is_new; }
120 ARDOUR::Session* the_session() { return session; }
122 bool will_create_new_session_automatically() const {
123 return _will_create_new_session_automatically;
126 void set_will_create_new_session_automatically (bool yn) {
127 _will_create_new_session_automatically = yn;
130 bool new_session(std::string path = string());
131 gint cmdline_new_session (string path);
132 int unload_session ();
133 void close_session();
135 int save_state_canfail (string state_name = "");
136 void save_state (const string & state_name = "");
137 void restore_state (string state_name = "");
139 static double gain_to_slider_position (ARDOUR::gain_t g);
140 static ARDOUR::gain_t slider_position_to_gain (double pos);
142 static ARDOUR_UI *instance () { return theArdourUI; }
144 PublicEditor& the_editor(){return *editor;}
145 Mixer_UI* the_mixer() { return mixer; }
147 void toggle_location_window ();
148 void toggle_color_manager ();
149 void toggle_big_clock_window ();
150 void toggle_connection_editor ();
151 void toggle_route_params_window ();
152 void toggle_editing_space();
154 Gtk::Tooltips& tooltips() { return _tooltips; }
156 static sigc::signal<void,bool> Blink;
157 static sigc::signal<void> RapidScreenUpdate;
158 static sigc::signal<void> SuperRapidScreenUpdate;
159 static sigc::signal<void,nframes_t> Clock;
161 /* this is a helper function to centralize the (complex) logic for
162 blinking rec-enable buttons.
165 void rec_enable_button_blink (bool onoff, ARDOUR::AudioDiskstream *, Gtk::Widget *w);
167 void name_io_setup (ARDOUR::AudioEngine&, string&, ARDOUR::IO& io, bool in);
169 static gint hide_and_quit (GdkEventAny *ev, ArdourDialog *);
171 XMLNode* editor_settings() const;
172 XMLNode* mixer_settings () const;
173 XMLNode* keyboard_settings () const;
175 void save_ardour_state ();
176 gboolean configure_handler (GdkEventConfigure* conf);
178 void do_transport_locate (nframes_t position);
179 void halt_on_xrun_message ();
181 AudioClock primary_clock;
182 AudioClock secondary_clock;
183 AudioClock preroll_clock;
184 AudioClock postroll_clock;
186 void store_clock_modes ();
187 void restore_clock_modes ();
189 void add_route (Gtk::Window* float_window);
191 void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many) {
192 session_add_audio_route (true, input_channels, output_channels, mode, how_many);
195 void session_add_audio_bus (int input_channels, int32_t output_channels, uint32_t how_many) {
196 session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, how_many);
199 void session_add_midi_track (uint32_t how_many) {
200 session_add_midi_route (true, how_many);
203 /*void session_add_midi_bus () {
204 session_add_midi_route (false);
207 void set_engine (ARDOUR::AudioEngine&);
208 gint start_engine ();
210 gint exit_on_main_window_close (GdkEventAny *);
212 void maximise_editing_space ();
213 void restore_editing_space ();
215 void set_native_file_header_format (ARDOUR::HeaderFormat sf);
216 void set_native_file_data_format (ARDOUR::SampleFormat sf);
218 void set_keybindings_path (std::string path);
219 void save_keybindings ();
221 void setup_profile ();
224 friend class PublicEditor;
226 void toggle_clocking ();
227 void toggle_auto_play ();
228 void toggle_auto_input ();
229 void toggle_punch_in ();
230 void toggle_punch_out ();
231 void toggle_auto_return ();
232 void toggle_click ();
234 void toggle_session_auto_loop ();
236 void toggle_options_window ();
239 struct GlobalClickBox : public Gtk::VBox {
240 Gtkmm2ext::ClickBox *box;
243 vector<string> &strings;
244 Gtk::Adjustment adjustment;
246 static void printer (char buf[32], Gtk::Adjustment &adj, void *arg);
248 GlobalClickBox (const string &str, vector<string> &vs)
250 adjustment (0, 0, vs.size() - 1, 1, 1, 0) {
251 box = new Gtkmm2ext::ClickBox (&adjustment, "ClickButton");
252 label.set_text (str);
253 label.set_name ("GlobalButtonLabel");
255 frame.set_shadow_type (Gtk::SHADOW_IN);
258 box->set_print_func (printer, this);
259 box->set_wrap (true);
263 ARDOUR::AudioEngine *engine;
264 ARDOUR::Session *session;
266 Gtk::Tooltips _tooltips;
268 void goto_editor_window ();
269 void goto_mixer_window ();
271 Gtk::Table adjuster_table;
272 Gtk::Frame adjuster_frame;
273 Gtk::Fixed adjuster_base;
275 GlobalClickBox *online_control_button;
276 vector<string> online_control_strings;
278 GlobalClickBox *crossfade_time_button;
279 vector<string> crossfade_time_strings;
281 Gtk::ToggleButton preroll_button;
282 Gtk::ToggleButton postroll_button;
284 Gtk::Table transport_table;
285 Gtk::Table option_table;
287 int setup_windows ();
288 void setup_transport ();
291 static ARDOUR_UI *theArdourUI;
297 int ask_about_saving_session (const string & why);
298 int save_the_session;
300 /* periodic safety backup, to be precise */
301 gint autosave_session();
302 void update_autosave();
303 sigc::connection _autosave_connection;
305 void queue_transport_change ();
306 void map_transport_state ();
307 int32_t do_engine_start ();
309 void engine_halted ();
310 void engine_stopped ();
311 void engine_running ();
315 static gint _blink (void *);
317 gint blink_timeout_tag;
319 void start_blinking ();
320 void stop_blinking ();
322 void about_signal_response(int response);
325 Gtk::VBox top_packer;
327 sigc::connection clock_signal_connection;
328 void update_clocks ();
329 void start_clocking ();
330 void stop_clocking ();
332 void manage_window (Gtk::Window&);
334 AudioClock big_clock;
335 Gtk::Frame big_clock_frame;
336 Gtk::Window* big_clock_window;
338 void update_transport_clocks (nframes_t pos);
339 void record_state_changed ();
341 /* Transport Control */
343 void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
344 void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
346 Gtkmm2ext::TearOff* transport_tearoff;
347 Gtk::Frame transport_frame;
348 Gtk::HBox transport_tearoff_hbox;
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 (float);
378 float get_value (void) const;
380 void set_id (const std::string&);
386 TransportControllable roll_controllable;
387 TransportControllable stop_controllable;
388 TransportControllable goto_start_controllable;
389 TransportControllable goto_end_controllable;
390 TransportControllable auto_loop_controllable;
391 TransportControllable play_selection_controllable;
392 TransportControllable rec_controllable;
393 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;
407 Gtk::ComboBoxText sync_option_combo;
409 void sync_option_changed ();
410 void toggle_time_master ();
411 void toggle_video_sync ();
413 Gtk::DrawingArea shuttle_box;
414 Gtk::EventBox speed_display_box;
415 Gtk::Label speed_display_label;
416 Gtk::Button shuttle_units_button;
417 Gtk::ComboBoxText shuttle_style_button;
418 Gtk::Menu* shuttle_unit_menu;
419 Gtk::Menu* shuttle_style_menu;
420 float shuttle_max_speed;
421 Gtk::Menu* shuttle_context_menu;
423 void build_shuttle_context_menu ();
424 void show_shuttle_context_menu ();
425 void shuttle_style_changed();
426 void shuttle_unit_clicked ();
427 void set_shuttle_max_speed (float);
428 void update_speed_display ();
429 float last_speed_displayed;
431 gint shuttle_box_button_press (GdkEventButton*);
432 gint shuttle_box_button_release (GdkEventButton*);
433 gint shuttle_box_scroll (GdkEventScroll*);
434 gint shuttle_box_motion (GdkEventMotion*);
435 gint shuttle_box_expose (GdkEventExpose*);
436 gint mouse_shuttle (double x, bool force);
437 void use_shuttle_fract (bool force);
438 void set_shuttle_fract (double);
440 bool shuttle_grabbed;
441 double shuttle_fract;
443 Gtkmm2ext::StatefulToggleButton punch_in_button;
444 Gtkmm2ext::StatefulToggleButton punch_out_button;
445 Gtkmm2ext::StatefulToggleButton auto_return_button;
446 Gtkmm2ext::StatefulToggleButton auto_play_button;
447 Gtkmm2ext::StatefulToggleButton auto_input_button;
448 Gtkmm2ext::StatefulToggleButton click_button;
449 Gtkmm2ext::StatefulToggleButton time_master_button;
451 Gtk::ToggleButton auditioning_alert_button;
452 Gtk::ToggleButton solo_alert_button;
456 void solo_blink (bool);
457 void audition_blink (bool);
459 void soloing_changed (bool);
460 void auditioning_changed (bool);
461 void _auditioning_changed (bool);
463 void solo_alert_toggle ();
464 void audition_alert_toggle ();
466 void primary_clock_value_changed ();
467 void secondary_clock_value_changed ();
469 /* called by Blink signal */
471 void transport_rec_enable_blink (bool onoff);
473 Gtk::Menu* session_popup_menu;
475 struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
476 RecentSessionModelColumns() {
480 Gtk::TreeModelColumn<Glib::ustring> visible_name;
481 Gtk::TreeModelColumn<Glib::ustring> fullpath;
484 RecentSessionModelColumns recent_session_columns;
485 Gtk::TreeView recent_session_display;
486 Glib::RefPtr<Gtk::TreeStore> recent_session_model;
488 ArdourDialog* session_selector_window;
489 Gtk::FileChooserDialog* open_session_selector;
491 void build_session_selector();
492 void redisplay_recent_sessions();
493 void recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
495 struct RecentSessionsSorter {
496 bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
497 return cmp_nocase(a.first, b.first) == -1;
501 /* menu bar and associated stuff */
503 Gtk::MenuBar* menu_bar;
504 Gtk::EventBox menu_bar_base;
507 void build_menu_bar ();
508 void build_control_surface_menu ();
510 Gtk::Label wall_clock_label;
511 Gtk::EventBox wall_clock_box;
512 gint update_wall_clock ();
514 Gtk::Label disk_space_label;
515 Gtk::EventBox disk_space_box;
516 void update_disk_space ();
518 Gtk::Label cpu_load_label;
519 Gtk::EventBox cpu_load_box;
520 void update_cpu_load ();
522 Gtk::Label buffer_load_label;
523 Gtk::EventBox buffer_load_box;
524 void update_buffer_load ();
526 Gtk::Label sample_rate_label;
527 Gtk::EventBox sample_rate_box;
528 void update_sample_rate (nframes_t);
530 gint every_second ();
531 gint every_point_one_seconds ();
532 gint every_point_zero_one_seconds ();
534 sigc::connection second_connection;
535 sigc::connection point_one_second_connection;
536 sigc::connection point_oh_five_second_connection;
537 sigc::connection point_zero_one_second_connection;
539 gint session_menu (GdkEventButton *);
541 bool _will_create_new_session_automatically;
543 NewSessionDialog* new_session_dialog;
545 void open_session ();
546 void open_recent_session ();
547 void save_template ();
549 void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many);
550 void session_add_midi_route (bool disk, uint32_t how_many);
552 void set_transport_sensitivity (bool);
554 void remove_last_capture ();
556 void transport_goto_zero ();
557 void transport_goto_start ();
558 void transport_goto_end ();
559 void transport_stop ();
560 void transport_stop_and_forget_capture ();
561 void transport_record ();
562 void transport_roll ();
563 void transport_play_selection();
564 void transport_forward (int option);
565 void transport_rewind (int option);
566 void transport_loop ();
568 void transport_rolling ();
569 void transport_rewinding ();
570 void transport_forwarding ();
571 void transport_stopped ();
573 bool _session_is_new;
574 void connect_to_session (ARDOUR::Session *);
575 void connect_dependents_to_session (ARDOUR::Session *);
576 void we_have_dependents ();
578 std::string keybindings_path;
580 void setup_keybindings ();
581 void setup_session_options ();
583 guint32 last_key_press_time;
585 void snapshot_session ();
590 PublicEditor *editor;
591 int create_editor ();
593 RouteParams_UI *route_params;
594 int create_route_params ();
596 ConnectionEditor *connection_editor;
597 int create_connection_editor ();
599 LocationUI *location_ui;
600 int create_location_ui ();
601 void handle_locations_change (ARDOUR::Location*);
603 ColorManager* color_manager;
607 OptionEditor *option_editor;
611 AddRouteDialog *add_route_dialog;
613 /* Keyboard Handling */
617 /* Keymap handling */
619 void install_actions ();
621 void toggle_record_enable (uint32_t);
623 uint32_t rec_enabled_streams;
624 void count_recenabled_streams (ARDOUR::Route&);
630 Gtk::MenuItem *cleanup_item;
632 void display_cleanup_results (ARDOUR::Session::cleanup_report& rep, const gchar* list_title, const string & msg);
636 bool have_configure_timeout;
637 struct timeval last_configure_time;
638 gint configure_timeout ();
640 struct timeval last_peak_grab;
641 struct timeval last_shuttle_request;
643 bool have_disk_speed_dialog_displayed;
644 void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
645 void disk_overrun_handler ();
646 void disk_underrun_handler ();
648 int pending_state_dialog ();
650 void disconnect_from_jack ();
651 void reconnect_to_jack ();
652 void set_jack_buffer_size (nframes_t);
654 Gtk::MenuItem* jack_disconnect_item;
655 Gtk::MenuItem* jack_reconnect_item;
656 Gtk::Menu* jack_bufsize_menu;
658 int make_session_clean ();
659 bool filter_ardour_session_dirs (const Gtk::FileFilter::Info&);
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 ();
672 void toggle_use_osc ();
674 void set_input_auto_connect (ARDOUR::AutoConnectOption);
675 void set_output_auto_connect (ARDOUR::AutoConnectOption);
676 void set_solo_model (ARDOUR::SoloModel);
677 void set_monitor_model (ARDOUR::MonitorModel);
678 void set_remote_model (ARDOUR::RemoteModel);
680 void toggle_StopPluginsWithTransport();
681 void toggle_DoNotRunPluginsWhileRecording();
682 void toggle_VerifyRemoveLastCapture();
683 void toggle_PeriodicSafetyBackups();
684 void toggle_StopRecordingOnXrun();
685 void toggle_StopTransportAtEndOfSession();
686 void toggle_GainReduceFastTransport();
687 void toggle_LatchedSolo();
688 void toggle_ShowSoloMutes();
689 void toggle_LatchedRecordEnable ();
690 void toggle_RegionEquivalentsOverlap ();
692 void mtc_port_changed ();
693 void map_solo_model ();
694 void map_monitor_model ();
695 void map_remote_model ();
696 void map_file_header_format ();
697 void map_file_data_format ();
698 void map_input_auto_connect ();
699 void map_output_auto_connect ();
700 void parameter_changed (const char*);
702 void set_meter_hold (ARDOUR::MeterHold);
703 void set_meter_falloff (ARDOUR::MeterFalloff);
704 void map_meter_hold ();
705 void map_meter_falloff ();
707 void toggle_control_protocol (ARDOUR::ControlProtocolInfo*);
708 void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo*, const char* group_name, std::string action_name);
710 bool can_save_keybindings;
713 void no_memory_warning ();
714 void check_memory_locking ();
717 #endif /* __ardour_gui_h__ */