send enter events to EVERY newly entered item (ignore the bool return from the event...
[ardour.git] / gtk2_ardour / region_view.cc
index 88f7cf9387e00692a36a3857707dd099909c5411..530d046f5ae8d823cb1471b62a01dc099ec71380 100644 (file)
@@ -183,9 +183,9 @@ RegionView::init (Gdk::Color const & basic_color, bool wfd)
                }
        }
 
-       if (name_pixbuf) {
-               name_pixbuf->set_data ("regionview", this);
-               name_pixbuf->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_name_event), name_pixbuf, this));
+       if (name_text) {
+               name_text->set_data ("regionview", this);
+               name_text->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_name_event), name_text, this));
        }
 
        if (wfd) {
@@ -196,8 +196,6 @@ RegionView::init (Gdk::Color const & basic_color, bool wfd)
 
        _region->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&RegionView::region_changed, this, _1), gui_context());
 
-       group->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_event), group, this));
-
        set_colors ();
 
        ColorsChanged.connect (sigc::mem_fun (*this, &RegionView::color_handler));
@@ -222,6 +220,12 @@ RegionView::~RegionView ()
        delete editor;
 }
 
+bool
+RegionView::canvas_group_event (GdkEvent* event)
+{
+       return trackview.editor().canvas_region_view_event (event, group, this);
+}
+
 void
 RegionView::set_silent_frames (const AudioIntervalResult& silences, double /*threshold*/)
 {
@@ -234,7 +238,7 @@ RegionView::set_silent_frames (const AudioIntervalResult& silences, double /*thr
                 return;
         }
 
-        uint32_t const color = ARDOUR_UI::config()->canvasvar_Silence.get();
+        uint32_t const color = ARDOUR_UI::config()->get_canvasvar_Silence();
 
        for (AudioIntervalResult::const_iterator i = silences.begin(); i != silences.end(); ++i) {
 
@@ -275,7 +279,7 @@ RegionView::set_silent_frames (const AudioIntervalResult& silences, double /*thr
         _silence_text = new ArdourCanvas::Text (group);
        _silence_text->set_ignore_events (true);
         _silence_text->set_font_description (get_font_for_style (N_("SilenceText")));
-        _silence_text->set_color (ARDOUR_UI::config()->canvasvar_SilenceText.get());
+        _silence_text->set_color (ARDOUR_UI::config()->get_canvasvar_SilenceText());
 
         /* both positions are relative to the region start offset in source */
 
@@ -423,7 +427,7 @@ RegionView::region_resized (const PropertyChange& what_changed)
 
                set_duration (_region->length(), 0);
 
-               unit_length = _region->length() / frames_per_pixel;
+               unit_length = _region->length() / samples_per_pixel;
 
                for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
 
@@ -489,12 +493,12 @@ RegionView::set_position (framepos_t pos, void* /*src*/, double* ignored)
 }
 
 void
-RegionView::set_frames_per_pixel (double fpp)
+RegionView::set_samples_per_pixel (double fpp)
 {
-       TimeAxisViewItem::set_frames_per_pixel (fpp);
+       TimeAxisViewItem::set_samples_per_pixel (fpp);
 
        for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
-               (*i)->set_frames_per_pixel (fpp);
+               (*i)->set_samples_per_pixel (fpp);
                (*i)->set_duration (_region->length() / fpp);
        }
 
@@ -509,7 +513,7 @@ RegionView::set_duration (framecnt_t frames, void *src)
        }
 
        for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
-               (*i)->set_duration (_region->length() / frames_per_pixel);
+               (*i)->set_duration (_region->length() / samples_per_pixel);
        }
 
        return true;
@@ -632,14 +636,15 @@ RegionView::region_sync_changed ()
                /* points set below */
 
                sync_mark = new ArdourCanvas::Polygon (group);
+               CANVAS_DEBUG_NAME (sync_mark, string_compose ("sync mark for %1", get_item_name()));
                sync_mark->set_fill_color (RGBA_TO_UINT(0,255,0,255));    // FIXME make a themeable colour
 
                sync_line = new ArdourCanvas::Line (group);
+               CANVAS_DEBUG_NAME (sync_line, string_compose ("sync mark for %1", get_item_name()));
                sync_line->set_outline_color (RGBA_TO_UINT(0,255,0,255)); // FIXME make a themeable colour
-               sync_line->set_outline_width  (1);
        }
 
-       /* this has to handle both a genuine change of position, a change of frames_per_pixel
+       /* this has to handle both a genuine change of position, a change of samples_per_pixel
           and a change in the bounds of the _region->
         */
 
@@ -667,7 +672,7 @@ RegionView::region_sync_changed ()
 
                        //points = sync_mark->property_points().get_value();
 
-                       double offset = sync_offset / frames_per_pixel;
+                       double offset = sync_offset / samples_per_pixel;
                        points.push_back (ArdourCanvas::Duple (offset - ((sync_mark_width-1)/2), 1));
                        points.push_back (ArdourCanvas::Duple (offset + ((sync_mark_width-1)/2), 1));
                        points.push_back (ArdourCanvas::Duple (offset, sync_mark_width - 1));
@@ -739,7 +744,7 @@ RegionView::set_height (double h)
                int sync_dir;
                framecnt_t sync_offset;
                sync_offset = _region->sync_offset (sync_dir);
-               double offset = sync_offset / frames_per_pixel;
+               double offset = sync_offset / samples_per_pixel;
 
                sync_line->set (
                        ArdourCanvas::Duple (offset, 0),
@@ -787,7 +792,7 @@ RegionView::update_coverage_frames (LayerDisplay d)
        bool me = false;
 
        /* the color that will be used to show parts of regions that will not be heard */
-       uint32_t const non_playing_color = ARDOUR_UI::config()->canvasvar_CoveredRegion.get ();
+       uint32_t const non_playing_color = ARDOUR_UI::config()->get_canvasvar_CoveredRegion ();
 
        while (t < end) {
 
@@ -838,8 +843,8 @@ RegionView::update_coverage_frames (LayerDisplay d)
                name_highlight->raise_to_top ();
        }
 
-       if (name_pixbuf) {
-               name_pixbuf->raise_to_top ();
+       if (name_text) {
+               name_text->raise_to_top ();
        }
 }
 
@@ -931,32 +936,12 @@ RegionView::thaw_after_trim ()
 
 
 void
-RegionView::trim_contents (framepos_t frame_delta, bool left_direction, bool swap_direction)
+RegionView::move_contents (frameoffset_t distance)
 {
        if (_region->locked()) {
                return;
        }
-
-       framepos_t new_bound;
-
-       RouteTimeAxisView& rtv = dynamic_cast<RouteTimeAxisView&> (trackview);
-       double const speed = rtv.track()->speed ();
-
-       if (left_direction) {
-               if (swap_direction) {
-                       new_bound = (framepos_t) (_region->position() / speed) + frame_delta;
-               } else {
-                       new_bound = (framepos_t) (_region->position() / speed) - frame_delta;
-               }
-       } else {
-               if (swap_direction) {
-                       new_bound = (framepos_t) (_region->position() / speed) - frame_delta;
-               } else {
-                       new_bound = (framepos_t) (_region->position() / speed) + frame_delta;
-               }
-       }
-
-       _region->trim_start ((framepos_t) (new_bound * speed));
+       _region->move_start (distance);
        region_changed (PropertyChange (ARDOUR::Properties::start));
 }