From 792fe016e7bf260c84d974abcb41ab0c7dbc5cfe Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 5 Jun 2014 18:18:28 -0400 Subject: [PATCH] clip rendering of ScrollGroup to just the part of the canvas covered by the scroll group. This stops tracks from appearing to scroll up under the rulers, among other things. --- libs/canvas/canvas/scroll_group.h | 2 ++ libs/canvas/scroll_group.cc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/libs/canvas/canvas/scroll_group.h b/libs/canvas/canvas/scroll_group.h index d33e9b9080..7652ae2e9b 100644 --- a/libs/canvas/canvas/scroll_group.h +++ b/libs/canvas/canvas/scroll_group.h @@ -40,6 +40,8 @@ class LIBCANVAS_API ScrollGroup : public Group bool covers_canvas (Duple const& d) const; bool covers_window (Duple const& d) const; + void render (Rect const & area, Cairo::RefPtr context) const; + private: ScrollSensitivity _scroll_sensitivity; Duple _scroll_offset; diff --git a/libs/canvas/scroll_group.cc b/libs/canvas/scroll_group.cc index 615be8007c..0ce612018a 100644 --- a/libs/canvas/scroll_group.cc +++ b/libs/canvas/scroll_group.cc @@ -20,6 +20,7 @@ #include "pbd/compose.h" +#include "canvas/canvas.h" #include "canvas/debug.h" #include "canvas/scroll_group.h" @@ -38,6 +39,35 @@ ScrollGroup::ScrollGroup (Group* parent, Duple position, ScrollSensitivity s) { } +void +ScrollGroup::render (Rect const & area, Cairo::RefPtr context) const +{ + /* clip the draw to the area that this scroll group nominally occupies + * WITHOUT scroll offsets in effect + */ + + boost::optional r = bounding_box(); + + if (!r) { + return; + } + + Rect self (_position.x, _position.y, _position.x + r.get().width(), _position.y + r.get().height()); + + self.x1 = min (_position.x + _canvas->width(), self.x1); + self.y1 = min (_position.y + _canvas->height(), self.y1); + + context->save (); + context->rectangle (self.x0, self.y0, self.width(), self.height()); + context->clip (); + + Group::render (area, context); + + context->restore (); + + +} + void ScrollGroup::scroll_to (Duple const& d) {