11 m_contentView(contentView),
12 m_dataSource(dataSource),
19 m_indicatorThickness(20),
20 m_showsIndicators(
true),
21 m_colorsBackground(
true),
22 m_backgroundColor(
Palette::WallScreen)
24 assert(m_dataSource !=
nullptr);
34 bool ScrollView::hasVerticalIndicator()
const {
35 if (m_showsIndicators) {
36 return m_verticalScrollIndicator.
end() < 1 || m_verticalScrollIndicator.
start() > 0;
41 bool ScrollView::hasHorizontalIndicator()
const {
42 if (m_showsIndicators) {
43 return m_horizontalScrollIndicator.
end() < 1 || m_horizontalScrollIndicator.
start() > 0;
48 int ScrollView::numberOfSubviews()
const {
49 return 1 + hasVerticalIndicator() + hasHorizontalIndicator();
52 View * ScrollView::subviewAtIndex(
int index) {
57 return hasHorizontalIndicator() ? &m_horizontalScrollIndicator : &m_verticalScrollIndicator;
59 return &m_verticalScrollIndicator;
65 if (!m_colorsBackground) {
74 ctx->
fillRect(
KDRect(0, 0, width, m_topMargin-offsetY), m_backgroundColor);
75 ctx->
fillRect(
KDRect(0, contentHeight+m_topMargin-offsetY, width, height - contentHeight - m_topMargin + offsetY), m_backgroundColor);
76 ctx->
fillRect(
KDRect(0, 0, m_leftMargin-offsetX, height), m_backgroundColor);
77 ctx->
fillRect(
KDRect(contentWidth + m_leftMargin - offsetX, 0, width - contentWidth - m_leftMargin + offsetX, height), m_backgroundColor);
87 if (visibleRect.
left() > p.
x()) {
88 offsetX = p.
x() - visibleRect.
left();
90 if (visibleRect.
right() < p.
x()) {
91 offsetX = p.
x() - visibleRect.
right();
93 if (visibleRect.
top() > p.
y()) {
94 offsetY = p.
y() - visibleRect.
top();
96 if (visibleRect.
bottom() < p.
y()) {
97 offsetY = p.
y() - visibleRect.
bottom();
99 if (offsetX != 0 || offsetY != 0) {
142 if (hasHorizontalIndicator() && hasVerticalIndicator()) {
145 m_indicatorThickness,
m_frame.
height() - m_indicatorThickness
147 m_verticalScrollIndicator.
setFrame(verticalIndicatorFrame);
150 m_frame.
width() - m_indicatorThickness, m_indicatorThickness
152 m_horizontalScrollIndicator.
setFrame(horizontalIndicatorFrame);
154 if (hasVerticalIndicator()) {
159 m_verticalScrollIndicator.
setFrame(verticalIndicatorFrame);
161 if (hasHorizontalIndicator()) {
166 m_horizontalScrollIndicator.
setFrame(horizontalIndicatorFrame);
172 if (!m_showsIndicators) {
176 bool hadVerticalIndicator = hasVerticalIndicator();
179 m_verticalScrollIndicator.
setStart(verticalStart/contentHeight);
180 m_verticalScrollIndicator.
setEnd(verticalEnd/contentHeight);
181 if (hadVerticalIndicator && !hasVerticalIndicator()) {
185 bool hadHorizontalIndicator = hasHorizontalIndicator();
188 m_horizontalScrollIndicator.
setStart(horizontalStart/contentWidth);
189 m_horizontalScrollIndicator.
setEnd(horizontalEnd/contentWidth);
190 if (hadHorizontalIndicator && !hasHorizontalIndicator()) {
200 if (m_dataSource->
setOffset(offset) || forceRelayout) {
213 #if ESCHER_VIEW_LOGGING 214 const char * ScrollView::className()
const {
218 void ScrollView::logAttributes(std::ostream &os)
const {
219 View::logAttributes(os);
bool contains(KDPoint p) const
KDPoint bottomRight() const
void setFrame(KDRect frame)
static constexpr KDCoordinate CommonRightMargin
constexpr KDCoordinate width() const
void markRectAsDirty(KDRect rect)
KDCoordinate right() const
KDCoordinate left() const
static constexpr KDCoordinate CommonBottomMargin
static constexpr KDCoordinate CommonLeftMargin
virtual KDSize minimalSizeForOptimalDisplay() const
void fillRect(KDRect rect, KDColor color)
static constexpr KDCoordinate CommonTopMargin
KDCoordinate width() const
KDPoint translatedBy(KDPoint other) const
KDCoordinate height() const
KDCoordinate bottom() const
constexpr KDCoordinate height() const