a slew of unconnected mostly minor tweaks to get Push2 support back to where it was...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 19 Sep 2016 21:11:22 +0000 (16:11 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Sep 2016 19:59:31 +0000 (14:59 -0500)
... prior to using the canvas for the video screen

libs/canvas/canvas/item.h
libs/surfaces/push2/buttons.cc
libs/surfaces/push2/canvas.cc
libs/surfaces/push2/mix.cc
libs/surfaces/push2/mix.h
libs/surfaces/push2/push2.cc
libs/surfaces/push2/push2.h

index e92fc7fb4b1ae5daa0e7e2321e8df51e0b06c9dc..4c0366b859e3a1a4e249783c446f2452f436fe94 100644 (file)
@@ -165,8 +165,8 @@ public:
        void raise (int);
        void lower_to_bottom ();
 
-        void hide ();
-       void show ();
+       virtual void hide ();
+        virtual void show ();
 
        /** @return true if this item is visible (ie it will be rendered),
         *  otherwise false
index bbe05995dbe1dd87f2b1336e6d74526e552286ba..bdcfc394d01206d865ecd7ad91fa566b0d68f0e9 100644 (file)
@@ -582,3 +582,144 @@ Push2::button_mix_press ()
                }
        }
 }
+
+std::string
+Push2::button_name_by_id (ButtonID id)
+{
+       switch (id) {
+       case TapTempo:
+               return "TapTempo";
+       case Metronome:
+               return "Metronome";
+       case Upper1:
+               return "Upper1";
+       case Upper2:
+               return "Upper2";
+       case Upper3:
+               return "Upper3";
+       case Upper4:
+               return "Upper4";
+       case Upper5:
+               return "Upper5";
+       case Upper6:
+               return "Upper6";
+       case Upper7:
+               return "Upper7";
+       case Upper8:
+               return "Upper8";
+       case Setup:
+               return "Setup";
+       case User:
+               return "User";
+       case Delete:
+               return "Delete";
+       case AddDevice:
+               return "AddDevice";
+       case Device:
+               return "Device";
+       case Mix:
+               return "Mix";
+       case Undo:
+               return "Undo";
+       case AddTrack:
+               return "AddTrack";
+       case Browse:
+               return "Browse";
+       case Clip:
+               return "Clip";
+       case Mute:
+               return "Mute";
+       case Solo:
+               return "Solo";
+       case Stop:
+               return "Stop";
+       case Lower1:
+               return "Lower1";
+       case Lower2:
+               return "Lower2";
+       case Lower3:
+               return "Lower3";
+       case Lower4:
+               return "Lower4";
+       case Lower5:
+               return "Lower5";
+       case Lower6:
+               return "Lower6";
+       case Lower7:
+               return "Lower7";
+       case Lower8:
+               return "Lower8";
+       case Master:
+               return "Master";
+       case Convert:
+               return "Convert";
+       case DoubleLoop:
+               return "DoubleLoop";
+       case Quantize:
+               return "Quantize";
+       case Duplicate:
+               return "Duplicate";
+       case New:
+               return "New";
+       case FixedLength:
+               return "FixedLength";
+       case Automate:
+               return "Automate";
+       case RecordEnable:
+               return "RecordEnable";
+       case Play:
+               return "Play";
+       case Fwd32ndT:
+               return "Fwd32ndT";
+       case Fwd32nd:
+               return "Fwd32nd";
+       case Fwd16thT:
+               return "Fwd16thT";
+       case Fwd16th:
+               return "Fwd16th";
+       case Fwd8thT:
+               return "Fwd8thT";
+       case Fwd8th:
+               return "Fwd8th";
+       case Fwd4trT:
+               return "Fwd4trT";
+       case Fwd4tr:
+               return "Fwd4tr";
+       case Up:
+               return "Up";
+       case Right:
+               return "Right";
+       case Down:
+               return "Down";
+       case Left:
+               return "Left";
+       case Repeat:
+               return "Repeat";
+       case Accent:
+               return "Accent";
+       case Scale:
+               return "Scale";
+       case Layout:
+               return "Layout";
+       case Note:
+               return "Note";
+       case Session:
+               return "Session";
+       case OctaveUp:
+               return "OctaveUp";
+       case PageRight:
+               return "PageRight";
+       case OctaveDown:
+               return "OctaveDown";
+       case PageLeft:
+               return "PageLeft";
+       case Shift:
+               return "Shift";
+       case Select:
+               return "Select";
+       default:
+               break;
+       }
+
+       return "???";
+}
index 9d5ad1456247e6b0290d49afa70ab4893e4b0caf..69af070c2764f93b5b48b9cd765e1b5c64ec79d2 100644 (file)
@@ -103,7 +103,7 @@ Push2Canvas::request_redraw (Rect const & r)
        cr.x = r.x0;
        cr.y = r.y0;
        cr.width = r.width();
-       cr.width = r.height();
+       cr.height = r.height();
 
        DEBUG_TRACE (DEBUG::Push2, string_compose ("invalidate rect %1\n", r));
 
index cd4464b22e4b536605ca18f58501312b776482da..b564eaee0cc5d523206eb9bd8e8efad5c502020f 100644 (file)
@@ -72,10 +72,20 @@ MixLayout::MixLayout (Push2& p, Session& s)
 
        Pango::FontDescription fd2 ("Sans 10");
        for (int n = 0; n < 8; ++n) {
+
+               /* background for text labels for knob function */
+
+               Rectangle* r = new Rectangle (this);
+               Coord x0 = 10 + (n*Push2Canvas::inter_button_spacing()) - 5;
+               r->set (Rect (x0, 2, x0 + Push2Canvas::inter_button_spacing(), 2 + 21));
+               backgrounds.push_back (r);
+
+               /* text labels for knob function*/
+
                Text* t = new Text (this);
-               upper_text.push_back (t);
                t->set_font_description (fd2);
                t->set_color (p2.get_color (Push2::ParameterName));
+               t->set_position (Duple (10 + (n*Push2Canvas::inter_button_spacing()), 5));
 
                string txt;
                switch (n) {
@@ -105,19 +115,22 @@ MixLayout::MixLayout (Push2& p, Session& s)
                        break;
                }
                t->set (txt);
+               upper_text.push_back (t);
 
-               t = new Text (this);
-               lower_text.push_back (t);
-               t->set_font_description (fd2);
-               t->set_color (p2.get_color (Push2::ParameterName));
-
-               Rectangle* r = new Rectangle (this);
-               r->set (Rect (10 + (n*Push2Canvas::inter_button_spacing()) - 5, 2, Push2Canvas::inter_button_spacing(), 21));
-               backgrounds.push_back (r);
+               /* knobs */
 
                knobs[n] = new Push2Knob (p2, this);
                knobs[n]->set_position (Duple (60 + (n*Push2Canvas::inter_button_spacing()), 95));
                knobs[n]->set_radius (25);
+
+               /* stripable names */
+
+               t = new Text (this);
+               t->set_font_description (fd2);
+               t->set_color (p2.get_color (Push2::ParameterName));
+               t->set_position (Duple (10 + (n*Push2Canvas::inter_button_spacing()), 140));
+               lower_text.push_back (t);
+
        }
 
        mode_button = p2.button_by_id (Push2::Upper1);
