summaryrefslogtreecommitdiff
path: root/NxWidgets/libnxwidgets
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-07 16:00:56 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-07 16:00:56 +0000
commit3c5cba9b94c3f5365034f044e18a58d425508c87 (patch)
treec29f3db20b8275cd22e7c4d36c3d722f2fdf6277 /NxWidgets/libnxwidgets
parent73bf549bd5a335d66ef80e50b551d356386facad (diff)
downloadpx4-nuttx-3c5cba9b94c3f5365034f044e18a58d425508c87.tar.gz
px4-nuttx-3c5cba9b94c3f5365034f044e18a58d425508c87.tar.bz2
px4-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')
-rw-r--r--NxWidgets/libnxwidgets/include/cnxwidget.hxx2
-rw-r--r--NxWidgets/libnxwidgets/src/cscrollingpanel.cxx46
2 files changed, 40 insertions, 8 deletions
diff --git a/NxWidgets/libnxwidgets/include/cnxwidget.hxx b/NxWidgets/libnxwidgets/include/cnxwidget.hxx
index 2ca055c1c..dda8efc1d 100644
--- a/NxWidgets/libnxwidgets/include/cnxwidget.hxx
+++ b/NxWidgets/libnxwidgets/include/cnxwidget.hxx
@@ -1058,7 +1058,7 @@ namespace NXWidgets
* @return True if the click was successful.
*/
- bool click(nxgl_coord_t x, nxgl_coord_t y);
+ virtual bool click(nxgl_coord_t x, nxgl_coord_t y);
/**
* Check if the click is a double-click.
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());
}
}
}