#include "ardour/midi_port.h"
#include "ardour/session.h"
#include "ardour/tempo.h"
+#include "ardour/vca_manager.h"
#include "canvas/colors.h"
, bank_start (0)
, vpot_mode (Volume)
{
- tc_clock_layout = Pango::Layout::create (context);
- bbt_clock_layout = Pango::Layout::create (context);
-
- Pango::FontDescription fd ("Sans Bold 24");
- tc_clock_layout->set_font_description (fd);
- bbt_clock_layout->set_font_description (fd);
-
Pango::FontDescription fd2 ("Sans 10");
for (int n = 0; n < 8; ++n) {
upper_layout[n] = Pango::Layout::create (context);
}
mode_button = p2.button_by_id (Push2::Upper1);
+
+ session.RouteAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::stripables_added, this), &p2);
+ session.vca_manager().VCAAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::stripables_added, this), &p2);
}
MixLayout::~MixLayout ()
p2.write (mode_button->state_msg());
switch_bank (bank_start);
- show_vpot_mode ();
}
bool
MixLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
{
- framepos_t audible = session.audible_frame();
- Timecode::Time TC;
- bool negative = false;
- string tc_clock_text;
- string bbt_clock_text;
-
- if (audible < 0) {
- audible = -audible;
- negative = true;
- }
-
- session.timecode_time (audible, TC);
-
- TC.negative = TC.negative || negative;
-
- tc_clock_text = Timecode::timecode_format_time(TC);
-
- Timecode::BBT_Time bbt = session.tempo_map().bbt_at_frame (audible);
- char buf[16];
-
-#define BBT_BAR_CHAR "|"
-
- if (negative) {
- snprintf (buf, sizeof (buf), "-%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
- bbt.bars, bbt.beats, bbt.ticks);
- } else {
- snprintf (buf, sizeof (buf), " %03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
- bbt.bars, bbt.beats, bbt.ticks);
- }
-
- bbt_clock_text = buf;
-
bool children_dirty = false;
- if (tc_clock_text != tc_clock_layout->get_text()) {
- children_dirty = true;
- tc_clock_layout->set_text (tc_clock_text);
- }
-
- if (bbt_clock_text != bbt_clock_layout->get_text()) {
- children_dirty = true;
- bbt_clock_layout->set_text (bbt_clock_text);
- }
-
for (int n = 0; n < 8; ++n) {
if (knobs[n]->dirty()) {
children_dirty = true;
for (int n = 0; n < 8; ++n) {
if (stripable[n]) {
+
string shortname = short_version (stripable[n]->name(), 10);
string text;
boost::shared_ptr<AutomationControl> ac;
context->rectangle (0, 0, p2.cols, p2.rows);
context->fill ();
- /* clocks */
-
- set_source_rgb (context, ArdourCanvas::contrasting_text_color (p2.get_color (Push2::DarkBackground)));
- context->move_to (650, 30);
- tc_clock_layout->update_from_cairo_context (context);
- tc_clock_layout->show_in_cairo_context (context);
- context->move_to (650, 65);
- bbt_clock_layout->update_from_cairo_context (context);
- bbt_clock_layout->show_in_cairo_context (context);
-
set_source_rgb (context, p2.get_color (Push2::ParameterName));
for (int n = 0; n < 8; ++n) {
knobs[s]->remove_flag (Push2Knob::ArcToZero);
}
break;
+ case Send1:
+ for (int s = 0; s < 8; ++s) {
+ if (stripable[s]) {
+ knobs[s]->set_controllable (stripable[s]->send_level_controllable (0));
+ } else {
+ knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+
+ }
+ knobs[s]->remove_flag (Push2Knob::ArcToZero);
+ }
+ break;
+ case Send2:
+ for (int s = 0; s < 8; ++s) {
+ if (stripable[s]) {
+ knobs[s]->set_controllable (stripable[s]->send_level_controllable (1));
+ } else {
+ knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+
+ }
+ knobs[s]->remove_flag (Push2Knob::ArcToZero);
+ }
+ break;
+ case Send3:
+ for (int s = 0; s < 8; ++s) {
+ if (stripable[s]) {
+ knobs[s]->set_controllable (stripable[s]->send_level_controllable (2));
+ } else {
+ knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+
+ }
+ knobs[s]->remove_flag (Push2Knob::ArcToZero);
+ }
+ break;
+ case Send4:
+ for (int s = 0; s < 8; ++s) {
+ if (stripable[s]) {
+ knobs[s]->set_controllable (stripable[s]->send_level_controllable (3));
+ } else {
+ knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+
+ }
+ knobs[s]->remove_flag (Push2Knob::ArcToZero);
+ }
+ break;
+ case Send5:
+ for (int s = 0; s < 8; ++s) {
+ if (stripable[s]) {
+ knobs[s]->set_controllable (stripable[s]->send_level_controllable (4));
+ } else {
+ knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+
+ }
+ knobs[s]->remove_flag (Push2Knob::ArcToZero);
+ }
+ break;
default:
break;
}
}
}
-void
-MixLayout::solo_change (int n)
-{
-}
-
-void
-MixLayout::mute_change (int n)
-{
-}
-
void
MixLayout::switch_bank (uint32_t base)
{
stripable_connections.drop_connections ();
- /* try to get the first stripable for the requested bank */
+ /* work backwards so we can tell if we should actually switch banks */
- stripable[0] = session.get_remote_nth_stripable (base, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
+ boost::shared_ptr<Stripable> s[8];
+ uint32_t old_empty = 0;
+ uint32_t new_empty = 0;
+
+ for (int n = 0; n < 8; ++n) {
+ if (!stripable[n]) {
+ old_empty++;
+ }
+ s[n] = session.get_remote_nth_stripable (base+n, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
+ if (!s[n]) {
+ new_empty++;
+ }
+ }
- if (!stripable[0]) {
+ if ((new_empty != 0) && (new_empty >= old_empty)) {
+ /* some missing strips; new bank the same or more empty stripables than the old one, do
+ nothing since we had already reached the end.
+ */
return;
}
- /* at least one stripable in this bank */
- bank_start = base;
+ for (int n = 0; n < 8; ++n) {
+ stripable[n] = s[n];
+ }
- stripable[1] = session.get_remote_nth_stripable (base+1, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
- stripable[2] = session.get_remote_nth_stripable (base+2, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
- stripable[3] = session.get_remote_nth_stripable (base+3, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
- stripable[4] = session.get_remote_nth_stripable (base+4, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
- stripable[5] = session.get_remote_nth_stripable (base+5, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
- stripable[6] = session.get_remote_nth_stripable (base+6, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
- stripable[7] = session.get_remote_nth_stripable (base+7, PresentationInfo::Flag (PresentationInfo::Route|PresentationInfo::VCA));
+ /* at least one stripable in this bank */
+ bank_start = base;
for (int n = 0; n < 8; ++n) {
if (!stripable[n]) {
stripable[n]->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::switch_bank, this, bank_start), &p2);
stripable[n]->presentation_info().PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&MixLayout::stripable_property_change, this, _1, n), &p2);
- solo_change (n);
- mute_change (n);
-
Push2::Button* b;
switch (n) {
p2.write (b->state_msg());
knobs[n]->set_text_color (stripable[n]->presentation_info().color());
+ knobs[n]->set_arc_start_color (stripable[n]->presentation_info().color());
+ knobs[n]->set_arc_end_color (stripable[n]->presentation_info().color());
}
+
+ show_vpot_mode ();
}
void
}
}
}
+
+void
+MixLayout::stripables_added ()
+{
+ /* reload current bank */
+ switch_bank (bank_start);
+}
, octave_shift (0)
, percussion (false)
{
+ cerr << "new push2 @ " << this << "\n";
+
context = Cairo::Context::create (frame_buffer);
build_maps ();
Push2::~Push2 ()
{
+ cerr << "push2 deleted\n";
stop ();
}
void
Push2::port_registration_handler ()
{
+ cerr << "preg for " << this << endl;
+
+ if (!_async_in && !_async_out) {
+ /* ports not registered yet */
+ return;
+ }
+
if (_async_in->connected() && _async_out->connected()) {
/* don't waste cycles here */
return;
/* display splash for 3 seconds */
if (get_microseconds() - splash_start > 3000000) {
- cerr << "splash done\n";
splash_start = 0;
} else {
return false;
colors.insert (make_pair (KnobLineShadow, ArdourCanvas::rgba_to_color (0, 0, 0, 0.3)));
colors.insert (make_pair (KnobLine, ArdourCanvas::rgba_to_color (1, 1, 1, 1)));
- colors.insert (make_pair (KnobForeground, ArdourCanvas::rgba_to_color (1, 1, 1, 1)));
- colors.insert (make_pair (KnobBackground, ArdourCanvas::rgba_to_color (1, 1, 1, 1)));
+ colors.insert (make_pair (KnobForeground, ArdourCanvas::rgba_to_color (0.2, 0.2, 0.2, 1)));
+ colors.insert (make_pair (KnobBackground, ArdourCanvas::rgba_to_color (0.2, 0.2, 0.2, 1)));
colors.insert (make_pair (KnobShadow, ArdourCanvas::rgba_to_color (0, 0, 0, 0.1)));
colors.insert (make_pair (KnobBorder, ArdourCanvas::rgba_to_color (0, 0, 0, 1)));