2 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <gtkmm/menu.h>
20 #include <gtkmm/menuitem.h>
22 #include "ardour/parameter_descriptor.h"
23 #include "ardour/parameter_types.h"
24 #include "ardour/stripable.h"
26 #include "public_editor.h"
27 #include "stripable_time_axis.h"
32 using namespace ARDOUR;
35 StripableTimeAxisView::StripableTimeAxisView (PublicEditor& ed, ARDOUR::Session* s, ArdourCanvas::Canvas& canvas)
36 : TimeAxisView(s, ed, (TimeAxisView*) 0, canvas)
37 , gain_automation_item(NULL)
38 , trim_automation_item(NULL)
39 , mute_automation_item(NULL)
40 , parent_canvas (canvas)
45 StripableTimeAxisView::~StripableTimeAxisView ()
50 StripableTimeAxisView::set_stripable (boost::shared_ptr<ARDOUR::Stripable> s)
53 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &StripableTimeAxisView::reset_samples_per_pixel));
57 StripableTimeAxisView::reset_samples_per_pixel ()
59 set_samples_per_pixel (_editor.get_current_zoom());
63 StripableTimeAxisView::set_samples_per_pixel (double fpp)
65 TimeAxisView::set_samples_per_pixel (fpp);
70 StripableTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
72 using namespace Menu_Helpers;
76 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &StripableTimeAxisView::automation_track_hidden), param));
78 _automation_tracks[param] = track;
80 /* existing state overrides "show" argument */
82 if (track->get_gui_property ("visible", visible)) {
86 /* this might or might not change the visibility status, so don't rely on it */
87 track->set_marked_for_display (show);
89 if (show && !no_redraw) {
93 if (!ARDOUR::parameter_is_midi((AutomationType)param.type())) {
94 /* MIDI-related parameters are always in the menu, there's no
95 reason to rebuild the menu just because we added a automation
96 lane for one of them. But if we add a non-MIDI automation
97 lane, then we need to invalidate the display menu.
105 StripableTimeAxisView::update_gain_track_visibility ()
107 bool const showit = gain_automation_item->get_active();
110 if (gain_track->get_gui_property ("visible", visible) && visible != showit) {
111 gain_track->set_marked_for_display (showit);
113 /* now trigger a redisplay */
116 _stripable->gui_changed (X_("visible_tracks"), (void *) 0); /* EMIT_SIGNAL */
122 StripableTimeAxisView::update_trim_track_visibility ()
124 bool const showit = trim_automation_item->get_active();
127 if (trim_track->get_gui_property ("visible", visible) && visible != showit) {
128 trim_track->set_marked_for_display (showit);
130 /* now trigger a redisplay */
133 _stripable->gui_changed (X_("visible_tracks"), (void *) 0); /* EMIT_SIGNAL */
139 StripableTimeAxisView::update_mute_track_visibility ()
141 bool const showit = mute_automation_item->get_active();
144 if (mute_track->get_gui_property ("visible", visible) && visible != showit) {
145 mute_track->set_marked_for_display (showit);
147 /* now trigger a redisplay */
150 _stripable->gui_changed (X_("visible_tracks"), (void *) 0); /* EMIT_SIGNAL */
156 StripableTimeAxisView::automation_child_menu_item (Evoral::Parameter param)
158 ParameterMenuMap::iterator i = _main_automation_menu_map.find (param);
159 if (i != _main_automation_menu_map.end()) {
167 StripableTimeAxisView::automation_track_hidden (Evoral::Parameter param)
169 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
175 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
177 if (menu && !_hidden && menu->get_active()) {
178 menu->set_active (false);
181 if (_stripable && !no_redraw) {
186 boost::shared_ptr<AutomationTimeAxisView>
187 StripableTimeAxisView::automation_child(Evoral::Parameter param)
189 AutomationTracks::iterator i = _automation_tracks.find(param);
190 if (i != _automation_tracks.end()) {
193 return boost::shared_ptr<AutomationTimeAxisView>();
198 StripableTimeAxisView::request_redraw ()
201 _stripable->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
206 StripableTimeAxisView::show_all_automation (bool apply_to_selection)
208 /* this protected member should not be called directly */
209 assert (!apply_to_selection);
212 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
213 i->second->set_marked_for_display (true);
215 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
218 menu->set_active(true);
224 StripableTimeAxisView::show_existing_automation (bool apply_to_selection)
226 /* this protected member should not be called directly */
227 assert (!apply_to_selection);
230 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
231 if (i->second->has_automation()) {
232 i->second->set_marked_for_display (true);
234 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
236 menu->set_active(true);
243 StripableTimeAxisView::hide_all_automation (bool apply_to_selection)
245 /* this protected member should not be called directly */
246 assert (!apply_to_selection);
249 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
250 i->second->set_marked_for_display (false);
252 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
255 menu->set_active (false);