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 "pbd/error.h"
33 #include "pbd/basename.h"
34 #include "pbd/fastlog.h"
36 #include "gtkmm2ext/cairocell.h"
37 #include "gtkmm2ext/utils.h"
38 #include "gtkmm2ext/click_box.h"
39 #include "gtkmm2ext/window_title.h"
41 #include "ardour/profile.h"
42 #include "ardour/session.h"
43 #include "ardour/types.h"
45 #include "ardour_ui.h"
47 #include "public_editor.h"
48 #include "audio_clock.h"
50 #include "main_clock.h"
52 #include "theme_manager.h"
53 #include "midi_tracer.h"
54 #include "shuttle_control.h"
55 #include "global_port_matrix.h"
56 #include "location_ui.h"
57 #include "rc_option_editor.h"
58 #include "time_info_box.h"
63 using namespace ARDOUR;
65 using namespace Gtkmm2ext;
68 using namespace ARDOUR_UI_UTILS;
72 ARDOUR_UI::tabs_button_event (GdkEventButton* ev)
74 std::vector<Widget*> children = _tabs.get_children();
76 for (std::vector<Widget*>::iterator w = children.begin(); w != children.end(); ++w) {
78 Gtk::Widget* close_button = reinterpret_cast<Gtk::Widget*> ((*w)->get_data ("close-button"));
82 Gtk::Allocation alloc (close_button->get_allocation());
85 /* Allocation origin uses toplevel window coordinates;
86 * event origin uses _tabs-centric coordinate space, so
87 * translate before computing if event is inside the
91 close_button->get_toplevel()->translate_coordinates (_tabs, alloc.get_x(), alloc.get_y(), dx, dy);
95 ev->x < dx + alloc.get_width() &&
96 ev->y < dy + alloc.get_height()) {
97 if (close_button->event ((GdkEvent*) ev)) {
108 ARDOUR_UI::tabs_page_removed (Gtk::Widget*, guint)
110 if (_tabs.get_n_pages() == 1) {
111 _tabs.set_show_tabs (false);
113 _tabs.set_show_tabs (true);
118 ARDOUR_UI::tabs_page_added (Gtk::Widget*, guint)
120 if (_tabs.get_n_pages() == 1) {
121 _tabs.set_show_tabs (false);
123 _tabs.set_show_tabs (true);
128 ARDOUR_UI::tabs_switch (GtkNotebookPage*, guint page_number)
133 ARDOUR_UI::setup_tooltips ()
135 set_tip (roll_button, _("Play from playhead"));
136 set_tip (stop_button, _("Stop playback"));
137 set_tip (rec_button, _("Toggle record"));
138 set_tip (play_selection_button, _("Play range/selection"));
139 set_tip (goto_start_button, _("Go to start of session"));
140 set_tip (goto_end_button, _("Go to end of session"));
141 set_tip (auto_loop_button, _("Play loop range"));
142 set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels"));
143 set_tip (auto_return_button, _("Return to last playback start when stopped"));
144 set_tip (follow_edits_button, _("Playhead follows range selections and edits"));
145 set_tip (auto_input_button, _("Be sensible about input monitoring"));
146 set_tip (click_button, _("Enable/Disable audio click"));
147 set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
148 set_tip (auditioning_alert_button, _("When active, auditioning is taking place.\nClick to stop the audition"));
149 set_tip (feedback_alert_button, _("When active, there is a feedback loop."));
150 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"));
151 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"));
152 set_tip (editor_meter_peak_display, _("Reset All Peak Indicators"));
153 set_tip (error_alert_button, _("Show Error Log and acknowledge warnings"));
155 synchronize_sync_source_and_video_pullup ();
157 editor->setup_tooltips ();
161 ARDOUR_UI::status_bar_button_press (GdkEventButton* ev)
163 bool handled = false;
165 switch (ev->button) {
167 status_bar_label.set_text ("");
178 ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
182 UI::display_message (prefix, prefix_len, ptag, mtag, msg);
184 ArdourLogLevel ll = LogLevelNone;
186 if (strcmp (prefix, _("[ERROR]: ")) == 0) {
187 text = "<span color=\"red\" weight=\"bold\">";
189 } else if (strcmp (prefix, _("[WARNING]: ")) == 0) {
190 text = "<span color=\"yellow\" weight=\"bold\">";
191 ll = LogLevelWarning;
192 } else if (strcmp (prefix, _("[INFO]: ")) == 0) {
193 text = "<span color=\"green\" weight=\"bold\">";
196 text = "<span color=\"white\" weight=\"bold\">???";
199 _log_not_acknowledged = std::max(_log_not_acknowledged, ll);
206 status_bar_label.set_markup (text);
211 ARDOUR_UI::tearoff_settings (const char* name) const
213 XMLNode* ui_node = Config->extra_xml(X_("UI"));
216 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
218 XMLNode* mnode = tearoff_node->child (name);
226 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
229 ARDOUR_UI::setup_transport ()
233 transport_hbox.set_border_width (PX_SCALE(3));
234 transport_hbox.set_spacing (PX_SCALE(3));
236 transport_base.set_name ("TransportBase");
237 transport_base.add (transport_hbox);
239 transport_frame.set_shadow_type (SHADOW_OUT);
240 transport_frame.set_name ("BaseFrame");
241 transport_frame.add (transport_base);
243 auto_return_button.set_text(_("Auto Return"));
245 follow_edits_button.set_text(_("Follow Edits"));
247 // auto_input_button.set_text (_("Auto Input"));
249 click_button.set_icon (ArdourIcon::TransportMetronom);
251 act = ActionManager::get_action ("Transport", "ToggleClick");
252 click_button.set_related_action (act);
253 click_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::click_button_clicked), false);
255 auto_return_button.set_name ("transport option button");
256 follow_edits_button.set_name ("transport option button");
257 auto_input_button.set_name ("transport option button");
259 /* these have to provide a clear indication of active state */
261 click_button.set_name ("transport button");
262 sync_button.set_name ("transport active option button");
264 stop_button.set_active (true);
266 goto_start_button.set_icon (ArdourIcon::TransportStart);
267 goto_end_button.set_icon (ArdourIcon::TransportEnd);
268 roll_button.set_icon (ArdourIcon::TransportPlay);
269 stop_button.set_icon (ArdourIcon::TransportStop);
270 play_selection_button.set_icon (ArdourIcon::TransportRange);
271 auto_loop_button.set_icon (ArdourIcon::TransportLoop);
272 rec_button.set_icon (ArdourIcon::RecButton);
273 midi_panic_button.set_icon (ArdourIcon::TransportPanic);
275 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
276 stop_button.set_related_action (act);
277 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
278 roll_button.set_related_action (act);
279 act = ActionManager::get_action (X_("Transport"), X_("Record"));
280 rec_button.set_related_action (act);
281 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
282 goto_start_button.set_related_action (act);
283 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
284 goto_end_button.set_related_action (act);
285 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
286 auto_loop_button.set_related_action (act);
287 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
288 play_selection_button.set_related_action (act);
289 act = ActionManager::get_action (X_("MIDI"), X_("panic"));
290 midi_panic_button.set_related_action (act);
291 act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
292 sync_button.set_related_action (act);
296 ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
297 ARDOUR_UI::Clock.connect (sigc::mem_fun (secondary_clock, &AudioClock::set));
299 primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
300 secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
301 big_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::big_clock_value_changed));
303 act = ActionManager::get_action ("Transport", "ToggleAutoReturn");
304 auto_return_button.set_related_action (act);
305 act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
306 follow_edits_button.set_related_action (act);
307 act = ActionManager::get_action ("Transport", "ToggleAutoInput");
308 auto_input_button.set_related_action (act);
312 /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */
314 solo_alert_button.set_name ("rude solo");
315 act = ActionManager::get_action (X_("Main"), X_("cancel-solo"));
316 solo_alert_button.set_related_action (act);
317 auditioning_alert_button.set_name ("rude audition");
318 auditioning_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press), false);
319 feedback_alert_button.set_name ("feedback alert");
320 feedback_alert_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::feedback_alert_press), false);
321 error_alert_button.set_name ("error alert");
322 error_alert_button.signal_button_release_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::error_alert_press), false);
323 act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
324 error_alert_button.set_related_action(act);
325 error_alert_button.set_fallthrough_to_parent(true);
327 alert_box.set_homogeneous (true);
328 alert_box.set_spacing (PX_SCALE(2));
329 alert_box.pack_start (solo_alert_button, true, true);
330 alert_box.pack_start (auditioning_alert_button, true, true);
331 alert_box.pack_start (feedback_alert_button, true, true);
333 /* all transport buttons should be the same size vertically and
337 Glib::RefPtr<SizeGroup> transport_button_size_group = SizeGroup::create (SIZE_GROUP_BOTH);
338 transport_button_size_group->add_widget (goto_start_button);
339 transport_button_size_group->add_widget (goto_end_button);
340 transport_button_size_group->add_widget (auto_loop_button);
341 transport_button_size_group->add_widget (rec_button);
342 transport_button_size_group->add_widget (play_selection_button);
343 transport_button_size_group->add_widget (roll_button);
344 transport_button_size_group->add_widget (stop_button);
346 /* the icon for this has an odd aspect ratio, so fatten up the button */
347 midi_panic_button.set_size_request (PX_SCALE(25), -1);
348 goto_start_button.set_size_request (PX_SCALE(28), PX_SCALE(44));
349 click_button.set_size_request (PX_SCALE(32), PX_SCALE(44));
352 HBox* tbox1 = manage (new HBox);
353 HBox* tbox2 = manage (new HBox);
354 HBox* tbox = manage (new HBox);
356 VBox* vbox1 = manage (new VBox);
357 VBox* vbox2 = manage (new VBox);
359 Alignment* a1 = manage (new Alignment);
360 Alignment* a2 = manage (new Alignment);
362 tbox1->set_spacing (PX_SCALE(2));
363 tbox2->set_spacing (PX_SCALE(2));
364 tbox->set_spacing (PX_SCALE(2));
366 if (!Profile->get_trx()) {
367 tbox1->pack_start (midi_panic_button, true, true, 5);
368 tbox1->pack_start (click_button, true, true, 5);
371 tbox1->pack_start (goto_start_button, true, true);
372 tbox1->pack_start (goto_end_button, true, true);
373 tbox1->pack_start (auto_loop_button, true, true);
375 if (!Profile->get_trx()) {
376 tbox2->pack_start (play_selection_button, true, true);
378 tbox2->pack_start (roll_button, true, true);
379 tbox2->pack_start (stop_button, true, true);
380 tbox2->pack_start (rec_button, true, true, 5);
382 vbox1->pack_start (*tbox1, true, true);
383 vbox2->pack_start (*tbox2, true, true);
386 a1->set (0.5, 0.5, 0.0, 1.0);
388 a2->set (0.5, 0.5, 0.0, 1.0);
390 tbox->pack_start (*a1, false, false);
391 tbox->pack_start (*a2, false, false);
393 HBox* clock_box = manage (new HBox);
395 clock_box->pack_start (*primary_clock, false, false);
396 if (!ARDOUR::Profile->get_small_screen() && !ARDOUR::Profile->get_trx()) {
397 clock_box->pack_start (*secondary_clock, false, false);
399 clock_box->set_spacing (PX_SCALE(3));
401 shuttle_box = manage (new ShuttleControl);
402 shuttle_box->show ();
404 VBox* transport_vbox = manage (new VBox);
405 transport_vbox->set_name ("TransportBase");
406 transport_vbox->set_border_width (0);
407 transport_vbox->set_spacing (PX_SCALE(3));
408 transport_vbox->pack_start (*tbox, true, true, 0);
410 if (!Profile->get_trx()) {
411 transport_vbox->pack_start (*shuttle_box, false, false, 0);
414 time_info_box = manage (new TimeInfoBox);
416 transport_hbox.pack_start (*transport_vbox, false, true);
418 /* transport related toggle controls */
420 VBox* auto_box = manage (new VBox);
421 auto_box->set_homogeneous (true);
422 auto_box->set_spacing (PX_SCALE(2));
423 auto_box->pack_start (sync_button, true, true);
424 if (!ARDOUR::Profile->get_trx()) {
425 auto_box->pack_start (follow_edits_button, true, true);
426 auto_box->pack_start (auto_return_button, true, true);
429 if (!ARDOUR::Profile->get_trx()) {
430 transport_hbox.pack_start (*auto_box, false, false);
432 transport_hbox.pack_start (*clock_box, true, true);
434 if (ARDOUR::Profile->get_trx()) {
435 transport_hbox.pack_start (*auto_box, false, false);
438 if (!ARDOUR::Profile->get_trx()) {
439 transport_hbox.pack_start (*time_info_box, false, false);
442 if (!ARDOUR::Profile->get_trx()) {
443 transport_hbox.pack_start (alert_box, false, false);
444 transport_hbox.pack_start (meter_box, false, false);
445 transport_hbox.pack_start (editor_meter_peak_display, false, false);
448 if (Profile->get_sae()) {
449 Image* img = manage (new Image ((::get_icon (X_("sae")))));
450 transport_hbox.pack_end (*img, false, false);
455 set_transport_sensitivity (false);
460 ARDOUR_UI::soloing_changed (bool onoff)
462 if (solo_alert_button.get_active() != onoff) {
463 solo_alert_button.set_active (onoff);
468 ARDOUR_UI::_auditioning_changed (bool onoff)
470 auditioning_alert_button.set_active (onoff);
471 set_transport_sensitivity (!onoff);
475 ARDOUR_UI::auditioning_changed (bool onoff)
477 UI::instance()->call_slot (MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::_auditioning_changed, this, onoff));
481 ARDOUR_UI::audition_alert_press (GdkEventButton*)
484 _session->cancel_audition();
490 ARDOUR_UI::feedback_alert_press (GdkEventButton *)
496 ARDOUR_UI::error_alert_press (GdkEventButton* ev)
498 bool do_toggle = true;
499 if (ev->button == 1) {
500 if (_log_not_acknowledged == LogLevelError) {
501 // just acknowledge the error, don't hide the log if it's already visible
502 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
503 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
504 if (tact && tact->get_active()) {
508 _log_not_acknowledged = LogLevelNone;
509 error_blink (false); // immediate acknowledge
511 // maybe fall through to to button toggle
516 ARDOUR_UI::solo_blink (bool onoff)
522 if (_session->soloing() || _session->listening()) {
524 solo_alert_button.set_active (true);
526 solo_alert_button.set_active (false);
529 solo_alert_button.set_active (false);
534 ARDOUR_UI::sync_blink (bool onoff)
536 if (_session == 0 || !_session->config.get_external_sync()) {
538 sync_button.set_active (false);
542 if (!_session->transport_locked()) {
543 /* not locked, so blink on and off according to the onoff argument */
546 sync_button.set_active (true);
548 sync_button.set_active (false);
552 sync_button.set_active (true);
557 ARDOUR_UI::audition_blink (bool onoff)
563 if (_session->is_auditioning()) {
565 auditioning_alert_button.set_active (true);
567 auditioning_alert_button.set_active (false);
570 auditioning_alert_button.set_active (false);
575 ARDOUR_UI::feedback_blink (bool onoff)
577 if (_feedback_exists) {
579 feedback_alert_button.set_active (true);
581 feedback_alert_button.set_active (false);
584 feedback_alert_button.set_active (false);
589 ARDOUR_UI::error_blink (bool onoff)
591 switch (_log_not_acknowledged) {
595 error_alert_button.set_custom_led_color(0xff0000ff); // bright red
597 error_alert_button.set_custom_led_color(0x880000ff); // dark red
600 case LogLevelWarning:
601 error_alert_button.set_custom_led_color(0xccaa00ff); // yellow
604 error_alert_button.set_custom_led_color(0x88cc00ff); // lime green
607 error_alert_button.set_custom_led_color(0x333333ff); // gray
615 ARDOUR_UI::set_transport_sensitivity (bool yn)
617 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
618 shuttle_box->set_sensitive (yn);
622 ARDOUR_UI::editor_realized ()
624 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
625 Config->map_parameters (pc);
627 UIConfiguration::instance().reset_dpi ();
631 ARDOUR_UI::maximise_editing_space ()
634 editor->maximise_editing_space ();
639 ARDOUR_UI::restore_editing_space ()
642 editor->restore_editing_space ();
647 ARDOUR_UI::show_ui_prefs ()
649 if (rc_option_editor) {
650 show_tabbable (rc_option_editor);
651 rc_option_editor->set_current_page (_("GUI"));
656 ARDOUR_UI::click_button_clicked (GdkEventButton* ev)
658 if (ev->button != 3) {
659 /* this handler is just for button-3 clicks */
663 show_tabbable (rc_option_editor);
664 rc_option_editor->set_current_page (_("Misc"));
669 ARDOUR_UI::toggle_follow_edits ()
671 RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
674 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic (act);
677 UIConfiguration::instance().set_follow_edits (tact->get_active ());
681 ARDOUR_UI::update_title ()
684 bool dirty = _session->dirty();
688 if (_session->snap_name() != _session->name()) {
689 session_name = _session->snap_name();
691 session_name = _session->name();
695 session_name = "*" + session_name;
698 WindowTitle title (session_name);
699 title += Glib::get_application_name();
700 _main_window.set_title (title.get_string());
702 WindowTitle title (Glib::get_application_name());
703 _main_window.set_title (title.get_string());