@@ -134,7 +147,7 @@ MixLayout::~MixLayout ()
 void
 MixLayout::show ()
 {
-       Item::show ();
+       Container::show ();
 
        mode_button->set_color (Push2::LED::White);
        mode_button->set_state (Push2::LED::OneShot24th);
@@ -148,15 +161,21 @@ MixLayout::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) cons
 {
        DEBUG_TRACE (DEBUG::Push2, string_compose ("mix render %1\n", area));
 
+       /* draw background */
+
        set_source_rgb (context, p2.get_color (Push2::DarkBackground));
        context->rectangle (0, 0, display_width(), display_height());
        context->fill ();
 
+       /* draw line across top (below labels) */
+
        context->move_to (0, 22.5);
        context->line_to (display_width(), 22.5);
        context->set_line_width (1.0);
        context->stroke ();
 
+       /* show the kids ... */
+
        render_children (area, context);
 }
 
@@ -217,6 +236,11 @@ MixLayout::show_vpot_mode ()
        mode_button->set_state (Push2::LED::OneShot24th);
        p2.write (mode_button->state_msg());
 
+       for (int s = 0; s < 8; ++s) {
+               backgrounds[s]->hide ();
+               upper_text[s]->set_color (p2.get_color (Push2::ParameterName));
+       }
+
        boost::shared_ptr<AutomationControl> ac;
        switch (vpot_mode) {
        case Volume:
@@ -228,6 +252,9 @@ MixLayout::show_vpot_mode ()
                        }
                        knobs[s]->remove_flag (Push2Knob::ArcToZero);
                }
