summaryrefslogtreecommitdiff
path: root/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-21 20:09:32 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-21 20:09:32 +0000
commit1b917134adffafb33057be34683b5f73807aeca8 (patch)
treea548cfe35af25a0d7b7b3a8a304784c334aecdb6 /NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
parent2e885817755dbb96fa4183a312ea181b28bb70b1 (diff)
downloadpx4-nuttx-1b917134adffafb33057be34683b5f73807aeca8.tar.gz
px4-nuttx-1b917134adffafb33057be34683b5f73807aeca8.tar.bz2
px4-nuttx-1b917134adffafb33057be34683b5f73807aeca8.zip
Patches from Petteri Aimonen (plus a few other things)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5448 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/libnxwidgets/src/cscrollingpanel.cxx')
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollingpanel.cxx40
1 files changed, 34 insertions, 6 deletions
diff --git a/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx b/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
index b7c507bb2..2541bb572 100644
--- a/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
+++ b/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx
@@ -215,10 +215,13 @@ void CScrollingPanel::scroll(int32_t dx, int32_t dy)
m_canvasY += dy;
m_canvasX += dx;
+ // Move children but do not redraw.
+
+ scrollChildren(dx, dy, false);
+
if (revealedRects.size() > 0)
{
// Draw background to revealed sections
- // Children will redraw themselves in moveTo.
for (int i = 0; i < revealedRects.size(); ++i)
{
@@ -231,6 +234,18 @@ void CScrollingPanel::scroll(int32_t dx, int32_t dy)
port->drawFilledRect(rrect.getX(), rrect.getY(),
rrect.getWidth(), rrect.getHeight(),
getBackgroundColor());
+
+ // Check if any children intersect this region.
+ // If it does, it should be redrawn.
+
+ for (int j = 0; j < m_children.size(); ++j)
+ {
+ CRect crect = m_children[j]->getBoundingBox();
+ if (crect.intersects(rrect))
+ {
+ m_children[j]->redraw();
+ }
+ }
}
}
}
@@ -240,11 +255,11 @@ void CScrollingPanel::scroll(int32_t dx, int32_t dy)
m_canvasY += dy;
m_canvasX += dx;
- }
-
- // Scroll all child widgets
+
+ // Scroll all child widgets and redraw them
- scrollChildren(dx, dy);
+ scrollChildren(dx, dy, true);
+ }
// Notify event handlers
@@ -332,9 +347,10 @@ void CScrollingPanel::onClick(nxgl_coord_t x, nxgl_coord_t y)
*
* @param dx The horizontal distance to scroll.
* @param dy The vertical distance to scroll.
+ * @param do_redraw Redraw widgets after moving.
*/
-void CScrollingPanel::scrollChildren(int32_t dx, int32_t dy)
+void CScrollingPanel::scrollChildren(int32_t dx, int32_t dy, bool do_redraw)
{
nxgl_coord_t widgetX = 0;
nxgl_coord_t widgetY = 0;
@@ -345,8 +361,20 @@ void CScrollingPanel::scrollChildren(int32_t dx, int32_t dy)
for (int32_t i = 0; i < m_children.size(); i++)
{
widget = m_children[i];
+ bool oldstate = widget->isDrawingEnabled();
+
+ if (!do_redraw)
+ {
+ widget->disableDrawing();
+ }
+
widgetX = (widget->getX() - thisX) + dx;
widgetY = (widget->getY() - thisY) + dy;
widget->moveTo(widgetX, widgetY);
+
+ if (!do_redraw && oldstate)
+ {
+ widget->enableDrawing();
+ }
}
}