properly handle FS pitch-bend - closes #7140
[ardour.git] / gtk2_ardour / ghostregion.cc
index ef0e020dcfc88039aa34db0b442b2112ac2eb749..494b13e47f6becee0d80a825458210c998f0268a 100644 (file)
@@ -181,6 +181,8 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv,
     : GhostRegion(rv, tv.ghost_group(), tv, source_tv, initial_unit_pos)
     , _optimization_iterator(events.end())
 {
+       set_colors();
+
        base_rect->lower_to_bottom();
        update_range ();
 
@@ -203,6 +205,8 @@ MidiGhostRegion::MidiGhostRegion(RegionView& rv,
                   initial_unit_pos)
     , _optimization_iterator(events.end())
 {
+       set_colors();
+
        base_rect->lower_to_bottom();
        update_range ();
 
@@ -265,11 +269,10 @@ void
 MidiGhostRegion::set_colors()
 {
        GhostRegion::set_colors();
+       _outline = UIConfiguration::instance().color ("ghost track midi outline");
 
        for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
-               _fill = UIConfiguration::instance().color_mod((*it)->event->base_color(), "ghost track midi fill");
-               _outline = UIConfiguration::instance().color ("ghost track midi outline");
-               (*it)->item->set_fill_color (_fill);
+               (*it)->item->set_fill_color (UIConfiguration::instance().color_mod((*it)->event->base_color(), "ghost track midi fill"));
                (*it)->item->set_outline_color (_outline);
        }
 }
@@ -333,7 +336,7 @@ MidiGhostRegion::add_note (NoteBase* n)
        GhostEvent* event = new GhostEvent (n, group);
        events.push_back (event);
 
-       event->item->set_fill_color (_fill);
+       event->item->set_fill_color (UIConfiguration::instance().color_mod(n->base_color(), "ghost track midi fill"));
        event->item->set_outline_color (_outline);
 
        MidiStreamView* mv = midi_view();
@@ -375,28 +378,35 @@ MidiGhostRegion::clear_events()
  *  @param parent The CanvasNote from the parent MidiRegionView.
  */
 void
-MidiGhostRegion::update_note (NoteBase* parent)
+MidiGhostRegion::update_note (Note* note)
 {
-       GhostEvent* ev = find_event (parent);
+       GhostEvent* ev = find_event (note);
        if (!ev) {
                return;
        }
 
-       Note*                    note = NULL;
        ArdourCanvas::Rectangle* rect = NULL;
-       Hit*                     hit  = NULL;
+       if ((rect = dynamic_cast<ArdourCanvas::Rectangle*>(ev->item))) {
+               rect->set (ArdourCanvas::Rect (note->x0(), rect->y0(), note->x1(), rect->y1()));
+       }
+}
+/** Update the x positions of our representation of a parent's hit.
+ *  @param hit The CanvasHit from the parent MidiRegionView.
+ */
+void
+MidiGhostRegion::update_hit (Hit* hit)
+{
+       GhostEvent* ev = find_event (hit);
+       if (!ev) {
+               return;
+       }
+
        ArdourCanvas::Polygon*   poly = NULL;
-       if ((note = dynamic_cast<Note*>(parent))) {
-               if ((rect = dynamic_cast<ArdourCanvas::Rectangle*>(ev->item))) {
-                       rect->set (ArdourCanvas::Rect (parent->x0(), rect->y0(), parent->x1(), rect->y1()));
-               }
-       } else if ((hit = dynamic_cast<Hit*>(parent))) {
-               if ((poly = dynamic_cast<ArdourCanvas::Polygon*>(ev->item))) {
-                       ArdourCanvas::Duple ppos = hit->position();
-                       ArdourCanvas::Duple gpos = poly->position();
-                       gpos.x = ppos.x;
-                       poly->set_position(gpos);
-               }
+       if ((poly = dynamic_cast<ArdourCanvas::Polygon*>(ev->item))) {
+               ArdourCanvas::Duple ppos = hit->position();
+               ArdourCanvas::Duple gpos = poly->position();
+               gpos.x = ppos.x;
+               poly->set_position(gpos);
        }
 }