+               backgrounds[0]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[0]->show ();
+               upper_text[0]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        case PanAzimuth:
                for (int s = 0; s < 8; ++s) {
@@ -239,6 +266,9 @@ MixLayout::show_vpot_mode ()
 
                        }
                }
+               backgrounds[1]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[1]->show ();
+               upper_text[1]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        case PanWidth:
                for (int s = 0; s < 8; ++s) {
@@ -250,6 +280,9 @@ MixLayout::show_vpot_mode ()
                        }
                        knobs[s]->remove_flag (Push2Knob::ArcToZero);
                }
+               backgrounds[2]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[2]->show ();
+               upper_text[2]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        case Send1:
                for (int s = 0; s < 8; ++s) {
@@ -261,6 +294,9 @@ MixLayout::show_vpot_mode ()
                        }
                        knobs[s]->remove_flag (Push2Knob::ArcToZero);
                }
+               backgrounds[3]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[3]->show ();
+               upper_text[3]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        case Send2:
                for (int s = 0; s < 8; ++s) {
@@ -272,6 +308,9 @@ MixLayout::show_vpot_mode ()
                        }
                        knobs[s]->remove_flag (Push2Knob::ArcToZero);
                }
+               backgrounds[4]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[4]->show ();
+               upper_text[4]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        case Send3:
                for (int s = 0; s < 8; ++s) {
@@ -283,6 +322,9 @@ MixLayout::show_vpot_mode ()
                        }
                        knobs[s]->remove_flag (Push2Knob::ArcToZero);
                }
+               backgrounds[5]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[5]->show ();
+               upper_text[5]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        case Send4:
                for (int s = 0; s < 8; ++s) {
@@ -294,6 +336,9 @@ MixLayout::show_vpot_mode ()
                        }
                        knobs[s]->remove_flag (Push2Knob::ArcToZero);
                }
+               backgrounds[6]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[6]->show ();
+               upper_text[6]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        case Send5:
                for (int s = 0; s < 8; ++s) {
@@ -305,12 +350,13 @@ MixLayout::show_vpot_mode ()
                        }
                        knobs[s]->remove_flag (Push2Knob::ArcToZero);
                }
+               backgrounds[7]->set_fill_color (p2.get_color (Push2::ParameterName));
+               backgrounds[7]->show ();
+               upper_text[7]->set_color (contrasting_text_color (p2.get_color (Push2::ParameterName)));
                break;
        default:
                break;
        }
-
-       _dirty = true;
 }
 
 void
@@ -373,25 +419,44 @@ MixLayout::strip_vpot_touch (int n, bool touching)
 }
 
 void
