2 * Copyright (C) 2005-2007 Doug McLain <doug@nostar.net>
3 * Copyright (C) 2005-2017 Tim Mayberry <mojofunk@gmail.com>
4 * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
6 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
7 * Copyright (C) 2006-2015 David Robillard <d@drobilla.net>
8 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
9 * Copyright (C) 2008-2010 Sakari Bergen <sakari.bergen@beatwaves.net>
10 * Copyright (C) 2012-2019 Robin Gareus <robin@gareus.org>
11 * Copyright (C) 2013-2015 Colin Fletcher <colin.m.fletcher@googlemail.com>
12 * Copyright (C) 2013-2016 John Emmas <john@creativepost.co.uk>
13 * Copyright (C) 2013-2016 Nick Mainsbridge <mainsbridge@gmail.com>
14 * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
15 * Copyright (C) 2015 André Nusser <andre.nusser@googlemail.com>
16 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
17 * Copyright (C) 2017 Johannes Mueller <github@johannes-mueller.org>
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 #include "gtk2ardour-config.h"
36 #include "gtk2ardour-version.h"
39 #include "ardour/monitor_processor.h"
40 #include "ardour/session.h"
41 #include "ardour/route.h"
44 #include "ardour_ui.h"
45 #include "audio_clock.h"
46 #include "gui_thread.h"
47 #include "main_clock.h"
48 #include "public_editor.h"
49 #include "ui_config.h"
53 using namespace ARDOUR;
55 using namespace Gtkmm2ext;
56 using namespace ArdourWidgets;
59 using namespace Editing;
62 ARDOUR_UI::cancel_solo ()
65 _session->cancel_all_solo ();
70 ARDOUR_UI::reset_focus (Gtk::Widget* w)
72 /* this resets focus to the first focusable parent of the given widget,
73 * or, if there is no focusable parent, cancels focus in the toplevel
74 * window that the given widget is packed into (if there is one).
81 Gtk::Widget* top = w->get_toplevel();
83 if (!top || !top->is_toplevel()) {
91 if (w->is_toplevel()) {
92 /* Setting the focus widget to a Gtk::Window causes all
93 * subsequent calls to ::has_focus() on the nominal
94 * focus widget in that window to return
95 * false. Workaround: never set focus to the toplevel
101 if (w->get_can_focus ()) {
102 Gtk::Window* win = dynamic_cast<Gtk::Window*> (top);
106 w = w->get_parent ();
109 if (top == &_main_window) {
113 /* no focusable parent found, cancel focus in top level window.
114 C++ API cannot be used for this. Thanks, references.
117 gtk_window_set_focus (GTK_WINDOW(top->gobj()), 0);
122 ARDOUR_UI::monitor_dim_all ()
124 boost::shared_ptr<Route> mon = _session->monitor_out ();
128 boost::shared_ptr<ARDOUR::MonitorProcessor> _monitor = mon->monitor_control ();
130 Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-dim-all");
131 _monitor->set_dim_all (tact->get_active());
135 ARDOUR_UI::monitor_cut_all ()
137 boost::shared_ptr<Route> mon = _session->monitor_out ();
141 boost::shared_ptr<ARDOUR::MonitorProcessor> _monitor = mon->monitor_control ();
143 Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-cut-all");
144 _monitor->set_cut_all (tact->get_active());
148 ARDOUR_UI::monitor_mono ()
150 boost::shared_ptr<Route> mon = _session->monitor_out ();
154 boost::shared_ptr<ARDOUR::MonitorProcessor> _monitor = mon->monitor_control ();
156 Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-mono");
157 _monitor->set_mono (tact->get_active());
161 ARDOUR_UI::shared_popup_menu ()
163 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::shared_popup_menu, ignored);
165 assert (!_shared_popup_menu || !_shared_popup_menu->is_visible());
166 delete _shared_popup_menu;
167 _shared_popup_menu = new Gtk::Menu;
168 return _shared_popup_menu;
172 ARDOUR_UI::set_flat_buttons ()
174 CairoWidget::set_flat_buttons( UIConfiguration::instance().get_flat_buttons() );
179 ARDOUR_UI::update_transport_clocks (samplepos_t pos)
181 switch (UIConfiguration::instance().get_primary_clock_delta_mode()) {
183 primary_clock->set (pos);
186 primary_clock->set (pos, false, editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD));
188 case DeltaOriginMarker:
190 Location* loc = _session->locations()->clock_origin_location ();
191 primary_clock->set (pos, false, loc ? loc->start() : 0);
196 switch (UIConfiguration::instance().get_secondary_clock_delta_mode()) {
198 secondary_clock->set (pos);
201 secondary_clock->set (pos, false, editor->get_preferred_edit_position (EDIT_IGNORE_PHEAD));
203 case DeltaOriginMarker:
205 Location* loc = _session->locations()->clock_origin_location ();
206 secondary_clock->set (pos, false, loc ? loc->start() : 0);
211 if (big_clock_window) {
212 big_clock->set (pos);
215 if (!editor->preview_video_drag_active ()) {
216 ARDOUR_UI::instance()->video_timeline->manual_seek_video_monitor(pos);
222 ARDOUR_UI::record_state_changed ()
224 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::record_state_changed);
227 /* why bother - the clock isn't visible */
231 ActionManager::set_sensitive (ActionManager::rec_sensitive_actions, !_session->actively_recording());
233 if (big_clock_window) {
234 if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) {
235 big_clock->set_active (true);
237 big_clock->set_active (false);