push2: track mix layout somewhat working
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 11 Jul 2016 22:17:04 +0000 (18:17 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Sep 2016 19:59:31 +0000 (14:59 -0500)
libs/surfaces/push2/buttons.cc
libs/surfaces/push2/layout.h
libs/surfaces/push2/menu.cc
libs/surfaces/push2/menu.h
libs/surfaces/push2/mix.cc
libs/surfaces/push2/mix.h
libs/surfaces/push2/push2.cc
libs/surfaces/push2/scale.cc
libs/surfaces/push2/scale.h
libs/surfaces/push2/track_mix.cc
libs/surfaces/push2/track_mix.h

index e7a775d00430497273cde8c55c5d65850348f074..bbe05995dbe1dd87f2b1336e6d74526e552286ba 100644 (file)
@@ -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);
                }
        }
index 1fc18af959ecdfc293d369af630ecd910f670aa0..fcc0b7a47973d8dd6bbf7ddad2265e33273d519a 100644 (file)
@@ -43,7 +43,7 @@ class Push2Layout
 
        bool mapped() const;
 
-       virtual bool redraw (Cairo::RefPtr<Cairo::Context>) const = 0;
+       virtual bool redraw (Cairo::RefPtr<Cairo::Context>, bool force) const = 0;
        virtual void on_show () {}
        virtual void on_hide () {}
 
index 583c0a235c10ae093068b58c45da639d8a093378..e3a900b90b12764ceb0792aa3d52a7c2c46589f1 100644 (file)
@@ -187,7 +187,7 @@ Push2Menu::get_active (int col)
 }
 
 void
-Push2Menu::redraw (Cairo::RefPtr<Cairo::Context> context) const
+Push2Menu::redraw (Cairo::RefPtr<Cairo::Context> context, bool force) const
 {
        for (int n = 0; n < 8; ++n) {
 
index a76bba170dc56b7b3d720b40f604d81b87f5f7de..946d2df56d5c3262dd6e2c765e81353d4290dc8d 100644 (file)
@@ -31,7 +31,7 @@ class Push2Menu {
    public:
        Push2Menu (Cairo::RefPtr<Cairo::Context>);
 
-       void redraw (Cairo::RefPtr<Cairo::Context>) const;
+       void redraw (Cairo::RefPtr<Cairo::Context>, bool force) const;
        bool dirty () const { return _dirty; }
 
        void fill_column (int col, std::vector<std::string>);
index 69d6373d42e968954e6e99220ef2a6b48584bb09..2d7c9b7781ec6e82accf31cea7533e395d2da4b4 100644 (file)
@@ -133,7 +133,7 @@ MixLayout::on_show ()
 }
 
 bool
-MixLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
+MixLayout::redraw (Cairo::RefPtr<Cairo::Context> context, bool force) const
 {
        bool children_dirty = false;
 
@@ -172,7 +172,7 @@ MixLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
                }
        }
 
-       if (!children_dirty && !_dirty) {
+       if (!children_dirty && !_dirty && !force) {
                return false;
        }
 
@@ -212,7 +212,7 @@ MixLayout::redraw (Cairo::RefPtr<Cairo::Context> 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) {
index a638a41c6067469c8da7dd99e406d47283230ca6..ebd936aff1ec93578cf66fa801b2fdb31f8a9799 100644 (file)
@@ -36,7 +36,7 @@ class MixLayout : public Push2Layout
        MixLayout (Push2& p, ARDOUR::Session&, Cairo::RefPtr<Cairo::Context>);
        ~MixLayout ();
 
-       bool redraw (Cairo::RefPtr<Cairo::Context>) const;
+       bool redraw (Cairo::RefPtr<Cairo::Context>, bool force) const;
        void on_show ();
 
        void button_upper (uint32_t n);
index 04001646a67d8c6365772bf056c29aa79672d580..412fc3c51beb7e284042c5da9656cecec97ff0e2 100644 (file)
@@ -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 ();
index 2f86d547867176a5a1fe92bb7416e0e06a803d5c..62c13c68f3c41708e989becf340fceea037d9d96 100644 (file)
@@ -63,7 +63,7 @@ ScaleLayout::~ScaleLayout ()
 }
 
 bool
-ScaleLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
+ScaleLayout::redraw (Cairo::RefPtr<Cairo::Context> context, bool force) const
 {
        bool draw = false;
 
@@ -79,7 +79,7 @@ ScaleLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
        context->rectangle (0, 0, 960, 160);
        context->fill ();
 
-       scale_menu->redraw (context);
+       scale_menu->redraw (context, force);
 
        return true;
 }
index a859756d2fbc2f0ad9fe2b67271a75b49ae9d5ce..6df6abf9211efa47e7eced9006fb659bd2ca0d8d 100644 (file)
@@ -33,7 +33,7 @@ class ScaleLayout : public Push2Layout
        ScaleLayout (Push2& p, ARDOUR::Session&, Cairo::RefPtr<Cairo::Context>);
        ~ScaleLayout ();
 
-       bool redraw (Cairo::RefPtr<Cairo::Context>) const;
+       bool redraw (Cairo::RefPtr<Cairo::Context>, bool force) const;
 
        void button_upper (uint32_t n);
        void button_lower (uint32_t n);
index 69d56425c018e4f44cb4ba1ec4935cde2559befe..e1165ee9cf69988a33dcf750b3becf47ee11db1b 100644 (file)
@@ -58,56 +58,86 @@ using namespace ArdourSurface;
 
 TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Context> 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<Push2Knob*>::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<Stripable> s = ControlProtocol::first_selected_stripable();
+       if (s) {
+               set_stripable (s);
        }
 }
+void
+TrackMixLayout::on_show ()
+{
+       selection_changed ();
+}
 
 bool
-TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context) const
+TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context, bool force) const
 {
        bool children_dirty = false;
 
-       for (vector<Push2Knob*>::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<Cairo::Context> 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<Push2Knob*>::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<AutomationControl> 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<Stripable> 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<Stripable> 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<AutomationControl>());
+               knobs[5]->set_controllable (boost::shared_ptr<AutomationControl>());
+               knobs[6]->set_controllable (boost::shared_ptr<AutomationControl>());
+               knobs[7]->set_controllable (boost::shared_ptr<AutomationControl>());
 
                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<Controllable> 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<AutomationControl> ac = knobs[n]->controllable();
+       if (ac) {
+               if (touching) {
+                       ac->start_touch (session.audible_frame());
+               } else {
+                       ac->stop_touch (true, session.audible_frame());
+               }
+       }
+}
index 84aa4f043d9a2e254cc5e816818e1cee204187b1..102b9940da2739de4a26e4f81451b280c587eb7d 100644 (file)
@@ -39,7 +39,8 @@ class TrackMixLayout : public Push2Layout
 
        void set_stripable (boost::shared_ptr<ARDOUR::Stripable>);
 
-       bool redraw (Cairo::RefPtr<Cairo::Context>) const;
+       bool redraw (Cairo::RefPtr<Cairo::Context>, 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<Pango::Layout> name_layout;
        Glib::RefPtr<Pango::Layout> upper_layout[8];
        Glib::RefPtr<Pango::Layout> lower_layout[8];
 
-       std::vector<Push2Knob*> 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 ();