2 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2016 Paul Davis
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include <gtkmm/menu.h>
21 #include <gtkmm/menuitem.h>
23 #include "ardour/parameter_descriptor.h"
24 #include "ardour/parameter_types.h"
25 #include "ardour/stripable.h"
27 #include "public_editor.h"
28 #include "stripable_time_axis.h"
33 using namespace ARDOUR;
36 StripableTimeAxisView::StripableTimeAxisView (PublicEditor& ed, ARDOUR::Session* s, ArdourCanvas::Canvas& canvas)
37 : TimeAxisView(s, ed, (TimeAxisView*) 0, canvas)
38 , gain_automation_item(NULL)
39 , trim_automation_item(NULL)
40 , mute_automation_item(NULL)
41 , parent_canvas (canvas)
46 StripableTimeAxisView::~StripableTimeAxisView ()
51 StripableTimeAxisView::set_stripable (boost::shared_ptr<ARDOUR::Stripable> s)
54 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &StripableTimeAxisView::reset_samples_per_pixel));
58 StripableTimeAxisView::reset_samples_per_pixel ()
60 set_samples_per_pixel (_editor.get_current_zoom());
64 StripableTimeAxisView::set_samples_per_pixel (double fpp)
66 TimeAxisView::set_samples_per_pixel (fpp);
71 StripableTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
73 using namespace Menu_Helpers;
77 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &StripableTimeAxisView::automation_track_hidden), param));
79 _automation_tracks[param] = track;
81 /* existing state overrides "show" argument */
83 if (track->get_gui_property ("visible", visible)) {
87 /* this might or might not change the visibility status, so don't rely on it */
88 track->set_marked_for_display (show);
90 if (show && !no_redraw) {
94 if (!ARDOUR::parameter_is_midi((AutomationType)param.type())) {
95 /* MIDI-related parameters are always in the menu, there's no
96 reason to rebuild the menu just because we added a automation
97 lane for one of them. But if we add a non-MIDI automation
98 lane, then we need to invalidate the display menu.
106 StripableTimeAxisView::update_gain_track_visibility ()
108 bool const showit = gain_automation_item->get_active();
111 if (gain_track->get_gui_property ("visible", visible) && visible != showit) {
112 gain_track->set_marked_for_display (showit);
114 /* now trigger a redisplay */
117 _stripable->gui_changed (X_("visible_tracks"), (void *) 0); /* EMIT_SIGNAL */
123 StripableTimeAxisView::update_trim_track_visibility ()
125 bool const showit = trim_automation_item->get_active();
128 if (trim_track->get_gui_property ("visible", visible) && visible != showit) {
129 trim_track->set_marked_for_display (showit);
131 /* now trigger a redisplay */
134 _stripable->gui_changed (X_("visible_tracks"), (void *) 0); /* EMIT_SIGNAL */
140 StripableTimeAxisView::update_mute_track_visibility ()
142 bool const showit = mute_automation_item->get_active();
145 if (mute_track->get_gui_property ("visible", visible) && visible != showit) {
146 mute_track->set_marked_for_display (showit);
148 /* now trigger a redisplay */
151 _stripable->gui_changed (X_("visible_tracks"), (void *) 0); /* EMIT_SIGNAL */
157 StripableTimeAxisView::automation_child_menu_item (Evoral::Parameter param)
159 ParameterMenuMap::iterator i = _main_automation_menu_map.find (param);
160 if (i != _main_automation_menu_map.end()) {
168 StripableTimeAxisView::automation_track_hidden (Evoral::Parameter param)
170 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
176 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
178 if (menu && !_hidden && menu->get_active()) {
179 menu->set_active (false);
182 if (_stripable && !no_redraw) {
187 boost::shared_ptr<AutomationTimeAxisView>
188 StripableTimeAxisView::automation_child(Evoral::Parameter param)
190 AutomationTracks::iterator i = _automation_tracks.find(param);
191 if (i != _automation_tracks.end()) {
194 return boost::shared_ptr<AutomationTimeAxisView>();
199 StripableTimeAxisView::request_redraw ()
202 _stripable->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
207 StripableTimeAxisView::show_all_automation (bool apply_to_selection)
209 /* this protected member should not be called directly */
210 assert (!apply_to_selection);
213 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
214 i->second->set_marked_for_display (true);
216 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
219 menu->set_active(true);
225 StripableTimeAxisView::show_existing_automation (bool apply_to_selection)
227 /* this protected member should not be called directly */
228 assert (!apply_to_selection);
231 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
232 if (i->second->has_automation()) {
233 i->second->set_marked_for_display (true);
235 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
237 menu->set_active(true);
244 StripableTimeAxisView::hide_all_automation (bool apply_to_selection)
246 /* this protected member should not be called directly */
247 assert (!apply_to_selection);
250 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
251 i->second->set_marked_for_display (false);
253 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
256 menu->set_active (false);