-MixLayout::stripable_property_change (PropertyChange const& what_changed, int which)
+MixLayout::stripable_property_change (PropertyChange const& what_changed, uint32_t which)
 {
+       if (what_changed.contains (Properties::hidden)) {
+               switch_bank (bank_start);
+       }
+
        if (what_changed.contains (Properties::selected)) {
+
                if (!stripable[which]) {
                        return;
                }
 
                if (stripable[which]->presentation_info().selected()) {
-                       selection_bg->show ();
-                       selection_bg->set_fill_color (stripable[which]->presentation_info().color());
-                       selection_bg->set (Rect (10  + (which*Push2Canvas::inter_button_spacing()) - 5, 137,
-                                                10 + (which*Push2Canvas::inter_button_spacing()) - 5 + Push2Canvas::inter_button_spacing(),
-                                                137 + 21));
-                       lower_text[which]->set_color (ArdourCanvas::contrasting_text_color (selection_bg->fill_color()));
+                       show_selection (which);
                } else {
-                       selection_bg->hide ();
-                       lower_text[which]->set_color (stripable[which]->presentation_info().color());
+                       hide_selection (which);
                }
        }
+
+}
+
+void
+MixLayout::show_selection (uint32_t n)
+{
+       selection_bg->show ();
+       selection_bg->set_fill_color (stripable[n]->presentation_info().color());
+       const Coord x0 = 10  + (n * Push2Canvas::inter_button_spacing()) - 5;
+       selection_bg->set (Rect (x0, 137, x0 + Push2Canvas::inter_button_spacing(), 137 + 21));
+       lower_text[n]->set_color (ArdourCanvas::contrasting_text_color (selection_bg->fill_color()));
+}
+
+void
+MixLayout::hide_selection (uint32_t n)
+{
+       selection_bg->hide ();
+       if (stripable[n]) {
+               lower_text[n]->set_color (stripable[n]->presentation_info().color());
+       }
 }
 
 void
@@ -437,28 +502,24 @@ MixLayout::switch_bank (uint32_t base)
        /* work backwards so we can tell if we should actually switch banks */
 
        boost::shared_ptr<Stripable> s[8];
-       uint32_t old_empty = 0;
-       uint32_t new_empty = 0;
+       uint32_t different = 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 (s[n] != stripable[n]) {
+                       different++;
                }
        }
 
-       if ((new_empty != 0) && (new_empty >= old_empty)) {
+       if (!different) {
                /* some missing strips; new bank the same or more empty stripables than the old one, do
                   nothing since we had already reached the end.
                */
-               for (int n = 0; n < 8; ++n) {
-                       upper_text[n]->hide ();
-                       lower_text[n]->hide ();
-                       backgrounds[n]->hide ();
-               }
+               return;
+       }
+
+       if (!s[0]) {
+               /* not even the first stripable exists, do nothing */
                return;
        }
 
@@ -472,16 +533,12 @@ MixLayout::switch_bank (uint32_t base)
 
        for (int n = 0; n < 8; ++n) {
                if (!stripable[n]) {
-                       upper_text[n]->hide ();
                        lower_text[n]->hide ();
-                       backgrounds[n]->hide ();
+                       hide_selection (n);
                        continue;
                }
 
-               upper_text[n]->show ();
                lower_text[n]->show ();
-               backgrounds[n]->show ();
-               backgrounds[n]->set_fill_color (stripable[n]->presentation_info().color());
 
                /* stripable goes away? refill the bank, starting at the same point */
 
@@ -490,6 +547,16 @@ MixLayout::switch_bank (uint32_t base)
                stripable[n]->solo_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::solo_changed, this, n), &p2);
                stripable[n]->mute_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::mute_changed, this, n), &p2);
 
+               if (stripable[n]->presentation_info().selected()) {
+                       show_selection (n);
+               } else {
+                       hide_selection (n);
+               }
+
+               /* this will set lower text to the correct value (basically
+                  the stripable name)
+               */
+
                solo_mute_changed (n);
 
                Push2::Button* b;
