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 <pangomm/layout.h>
21 #include "pbd/compose.h"
22 #include "pbd/convert.h"
23 #include "pbd/debug.h"
24 #include "pbd/failed_constructor.h"
25 #include "pbd/file_utils.h"
26 #include "pbd/search_path.h"
27 #include "pbd/enumwriter.h"
29 #include "midi++/parser.h"
30 #include "timecode/time.h"
31 #include "timecode/bbt_time.h"
33 #include "ardour/async_midi_port.h"
34 #include "ardour/audioengine.h"
35 #include "ardour/debug.h"
36 #include "ardour/filesystem_paths.h"
37 #include "ardour/midiport_manager.h"
38 #include "ardour/midi_track.h"
39 #include "ardour/midi_port.h"
40 #include "ardour/session.h"
41 #include "ardour/tempo.h"
43 #include "gtkmm2ext/gui_thread.h"
44 #include "gtkmm2ext/rgb_macros.h"
49 #include "track_mix.h"
54 using namespace ARDOUR;
58 using namespace ArdourSurface;
60 TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Context> context)
64 Pango::FontDescription fd2 ("Sans 10");
66 for (int n = 0; n < 8; ++n) {
67 upper_layout[n] = Pango::Layout::create (context);
68 upper_layout[n]->set_font_description (fd2);
70 lower_layout[n] = Pango::Layout::create (context);
71 lower_layout[n]->set_font_description (fd2);
75 upper_layout[n]->set_text (_("TRACK VOLUME"));
76 lower_layout[n]->set_text (_("MUTE"));
79 upper_layout[n]->set_text (_("TRACK PAN"));
80 lower_layout[n]->set_text (_("SOLO"));
83 upper_layout[n]->set_text (_("TRACK WIDTH"));
84 lower_layout[n]->set_text (_("REC-ENABLE"));
87 upper_layout[n]->set_text (_("TRACK TRIM"));
88 lower_layout[n]->set_text (_("IN"));
91 upper_layout[n]->set_text (_(""));
92 lower_layout[n]->set_text (_("DISK"));
95 upper_layout[n]->set_text (_(""));
96 lower_layout[n]->set_text (_("SOLO ISO"));
99 upper_layout[n]->set_text (_(""));
100 lower_layout[n]->set_text (_("SOLO LOCK"));
103 upper_layout[n]->set_text (_(""));
104 lower_layout[n]->set_text (_(""));
108 knobs[n] = new Push2Knob (p2, context);
109 knobs[n]->set_position (60 + (120*n), 95);
110 knobs[n]->set_radius (25);
113 ControlProtocol::StripableSelectionChanged.connect (selection_connection, invalidator (*this), boost::bind (&TrackMixLayout::selection_changed, this), &p2);
116 TrackMixLayout::~TrackMixLayout ()
118 for (int n = 0; n < 8; ++n) {
124 TrackMixLayout::selection_changed ()
126 boost::shared_ptr<Stripable> s = ControlProtocol::first_selected_stripable();
132 TrackMixLayout::on_show ()
134 selection_changed ();
138 TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context, bool force) const
140 bool children_dirty = false;
142 for (int n = 0; n < 8; ++n) {
143 if (knobs[n]->dirty()) {
144 children_dirty = true;
149 if (!children_dirty) {
153 set_source_rgb (context, p2.get_color (Push2::DarkBackground));
154 context->rectangle (0, 0, p2.cols, p2.rows);
157 for (int n = 0; n < 8; ++n) {
159 if (!upper_layout[n]->get_text().empty()) {
161 /* Draw highlight box */
163 uint32_t color = p2.get_color (Push2::ParameterName);
164 set_source_rgb (context, color);
166 context->move_to (10 + (n*120), 2);
167 upper_layout[n]->update_from_cairo_context (context);
168 upper_layout[n]->show_in_cairo_context (context);
171 if (!lower_layout[n]->get_text().empty()) {
172 context->move_to (10 + (n*120), 140);
173 lower_layout[n]->update_from_cairo_context (context);
174 lower_layout[n]->show_in_cairo_context (context);
178 context->move_to (0, 22.5);
179 context->line_to (p2.cols, 22.5);
180 context->set_line_width (1.0);
183 for (int n = 0; n < 8; ++n) {
184 knobs[n]->redraw (context, force);
191 TrackMixLayout::button_upper (uint32_t n)
196 TrackMixLayout::button_lower (uint32_t n)
201 TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
203 stripable_connections.drop_connections ();
209 stripable->DropReferences.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::drop_stripable, this), &p2);
211 stripable->PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
212 stripable->presentation_info().PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
214 knobs[0]->set_controllable (stripable->gain_control());
215 knobs[1]->set_controllable (stripable->pan_azimuth_control());
216 knobs[1]->add_flag (Push2Knob::ArcToZero);
217 knobs[2]->set_controllable (stripable->pan_width_control());
218 knobs[3]->set_controllable (stripable->trim_control());
219 knobs[3]->add_flag (Push2Knob::ArcToZero);
220 knobs[4]->set_controllable (boost::shared_ptr<AutomationControl>());
221 knobs[5]->set_controllable (boost::shared_ptr<AutomationControl>());
222 knobs[6]->set_controllable (boost::shared_ptr<AutomationControl>());
223 knobs[7]->set_controllable (boost::shared_ptr<AutomationControl>());
233 TrackMixLayout::drop_stripable ()
235 stripable_connections.drop_connections ();
241 TrackMixLayout::name_changed ()
247 TrackMixLayout::color_changed ()
249 uint32_t rgb = stripable->presentation_info().color();
251 for (int n = 0; n < 8; ++n) {
252 knobs[n]->set_text_color (rgb);
253 knobs[n]->set_arc_start_color (rgb);
254 knobs[n]->set_arc_end_color (rgb);
259 TrackMixLayout::stripable_property_change (PropertyChange const& what_changed)
261 if (what_changed.contains (Properties::color)) {
264 if (what_changed.contains (Properties::name)) {
270 TrackMixLayout::strip_vpot (int n, int delta)
272 boost::shared_ptr<Controllable> ac = knobs[n]->controllable();
275 ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup);
280 TrackMixLayout::strip_vpot_touch (int n, bool touching)
282 boost::shared_ptr<AutomationControl> ac = knobs[n]->controllable();
285 ac->start_touch (session.audible_frame());
287 ac->stop_touch (true, session.audible_frame());