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) {