From 0dbe3858ea4f8a9cbc93d220286522bae06b5d31 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 7 Dec 2012 16:00:56 +0000 Subject: [PATCH] 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 --- ChangeLog.txt | 6 +++- libnxwidgets/include/cnxwidget.hxx | 2 +- libnxwidgets/src/cscrollingpanel.cxx | 46 +++++++++++++++++++++++----- nxwm/include/cstartwindow.hxx | 4 +-- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index c3ae00d6a..7f7b21247 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -213,4 +213,8 @@ Submitted by Petteri Aimonen. * NxWidgets:CText and NxWidgets:CNumericEdite: Fix some memory freeing bugs (from Petteri Aimonen). - \ No newline at end of file +* NxWidgets::CScrollingPanel: Usability improvements. It is borderless for now, + because there was no easy way to redraw only the required part of the border. + Contributed by Petteri Aimonen. +* NxWidgets::CNxWidgets and NxWM::CStartWindow: Small changes to make sub- + classing easier (from Petteri Aimonen). diff --git a/libnxwidgets/include/cnxwidget.hxx b/libnxwidgets/include/cnxwidget.hxx index 2ca055c1c..dda8efc1d 100644 --- a/libnxwidgets/include/cnxwidget.hxx +++ b/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/libnxwidgets/src/cscrollingpanel.cxx b/libnxwidgets/src/cscrollingpanel.cxx index d3ee40cf9..b7c507bb2 100644 --- a/libnxwidgets/src/cscrollingpanel.cxx +++ b/libnxwidgets/src/cscrollingpanel.cxx @@ -70,11 +70,12 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include #include +#include #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()); } } } diff --git a/nxwm/include/cstartwindow.hxx b/nxwm/include/cstartwindow.hxx index 671b01087..52a67fbd4 100644 --- a/nxwm/include/cstartwindow.hxx +++ b/nxwm/include/cstartwindow.hxx @@ -97,8 +97,8 @@ namespace NxWM */ class CStartWindow : public IApplication, - private IApplicationCallback, - private NXWidgets::CWidgetEventHandler + protected IApplicationCallback, + protected NXWidgets::CWidgetEventHandler { protected: /**