midi scrooming performance updates.
authornick_m <mainsbridge@gmail.com>
Thu, 22 Dec 2016 13:51:34 +0000 (00:51 +1100)
committernick_m <mainsbridge@gmail.com>
Thu, 22 Dec 2016 13:51:34 +0000 (00:51 +1100)
- MGR visibility is handled by update_note/hit()
  MRV unconditionally updates MGR events
- remove MidiGhostRegion::update_range()
- rename set_contents_height -> update_contents_height

gtk2_ardour/ghostregion.cc
gtk2_ardour/ghostregion.h
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_time_axis.cc

index 10893c0f1b0fcc8248cc3d689cc6d102c10ed99c..1da70631f719c907ac60108535a4336f0673a88c 100644 (file)
@@ -184,9 +184,6 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv,
        _outline = UIConfiguration::instance().color ("ghost track midi outline");
 
        base_rect->lower_to_bottom();
-       update_range ();
-
-       midi_view()->NoteRangeChanged.connect (sigc::mem_fun (*this, &MidiGhostRegion::update_range));
 }
 
 /**
@@ -208,9 +205,6 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv,
        _outline = UIConfiguration::instance().color ("ghost track midi outline");
 
        base_rect->lower_to_bottom();
-       update_range ();
-
-       midi_view()->NoteRangeChanged.connect (sigc::mem_fun (*this, &MidiGhostRegion::update_range));
 }
 
 MidiGhostRegion::~MidiGhostRegion()
@@ -262,7 +256,7 @@ void
 MidiGhostRegion::set_height ()
 {
        GhostRegion::set_height();
-       set_contents_height ();
+       update_contents_height ();
 }
 
 void
@@ -297,27 +291,7 @@ note_y(TimeAxisView& trackview, MidiStreamView* mv, uint8_t note_num)
 }
 
 void
-MidiGhostRegion::update_range ()
-{
-       MidiStreamView* mv = midi_view();
-
-       if (!mv) {
-               return;
-       }
-
-       for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
-               uint8_t const note_num = (*it).second->event->note()->note();
-
-               if (note_num < mv->lowest_note() || note_num > mv->highest_note()) {
-                       (*it).second->item->hide();
-               } else {
-                       (*it).second->item->show();
-               }
-       }
-}
-
-void
-MidiGhostRegion::set_contents_height ()
+MidiGhostRegion::update_contents_height ()
 {
        MidiStreamView* mv = midi_view();
 
@@ -408,10 +382,14 @@ MidiGhostRegion::update_note (Note* note)
        double const y = note_y(trackview, mv, note_num);
        double const h = note_height(trackview, mv);
 
-       if ((_tmp_rect = dynamic_cast<ArdourCanvas::Rectangle*>(ev->item))) {
-               _tmp_rect->set (ArdourCanvas::Rect (note->x0(), y, note->x1(), y + h));
+       if (note_num < mv->lowest_note() || note_num > mv->highest_note()) {
+               ev->item->hide();
+       } else {
+               if ((_tmp_rect = dynamic_cast<ArdourCanvas::Rectangle*>(ev->item))) {
+                       _tmp_rect->set (ArdourCanvas::Rect (note->x0(), y, note->x1(), y + h));
+               }
+               ev->item->show();
        }
-
 }
 
 /** Update the x positions of our representation of a parent's hit.
@@ -436,14 +414,18 @@ MidiGhostRegion::update_hit (Hit* hit)
 
        double const h = note_height(trackview, mv);
        double const y = note_y(trackview, mv, note_num);
-
-       if ((_tmp_poly = dynamic_cast<ArdourCanvas::Polygon*>(ev->item))) {
-               ArdourCanvas::Duple ppos = hit->position();
-               ArdourCanvas::Duple gpos = _tmp_poly->position();
-               gpos.x = ppos.x;
-               gpos.y = y;
-               _tmp_poly->set_position(gpos);
-               _tmp_poly->set(Hit::points(h));
+       if (note_num < mv->lowest_note() || note_num > mv->highest_note()) {
+               ev->item->hide();
+       } else {
+               if ((_tmp_poly = dynamic_cast<ArdourCanvas::Polygon*>(ev->item))) {
+                       ArdourCanvas::Duple ppos = hit->position();
+                       ArdourCanvas::Duple gpos = _tmp_poly->position();
+                       gpos.x = ppos.x;
+                       gpos.y = y;
+                       _tmp_poly->set_position(gpos);
+                       _tmp_poly->set(Hit::points(h));
+               }
+               ev->item->show();
        }
 }
 
index f4848fd3ccd2f659e2d7d7e18ff83e80b109d751..000399007b3118df9be0aa5afec5263c27ac0aba 100644 (file)
@@ -106,8 +106,7 @@ public:
        void set_samples_per_pixel (double spu);
        void set_colors();
 
-       void update_range();
-       void set_contents_height();
+       void update_contents_height();
 
        void add_note(NoteBase*);
        void update_note (Note*);
index 4e0e2af1e42f7446e1923120cc08e7983c904a40..90a1e368836a463b254aca3935b6d02fc7b71cb8 100644 (file)
@@ -1189,6 +1189,8 @@ MidiRegionView::redisplay_model()
        bool empty_when_starting = _events.empty();
        MidiModel::ReadLock lock(_model->read_lock());
        MidiModel::Notes missing_notes = _model->notes(); // copy
+       Note* sus = NULL;
+       Hit*  hit = NULL;
 
        if (!empty_when_starting) {
                MidiModel::Notes::iterator f;
@@ -1225,10 +1227,11 @@ MidiRegionView::redisplay_model()
                        } else {
                                NoteBase* cne = (*i);
                                bool visible;
+                               bool update = false;
 
                                if (note_in_region_range (note, visible)) {
                                        if (visible) {
-                                               update_note (cne);
+                                               update = true;
                                                cne->show ();
                                        } else {
                                                cne->hide ();
@@ -1236,7 +1239,31 @@ MidiRegionView::redisplay_model()
                                } else {
                                        cne->hide ();
                                }
+                               if ((sus = dynamic_cast<Note*>(cne))) {
+
+                                       if (update) {
+                                               update_sustained (sus);
+                                       }
+
+                                       for (std::vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
+                                               MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*i);
+                                               if (gr) {
+                                                       gr->update_note (sus);
+                                               }
+                                       }
+                               } else if ((hit = dynamic_cast<Hit*>(cne))) {
 
+                                       if (update) {
+                                               update_hit (hit);
+                                       }
+
+                                       for (std::vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
+                                               MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*i);
+                                               if (gr) {
+                                                       gr->update_hit (hit);
+                                               }
+                                       }
+                               }
                                ++i;
                        }
                }
@@ -1248,18 +1275,14 @@ MidiRegionView::redisplay_model()
                NoteBase* cne = add_note (note, true);
                bool visible;
 
-               if (note_in_region_range (note, visible)) {
-                       if (visible) {
-                               set<Evoral::event_id_t>::iterator it;
-
-                               cne->show ();
+               for (set<Evoral::event_id_t>::iterator it = _pending_note_selection.begin(); it != _pending_note_selection.end(); ++it) {
+                       if ((*it) == note->id()) {
+                               add_to_selection (cne);
+                       }
+               }
 
-                               for (it = _pending_note_selection.begin(); it != _pending_note_selection.end(); ++it) {
-                                       if ((*it) == note->id()) {
-                                               add_to_selection (cne);
-                                       }
-                               }
-                       } else {
+               if (note_in_region_range (note, visible)) {
+                       if (!visible) {
                                cne->hide ();
                        }
                } else {
@@ -1747,14 +1770,6 @@ MidiRegionView::update_sustained (Note* ev, bool update_ghost_regions)
        ev->set_fill_color(base_col);
        ev->set_outline_color(ev->calculate_outline(base_col, ev->selected()));
 
-       if (update_ghost_regions) {
-               for (std::vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
-                       MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*i);
-                       if (gr) {
-                               gr->update_note (ev);
-                       }
-               }
-       }
 }
 
 void
@@ -1784,14 +1799,6 @@ MidiRegionView::update_hit (Hit* ev, bool update_ghost_regions)
        ev->set_fill_color(base_col);
        ev->set_outline_color(ev->calculate_outline(base_col, ev->selected()));
 
-       if (update_ghost_regions) {
-               for (std::vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
-                       MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*i);
-                       if (gr) {
-                               gr->update_hit (ev);
-                       }
-               }
-       }
 }
 
 /** Add a MIDI note to the view (with length).
index 1679039990b1cebb3c2a5774d0bafd15551344bf..6bbc813eb2f960508901eb78a8d4805f2a19a763 100644 (file)
@@ -1239,13 +1239,6 @@ MidiTimeAxisView::set_note_range (MidiStreamView::VisibleNoteRange range, bool a
 void
 MidiTimeAxisView::update_range()
 {
-       MidiGhostRegion* mgr;
-
-       for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
-               if ((mgr = dynamic_cast<MidiGhostRegion*>(*i)) != 0) {
-                       mgr->update_range();
-               }
-       }
 }
 
 void