13
0

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.
This commit is contained in:
Paul Davis 2014-06-05 18:18:28 -04:00
parent eec24b6287
commit 792fe016e7
2 changed files with 32 additions and 0 deletions

View File

@ -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<Cairo::Context> context) const;
private:
ScrollSensitivity _scroll_sensitivity;
Duple _scroll_offset;

View File

@ -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<Cairo::Context> context) const
{
/* clip the draw to the area that this scroll group nominally occupies
* WITHOUT scroll offsets in effect
*/
boost::optional<Rect> 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)
{