1/*
2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Ingo Weinhold <bonefish@cs.tu-berlin.de>
7 */
8
9#include "ScrollableView.h"
10
11#include <View.h>
12
13// constructor
14ScrollableView::ScrollableView()
15	: Scrollable()
16{
17}
18
19// destructor
20ScrollableView::~ScrollableView()
21{
22}
23
24// ScrollOffsetChanged
25void
26ScrollableView::ScrollOffsetChanged(BPoint oldOffset, BPoint newOffset)
27{
28	if (BView* view = dynamic_cast<BView*>(this)) {
29		// We keep it simple: The part of the data rect we shall show now
30		// has existed before as well (even if partially or completely
31		// obscured), so we let CopyBits() do the messy details.
32		BRect bounds(view->Bounds());
33		view->CopyBits(bounds.OffsetByCopy(newOffset - oldOffset), bounds);
34		// move our children
35		for (int32 i = 0; BView* child = view->ChildAt(i); i++)
36			child->MoveTo(child->Frame().LeftTop() + oldOffset - newOffset);
37	}
38}
39
40