diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-07 16:00:56 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-07 16:00:56 +0000 |
commit | 3c5cba9b94c3f5365034f044e18a58d425508c87 (patch) | |
tree | c29f3db20b8275cd22e7c4d36c3d722f2fdf6277 /NxWidgets/libnxwidgets/src/cscrollingpanel.cxx | |
parent | 73bf549bd5a335d66ef80e50b551d356386facad (diff) | |
download | nuttx-3c5cba9b94c3f5365034f044e18a58d425508c87.tar.gz nuttx-3c5cba9b94c3f5365034f044e18a58d425508c87.tar.bz2 nuttx-3c5cba9b94c3f5365034f044e18a58d425508c87.zip |
Patches from Petteri Aimonen + stdbool and rand() changes for Freddie Chopin
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5415 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/libnxwidgets/src/cscrollingpanel.cxx')
-rw-r--r-- | NxWidgets/libnxwidgets/src/cscrollingpanel.cxx | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx b/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx index d3ee40cf9..b7c507bb2 100644 --- a/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx +++ b/NxWidgets/libnxwidgets/src/cscrollingpanel.cxx @@ -70,11 +70,12 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include <nuttx/config.h> #include <stdint.h> #include <stdbool.h> +#include <debug.h> #include "cwidgetcontrol.hxx" #include "cscrollingpanel.hxx" @@ -113,6 +114,13 @@ CScrollingPanel::CScrollingPanel(CWidgetControl *pWidgetControl, : CNxWidget(pWidgetControl, x, y, width, height, flags, style) { m_widgetControl = pWidgetControl; + + // NOTE: CScrollingPanel is temporarily borderless because there was no + // easy way to redraw only the required part of the border. + + m_flags.permeable = true; + m_flags.borderless = true; + CRect rect; getClientRect(rect); @@ -120,12 +128,10 @@ CScrollingPanel::CScrollingPanel(CWidgetControl *pWidgetControl, m_canvasHeight = rect.getHeight(); m_canvasX = 0; m_canvasY = 0; - + setAllowsVerticalScroll(true); setAllowsHorizontalScroll(true); setContentScrolled(true); - - m_flags.permeable = true; } /** @@ -186,6 +192,24 @@ void CScrollingPanel::scroll(int32_t dx, int32_t dy) CGraphicsPort *port = m_widgetControl->getGraphicsPort(); port->move(getX(), getY(), dx, dy, rect.getWidth(), rect.getHeight()); + if (dx > 0) + { + revealedRects.push_back(CRect(getX(), getY(), dx, rect.getHeight())); + } + else if (dx < 0) + { + revealedRects.push_back(CRect(getX() + rect.getWidth() + dx, getY(), -dx, rect.getHeight())); + } + + if (dy > 0) + { + revealedRects.push_back(CRect(getX(), getY(), rect.getWidth(), dy)); + } + else if (dy < 0) + { + revealedRects.push_back(CRect(getX(), getY() + rect.getHeight() + dy, rect.getWidth(), -dy)); + } + // Adjust the scroll values m_canvasY += dy; @@ -193,12 +217,20 @@ void CScrollingPanel::scroll(int32_t dx, int32_t dy) if (revealedRects.size() > 0) { - // Draw revealed sections + // Draw background to revealed sections + // Children will redraw themselves in moveTo. for (int i = 0; i < revealedRects.size(); ++i) { - drawBorder(port); - drawContents(port); + CRect &rrect = revealedRects[i]; + + gvdbg("Redrawing %d,%d,%d,%d after scroll\n", + rrect.getX(), rrect.getY(), + rrect.getWidth(), rrect.getHeight()); + + port->drawFilledRect(rrect.getX(), rrect.getY(), + rrect.getWidth(), rrect.getHeight(), + getBackgroundColor()); } } } |