index 85b1feba10760a71c395af6cd04c0751cc0f58d4..719030914171c166e64fcf0240c168ad2037d629 100644 (file)
@@ -57,7 +57,6 @@ class MixLayout : public Push2Layout
        void strip_vpot_touch (int, bool);
 
   private:
-       mutable bool _dirty;
        std::vector<ArdourCanvas::Text*> upper_text;
        std::vector<ArdourCanvas::Text*> lower_text;
        std::vector<ArdourCanvas::Rectangle*> backgrounds;
@@ -73,7 +72,7 @@ class MixLayout : public Push2Layout
        PBD::ScopedConnectionList session_connections;
        void stripables_added ();
 
-       void stripable_property_change (PBD::PropertyChange const& what_changed, int which);
+       void stripable_property_change (PBD::PropertyChange const& what_changed, uint32_t which);
 
        void switch_bank (uint32_t base);
 
@@ -91,6 +90,8 @@ class MixLayout : public Push2Layout
        void solo_changed (uint32_t n);
        void mute_changed (uint32_t n);
        void solo_mute_changed (uint32_t n);
+       void show_selection (uint32_t n);
+       void hide_selection (uint32_t n);
 };
 
 } /* namespace */
index 6887bb73a5881e2f9675014092058759d18702da..7a40b067c8c397b60c1e6b7a0c5ba4279aea03f2 100644 (file)
@@ -729,7 +729,7 @@ Push2::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
 void
 Push2::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoBytes* ev)
 {
-       DEBUG_TRACE (DEBUG::Push2, string_compose ("Note On %1 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity));
+       // DEBUG_TRACE (DEBUG::Push2, string_compose ("Note On %1 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity));
 
        if (ev->velocity == 0) {
                handle_midi_note_off_message (parser, ev);
@@ -811,7 +811,7 @@ Push2::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoBytes* e
 void
 Push2::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
 {
-       DEBUG_TRACE (DEBUG::Push2, string_compose ("Note Off %1 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity));
+       // DEBUG_TRACE (DEBUG::Push2, string_compose ("Note Off %1 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity));
 
        if (ev->note_number < 11) {
                /* theoretically related to encoder touch start/end, but
@@ -1446,12 +1446,6 @@ Push2::stripable_selection_change (StripableNotificationListPtr selected)
                }
        }
 
-       if (new_pad_target) {
-               cerr << "new midi pad target " << new_pad_target->name() << endl;
-       } else {
-               cerr << "no midi pad target\n";
-       }
-
        if (current_midi_track == new_pad_target) {
                /* nothing to do */
                return;
@@ -1465,7 +1459,6 @@ Push2::stripable_selection_change (StripableNotificationListPtr selected)
        /* disconnect from pad port, if appropriate */
 
        if (current_midi_track && pad_port) {
-               cerr << "Disconnect pads from " << current_midi_track->name() << endl;
                current_midi_track->input()->disconnect (current_midi_track->input()->nth(0), pad_port->name(), this);
        }
 
@@ -1474,7 +1467,6 @@ Push2::stripable_selection_change (StripableNotificationListPtr selected)
         */
 
        if (new_pad_target && pad_port) {
-               cerr << "Reconnect pads to " << new_pad_target->name() << endl;
                new_pad_target->input()->connect (new_pad_target->input()->nth (0), pad_port->name(), this);
                current_pad_target = new_pad_target;
        } else {
index b27de8704ce26a9340546b05735f519fffc5d8c3..f1a5d8fcfd64cf1477f26f8605620a42574b4b6f 100644 (file)
@@ -346,6 +346,7 @@ class Push2 : public ARDOUR::ControlProtocol
        ModifierState modifier_state() const { return _modifier_state; }
 
        Button* button_by_id (ButtonID);
+       static std::string button_name_by_id (ButtonID);
 
        void write (const MidiByteArray&);