1 /*
2  * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
4  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
5  * Copyright (C) 2006-2007 Doug McLain <doug@nostar.net>
6  * Copyright (C) 2006-2011 David Robillard <d@drobilla.net>
7  * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
8  * Copyright (C) 2007-2015 Tim Mayberry <mojofunk@gmail.com>
9  * Copyright (C) 2008 Hans Baier <hansfbaier@googlemail.com>
10  * Copyright (C) 2012-2015 Colin Fletcher <colin.m.fletcher@googlemail.com>
11  * Copyright (C) 2013-2015 Nick Mainsbridge <mainsbridge@gmail.com>
12  * Copyright (C) 2013-2016 John Emmas <john@creativepost.co.uk>
13  * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
14  * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
15  * Copyright (C) 2017 Johannes Mueller <github@johannes-mueller.org>
16  * Copyright (C) 2018 Len Ovens <len@ovenwerks.net>
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License along
29  * with this program; if not, write to the Free Software Foundation, Inc.,
30  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31  */
32 
33 #ifndef __ardour_gui_h__
34 #define __ardour_gui_h__
35 
36 #include <time.h>
37 
38 /* need _BSD_SOURCE to get timersub macros */
39 
40 #ifdef _BSD_SOURCE
41 #include <sys/time.h>
42 #else
43 #define _BSD_SOURCE
44 #include <sys/time.h>
45 #undef _BSD_SOURCE
46 #endif
47 
48 #include <list>
49 #include <cmath>
50 
51 
52 #include "pbd/xml++.h"
53 #include <gtkmm/box.h>
54 #include <gtkmm/frame.h>
55 #include <gtkmm/label.h>
56 #include <gtkmm/table.h>
57 #include <gtkmm/fixed.h>
58 #include <gtkmm/drawingarea.h>
59 #include <gtkmm/eventbox.h>
60 #include <gtkmm/menu.h>
61 #include <gtkmm/menuitem.h>
62 #include <gtkmm/messagedialog.h>
63 #include <gtkmm/notebook.h>
64 #include <gtkmm/button.h>
65 #include <gtkmm/togglebutton.h>
66 #include <gtkmm/treeview.h>
67 #include <gtkmm/menubar.h>
68 #include <gtkmm/textbuffer.h>
69 #include <gtkmm/adjustment.h>
70 
71 #include "gtkmm2ext/gtk_ui.h"
72 #include "gtkmm2ext/bindings.h"
73 #include "gtkmm2ext/visibility_tracker.h"
74 
75 #include "ardour/ardour.h"
76 #include "ardour/types.h"
77 #include "ardour/utils.h"
78 #include "ardour/plugin.h"
79 #include "ardour/session_handle.h"
80 #include "ardour/system_exec.h"
81 
82 #include "video_timeline.h"
83 
84 #include "widgets/ardour_button.h"
85 #include "widgets/ardour_spacer.h"
86 
87 #include "add_route_dialog.h"
88 #include "ardour_dialog.h"
89 #include "ardour_window.h"
90 #include "editing.h"
91 #include "enums.h"
92 #include "mini_timeline.h"
93 #include "shuttle_control.h"
94 #include "startup_fsm.h"
95 #include "transport_control.h"
96 #include "transport_control_ui.h"
97 #include "visibility_group.h"
98 #include "window_manager.h"
99 
100 #ifdef COMPILER_MSVC
101 #include "about.h"
102 #include "add_video_dialog.h"
103 #include "big_clock_window.h"
104 #include "big_transport_window.h"
105 #include "bundle_manager.h"
106 #include "dsp_stats_window.h"
107 #include "engine_dialog.h"
108 #include "export_video_dialog.h"
109 #include "global_port_matrix.h"
110 #include "idleometer.h"
111 #include "keyeditor.h"
112 #include "location_ui.h"
113 #include "lua_script_manager.h"
114 #include "plugin_dspload_window.h"
115 #include "rc_option_editor.h"
116 #include "route_dialogs.h"
117 #include "route_params_ui.h"
118 #include "session_option_editor.h"
119 #include "speaker_dialog.h"
120 #include "transport_masters_dialog.h"
121 #include "virtual_keyboard_window.h"
122 #else
123 class About;
124 class AddRouteDialog;
125 class AddVideoDialog;
126 class BigClockWindow;
127 class BigTransportWindow;
128 class BundleManager;
129 class EngineControl;
130 class ExportVideoDialog;
131 class KeyEditor;
132 class LocationUIWindow;
133 class LuaScriptManager;
134 class RCOptionEditor;
135 class RouteParams_UI;
136 class SessionOptionEditor;
137 class SpeakerDialog;
138 class GlobalPortMatrixWindow;
139 class IdleOMeter;
140 class PluginDSPLoadWindow;
141 class DspStatisticsWindow;
142 class TransportMastersWindow;
143 class VirtualKeyboardWindow;
144 #endif
145 
146 class VideoTimeLine;
147 class ArdourKeyboard;
148 class AudioClock;
149 class ConnectionEditor;
150 class DuplicateRouteDialog;
151 class MainClock;
152 class Mixer_UI;
153 class PublicEditor;
154 class RecorderUI;
155 class SaveAsDialog;
156 class SaveTemplateDialog;
157 class SessionDialog;
158 class SessionOptionEditorWindow;
159 class Splash;
160 class TimeInfoBox;
161 class Meterbridge;
162 class LuaWindow;
163 class MidiTracer;
164 class NSM_Client;
165 class LevelMeterHBox;
166 class GUIObjectState;
167 
168 namespace ARDOUR {
169 	class ControlProtocolInfo;
170 	class IO;
171 	class Port;
172 	class Route;
173 	class RouteGroup;
174 	class Location;
175 	class ProcessThread;
176 }
177 
178 namespace Gtk {
179 	class ProgressBar;
180 }
181 
182 namespace ArdourWidgets {
183 	class Prompter;
184 	class Tabbable;
185 }
186 
187 #define MAX_LUA_ACTION_SCRIPTS 32
188 #define MAX_LUA_ACTION_BUTTONS 12
189 
190 class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr, public TransportControlProvider
191 {
192 public:
193 	ARDOUR_UI (int *argcp, char **argvp[], const char* localedir);
194 	~ARDOUR_UI();
195 
196 	bool run_startup (bool should_be_new, std::string load_template);
197 
198 	void hide_splash ();
199 
200 	void launch_chat ();
201 	void launch_tutorial ();
202 	void launch_reference ();
203 	void launch_tracker ();
204 	void launch_subscribe ();
205 	void launch_cheat_sheet ();
206 	void launch_website ();
207 	void launch_website_dev ();
208 	void launch_forums ();
209 	void launch_howto_report ();
210 	void show_about ();
211 	void hide_about ();
212 
213 	void load_from_application_api (const std::string& path);
214 	void finish();
215 
216 	int load_session (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
217 	bool session_load_in_progress;
218 	int build_session (std::string const& path, std::string const& snapshot, std::string const& session_template, ARDOUR::BusProfile const&, bool from_startup_fsm, bool unnamed);
session_is_new()219 	bool session_is_new() const { return _session_is_new; }
220 
the_session()221 	ARDOUR::Session* the_session() { return _session; }
222 
223 	bool get_smart_mode () const;
224 
get_rc_option_editor()225 	RCOptionEditor* get_rc_option_editor() { return rc_option_editor; }
226 	void show_tabbable (ArdourWidgets::Tabbable*);
227 
228 	void start_session_load (bool create_new);
229 	void session_dialog_response_handler (int response, SessionDialog* session_dialog);
230 	void build_session_from_dialog (SessionDialog&, std::string const& session_name, std::string const& session_path, std::string const& session_template);
231 	bool ask_about_loading_existing_session (const std::string& session_path);
232 	int load_session_from_startup_fsm ();
233 
234 	/// @return true if session was successfully unloaded.
235 	int unload_session (bool hide_stuff = false);
236 	void close_session();
237 
238 	int  save_state_canfail (std::string state_name = "", bool switch_to_it = false);
239 	void save_state (const std::string & state_name = "", bool switch_to_it = false);
240 
instance()241 	static ARDOUR_UI *instance () { return theArdourUI; }
242 
243 	/* signal emitted when escape key is pressed. All UI components that
244 	   need to respond to Escape in some way (e.g. break drag, clear
245 	   selection, etc) should connect to and handle this.
246 	*/
247 	PBD::Signal0<void> Escape;
248 
the_editor()249 	PublicEditor&	  the_editor() { return *editor;}
the_mixer()250 	Mixer_UI* the_mixer() { return mixer; }
251 
252 	Gtk::Menu* shared_popup_menu ();
253 
254 	void new_midi_tracer_window ();
255 	void toggle_editing_space();
256 	void toggle_mixer_space();
257 	void toggle_keep_tearoffs();
258 
259 	void reset_focus (Gtk::Widget*);
260 
261 	static PublicEditor* _instance;
262 
263 	/** Emitted frequently with the audible sample, false, and the edit point as
264 	 *  parameters respectively.
265 	 *
266 	 *  (either RapidScreenUpdate || SuperRapidScreenUpdate - user-config)
267 	 */
268 	static sigc::signal<void, samplepos_t> Clock;
269 
close_all_dialogs()270 	static void close_all_dialogs () { CloseAllDialogs(); }
271 	static sigc::signal<void> CloseAllDialogs;
272 
273 	XMLNode* main_window_settings() const;
274 	XMLNode* editor_settings() const;
275 	XMLNode* preferences_settings() const;
276 	XMLNode* mixer_settings () const;
277 	XMLNode* recorder_settings () const;
278 	XMLNode* keyboard_settings () const;
279 	XMLNode* tearoff_settings (const char*) const;
280 
281 	void save_ardour_state ();
282 	gboolean configure_handler (GdkEventConfigure* conf);
283 
284 	void halt_on_xrun_message ();
285 	void xrun_handler (samplepos_t);
286 	void create_xrun_marker (samplepos_t);
287 
288 	GUIObjectState* gui_object_state;
289 
290 	MainClock* primary_clock;
291 	MainClock* secondary_clock;
292 	void focus_on_clock ();
293 	AudioClock*   big_clock;
294 
295 	VideoTimeLine *video_timeline;
296 
297 	void store_clock_modes ();
298 	void restore_clock_modes ();
299 	void reset_main_clocks ();
300 
301 	void synchronize_sync_source_and_video_pullup ();
302 
303 	void add_route ();
304 	void add_route_dialog_response (int);
305 
306 	void add_routes_part_two ();
307 	void add_routes_thread ();
308 
309 	void start_duplicate_routes ();
310 
311 	void add_video (Gtk::Window* float_window);
312 	void remove_video ();
313 	void start_video_server_menu (Gtk::Window* float_window);
314 	bool start_video_server (Gtk::Window* float_window, bool popup_msg);
315 	void stop_video_server (bool ask_confirm=false);
316 	void flush_videotimeline_cache (bool localcacheonly=false);
317 	void export_video (bool range = false);
318 
319 	void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *,
320 	                              uint32_t, std::string const &, bool, ARDOUR::PresentationInfo::order_t order);
321 
322 	void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, bool,
323 	                             ARDOUR::PluginInfoPtr, ARDOUR::Plugin::PresetRecord*,
324 	                             ARDOUR::PresentationInfo::order_t order);
325 
326 	void session_add_foldback_bus (int32_t, uint32_t, std::string const &);
327 
328 	void display_insufficient_ports_message ();
329 
330 	void attach_to_engine ();
331 	void post_engine ();
332 
333 	gint exit_on_main_window_close (GdkEventAny *);
334 
335 	void maximise_editing_space ();
336 	void restore_editing_space ();
337 
338 	void show_ui_prefs ();
339 	void show_mixer_prefs ();
340 
341 	bool check_audioengine(Gtk::Window&);
342 
343 	void setup_profile ();
344 	void setup_tooltips ();
345 
346 	void set_shuttle_fract (double);
347 
348 	void get_process_buffers ();
349 	void drop_process_buffers ();
350 
351 	void reset_peak_display ();
352 	void reset_route_peak_display (ARDOUR::Route*);
353 	void reset_group_peak_display (ARDOUR::RouteGroup*);
354 
announce_string()355 	const std::string& announce_string() const { return _announce_string; }
356 
357 	void hide_application ();
358 
359 	Gtk::Notebook& tabs();
main_window()360 	Gtk::Window& main_window () { return _main_window; }
361 
362 	void setup_toplevel_window (Gtk::Window&, const std::string& name, void* owner);
363 
364 	/* called from a static C function */
365 
366 	GtkNotebook* tab_window_root_drop (GtkNotebook* src,
367 	                                   GtkWidget* w,
368 	                                   gint x,
369 	                                   gint y,
370 	                                   gpointer user_data);
371 
372 	bool tabbed_window_state_event_handler (GdkEventWindowState*, void* object);
373 	bool key_event_handler (GdkEventKey*, Gtk::Window* window);
374 
375 	ARDOUR::PresentationInfo::order_t translate_order (RouteDialogs::InsertAt);
376 
377 	std::map<std::string, std::string> route_setup_info (const std::string& script_path);
378 
379 	void gui_idle_handler ();
380 
381 protected:
382 	friend class PublicEditor;
383 
384 	void toggle_use_monitor_section ();
385 	void monitor_dim_all ();
386 	void monitor_cut_all ();
387 	void monitor_mono ();
388 
389 	void toggle_auto_play ();
390 	void toggle_auto_input ();
391 	void toggle_punch ();
392 	void unset_dual_punch ();
393 	bool ignore_dual_punch;
394 	void toggle_punch_in ();
395 	void toggle_punch_out ();
396 	void toggle_session_monitoring_in ();
397 	void toggle_session_monitoring_disk ();
398 	void show_loop_punch_ruler_and_disallow_hide ();
399 	void reenable_hide_loop_punch_ruler_if_appropriate ();
400 	void toggle_auto_return ();
401 	void toggle_click ();
402 	void toggle_session_auto_loop ();
403 	void toggle_rc_options_window ();
404 	void toggle_session_options_window ();
405 
406 private:
407 
408 	Gtk::Window   _main_window;
409 	Gtkmm2ext::VisibilityTracker* main_window_visibility;
410 	Gtk::VBox      main_vpacker;
411 	Gtk::HBox      status_bar_hpacker;
412 	Gtk::Notebook _tabs;
413 	PublicEditor*  editor;
414 	Mixer_UI*      mixer;
415 	RecorderUI*    recorder;
416 	Gtk::Tooltips _tooltips;
417 	NSM_Client*    nsm;
418 	bool          _was_dirty;
419 	bool          _mixer_on_top;
420 
421 	Gtk::Menu*    _shared_popup_menu;
422 
423 	void hide_tabbable (ArdourWidgets::Tabbable*);
424 	void detach_tabbable (ArdourWidgets::Tabbable*);
425 	void attach_tabbable (ArdourWidgets::Tabbable*);
426 	void button_change_tabbable_visibility (ArdourWidgets::Tabbable*);
427 	void key_change_tabbable_visibility (ArdourWidgets::Tabbable*);
428 	void toggle_editor_and_mixer ();
429 
430 	void tabbable_state_change (ArdourWidgets::Tabbable&);
431 
432 	void toggle_meterbridge ();
433 	void toggle_luawindow ();
434 
435 	int  setup_windows ();
436 	void setup_transport ();
437 	void setup_clock ();
438 
439 	static ARDOUR_UI *theArdourUI;
440 	SessionDialog *_session_dialog;
441 
442 	StartupFSM* startup_fsm;
443 
444 	int starting ();
445 	int nsm_init ();
446 	void startup_done ();
447 	void sfsm_response (StartupFSM::Result);
448 
449 	int ask_about_saving_session (const std::vector<std::string>& actions);
450 
451 	void audio_midi_setup_reconfigure_done (int response, std::string path, std::string snapshot, std::string mix_template);
452 	int  load_session_stage_two (const std::string& path, const std::string& snapshot, std::string mix_template = std::string());
453 	void audio_midi_setup_for_new_session_done (int response, std::string path, std::string snapshot, std::string session_template, ARDOUR::BusProfile const&, bool unnamed);
454 	int  build_session_stage_two (std::string const& path, std::string const& snapshot, std::string const& session_template, ARDOUR::BusProfile const&, bool unnamed);
455 	sigc::connection _engine_dialog_connection;
456 
457 	void save_session_at_its_request (std::string);
458 	/* periodic safety backup, to be precise */
459 	gint autosave_session();
460 	void update_autosave();
461 	sigc::connection _autosave_connection;
462 
463 	void session_dirty_changed ();
464 	void update_title ();
465 
466 	void map_transport_state ();
467 	int32_t do_engine_start ();
468 
469 	void engine_halted (const char* reason, bool free_reason);
470 	void engine_stopped ();
471 	void engine_running (uint32_t cnt);
472 
473 	void use_config ();
474 
475 	void about_signal_response(int response);
476 
477 	Gtk::VBox    top_packer;
478 
479 	sigc::connection clock_signal_connection;
480 	void         update_clocks ();
481 	void         start_clocking ();
482 	void         stop_clocking ();
483 
484 	void update_transport_clocks (samplepos_t pos);
485 	void record_state_changed ();
486 
487 	std::list<MidiTracer*> _midi_tracer_windows;
488 
489 	/* Transport Control */
490 
491 	Gtk::Table               transport_table;
492 	Gtk::Frame               transport_frame;
493 	Gtk::HBox                transport_hbox;
494 
495 	ArdourWidgets::ArdourVSpacer* secondary_clock_spacer;
496 	void repack_transport_hbox ();
497 	void update_clock_visibility ();
498 	void toggle_follow_edits ();
499 
500 	void set_transport_controllable_state (const XMLNode&);
501 	XMLNode& get_transport_controllable_state ();
502 
503 	TransportControlUI transport_ctrl;
504 
505 	ArdourWidgets::ArdourButton punch_in_button;
506 	ArdourWidgets::ArdourButton punch_out_button;
507 	ArdourWidgets::ArdourButton layered_button;
508 
509 	ArdourWidgets::ArdourVSpacer recpunch_spacer;
510 	ArdourWidgets::ArdourVSpacer latency_spacer;
511 	ArdourWidgets::ArdourVSpacer monitor_spacer;
512 	ArdourWidgets::ArdourVSpacer scripts_spacer;
513 
514 	ArdourWidgets::ArdourButton monitor_dim_button;
515 	ArdourWidgets::ArdourButton monitor_mono_button;
516 	ArdourWidgets::ArdourButton monitor_mute_button;
517 
518 	Gtk::Label   punch_label;
519 	Gtk::Label   layered_label;
520 
521 	Gtk::Label   punch_space;
522 
523 	void toggle_external_sync ();
524 	void toggle_time_master ();
525 	void toggle_video_sync ();
526 
527 
528 	ArdourWidgets::ArdourButton latency_disable_button;
529 
530 	Gtk::Label route_latency_value;
531 	Gtk::Label io_latency_label;
532 	Gtk::Label io_latency_value;
533 
534 	ShuttleControl     shuttle_box;
535 	MiniTimeline       mini_timeline;
536 	TimeInfoBox*       time_info_box;
537 
538 
539 	ArdourWidgets::ArdourVSpacer      meterbox_spacer;
540 	ArdourWidgets::ArdourVSpacer      meterbox_spacer2;
541 
542 	ArdourWidgets::ArdourButton auto_return_button;
543 	ArdourWidgets::ArdourButton follow_edits_button;
544 	ArdourWidgets::ArdourButton sync_button;
545 
546 	ArdourWidgets::ArdourButton auditioning_alert_button;
547 	ArdourWidgets::ArdourButton solo_alert_button;
548 	ArdourWidgets::ArdourButton feedback_alert_button;
549 	ArdourWidgets::ArdourButton error_alert_button;
550 
551 	ArdourWidgets::ArdourButton action_script_call_btn[MAX_LUA_ACTION_BUTTONS];
552 
553 	Gtk::VBox alert_box;
554 
555 	Gtk::Table editor_meter_table;
556 	ArdourWidgets::ArdourButton editor_meter_peak_display;
557 	LevelMeterHBox *            editor_meter;
558 
559 	bool  _clear_editor_meter;
560 	bool  _editor_meter_peaked;
561 	bool  editor_meter_peak_button_release (GdkEventButton*);
562 
563 	void blink_handler (bool);
564 	sigc::connection blink_connection;
565 
566 	void cancel_solo ();
567 	void solo_blink (bool);
568 	void sync_blink (bool);
569 	void audition_blink (bool);
570 	void feedback_blink (bool);
571 	void error_blink (bool);
572 
573 	void set_flat_buttons();
574 
575 	void soloing_changed (bool);
576 	void auditioning_changed (bool);
577 	void _auditioning_changed (bool);
578 
579 	bool solo_alert_press (GdkEventButton* ev);
580 	void audition_alert_clicked ();
581 	bool error_alert_press (GdkEventButton *);
582 
583 	void layered_button_clicked ();
584 
585 	void big_clock_value_changed ();
586 	void primary_clock_value_changed ();
587 	void secondary_clock_value_changed ();
588 
589 	/* called by Blink signal */
590 
591 	void transport_rec_enable_blink (bool onoff);
592 
593 	/* menu bar and associated stuff */
594 
595 	Gtk::MenuBar* menu_bar;
596 	Gtk::EventBox menu_bar_base;
597 	Gtk::HBox     menu_hbox;
598 
599 	void use_menubar_as_top_menubar ();
600 	void build_menu_bar ();
601 
602 	Gtk::Label   wall_clock_label;
603 	gint update_wall_clock ();
604 
605 	Gtk::Label  disk_space_label;
606 	void update_disk_space ();
607 	void format_disk_space_label (float);
608 
609 	Gtk::Label   timecode_format_label;
610 	void update_timecode_format ();
611 
612 	Gtk::Label  dsp_load_label;
613 	void update_cpu_load ();
614 
615 	Gtk::Label   peak_thread_work_label;
616 	void update_peak_thread_work ();
617 
618 	Gtk::Label   sample_rate_label;
619 	void update_sample_rate (ARDOUR::samplecnt_t);
620 
621 	Gtk::Label    format_label;
622 	void update_format ();
623 
624 	Gtk::Label session_path_label;
625 	void update_path_label ();
626 
627 	Gtk::Label snapshot_name_label;
628 
629 	void every_second ();
630 	void every_point_one_seconds ();
631 	void every_point_zero_something_seconds ();
632 
633 	sigc::connection second_connection;
634 	sigc::connection point_one_second_connection;
635 	sigc::connection point_zero_something_second_connection;
636 	sigc::connection fps_connection;
637 
638 	void set_fps_timeout_connection ();
639 
640 	void open_session ();
641 	void open_recent_session ();
642 	void save_template_dialog_response (int response, SaveTemplateDialog* d);
643 	void save_template ();
644 	void manage_templates ();
645 
646 	void meta_session_setup (const std::string& script_path);
647 	void meta_route_setup (const std::string& script_path);
648 
649 	void edit_metadata ();
650 	void import_metadata ();
651 
652 	void set_transport_sensitivity (bool);
653 	void set_punch_sensitivity ();
654 
655 	//stuff for ProTools-style numpad
656 	void transport_numpad_event (int num);
657 	void transport_numpad_decimal ();
658 	bool _numpad_locate_happening;
659 	int _pending_locate_num;
660 	gint transport_numpad_timeout ();
661 	sigc::connection _numpad_timeout_connection;
662 
663 	void transport_goto_nth_marker (int nth);
664 	void transport_goto_zero ();
665 	void transport_goto_start ();
666 	void transport_goto_end ();
667 	void transport_goto_wallclock ();
668 	void transport_stop ();
669 	void transport_record (bool roll);
670 	void transport_roll ();
671 	void transport_play_selection();
672 	void transport_play_preroll();
673 	void transport_rec_preroll();
674 	void transport_rec_count_in();
675 	void transport_forward ();
676 	void transport_rewind ();
677 	void transport_ffwd_rewind (bool fwd);
678 	void transport_loop ();
679 	void toggle_roll (bool with_abort, bool roll_out_of_bounded_mode);
680 	bool trx_record_enable_all_tracks ();
681 
682 	bool _session_is_new;
683 	void set_session (ARDOUR::Session *);
684 	void connect_dependents_to_session (ARDOUR::Session *);
685 	void we_have_dependents ();
686 
687 	void setup_session_options ();
688 
689 	guint32  last_key_press_time;
690 
691 	bool process_snapshot_session_prompter (ArdourWidgets::Prompter& prompter, bool switch_to_it);
692 	void snapshot_session (bool switch_to_it);
693 
694 	void quick_snapshot_session (bool switch_to_it);  //does not promtp for name, just makes a timestamped file
695 
696 	SaveAsDialog* save_as_dialog;
697 
698 	bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
699 	void save_session_as ();
700 	void archive_session ();
701 	void rename_session (bool for_unnamed);
702 
703 	int         create_mixer ();
704 	int         create_editor ();
705 	int         create_meterbridge ();
706 	int         create_luawindow ();
707 	int         create_masters ();
708 	int         create_recorder ();
709 
710 	Meterbridge  *meterbridge;
711 	LuaWindow    *luawindow;
712 
713 	/* Dialogs that can be created via new<T> */
714 
715 	RCOptionEditor* rc_option_editor;
716 	Gtk::HBox rc_option_editor_placeholder;
717 
718 	WM::Proxy<SpeakerDialog> speaker_config_window;
719 	WM::Proxy<AddRouteDialog> add_route_dialog;
720 	WM::Proxy<About> about;
721 	WM::Proxy<LocationUIWindow> location_ui;
722 	WM::Proxy<RouteParams_UI> route_params;
723 	WM::Proxy<EngineControl> audio_midi_setup;
724 	WM::Proxy<ExportVideoDialog> export_video_dialog;
725 	WM::Proxy<LuaScriptManager> lua_script_window;
726 	WM::Proxy<IdleOMeter> idleometer;
727 	WM::Proxy<PluginDSPLoadWindow> plugin_dsp_load_window;
728 	WM::Proxy<DspStatisticsWindow> dsp_statistics_window;
729 	WM::Proxy<TransportMastersWindow> transport_masters_window;
730 
731 	/* Windows/Dialogs that require a creator method */
732 
733 	WM::ProxyWithConstructor<SessionOptionEditor> session_option_editor;
734 	WM::ProxyWithConstructor<AddVideoDialog> add_video_dialog;
735 	WM::ProxyWithConstructor<BundleManager> bundle_manager;
736 	WM::ProxyWithConstructor<BigClockWindow> big_clock_window;
737 	WM::ProxyWithConstructor<BigTransportWindow> big_transport_window;
738 	WM::ProxyWithConstructor<VirtualKeyboardWindow> virtual_keyboard_window;
739 	WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
740 	WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
741 	WM::ProxyWithConstructor<KeyEditor> key_editor;
742 
743 	/* creator methods */
744 
745 	SessionOptionEditor*    create_session_option_editor ();
746 	BundleManager*          create_bundle_manager ();
747 	AddVideoDialog*         create_add_video_dialog ();
748 	BigClockWindow*         create_big_clock_window();
749 	BigTransportWindow*     create_big_transport_window();
750 	VirtualKeyboardWindow*  create_virtual_keyboard_window();
751 	GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
752 	KeyEditor*              create_key_editor ();
753 
754 	ARDOUR::SystemExec *video_server_process;
755 
756 	void handle_locations_change (ARDOUR::Location*);
757 
758 	/* Keyboard Handling */
759 
760 	ArdourKeyboard* keyboard;
761 
762 	/* Keymap handling */
763 
764 	void install_actions ();
765 	void install_dependent_actions ();
766 
767 	void toggle_record_enable (uint16_t);
768 
769 	uint32_t rec_enabled_streams;
770 	void count_recenabled_streams (ARDOUR::Route&);
771 
772 	/* cleanup */
773 
774 	Gtk::MenuItem *cleanup_item;
775 
776 	void display_cleanup_results (ARDOUR::CleanupReport const& rep, const gchar* list_title, const bool msg_delete);
777 	void cleanup ();
778 	void cleanup_peakfiles ();
779 	void flush_trash ();
780 
781 	bool have_configure_timeout;
782 	PBD::microseconds_t last_configure_time;
783 	gint configure_timeout ();
784 
785 	PBD::microseconds_t last_peak_grab;
786 	PBD::microseconds_t last_shuttle_request;
787 
788 	bool have_disk_speed_dialog_displayed;
789 	void disk_speed_dialog_gone (int ignored_response, Gtk::MessageDialog*);
790 	void disk_overrun_handler ();
791 	void disk_underrun_handler ();
792 
793 	void session_format_mismatch (std::string, std::string);
794 
795 	void session_dialog (std::string);
796 	int pending_state_dialog ();
797 	int sr_mismatch_dialog (ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
798 	void sr_mismatch_message (ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
799 
800 	Gtk::MenuItem* jack_disconnect_item;
801 	Gtk::MenuItem* jack_reconnect_item;
802 	Gtk::Menu*     jack_bufsize_menu;
803 
804 	Glib::RefPtr<Gtk::ActionGroup> common_actions;
805 
806 	void editor_realized ();
807 
808 	std::vector<std::string> positional_sync_strings;
809 
810 	void toggle_use_mmc ();
811 	void toggle_send_mmc ();
812 	void toggle_send_mtc ();
813 	void toggle_send_midi_clock ();
814 
815 	void toggle_use_osc ();
816 
817 	void parameter_changed (std::string);
818 	void session_parameter_changed (std::string);
819 
820 	bool first_idle ();
821 
822 	void check_memory_locking ();
823 
824 	void audioengine_setup ();
825 
826 	void display_message (const char* prefix, gint prefix_len, Glib::RefPtr<Gtk::TextBuffer::Tag>, Glib::RefPtr<Gtk::TextBuffer::Tag>, const char* msg);
827 	Gtk::Label status_bar_label;
828 	bool status_bar_button_press (GdkEventButton*);
829 
830 	PBD::ScopedConnectionList forever_connections;
831 	PBD::ScopedConnection halt_connection;
832 	PBD::ScopedConnection editor_meter_connection;
833 
834 	/* these are used only in response to a platform-specific "ShouldQuit" signal */
835 	bool idle_finish ();
836 	void queue_finish ();
837 	void fontconfig_dialog ();
838 
839 	int missing_file (ARDOUR::Session*s, std::string str, ARDOUR::DataType type);
840 	int ambiguous_file (std::string file, std::vector<std::string> hits);
841 
842 	bool click_button_clicked (GdkEventButton *);
843 	bool sync_button_clicked (GdkEventButton *);
844 
845 	VisibilityGroup _status_bar_visibility;
846 
847 	/** A ProcessThread so that we have some thread-local buffers for use by
848 	 *  PluginEqGui::impulse_analysis ().
849 	 */
850 	ARDOUR::ProcessThread* _process_thread;
851 
852 	void toggle_latency_switch ();
853 	void latency_switch_changed ();
854 	void session_latency_updated (bool);
855 
856 	void feedback_detected ();
857 
858 	ArdourWidgets::ArdourButton             midi_panic_button;
859 	void                     midi_panic ();
860 
861 	void successful_graph_sort ();
862 	bool _feedback_exists;
863 	bool _ambiguous_latency;
864 
865 	enum ArdourLogLevel {
866 		LogLevelNone = 0,
867 		LogLevelInfo,
868 		LogLevelWarning,
869 		LogLevelError
870 	};
871 
872 	ArdourLogLevel _log_not_acknowledged;
873 
874 	void on_theme_changed ();
875 
876 	bool path_button_press (GdkEventButton* ev);
877 	bool audio_button_press (GdkEventButton* ev);
878 	bool format_button_press (GdkEventButton* ev);
879 	bool timecode_button_press (GdkEventButton* ev);
880 	bool xrun_button_press (GdkEventButton* ev);
881 	bool xrun_button_release (GdkEventButton* ev);
882 
883 	std::string _announce_string;
884 	void check_announcements ();
885 
886 	void audioengine_became_silent ();
887 
888 	DuplicateRouteDialog* duplicate_routes_dialog;
889 
890 	void grab_focus_after_dialog ();
891 
892 	void tabs_switch (GtkNotebookPage*, guint page_number);
893 	void tabs_page_added (Gtk::Widget*, guint);
894 	void tabs_page_removed (Gtk::Widget*, guint);
895 	ArdourWidgets::ArdourButton editor_visibility_button;
896 	ArdourWidgets::ArdourButton mixer_visibility_button;
897 	ArdourWidgets::ArdourButton prefs_visibility_button;
898 	ArdourWidgets::ArdourButton recorder_visibility_button;
899 
900 	bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev, Gtkmm2ext::Bindings*);
901 	bool try_gtk_accel_binding (GtkWindow* win, GdkEventKey* ev, bool translate, GdkModifierType modifier);
902 
903 	bool main_window_delete_event (GdkEventAny*);
904 	bool idle_ask_about_quit ();
905 
906 	bool tabbable_visibility_button_press (GdkEventButton* ev, std::string const& tabbable_name);
907 
908 	void step_up_through_tabs ();
909 	void step_down_through_tabs ();
910 
911 	void escape ();
912 	void close_current_dialog ();
913 
914 	bool bind_lua_action_script (GdkEventButton*, int);
915 	void action_script_changed (int i, const std::string&);
916 
917 	void ask_about_scratch_deletion ();
918 };
919 
920 #endif /* __ardour_gui_h__ */
921