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"
45 #include "track_mix.h"
49 using namespace ARDOUR;
53 using namespace ArdourSurface;
55 TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Context> context)
59 name_layout = Pango::Layout::create (context);
61 Pango::FontDescription fd ("Sans Bold 24");
62 name_layout->set_font_description (fd);
64 Pango::FontDescription fd2 ("Sans 10");
65 for (int n = 0; n < 8; ++n) {
66 upper_layout[n] = Pango::Layout::create (context);
67 upper_layout[n]->set_font_description (fd2);
68 upper_layout[n]->set_text ("solo");
69 lower_layout[n] = Pango::Layout::create (context);
70 lower_layout[n]->set_font_description (fd2);
71 lower_layout[n]->set_text ("mute");
76 TrackMixLayout::~TrackMixLayout ()
81 TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
87 context->set_source_rgb (0.764, 0.882, 0.882);
88 context->rectangle (0, 0, 960, 160);
91 context->set_source_rgb (0.23, 0.0, 0.349);
92 context->move_to (10, 2);
93 name_layout->update_from_cairo_context (context);
94 name_layout->show_in_cairo_context (context);
100 TrackMixLayout::button_upper (uint32_t n)
105 TrackMixLayout::button_lower (uint32_t n)
110 TrackMixLayout::strip_vpot (int n, int delta)
115 TrackMixLayout::strip_vpot_touch (int, bool)
120 TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
125 stripable->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::drop_stripable, this), &p2);
127 stripable->PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
128 stripable->presentation_info().PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
138 TrackMixLayout::drop_stripable ()
140 stripable_connections.drop_connections ();
146 TrackMixLayout::name_changed ()
148 name_layout->set_text (stripable->name());
153 TrackMixLayout::color_changed ()
155 uint32_t rgb = stripable->presentation_info().color();
156 uint8_t index = p2.get_color_index (rgb);
158 Push2::Button* b = p2.button_by_id (Push2::Upper1);
159 b->set_color (index);
160 b->set_state (Push2::LED::OneShot24th);
161 p2.write (b->state_msg ());
165 TrackMixLayout::stripable_property_change (PropertyChange const& what_changed)
167 if (what_changed.contains (Properties::color)) {
170 if (what_changed.contains (Properties::name)) {