MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / onSetViewScroll

Method onSetViewScroll

src/ui/view.cpp:230–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230void View::onSetViewScroll(const gfx::Point& pt)
231{
232 Point oldScroll = viewScroll();
233 Size maxsize = getScrollableSize();
234 Size visible = visibleSize();
235 Point newScroll(MID(0, pt.x, MAX(0, maxsize.w - visible.w)),
236 MID(0, pt.y, MAX(0, maxsize.h - visible.h)));
237
238 if (newScroll == oldScroll)
239 return;
240
241 // This is the movement for the scrolled region (which is inverse to
242 // the scroll position delta/movement).
243 Point delta = oldScroll - newScroll;
244
245 // Visible viewport region that is not overlapped by windows
246 Region drawableRegion;
247 m_viewport.getDrawableRegion(
248 drawableRegion, DrawableRegionFlags(kCutTopWindows | kUseChildArea));
249
250 // Start the region to scroll equal to the drawable viewport region.
251 Rect cpos = m_viewport.childrenBounds();
252 Region validRegion(cpos);
253 validRegion &= drawableRegion;
254
255 // Remove all children invalid regions from this "validRegion"
256 {
257 std::queue<Widget*> items;
258 items.push(&m_viewport);
259 while (!items.empty()) {
260 Widget* item = items.front();
261 items.pop();
262 for (Widget* child : item->children())
263 items.push(child);
264
265 if (item->isVisible())
266 validRegion -= item->getUpdateRegion();
267 }
268 }
269
270 // Remove invalid region in the screen (areas that weren't
271 // re-painted yet)
272 Manager* manager = this->manager();
273 if (manager)
274 validRegion -= manager->getInvalidRegion();
275
276 // Add extra regions that cannot be scrolled (this can be customized
277 // by subclassing ui::View). We use two ScrollRegionEvent, this
278 // first one with the old scroll position. And the next one with the
279 // new scroll position.
280 {
281 ScrollRegionEvent ev(this, validRegion);
282 onScrollRegion(ev);
283 }
284
285 // Move viewport children
286 cpos.offset(-newScroll);
287 for (auto child : m_viewport.children()) {

Callers

nothing calls this directly

Calls 15

move_regionFunction · 0.85
display_wFunction · 0.85
display_hFunction · 0.85
getDrawableRegionMethod · 0.80
childrenBoundsMethod · 0.80
popMethod · 0.80
managerMethod · 0.80
setBoundsMethod · 0.80
offsetWidgetsMethod · 0.80
setPosMethod · 0.80
getDisplayMethod · 0.80

Tested by

no test coverage detected