From ad7543c02f947e15a88b5eeae8db6dc55bad9b60 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 11 Jul 2016 18:17:04 -0400 Subject: push2: track mix layout somewhat working --- libs/surfaces/push2/buttons.cc | 2 + libs/surfaces/push2/layout.h | 2 +- libs/surfaces/push2/menu.cc | 2 +- libs/surfaces/push2/menu.h | 2 +- libs/surfaces/push2/mix.cc | 6 +- libs/surfaces/push2/mix.h | 2 +- libs/surfaces/push2/push2.cc | 3 +- libs/surfaces/push2/scale.cc | 4 +- libs/surfaces/push2/scale.h | 2 +- libs/surfaces/push2/track_mix.cc | 178 +++++++++++++++++++++++++-------------- libs/surfaces/push2/track_mix.h | 9 +- 11 files changed, 134 insertions(+), 78 deletions(-) (limited to 'libs/surfaces/push2') diff --git a/libs/surfaces/push2/buttons.cc b/libs/surfaces/push2/buttons.cc index e7a775d004..bbe05995db 100644 --- a/libs/surfaces/push2/buttons.cc +++ b/libs/surfaces/push2/buttons.cc @@ -573,9 +573,11 @@ void Push2::button_mix_press () { if (_current_layout == track_mix_layout) { + cerr << "back to mix\n"; set_current_layout (mix_layout); } else { if (ControlProtocol::first_selected_stripable()) { + cerr << "back to trackmix\n"; set_current_layout (track_mix_layout); } } diff --git a/libs/surfaces/push2/layout.h b/libs/surfaces/push2/layout.h index 1fc18af959..fcc0b7a479 100644 --- a/libs/surfaces/push2/layout.h +++ b/libs/surfaces/push2/layout.h @@ -43,7 +43,7 @@ class Push2Layout bool mapped() const; - virtual bool redraw (Cairo::RefPtr) const = 0; + virtual bool redraw (Cairo::RefPtr, bool force) const = 0; virtual void on_show () {} virtual void on_hide () {} diff --git a/libs/surfaces/push2/menu.cc b/libs/surfaces/push2/menu.cc index 583c0a235c..e3a900b90b 100644 --- a/libs/surfaces/push2/menu.cc +++ b/libs/surfaces/push2/menu.cc @@ -187,7 +187,7 @@ Push2Menu::get_active (int col) } void -Push2Menu::redraw (Cairo::RefPtr context) const +Push2Menu::redraw (Cairo::RefPtr context, bool force) const { for (int n = 0; n < 8; ++n) { diff --git a/libs/surfaces/push2/menu.h b/libs/surfaces/push2/menu.h index a76bba170d..946d2df56d 100644 --- a/libs/surfaces/push2/menu.h +++ b/libs/surfaces/push2/menu.h @@ -31,7 +31,7 @@ class Push2Menu { public: Push2Menu (Cairo::RefPtr); - void redraw (Cairo::RefPtr) const; + void redraw (Cairo::RefPtr, bool force) const; bool dirty () const { return _dirty; } void fill_column (int col, std::vector); diff --git a/libs/surfaces/push2/mix.cc b/libs/surfaces/push2/mix.cc index 69d6373d42..2d7c9b7781 100644 --- a/libs/surfaces/push2/mix.cc +++ b/libs/surfaces/push2/mix.cc @@ -133,7 +133,7 @@ MixLayout::on_show () } bool -MixLayout::redraw (Cairo::RefPtr context) const +MixLayout::redraw (Cairo::RefPtr context, bool force) const { bool children_dirty = false; @@ -172,7 +172,7 @@ MixLayout::redraw (Cairo::RefPtr context) const } } - if (!children_dirty && !_dirty) { + if (!children_dirty && !_dirty && !force) { return false; } @@ -212,7 +212,7 @@ MixLayout::redraw (Cairo::RefPtr context) const context->stroke (); for (int n = 0; n < 8; ++n) { - knobs[n]->redraw (context); + knobs[n]->redraw (context, force); } for (int n = 0; n < 8; ++n) { diff --git a/libs/surfaces/push2/mix.h b/libs/surfaces/push2/mix.h index a638a41c60..ebd936aff1 100644 --- a/libs/surfaces/push2/mix.h +++ b/libs/surfaces/push2/mix.h @@ -36,7 +36,7 @@ class MixLayout : public Push2Layout MixLayout (Push2& p, ARDOUR::Session&, Cairo::RefPtr); ~MixLayout (); - bool redraw (Cairo::RefPtr) const; + bool redraw (Cairo::RefPtr, bool force) const; void on_show (); void button_upper (uint32_t n); diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 04001646a6..412fc3c51b 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -541,7 +541,7 @@ Push2::redraw () render_needed = true; } - bool dirty = _current_layout->redraw (context); + bool dirty = _current_layout->redraw (context, render_needed); drawn_layout = _current_layout; return dirty || render_needed; @@ -1729,6 +1729,7 @@ Push2::set_current_layout (Push2Layout* layout) } _current_layout = layout; + drawn_layout = 0; if (_current_layout) { _current_layout->on_show (); diff --git a/libs/surfaces/push2/scale.cc b/libs/surfaces/push2/scale.cc index 2f86d54786..62c13c68f3 100644 --- a/libs/surfaces/push2/scale.cc +++ b/libs/surfaces/push2/scale.cc @@ -63,7 +63,7 @@ ScaleLayout::~ScaleLayout () } bool -ScaleLayout::redraw (Cairo::RefPtr context) const +ScaleLayout::redraw (Cairo::RefPtr context, bool force) const { bool draw = false; @@ -79,7 +79,7 @@ ScaleLayout::redraw (Cairo::RefPtr context) const context->rectangle (0, 0, 960, 160); context->fill (); - scale_menu->redraw (context); + scale_menu->redraw (context, force); return true; } diff --git a/libs/surfaces/push2/scale.h b/libs/surfaces/push2/scale.h index a859756d2f..6df6abf921 100644 --- a/libs/surfaces/push2/scale.h +++ b/libs/surfaces/push2/scale.h @@ -33,7 +33,7 @@ class ScaleLayout : public Push2Layout ScaleLayout (Push2& p, ARDOUR::Session&, Cairo::RefPtr); ~ScaleLayout (); - bool redraw (Cairo::RefPtr) const; + bool redraw (Cairo::RefPtr, bool force) const; void button_upper (uint32_t n); void button_lower (uint32_t n); diff --git a/libs/surfaces/push2/track_mix.cc b/libs/surfaces/push2/track_mix.cc index 69d56425c0..e1165ee9cf 100644 --- a/libs/surfaces/push2/track_mix.cc +++ b/libs/surfaces/push2/track_mix.cc @@ -58,56 +58,86 @@ using namespace ArdourSurface; TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr context) : Push2Layout (p, s) - , _dirty (false) + , _dirty (true) { - name_layout = Pango::Layout::create (context); - - Pango::FontDescription fd ("Sans Bold 14"); - name_layout->set_font_description (fd); - Pango::FontDescription fd2 ("Sans 10"); + for (int n = 0; n < 8; ++n) { upper_layout[n] = Pango::Layout::create (context); upper_layout[n]->set_font_description (fd2); - upper_layout[n]->set_text ("solo"); + + switch (n) { + case 0: + upper_layout[n]->set_text (_("TRACK VOLUME")); + break; + case 1: + upper_layout[n]->set_text (_("TRACK PAN")); + break; + case 2: + upper_layout[n]->set_text (_("TRACK WIDTH")); + break; + case 3: + upper_layout[n]->set_text (_("TRACK TRIM")); + break; + case 4: + upper_layout[n]->set_text (_("")); + break; + case 5: + upper_layout[n]->set_text (_("")); + break; + case 6: + upper_layout[n]->set_text (_("")); + break; + case 7: + upper_layout[n]->set_text (_("")); + break; + } + lower_layout[n] = Pango::Layout::create (context); lower_layout[n]->set_font_description (fd2); - lower_layout[n]->set_text ("mute"); - } - Push2Knob* knob; - - knob = new Push2Knob (p2, context); - knob->set_position (60, 80); - knob->set_radius (35); - knobs.push_back (knob); + knobs[n] = new Push2Knob (p2, context); + knobs[n]->set_position (60 + (120*n), 95); + knobs[n]->set_radius (25); + } - knob = new Push2Knob (p2, context); - knob->set_position (180, 80); - knob->set_radius (35); - knobs.push_back (knob); + ControlProtocol::StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::selection_changed, this), &p2); } TrackMixLayout::~TrackMixLayout () { - for (vector::iterator k = knobs.begin(); k != knobs.end(); ++k) { - delete *k; + for (int n = 0; n < 8; ++n) { + delete knobs[n]; + } +} + +void +TrackMixLayout::selection_changed () +{ + boost::shared_ptr s = ControlProtocol::first_selected_stripable(); + if (s) { + set_stripable (s); } } +void +TrackMixLayout::on_show () +{ + selection_changed (); +} bool -TrackMixLayout::redraw (Cairo::RefPtr context) const +TrackMixLayout::redraw (Cairo::RefPtr context, bool force) const { bool children_dirty = false; - for (vector::const_iterator k = knobs.begin(); k != knobs.end(); ++k) { - if ((*k)->dirty()) { + for (int n = 0; n < 8; ++n) { + if (knobs[n]->dirty()) { children_dirty = true; break; } } - if (!children_dirty && !_dirty) { + if (!children_dirty) { return false; } @@ -115,19 +145,28 @@ TrackMixLayout::redraw (Cairo::RefPtr context) const context->rectangle (0, 0, p2.cols, p2.rows); context->fill (); - if (stripable) { - int r,g,b,a; - UINT_TO_RGBA (stripable->presentation_info().color(), &r, &g, &b, &a); - context->set_source_rgb (r/255.0, g/255.0, b/255.0); - } else { - context->set_source_rgb (0.23, 0.0, 0.349); + for (int n = 0; n < 8; ++n) { + + if (upper_layout[n]->get_text().empty()) { + continue; + } + + /* Draw highlight box */ + + uint32_t color = p2.get_color (Push2::ParameterName); + set_source_rgb (context, color); + context->move_to (10 + (n*120), 2); + upper_layout[n]->update_from_cairo_context (context); + upper_layout[n]->show_in_cairo_context (context); } - context->move_to (10, 2); - name_layout->update_from_cairo_context (context); - name_layout->show_in_cairo_context (context); - for (vector::const_iterator k = knobs.begin(); k != knobs.end(); ++k) { - (*k)->redraw (context); + context->move_to (0, 22.5); + context->line_to (p2.cols, 22.5); + context->set_line_width (1.0); + context->stroke (); + + for (int n = 0; n < 8; ++n) { + knobs[n]->redraw (context, force); } return true; @@ -143,34 +182,15 @@ TrackMixLayout::button_lower (uint32_t n) { } -void -TrackMixLayout::strip_vpot (int n, int delta) -{ - if (!stripable) { - return; - } - - switch (n) { - case 0: /* gain */ - boost::shared_ptr ac = stripable->gain_control(); - if (ac) { - ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup); - } - break; - } -} - -void -TrackMixLayout::strip_vpot_touch (int, bool) -{ -} - void TrackMixLayout::set_stripable (boost::shared_ptr s) { + stripable_connections.drop_connections (); + stripable = s; if (stripable) { + stripable->DropReferences.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::drop_stripable, this), &p2); stripable->PropertyChanged.connect (stripable_connections, MISSING_INVALIDATOR, boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2); @@ -178,6 +198,14 @@ TrackMixLayout::set_stripable (boost::shared_ptr s) knobs[0]->set_controllable (stripable->gain_control()); knobs[1]->set_controllable (stripable->pan_azimuth_control()); + knobs[1]->add_flag (Push2Knob::ArcToZero); + knobs[2]->set_controllable (stripable->pan_width_control()); + knobs[3]->set_controllable (stripable->trim_control()); + knobs[3]->add_flag (Push2Knob::ArcToZero); + knobs[4]->set_controllable (boost::shared_ptr()); + knobs[5]->set_controllable (boost::shared_ptr()); + knobs[6]->set_controllable (boost::shared_ptr()); + knobs[7]->set_controllable (boost::shared_ptr()); name_changed (); color_changed (); @@ -197,7 +225,6 @@ TrackMixLayout::drop_stripable () void TrackMixLayout::name_changed () { - name_layout->set_text (stripable->name()); _dirty = true; } @@ -205,12 +232,12 @@ void TrackMixLayout::color_changed () { uint32_t rgb = stripable->presentation_info().color(); - uint8_t index = p2.get_color_index (rgb); - Push2::Button* b = p2.button_by_id (Push2::Upper1); - b->set_color (index); - b->set_state (Push2::LED::OneShot24th); - p2.write (b->state_msg ()); + for (int n = 0; n < 8; ++n) { + knobs[n]->set_text_color (rgb); + knobs[n]->set_arc_start_color (rgb); + knobs[n]->set_arc_end_color (rgb); + } } void @@ -223,3 +250,26 @@ TrackMixLayout::stripable_property_change (PropertyChange const& what_changed) name_changed (); } } + +void +TrackMixLayout::strip_vpot (int n, int delta) +{ + boost::shared_ptr ac = knobs[n]->controllable(); + + if (ac) { + ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup); + } +} + +void +TrackMixLayout::strip_vpot_touch (int n, bool touching) +{ + boost::shared_ptr ac = knobs[n]->controllable(); + if (ac) { + if (touching) { + ac->start_touch (session.audible_frame()); + } else { + ac->stop_touch (true, session.audible_frame()); + } + } +} diff --git a/libs/surfaces/push2/track_mix.h b/libs/surfaces/push2/track_mix.h index 84aa4f043d..102b9940da 100644 --- a/libs/surfaces/push2/track_mix.h +++ b/libs/surfaces/push2/track_mix.h @@ -39,7 +39,8 @@ class TrackMixLayout : public Push2Layout void set_stripable (boost::shared_ptr); - bool redraw (Cairo::RefPtr) const; + bool redraw (Cairo::RefPtr, bool force) const; + void on_show (); void button_upper (uint32_t n); void button_lower (uint32_t n); @@ -52,14 +53,16 @@ class TrackMixLayout : public Push2Layout PBD::ScopedConnectionList stripable_connections; bool _dirty; - Glib::RefPtr name_layout; Glib::RefPtr upper_layout[8]; Glib::RefPtr lower_layout[8]; - std::vector knobs; + Push2Knob* knobs[8]; void stripable_property_change (PBD::PropertyChange const& what_changed); + PBD::ScopedConnection selection_connection; + void selection_changed (); + void drop_stripable (); void name_changed (); void color_changed (); -- cgit v1.2.3