2 Copyright (C) 2016 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.
19 #include <cairomm/region.h>
20 #include <pangomm/layout.h>
22 #include "pbd/compose.h"
23 #include "pbd/convert.h"
24 #include "pbd/debug.h"
25 #include "pbd/failed_constructor.h"
26 #include "pbd/file_utils.h"
28 #include "pbd/search_path.h"
29 #include "pbd/enumwriter.h"
31 #include "midi++/parser.h"
32 #include "timecode/time.h"
33 #include "timecode/bbt_time.h"
35 #include "ardour/async_midi_port.h"
36 #include "ardour/audioengine.h"
37 #include "ardour/debug.h"
38 #include "ardour/filesystem_paths.h"
39 #include "ardour/midiport_manager.h"
40 #include "ardour/midi_track.h"
41 #include "ardour/midi_port.h"
42 #include "ardour/session.h"
43 #include "ardour/tempo.h"
45 #include "gtkmm2ext/gui_thread.h"
46 #include "gtkmm2ext/rgb_macros.h"
52 #include "track_mix.h"
55 using namespace ARDOUR;
59 using namespace ArdourSurface;
60 using namespace ArdourCanvas;
62 TrackMixLayout::TrackMixLayout (Push2& p, Session& s)
65 Pango::FontDescription fd2 ("Sans 10");
67 for (int n = 0; n < 8; ++n) {
68 Text* t = new Text (this);
69 t->set_font_description (fd2);
70 t->set_color (p2.get_color (Push2::ParameterName));
71 t->set_position ( Duple (10 + (n*Push2Canvas::inter_button_spacing()), 2));
73 upper_text.push_back (t);
76 t->set_font_description (fd2);
77 t->set_color (p2.get_color (Push2::ParameterName));
78 t->set_position (Duple (10 + (n*Push2Canvas::inter_button_spacing()), 140));
80 lower_text.push_back (t);
84 upper_text[n]->set (_("TRACK VOLUME"));
85 lower_text[n]->set (_("MUTE"));
88 upper_text[n]->set (_("TRACK PAN"));
89 lower_text[n]->set (_("SOLO"));
92 upper_text[n]->set (_("TRACK WIDTH"));
93 lower_text[n]->set (_("REC-ENABLE"));
96 upper_text[n]->set (_("TRACK TRIM"));
97 lower_text[n]->set (_("IN"));
100 upper_text[n]->set (_(""));
101 lower_text[n]->set (_("DISK"));
104 upper_text[n]->set (_(""));
105 lower_text[n]->set (_("SOLO ISO"));
108 upper_text[n]->set (_(""));
109 lower_text[n]->set (_("SOLO LOCK"));
112 upper_text[n]->set (_(""));
113 lower_text[n]->set (_(""));
117 knobs[n] = new Push2Knob (p2, this);
118 knobs[n]->set_position (60 + (Push2Canvas::inter_button_spacing()*n), 95);
119 knobs[n]->set_radius (25);
122 ControlProtocol::StripableSelectionChanged.connect (selection_connection, invalidator (*this), boost::bind (&TrackMixLayout::selection_changed, this), &p2);
125 TrackMixLayout::~TrackMixLayout ()
127 for (int n = 0; n < 8; ++n) {
133 TrackMixLayout::selection_changed ()
135 boost::shared_ptr<Stripable> s = ControlProtocol::first_selected_stripable();
141 TrackMixLayout::show ()
143 selection_changed ();
147 TrackMixLayout::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
149 set_source_rgb (context, p2.get_color (Push2::DarkBackground));
150 context->rectangle (0, 0, display_width(), display_height());
153 context->move_to (0, 22.5);
154 context->line_to (display_width(), 22.5);
155 context->set_line_width (1.0);
158 Container::render_children (area, context);
162 TrackMixLayout::button_upper (uint32_t n)
167 TrackMixLayout::button_lower (uint32_t n)
172 TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
174 stripable_connections.drop_connections ();
180 stripable->DropReferences.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::drop_stripable, this), &p2);
182 stripable->PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
183 stripable->presentation_info().PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
185 knobs[0]->set_controllable (stripable->gain_control());
186 knobs[1]->set_controllable (stripable->pan_azimuth_control());
187 knobs[1]->add_flag (Push2Knob::ArcToZero);
188 knobs[2]->set_controllable (stripable->pan_width_control());
189 knobs[3]->set_controllable (stripable->trim_control());
190 knobs[3]->add_flag (Push2Knob::ArcToZero);
191 knobs[4]->set_controllable (boost::shared_ptr<AutomationControl>());
192 knobs[5]->set_controllable (boost::shared_ptr<AutomationControl>());
193 knobs[6]->set_controllable (boost::shared_ptr<AutomationControl>());
194 knobs[7]->set_controllable (boost::shared_ptr<AutomationControl>());
204 TrackMixLayout::drop_stripable ()
206 stripable_connections.drop_connections ();
212 TrackMixLayout::name_changed ()
218 TrackMixLayout::color_changed ()
220 uint32_t rgb = stripable->presentation_info().color();
222 for (int n = 0; n < 8; ++n) {
223 knobs[n]->set_text_color (rgb);
224 knobs[n]->set_arc_start_color (rgb);
225 knobs[n]->set_arc_end_color (rgb);
230 TrackMixLayout::stripable_property_change (PropertyChange const& what_changed)
232 if (what_changed.contains (Properties::color)) {
235 if (what_changed.contains (Properties::name)) {
241 TrackMixLayout::strip_vpot (int n, int delta)
243 boost::shared_ptr<Controllable> ac = knobs[n]->controllable();
246 ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup);
251 TrackMixLayout::strip_vpot_touch (int n, bool touching)
253 boost::shared_ptr<AutomationControl> ac = knobs[n]->controllable();
256 ac->start_touch (session.audible_frame());
258 ac->stop_touch (true, session.audible_frame());