Make menu item for Add Track/Bus/VCA dialog consistent with window title
[ardour.git] / gtk2_ardour / ghostregion.cc
index 7c697a1b0f4c9165c5ca732f226df0616476fd81..1936609e8a57595476675905fa16621c2dc48ac7 100644 (file)
@@ -30,6 +30,7 @@
 #include "ghostregion.h"
 #include "midi_streamview.h"
 #include "midi_time_axis.h"
+#include "region_view.h"
 #include "rgb_macros.h"
 #include "note.h"
 #include "hit.h"
@@ -40,11 +41,14 @@ using namespace Editing;
 using namespace ArdourCanvas;
 using namespace ARDOUR;
 
-PBD::Signal1<void,GhostRegion*> GhostRegion::CatchDeletion;
-
-GhostRegion::GhostRegion (ArdourCanvas::Container* parent, TimeAxisView& tv, TimeAxisView& source_tv, double initial_pos)
-       : trackview (tv)
-       , source_trackview (source_tv)
+GhostRegion::GhostRegion(RegionView& rv,
+                         ArdourCanvas::Container* parent,
+                         TimeAxisView& tv,
+                         TimeAxisView& source_tv,
+                         double initial_pos)
+    : parent_rv(rv)
+    , trackview(tv)
+    , source_trackview(source_tv)
 {
        group = new ArdourCanvas::Container (parent);
        CANVAS_DEBUG_NAME (group, "ghost region");
@@ -70,7 +74,8 @@ GhostRegion::GhostRegion (ArdourCanvas::Container* parent, TimeAxisView& tv, Tim
 
 GhostRegion::~GhostRegion ()
 {
-       CatchDeletion (this);
+       parent_rv.remove_ghost(this);
+       trackview.erase_ghost(this);
        delete base_rect;
        delete group;
 }
@@ -108,8 +113,11 @@ GhostRegion::is_automation_ghost()
        return (dynamic_cast<AutomationTimeAxisView*>(&trackview)) != 0;
 }
 
-AudioGhostRegion::AudioGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos)
-       : GhostRegion(tv.ghost_group(), tv, source_tv, initial_unit_pos)
+AudioGhostRegion::AudioGhostRegion(RegionView& rv,
+                                   TimeAxisView& tv,
+                                   TimeAxisView& source_tv,
+                                   double initial_unit_pos)
+    : GhostRegion(rv, tv.ghost_group(), tv, source_tv, initial_unit_pos)
 {
 
 }
@@ -162,12 +170,16 @@ AudioGhostRegion::set_colors ()
 /** The general constructor; called when the destination timeaxisview doesn't have
  *  a midistreamview.
  *
+ *  @param rv The parent RegionView that is being ghosted.
  *  @param tv TimeAxisView that this ghost region is on.
  *  @param source_tv TimeAxisView that we are the ghost for.
  */
-MidiGhostRegion::MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos)
-       : GhostRegion(tv.ghost_group(), tv, source_tv, initial_unit_pos)
-       , _optimization_iterator (events.end ())
+MidiGhostRegion::MidiGhostRegion(RegionView& rv,
+                                 TimeAxisView& tv,
+                                 TimeAxisView& source_tv,
+                                 double initial_unit_pos)
+    : GhostRegion(rv, tv.ghost_group(), tv, source_tv, initial_unit_pos)
+    , _optimization_iterator(events.end())
 {
        base_rect->lower_to_bottom();
        update_range ();
@@ -176,12 +188,20 @@ MidiGhostRegion::MidiGhostRegion(TimeAxisView& tv, TimeAxisView& source_tv, doub
 }
 
 /**
+ *  @param rv The parent RegionView being ghosted.
  *  @param msv MidiStreamView that this ghost region is on.
  *  @param source_tv TimeAxisView that we are the ghost for.
  */
-MidiGhostRegion::MidiGhostRegion(MidiStreamView& msv, TimeAxisView& source_tv, double initial_unit_pos)
-       : GhostRegion(msv.midi_underlay_group, msv.trackview(), source_tv, initial_unit_pos)
-       , _optimization_iterator (events.end ())
+MidiGhostRegion::MidiGhostRegion(RegionView& rv,
+                                 MidiStreamView& msv,
+                                 TimeAxisView& source_tv,
+                                 double initial_unit_pos)
+    : GhostRegion(rv,
+                  msv.midi_underlay_group,
+                  msv.trackview(),
+                  source_tv,
+                  initial_unit_pos)
+    , _optimization_iterator(events.end())
 {
        base_rect->lower_to_bottom();
        update_range ();
@@ -247,8 +267,10 @@ MidiGhostRegion::set_colors()
        GhostRegion::set_colors();
 
        for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
-               (*it)->item->set_fill_color (UIConfiguration::instance().color_mod((*it)->event->base_color(), "ghost track midi fill"));
-               (*it)->item->set_outline_color (UIConfiguration::instance().color ("ghost track midi outline"));
+               _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_outline_color (_outline);
        }
 }
 
@@ -311,8 +333,8 @@ MidiGhostRegion::add_note (NoteBase* n)
        GhostEvent* event = new GhostEvent (n, group);
        events.push_back (event);
 
-       event->item->set_fill_color (UIConfiguration::instance().color_mod(n->base_color(), "ghost track midi fill"));
-       event->item->set_outline_color (UIConfiguration::instance().color ("ghost track midi outline"));
+       event->item->set_fill_color (_fill);
+       event->item->set_outline_color (_outline);
 
        MidiStreamView* mv = midi_view();
 
@@ -327,8 +349,7 @@ MidiGhostRegion::add_note (NoteBase* n)
                        ArdourCanvas::Rectangle* rect = NULL;
                        ArdourCanvas::Polygon*   poly = NULL;
                        if ((rect = dynamic_cast<ArdourCanvas::Rectangle*>(event->item))) {
-                               rect->set_y0 (y);
-                               rect->set_y1 (y + h);
+                               rect->set (ArdourCanvas::Rect (rect->x0(), y, rect->x1(), y + h));
                        } else if ((poly = dynamic_cast<ArdourCanvas::Polygon*>(event->item))) {
                                Duple position = poly->position();
                                position.y = y;
@@ -354,31 +375,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))) {
-                       double const x1 = parent->x0 ();
-                       double const x2 = parent->x1 ();
-                       rect->set_x0 (x1);
-                       rect->set_x1 (x2);
-               }
-       } 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);
        }
 }