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::setup_tooltips ()
110 set_tip (roll_button, _("Play from playhead"));
111 set_tip (stop_button, _("Stop playback"));
112 set_tip (rec_button, _("Toggle record"));
113 set_tip (play_selection_button, _("Play range/selection"));
114 set_tip (goto_start_button, _("Go to start of session"));
115 set_tip (goto_end_button, _("Go to end of session"));
116 set_tip (auto_loop_button, _("Play loop range"));
117 set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels"));
118 set_tip (auto_return_button, _("Return to last playback start when stopped"));
119 set_tip (follow_edits_button, _("Playhead follows range selections and edits"));
120 set_tip (auto_input_button, _("Be sensible about input monitoring"));
121 set_tip (click_button, _("Enable/Disable audio click"));
122 set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything"));
123 set_tip (auditioning_alert_button, _("When active, auditioning is taking place.\nClick to stop the audition"));
124 set_tip (feedback_alert_button, _("When active, there is a feedback loop."));
125 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"));
126 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"));
127 set_tip (editor_meter_peak_display, _("Reset All Peak Indicators"));
128 set_tip (error_alert_button, _("Show Error Log and acknowledge warnings"));
130 synchronize_sync_source_and_video_pullup ();
132 editor->setup_tooltips ();
136 ARDOUR_UI::status_bar_button_press (GdkEventButton* ev)
138 bool handled = false;
140 switch (ev->button) {
142 status_bar_label.set_text ("");
153 ARDOUR_UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
157 UI::display_message (prefix, prefix_len, ptag, mtag, msg);
159 ArdourLogLevel ll = LogLevelNone;
161 if (strcmp (prefix, _("[ERROR]: ")) == 0) {
162 text = "<span color=\"red\" weight=\"bold\">";
164 } else if (strcmp (prefix, _("[WARNING]: ")) == 0) {
165 text = "<span color=\"yellow\" weight=\"bold\">";
166 ll = LogLevelWarning;
167 } else if (strcmp (prefix, _("[INFO]: ")) == 0) {
168 text = "<span color=\"green\" weight=\"bold\">";
171 text = "<span color=\"white\" weight=\"bold\">???";
174 _log_not_acknowledged = std::max(_log_not_acknowledged, ll);
181 status_bar_label.set_markup (text);
186 ARDOUR_UI::tearoff_settings (const char* name) const
188 XMLNode* ui_node = Config->extra_xml(X_("UI"));
191 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
193 XMLNode* mnode = tearoff_node->child (name);
201 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
204 ARDOUR_UI::setup_transport ()
208 transport_hbox.set_border_width (PX_SCALE(3));
209 transport_hbox.set_spacing (PX_SCALE(3));
211 transport_base.set_name ("TransportBase");
212 transport_base.add (transport_hbox);
214 transport_frame.set_shadow_type (SHADOW_OUT);
215 transport_frame.set_name ("BaseFrame");
216 transport_frame.add (transport_base);
218 auto_return_button.set_text(_("Auto Return"));
220 follow_edits_button.set_text(_("Follow Edits"));
222 // auto_input_button.set_text (_("Auto Input"));
224 click_button.set_icon (ArdourIcon::TransportMetronom);
226 act = ActionManager::get_action ("Transport", "ToggleClick");
227 click_button.set_related_action (act);
228 click_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::click_button_clicked), false);
230 auto_return_button.set_name ("transport option button");
231 follow_edits_button.set_name ("transport option button");
232 auto_input_button.set_name ("transport option button");
234 /* these have to provide a clear indication of active state */
236 click_button.set_name ("transport button");
237 sync_button.set_name ("transport active option button");
239 stop_button.set_active (true);
241 goto_start_button.set_icon (ArdourIcon::TransportStart);
242 goto_end_button.set_icon (ArdourIcon::TransportEnd);
243 roll_button.set_icon (ArdourIcon::TransportPlay);
244 stop_button.set_icon (ArdourIcon::TransportStop);
245 play_selection_button.set_icon (ArdourIcon::TransportRange);
246 auto_loop_button.set_icon (ArdourIcon::TransportLoop);
247 rec_button.set_icon (ArdourIcon::RecButton);
248 midi_panic_button.set_icon (ArdourIcon::TransportPanic);
250 act = ActionManager::get_action (X_("Transport"), X_("Stop"));
251 stop_button.set_related_action (act);
252 act = ActionManager::get_action (X_("Transport"), X_("Roll"));
253 roll_button.set_related_action (act);
254 act = ActionManager::get_action (X_("Transport"), X_("Record"));
255 rec_button.set_related_action (act);
256 act = ActionManager::get_action (X_("Transport"), X_("GotoStart"));
257 goto_start_button.set_related_action (act);
258 act = ActionManager::get_action (X_("Transport"), X_("GotoEnd"));
259 goto_end_button.set_related_action (act);
260 act = ActionManager::get_action (X_("Transport"), X_("Loop"));
261 auto_loop_button.set_related_action (act);
262 act = ActionManager::get_action (X_("Transport"), X_("PlaySelection"));
263 play_selection_button.set_related_action (act);
264 act = ActionManager::get_action (X_("MIDI"), X_("panic"));
265 midi_panic_button.set_related_action (act);
266 act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
267 sync_button.set_related_action (act);
271 ARDOUR_UI::Clock.connect (sigc::mem_fun (primary_clock, &AudioClock::set));
272 ARDOUR_UI::Clock.connect (sigc::mem_fun (secondary_clock, &AudioClock::set));
274 primary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
275 secondary_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
276 big_clock->ValueChanged.connect (sigc::mem_fun(*this, &ARDOUR_UI::big_clock_value_changed));
278 act = ActionManager::get_action ("Transport", "ToggleAutoReturn");
279 auto_return_button.set_related_action (act);
280 act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
281 follow_edits_button.set_related_action (act);
282 act = ActionManager::get_action ("Transport", "ToggleAutoInput");
283 auto_input_button.set_related_action (act);
287 /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */
289 solo_alert_button.set_name ("rude solo");
290 act = ActionManager::get_action (X_("Main"), X_("cancel-solo"));
291 solo_alert_button.set_related_action (act);
292 auditioning_alert_button.set_name ("rude audition");
293 auditioning_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press), false);
294 feedback_alert_button.set_name ("feedback alert");
295 feedback_alert_button.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::feedback_alert_press), false);
296 error_alert_button.set_name ("error alert");
297 error_alert_button.signal_button_release_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::error_alert_press), false);
298 act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
299 error_alert_button.set_related_action(act);
300 error_alert_button.set_fallthrough_to_parent(true);
302 alert_box.set_homogeneous (true);
303 alert_box.set_spacing (PX_SCALE(2));
304 alert_box.pack_start (solo_alert_button, true, true);
305 alert_box.pack_start (auditioning_alert_button, true, true);
306 alert_box.pack_start (feedback_alert_button, true, true);
308 /* all transport buttons should be the same size vertically and
312 Glib::RefPtr<SizeGroup> transport_button_size_group = SizeGroup::create (SIZE_GROUP_BOTH);
313 transport_button_size_group->add_widget (goto_start_button);
314 transport_button_size_group->add_widget (goto_end_button);
315 transport_button_size_group->add_widget (auto_loop_button);
316 transport_button_size_group->add_widget (rec_button);
317 transport_button_size_group->add_widget (play_selection_button);
318 transport_button_size_group->add_widget (roll_button);
319 transport_button_size_group->add_widget (stop_button);
321 /* the icon for this has an odd aspect ratio, so fatten up the button */
322 midi_panic_button.set_size_request (PX_SCALE(25), -1);
323 goto_start_button.set_size_request (PX_SCALE(28), PX_SCALE(44));
324 click_button.set_size_request (PX_SCALE(32), PX_SCALE(44));
327 HBox* tbox1 = manage (new HBox);
328 HBox* tbox2 = manage (new HBox);
329 HBox* tbox = manage (new HBox);
331 VBox* vbox1 = manage (new VBox);
332 VBox* vbox2 = manage (new VBox);
334 Alignment* a1 = manage (new Alignment);
335 Alignment* a2 = manage (new Alignment);
337 tbox1->set_spacing (PX_SCALE(2));
338 tbox2->set_spacing (PX_SCALE(2));
339 tbox->set_spacing (PX_SCALE(2));
341 if (!Profile->get_trx()) {
342 tbox1->pack_start (midi_panic_button, true, true, 5);
343 tbox1->pack_start (click_button, true, true, 5);
346 tbox1->pack_start (goto_start_button, true, true);
347 tbox1->pack_start (goto_end_button, true, true);
348 tbox1->pack_start (auto_loop_button, true, true);
350 if (!Profile->get_trx()) {
351 tbox2->pack_start (play_selection_button, true, true);
353 tbox2->pack_start (roll_button, true, true);
354 tbox2->pack_start (stop_button, true, true);
355 tbox2->pack_start (rec_button, true, true, 5);
357 vbox1->pack_start (*tbox1, true, true);
358 vbox2->pack_start (*tbox2, true, true);
361 a1->set (0.5, 0.5, 0.0, 1.0);
363 a2->set (0.5, 0.5, 0.0, 1.0);
365 tbox->pack_start (*a1, false, false);
366 tbox->pack_start (*a2, false, false);
368 HBox* clock_box = manage (new HBox);
370 clock_box->pack_start (*primary_clock, false, false);
371 if (!ARDOUR::Profile->get_small_screen() && !ARDOUR::Profile->get_trx()) {
372 clock_box->pack_start (*secondary_clock, false, false);
374 clock_box->set_spacing (PX_SCALE(3));
376 shuttle_box = manage (new ShuttleControl);
377 shuttle_box->show ();
379 VBox* transport_vbox = manage (new VBox);
380 transport_vbox->set_name ("TransportBase");
381 transport_vbox->set_border_width (0);
382 transport_vbox->set_spacing (PX_SCALE(3));
383 transport_vbox->pack_start (*tbox, true, true, 0);
385 if (!Profile->get_trx()) {
386 transport_vbox->pack_start (*shuttle_box, false, false, 0);
389 time_info_box = manage (new TimeInfoBox);
391 transport_hbox.pack_start (*transport_vbox, false, true);
393 /* transport related toggle controls */
395 VBox* auto_box = manage (new VBox);
396 auto_box->set_homogeneous (true);
397 auto_box->set_spacing (PX_SCALE(2));
398 auto_box->pack_start (sync_button, true, true);
399 if (!ARDOUR::Profile->get_trx()) {
400 auto_box->pack_start (follow_edits_button, true, true);
401 auto_box->pack_start (auto_return_button, true, true);
404 if (!ARDOUR::Profile->get_trx()) {
405 transport_hbox.pack_start (*auto_box, false, false);
407 transport_hbox.pack_start (*clock_box, true, true);
409 if (ARDOUR::Profile->get_trx()) {
410 transport_hbox.pack_start (*auto_box, false, false);
413 if (!ARDOUR::Profile->get_trx()) {
414 transport_hbox.pack_start (*time_info_box, false, false);
417 if (!ARDOUR::Profile->get_trx()) {
418 transport_hbox.pack_start (alert_box, false, false);
419 transport_hbox.pack_start (meter_box, false, false);
420 transport_hbox.pack_start (editor_meter_peak_display, false, false);
425 set_transport_sensitivity (false);
430 ARDOUR_UI::soloing_changed (bool onoff)
432 if (solo_alert_button.get_active() != onoff) {
433 solo_alert_button.set_active (onoff);
438 ARDOUR_UI::_auditioning_changed (bool onoff)
440 auditioning_alert_button.set_active (onoff);
441 set_transport_sensitivity (!onoff);
445 ARDOUR_UI::auditioning_changed (bool onoff)
447 UI::instance()->call_slot (MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::_auditioning_changed, this, onoff));
451 ARDOUR_UI::audition_alert_press (GdkEventButton*)
454 _session->cancel_audition();
460 ARDOUR_UI::feedback_alert_press (GdkEventButton *)
466 ARDOUR_UI::error_alert_press (GdkEventButton* ev)
468 bool do_toggle = true;
469 if (ev->button == 1) {
470 if (_log_not_acknowledged == LogLevelError) {
471 // just acknowledge the error, don't hide the log if it's already visible
472 RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-log-window"));
473 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
474 if (tact && tact->get_active()) {
478 _log_not_acknowledged = LogLevelNone;
479 error_blink (false); // immediate acknowledge
481 // maybe fall through to to button toggle
486 ARDOUR_UI::solo_blink (bool onoff)
492 if (_session->soloing() || _session->listening()) {
494 solo_alert_button.set_active (true);
496 solo_alert_button.set_active (false);
499 solo_alert_button.set_active (false);
504 ARDOUR_UI::sync_blink (bool onoff)
506 if (_session == 0 || !_session->config.get_external_sync()) {
508 sync_button.set_active (false);
512 if (!_session->transport_locked()) {
513 /* not locked, so blink on and off according to the onoff argument */
516 sync_button.set_active (true);
518 sync_button.set_active (false);
522 sync_button.set_active (true);
527 ARDOUR_UI::audition_blink (bool onoff)
533 if (_session->is_auditioning()) {
535 auditioning_alert_button.set_active (true);
537 auditioning_alert_button.set_active (false);
540 auditioning_alert_button.set_active (false);
545 ARDOUR_UI::feedback_blink (bool onoff)
547 if (_feedback_exists) {
549 feedback_alert_button.set_active (true);
551 feedback_alert_button.set_active (false);
554 feedback_alert_button.set_active (false);
559 ARDOUR_UI::error_blink (bool onoff)
561 switch (_log_not_acknowledged) {
565 error_alert_button.set_custom_led_color(0xff0000ff); // bright red
567 error_alert_button.set_custom_led_color(0x880000ff); // dark red
570 case LogLevelWarning:
571 error_alert_button.set_custom_led_color(0xccaa00ff); // yellow
574 error_alert_button.set_custom_led_color(0x88cc00ff); // lime green
577 error_alert_button.set_custom_led_color(0x333333ff); // gray
585 ARDOUR_UI::set_transport_sensitivity (bool yn)
587 ActionManager::set_sensitive (ActionManager::transport_sensitive_actions, yn);
588 shuttle_box->set_sensitive (yn);
592 ARDOUR_UI::editor_realized ()
594 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
595 Config->map_parameters (pc);
597 UIConfiguration::instance().reset_dpi ();
601 ARDOUR_UI::maximise_editing_space ()
604 editor->maximise_editing_space ();
609 ARDOUR_UI::restore_editing_space ()
612 editor->restore_editing_space ();
617 ARDOUR_UI::show_ui_prefs ()
619 if (rc_option_editor) {
620 show_tabbable (rc_option_editor);
621 rc_option_editor->set_current_page (_("GUI"));
626 ARDOUR_UI::click_button_clicked (GdkEventButton* ev)
628 if (ev->button != 3) {
629 /* this handler is just for button-3 clicks */
633 show_tabbable (rc_option_editor);
634 rc_option_editor->set_current_page (_("Misc"));
639 ARDOUR_UI::toggle_follow_edits ()
641 RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleFollowEdits"));
644 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic (act);
647 UIConfiguration::instance().set_follow_edits (tact->get_active ());
651 ARDOUR_UI::update_title ()
654 bool dirty = _session->dirty();
658 if (_session->snap_name() != _session->name()) {
659 session_name = _session->snap_name();
661 session_name = _session->name();
665 session_name = "*" + session_name;
668 WindowTitle title (session_name);
669 title += Glib::get_application_name();
670 _main_window.set_title (title.get_string());
672 WindowTitle title (Glib::get_application_name());
673 _main_window.set_title (title.get_string());