2 * Copyright (C) 2014-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2015 David Robillard <d@drobilla.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "pbd/compose.h"
24 #include "canvas/canvas.h"
25 #include "canvas/debug.h"
26 #include "canvas/scroll_group.h"
29 using namespace ArdourCanvas;
31 ScrollGroup::ScrollGroup (Canvas* c, ScrollSensitivity s)
33 , _scroll_sensitivity (s)
37 ScrollGroup::ScrollGroup (Item* parent, ScrollSensitivity s)
39 , _scroll_sensitivity (s)
44 ScrollGroup::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
46 /* clip the draw to the area that this scroll group nominally occupies
47 * WITHOUT scroll offsets in effect
50 Rect r = bounding_box();
56 Rect self (_position.x + r.x0,
61 self.x1 = min (_position.x + _canvas->width(), self.x1);
62 self.y1 = min (_position.y + _canvas->height(), self.y1);
65 context->rectangle (self.x0, self.y0, self.width(), self.height());
68 Container::render (area, context);
74 ScrollGroup::scroll_to (Duple const& d)
76 if (_scroll_sensitivity & ScrollsHorizontally) {
77 _scroll_offset.x = d.x;
80 if (_scroll_sensitivity & ScrollsVertically) {
81 _scroll_offset.y = d.y;
86 ScrollGroup::covers_canvas (Duple const& d) const
88 Rect r = bounding_box ();
94 /* Bounding box is in item coordinates, but we need
95 to consider the position of the bounding box
99 return r.translate (position()).contains (d);
103 ScrollGroup::covers_window (Duple const& d) const
105 Rect r = bounding_box ();
111 /* Bounding box is in item coordinates, but we need
112 to consider the position of the bounding box
116 return r.translate (position()).contains (d);