push2: add a little meat to the bones of the TrackMix layout (just a name, for now)
[ardour.git] / libs / surfaces / push2 / track_mix.cc
1 /*
2   Copyright (C) 2016 Paul Davis
3
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.
8
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.
13
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.
17 */
18
19 #include <pangomm/layout.h>
20
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"
28
29 #include "midi++/parser.h"
30 #include "timecode/time.h"
31 #include "timecode/bbt_time.h"
32
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"
42
43 #include "menu.h"
44 #include "push2.h"
45 #include "track_mix.h"
46
47 #include "i18n.h"
48
49 using namespace ARDOUR;
50 using namespace std;
51 using namespace PBD;
52 using namespace Glib;
53 using namespace ArdourSurface;
54
55 TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Context> context)
56         : Push2Layout (p, s)
57         , _dirty (false)
58 {
59         name_layout = Pango::Layout::create (context);
60
61         Pango::FontDescription fd ("Sans Bold 24");
62         name_layout->set_font_description (fd);
63 }
64
65 TrackMixLayout::~TrackMixLayout ()
66 {
67 }
68
69 bool
70 TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
71 {
72         if (!_dirty) {
73                 return false;
74         }
75
76         context->set_source_rgb (0.764, 0.882, 0.882);
77         context->rectangle (0, 0, 960, 160);
78         context->fill ();
79
80         context->set_source_rgb (0.23, 0.0, 0.349);
81         context->move_to (10, 2);
82         name_layout->update_from_cairo_context (context);
83         name_layout->show_in_cairo_context (context);
84
85         return true;
86 }
87
88 void
89 TrackMixLayout::button_upper (uint32_t n)
90 {
91 }
92
93 void
94 TrackMixLayout::button_lower (uint32_t n)
95 {
96 }
97
98 void
99 TrackMixLayout::strip_vpot (int n, int delta)
100 {
101 }
102
103 void
104 TrackMixLayout::strip_vpot_touch (int, bool)
105 {
106 }
107
108 void
109 TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
110 {
111         stripable = s;
112
113         if (stripable) {
114                 stripable->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::drop_stripable, this), &p2);
115                 name_changed ();
116         }
117
118         _dirty = true;
119 }
120
121 void
122 TrackMixLayout::drop_stripable ()
123 {
124         stripable_connections.drop_connections ();
125         stripable.reset ();
126         _dirty = true;
127 }
128
129 void
130 TrackMixLayout::name_changed ()
131 {
132         name_layout->set_text (stripable->name());
133         _dirty = true;
134 }