mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher/scroll_view] Simplify subviews management
This commit is contained in:
committed by
EmilieNumworks
parent
42d6ec66ab
commit
5b78d65b6d
@@ -28,8 +28,11 @@ public:
|
||||
class Decorator {
|
||||
public:
|
||||
Decorator();
|
||||
int numberOfIndicators();
|
||||
View * indicatorAtIndex(int index);
|
||||
int numberOfIndicators() { return 2; }
|
||||
View * indicatorAtIndex(int index) {
|
||||
assert(0 < index && index <= numberOfIndicators());
|
||||
return &m_verticalBar + (index-1);
|
||||
}
|
||||
void layoutIndicators(KDSize content, KDPoint offset, KDSize frame);
|
||||
ScrollViewVerticalBar * verticalBar() { return &m_verticalBar; }
|
||||
ScrollViewHorizontalBar * horizontalBar() { return &m_horizontalBar; }
|
||||
|
||||
@@ -152,24 +152,6 @@ ScrollView::Decorator::Decorator() :
|
||||
{
|
||||
}
|
||||
|
||||
int ScrollView::Decorator::numberOfIndicators() {
|
||||
return m_verticalBar.visible() + m_horizontalBar.visible();
|
||||
}
|
||||
|
||||
View * ScrollView::Decorator::indicatorAtIndex(int index) {
|
||||
switch (index) {
|
||||
case 1:
|
||||
if (m_horizontalBar.visible()) {
|
||||
return &m_horizontalBar;
|
||||
} else {
|
||||
return &m_verticalBar;
|
||||
}
|
||||
case 2:
|
||||
return &m_verticalBar;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ScrollView::Decorator::layoutIndicators(KDSize content, KDPoint offset, KDSize frame) {
|
||||
m_horizontalBar.update(
|
||||
content.width(),
|
||||
|
||||
@@ -32,6 +32,9 @@ void ScrollViewBar::update(KDCoordinate totalContentLength, KDCoordinate content
|
||||
}
|
||||
|
||||
void ScrollViewHorizontalBar::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
if (!visible()) {
|
||||
return;
|
||||
}
|
||||
ctx->fillRect(
|
||||
KDRect(
|
||||
m_margin, (m_frame.height() - k_indicatorThickness)/2,
|
||||
@@ -49,6 +52,9 @@ void ScrollViewHorizontalBar::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
}
|
||||
|
||||
void ScrollViewVerticalBar::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
if (!visible()) {
|
||||
return;
|
||||
}
|
||||
ctx->fillRect(
|
||||
KDRect(
|
||||
(m_frame.width() - k_indicatorThickness)/2, m_margin,
|
||||
|
||||
Reference in New Issue
Block a user