2 Copyright (C) 1999 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.
21 #include "gtk2ardour-config.h"
31 #include <sigc++/bind.h>
32 #include "canvas/canvas.h"
34 #include "pbd/error.h"
35 #include "pbd/basename.h"
36 #include "pbd/fastlog.h"
38 #include "gtkmm2ext/cairocell.h"
39 #include "gtkmm2ext/utils.h"
40 #include "gtkmm2ext/click_box.h"
41 #include "gtkmm2ext/window_title.h"
43 #include "ardour/profile.h"
44 #include "ardour/session.h"
45 #include "ardour/types.h"
47 #include "ardour_ui.h"
49 #include "public_editor.h"
50 #include "audio_clock.h"
52 #include "main_clock.h"
55 #include "theme_manager.h"
56 #include "midi_tracer.h"
57 #include "shuttle_control.h"
58 #include "global_port_matrix.h"
59 #include "location_ui.h"
60 #include "rc_option_editor.h"
61 #include "time_info_box.h"
66 using namespace ARDOUR;
68 using namespace Gtkmm2ext;
71 using namespace ARDOUR_UI_UTILS;
75 ARDOUR_UI::setup_tooltips ()
77 ArdourCanvas::Canvas::set_tooltip_timeout (Gtk::Settings::get_default()->property_gtk_tooltip_timeout ());
79 set_tip (roll_button, _("Play from playhead"));
80 set_tip (stop_button, _("Stop playback"));
81 set_tip (rec_button, _("Toggle record"));
82 set_tip (play_selection_button, _("Play range/selection"));
83 set_tip (goto_start_button, _("Go to start of session"));
84 set_tip (goto_end_button, _("Go to end of session"));
85 set_tip (auto_loop_button, _("Play loop range"));
86 set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels"));
87 set_tip (auto_return_button, _("Return to last playback start when stopped"));
88 set_tip (follow_edits_button, _("Playhead follows range selections and edits"));
89 set_tip (auto_input_button, _("Be sensible about input monitoring"));
90 set_tip (click_button, _("Enable/Disable audio click"));
91 set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
92 set_tip (auditioning_alert_button, _("When active, auditioning is taking place.\nClick to stop the audition"));
93 set_tip (feedback_alert_button, _("When active, there is a feedback loop."));
94 set_tip (primary_clock, _("<b>Primary Clock</b> right-click to set display mode. Click to edit, click+drag a digit or mouse-over+scroll wheel to modify.\nText edits: right-to-left overwrite <tt>Esc</tt>: cancel; <tt>Enter</tt>: confirm; postfix the edit with '+' or '-' to enter delta times.\n"));
95 set_tip (secondary_clock, _("<b>Secondary Clock</b> right-click to set display mode. Click to edit, click+drag a digit or mouse-over+scroll wheel to modify.\nText edits: right-to-left overwrite <tt>Esc</tt>: cancel; <tt>Enter</tt>: confirm; postfix the edit with '+' or '-' to enter delta times.\n"));
96 set_tip (editor_meter_peak_display, _("Reset All Peak Indicators"));
97 set_tip (error_alert_button, _("Show Error Log and acknowledge warnings"));
99 synchronize_sync_source_and_video_pullup ();
101 editor->setup_tooltips ();
105 ARDOUR_UI::status_bar_button_press (GdkEventButton* ev)
107 bool handled = false;
109 switch (ev->button) {
111 status_bar_label.set_text ("");
122 ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
126 UI::display_message (prefix, prefix_len, ptag, mtag, msg);
128 ArdourLogLevel ll = LogLevelNone;
130 if (strcmp (prefix, _("[ERROR]: ")) == 0) {
131 text = "<span color=\"red\" weight=\"bold\">";
133 } else if (strcmp (prefix, _("[WARNING]: ")) == 0) {
134 text = "<span color=\"yellow\" weight=\"bold\">";
135 ll = LogLevelWarning;
136 } else if (strcmp (prefix, _("[INFO]: ")) == 0) {
137 text = "<span color=\"green\" weight=\"bold\">";
140 text = "<span color=\"white\" weight=\"bold\">???";
143 _log_not_acknowledged = std::max(_log_not_acknowledged, ll);
150 status_bar_label.set_markup (text);
155 ARDOUR_UI::tearoff_settings (const char* name) const
157 XMLNode* ui_node = Config->extra_xml(X_("UI"));
160 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
162 XMLNode* mnode = tearoff_node->child (name);
170 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
173 bool drag_failed (const Glib::RefPtr<Gdk::DragContext>& context, DragResult result, Tabbable* tab)
175 if (result == Gtk::DRAG_RESULT_NO_TARGET) {
183 ARDOUR_UI::setup_transport ()
187 transport_hbox.set_border_width (PX_SCALE(3));
188 transport_hbox.set_spacing (PX_SCALE(3));
190 transport_base.set_name ("TransportBase");
191 transport_base.add (transport_hbox);
193 transport_frame.set_shadow_type (SHADOW_OUT);
194 transport_frame.set_name ("BaseFrame");
195 transport_frame.add (transport_base);
197 auto_return_button.set_text(_("Auto Return"));
199 follow_edits_button.set_text(_("Follow Edits"));
201 // auto_input_button.set_text (_("Auto Input"));
203 click_button.set_icon (ArdourIcon::TransportMetronom);
205 act = ActionManager::get_action ("Transport", "ToggleClick");
206 click_button.set_related_action (act);
207 click_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::click_button_clicked), false);
209 auto_return_button.set_name ("transport option button");
210 follow_edits_button.set_name ("transport option button");
211 auto_input_button.set_name ("transport option button");
213 /* these have to provide a clear indication of active state */
215 click_button.set_name ("transport button");
216 sync_button.set_name ("transport active option button");
218 stop_button.set_active (true);
220 goto_start_button.set_icon (ArdourIcon::TransportStart);
221 goto_end_button.set_icon (ArdourIcon::TransportEnd);
222 roll_button.set_icon (ArdourIcon::TransportPlay);
223 stop_button.set_icon (ArdourIcon::TransportStop);
224 play_selection_button.set_icon (ArdourIcon::TransportRange);
225 auto_loop_button.set_icon (ArdourIcon::TransportLoop);
226 rec_button.set_icon (ArdourIcon::RecButton);
227 midi_panic_button.set_icon (ArdourIcon::TransportPanic);
229 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
230 stop_button.set_related_action (act);
231 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
232 roll_button.set_related_action (act);
233 act = ActionManager::get_action (X_("Transport"), X_("Record"));
234 rec_button.set_related_action (act);
235 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
236 goto_start_button.set_related_action (act);
237 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
238 goto_end_button.set_related_action (act);
239 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
240 auto_loop_button.set_related_action (act);
241 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
242 play_selection_button.set_related_action (act);
243 act = ActionManager::get_action (X_("MIDI"), X_("panic"));
244 midi_panic_button.set_related_action (act);
245 act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
246 sync_button.set_related_action (act);
250 ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
251 ARDOUR_UI::Clock.connect (sigc::mem_fun (secondary_clock, &AudioClock::set));
253 primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
254 secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
255 big_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::big_clock_value_changed));
257 act = ActionManager::get_action ("Transport", "ToggleAutoReturn");
258 auto_return_button.set_related_action (act);
259 act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
260 follow_edits_button.set_related_action (act);
261 act = ActionManager::get_action ("Transport", "ToggleAutoInput");
262 auto_input_button.set_related_action (act);
266 /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */
268 solo_alert_button.set_name ("rude solo");
269 act = ActionManager::get_action (X_("Main"), X_("cancel-solo"));
270 solo_alert_button.set_related_action (act);
271 auditioning_alert_button.set_name ("rude audition");
272 auditioning_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press), false);
273 feedback_alert_button.set_name ("feedback alert");
274 feedback_alert_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::feedback_alert_press), false);
275 error_alert_button.set_name ("error alert");
276 error_alert_button.signal_button_release_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::error_alert_press), false);
277 act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
278 error_alert_button.set_related_action(act);
279 error_alert_button.set_fallthrough_to_parent(true);
281 alert_box.set_homogeneous (true);
282 alert_box.set_spacing (PX_SCALE(2));
283 alert_box.pack_start (solo_alert_button, true, true);
284 alert_box.pack_start (auditioning_alert_button, true, true);
285 alert_box.pack_start (feedback_alert_button, true, true);
287 /* all transport buttons should be the same size vertically and
291 Glib::RefPtr<SizeGroup> transport_button_size_group = SizeGroup::create (SIZE_GROUP_BOTH);
292 transport_button_size_group->add_widget (goto_start_button);
293 transport_button_size_group->add_widget (goto_end_button);
294 transport_button_size_group->add_widget (auto_loop_button);
295 transport_button_size_group->add_widget (rec_button);
296 transport_button_size_group->add_widget (play_selection_button);
297 transport_button_size_group->add_widget (roll_button);
298 transport_button_size_group->add_widget (stop_button);
300 /* the icon for this has an odd aspect ratio, so fatten up the button */
301 midi_panic_button.set_size_request (PX_SCALE(25), -1);
302 goto_start_button.set_size_request (PX_SCALE(28), PX_SCALE(44));
303 click_button.set_size_request (PX_SCALE(32), PX_SCALE(44));
306 HBox* tbox1 = manage (new HBox);
307 HBox* tbox2 = manage (new HBox);
308 HBox* tbox = manage (new HBox);
310 VBox* vbox1 = manage (new VBox);
311 VBox* vbox2 = manage (new VBox);
313 Alignment* a1 = manage (new Alignment);
314 Alignment* a2 = manage (new Alignment);
316 tbox1->set_spacing (PX_SCALE(2));
317 tbox2->set_spacing (PX_SCALE(2));
318 tbox->set_spacing (PX_SCALE(2));
320 if (!Profile->get_trx()) {
321 tbox1->pack_start (midi_panic_button, true, true, 5);
322 tbox1->pack_start (click_button, true, true, 5);
325 tbox1->pack_start (goto_start_button, true, true);
326 tbox1->pack_start (goto_end_button, true, true);
327 tbox1->pack_start (auto_loop_button, true, true);
329 if (!Profile->get_trx()) {
330 tbox2->pack_start (play_selection_button, true, true);
332 tbox2->pack_start (roll_button, true, true);
333 tbox2->pack_start (stop_button, true, true);
334 tbox2->pack_start (rec_button, true, true, 5);
336 vbox1->pack_start (*tbox1, true, true);
337 vbox2->pack_start (*tbox2, true, true);
340 a1->set (0.5, 0.5, 0.0, 1.0);
342 a2->set (0.5, 0.5, 0.0, 1.0);
344 tbox->pack_start (*a1, false, false);
345 tbox->pack_start (*a2, false, false);
347 HBox* clock_box = manage (new HBox);
349 clock_box->pack_start (*primary_clock, false, false);
350 if (!ARDOUR::Profile->get_small_screen() && !ARDOUR::Profile->get_trx()) {
351 clock_box->pack_start (*secondary_clock, false, false);
353 clock_box->set_spacing (PX_SCALE(3));
355 shuttle_box = manage (new ShuttleControl);
356 shuttle_box->show ();
358 VBox* transport_vbox = manage (new VBox);
359 transport_vbox->set_name ("TransportBase");
360 transport_vbox->set_border_width (0);
361 transport_vbox->set_spacing (PX_SCALE(3));
362 transport_vbox->pack_start (*tbox, true, true, 0);
364 if (!Profile->get_trx()) {
365 transport_vbox->pack_start (*shuttle_box, false, false, 0);
368 time_info_box = manage (new TimeInfoBox);
370 transport_hbox.pack_start (*transport_vbox, false, true);
372 /* transport related toggle controls */
374 VBox* auto_box = manage (new VBox);
375 auto_box->set_homogeneous (true);
376 auto_box->set_spacing (PX_SCALE(2));
377 auto_box->pack_start (sync_button, true, true);
378 if (!ARDOUR::Profile->get_trx()) {
379 auto_box->pack_start (follow_edits_button, true, true);
380 auto_box->pack_start (auto_return_button, true, true);
383 if (!ARDOUR::Profile->get_trx()) {
384 transport_hbox.pack_start (*auto_box, false, false);
386 transport_hbox.pack_start (*clock_box, true, true);
388 if (ARDOUR::Profile->get_trx()) {
389 transport_hbox.pack_start (*auto_box, false, false);
392 if (!ARDOUR::Profile->get_trx()) {
393 transport_hbox.pack_start (*time_info_box, false, false);
396 if (!ARDOUR::Profile->get_trx()) {
397 transport_hbox.pack_start (alert_box, false, false);
398 transport_hbox.pack_start (meter_box, false, false);
399 transport_hbox.pack_start (editor_meter_peak_display, false, false);
402 Gtk::VBox* window_button_box = manage (new Gtk::VBox);
404 editor_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), editor));
405 mixer_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), mixer));
406 prefs_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), rc_option_editor));
408 /* catch context clicks so that we can show a menu on these buttons */
410 editor_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("editor")), false);
411 mixer_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("mixer")), false);
412 prefs_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("preferences")), false);
414 editor_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-editor-visibility")));
415 editor_visibility_button.set_name (X_("page switch button"));
416 mixer_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-mixer-visibility")));
417 mixer_visibility_button.set_name (X_("page switch button"));
418 prefs_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-preferences-visibility")));
419 prefs_visibility_button.set_name (X_("page switch button"));
421 Gtkmm2ext::UI::instance()->set_tip (editor_visibility_button,
422 string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n"
423 "To put the window back, use the Window > %1 > Attach menu action"), editor->name()));
425 Gtkmm2ext::UI::instance()->set_tip (mixer_visibility_button,
426 string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n"
427 "To put the window back, use the Window > %1 > Attach menu action"), mixer->name()));
429 Gtkmm2ext::UI::instance()->set_tip (prefs_visibility_button,
430 string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n"
431 "To put the window back, use the Window > %1 > Attach menu action"), rc_option_editor->name()));
433 window_button_box->pack_start (editor_visibility_button, true, false);
434 window_button_box->pack_start (mixer_visibility_button, true, false);
435 window_button_box->pack_start (prefs_visibility_button, true, false);
437 transport_hbox.pack_end (*window_button_box, false, false);
438 transport_hbox.pack_end (action_script_table, false, false);
442 set_transport_sensitivity (false);
447 ARDOUR_UI::soloing_changed (bool onoff)
449 if (solo_alert_button.get_active() != onoff) {
450 solo_alert_button.set_active (onoff);
455 ARDOUR_UI::_auditioning_changed (bool onoff)
457 auditioning_alert_button.set_active (onoff);
458 set_transport_sensitivity (!onoff);
462 ARDOUR_UI::auditioning_changed (bool onoff)
464 UI::instance()->call_slot (MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::_auditioning_changed, this, onoff));
468 ARDOUR_UI::audition_alert_press (GdkEventButton*)
471 _session->cancel_audition();
477 ARDOUR_UI::feedback_alert_press (GdkEventButton *)
483 ARDOUR_UI::error_alert_press (GdkEventButton* ev)
485 bool do_toggle = true;
486 if (ev->button == 1) {
487 if (_log_not_acknowledged == LogLevelError) {
488 // just acknowledge the error, don't hide the log if it's already visible
489 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
490 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
491 if (tact && tact->get_active()) {
495 _log_not_acknowledged = LogLevelNone;
496 error_blink (false); // immediate acknowledge
498 // maybe fall through to to button toggle
503 ARDOUR_UI::solo_blink (bool onoff)
509 if (_session->soloing() || _session->listening()) {
511 solo_alert_button.set_active (true);
513 solo_alert_button.set_active (false);
516 solo_alert_button.set_active (false);
521 ARDOUR_UI::sync_blink (bool onoff)
523 if (_session == 0 || !_session->config.get_external_sync()) {
525 sync_button.set_active (false);
529 if (!_session->transport_locked()) {
530 /* not locked, so blink on and off according to the onoff argument */
533 sync_button.set_active (true);
535 sync_button.set_active (false);
539 sync_button.set_active (true);
544 ARDOUR_UI::audition_blink (bool onoff)
550 if (_session->is_auditioning()) {
552 auditioning_alert_button.set_active (true);
554 auditioning_alert_button.set_active (false);
557 auditioning_alert_button.set_active (false);
562 ARDOUR_UI::feedback_blink (bool onoff)
564 if (_feedback_exists) {
566 feedback_alert_button.set_active (true);
568 feedback_alert_button.set_active (false);
571 feedback_alert_button.set_active (false);
576 ARDOUR_UI::error_blink (bool onoff)
578 switch (_log_not_acknowledged) {
582 error_alert_button.set_custom_led_color(0xff0000ff); // bright red
584 error_alert_button.set_custom_led_color(0x880000ff); // dark red
587 case LogLevelWarning:
588 error_alert_button.set_custom_led_color(0xccaa00ff); // yellow
591 error_alert_button.set_custom_led_color(0x88cc00ff); // lime green
594 error_alert_button.set_custom_led_color(0x333333ff); // gray
602 ARDOUR_UI::set_transport_sensitivity (bool yn)
604 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
605 shuttle_box->set_sensitive (yn);
609 ARDOUR_UI::editor_realized ()
611 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
612 Config->map_parameters (pc);
614 UIConfiguration::instance().reset_dpi ();
618 ARDOUR_UI::maximise_editing_space ()
621 editor->maximise_editing_space ();
626 ARDOUR_UI::restore_editing_space ()
629 editor->restore_editing_space ();
634 ARDOUR_UI::show_ui_prefs ()
636 if (rc_option_editor) {
637 show_tabbable (rc_option_editor);
638 rc_option_editor->set_current_page (_("GUI"));
643 ARDOUR_UI::click_button_clicked (GdkEventButton* ev)
645 if (ev->button != 3) {
646 /* this handler is just for button-3 clicks */
650 show_tabbable (rc_option_editor);
651 rc_option_editor->set_current_page (_("Misc"));
656 ARDOUR_UI::toggle_follow_edits ()
658 RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
661 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic (act);
664 UIConfiguration::instance().set_follow_edits (tact->get_active ());
668 ARDOUR_UI::update_title ()
671 bool dirty = _session->dirty();
675 if (_session->snap_name() != _session->name()) {
676 session_name = _session->snap_name();
678 session_name = _session->name();
682 session_name = "*" + session_name;
685 WindowTitle title (session_name);
686 title += Glib::get_application_name();
687 _main_window.set_title (title.get_string());
689 WindowTitle title (Glib::get_application_name());
690 _main_window.set_title (title.get_string());