From 91e38a73cd93af894ecaf44476ae8e6313670cb5 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 15 May 2012 16:40:43 +0000 Subject: NxWidgets: New pre-release event. Action now raised on pre-release. NxWM: Use action event to process icon touches; Fix initialization of image highlighted state. git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4740 42af7a65-404d-4744-a932-0658087f49c3 --- NxWidgets/libnxwidgets/include/cbutton.hxx | 11 +++++++- NxWidgets/libnxwidgets/include/cbuttonarray.hxx | 11 +++++++- NxWidgets/libnxwidgets/include/cimage.hxx | 15 ++++++++--- NxWidgets/libnxwidgets/include/cnxwidget.hxx | 17 ++++++++++--- .../libnxwidgets/include/crlepalettebitmap.hxx | 2 +- .../libnxwidgets/include/cwidgeteventhandler.hxx | 2 +- NxWidgets/libnxwidgets/src/cbitmap.cxx | 2 +- NxWidgets/libnxwidgets/src/cbutton.cxx | 15 +++++++++-- NxWidgets/libnxwidgets/src/cbuttonarray.cxx | 14 +++++++++-- NxWidgets/libnxwidgets/src/cimage.cxx | 29 ++++++++++++++++------ NxWidgets/libnxwidgets/src/cnxwidget.cxx | 21 ++++++++++++++-- NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx | 2 +- NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx | 2 +- .../libnxwidgets/src/cwidgeteventhandlerlist.cxx | 2 +- 14 files changed, 118 insertions(+), 27 deletions(-) (limited to 'NxWidgets/libnxwidgets') diff --git a/NxWidgets/libnxwidgets/include/cbutton.hxx b/NxWidgets/libnxwidgets/include/cbutton.hxx index 4af39f0ef..45481387f 100644 --- a/NxWidgets/libnxwidgets/include/cbutton.hxx +++ b/NxWidgets/libnxwidgets/include/cbutton.hxx @@ -179,7 +179,16 @@ namespace NXWidgets virtual void onClick(nxgl_coord_t x, nxgl_coord_t y); /** - * Raises an action event and redraws the button. + * Raises an action. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + + virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y); + + /** + * Redraws the button. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. diff --git a/NxWidgets/libnxwidgets/include/cbuttonarray.hxx b/NxWidgets/libnxwidgets/include/cbuttonarray.hxx index 487a6cb9f..435fa1080 100644 --- a/NxWidgets/libnxwidgets/include/cbuttonarray.hxx +++ b/NxWidgets/libnxwidgets/include/cbuttonarray.hxx @@ -133,7 +133,16 @@ namespace NXWidgets virtual void onClick(nxgl_coord_t x, nxgl_coord_t y); /** - * Raises an action event and redraws the button. + * Raises an action. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + + virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y); + + /** + * Redraws the button. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. diff --git a/NxWidgets/libnxwidgets/include/cimage.hxx b/NxWidgets/libnxwidgets/include/cimage.hxx index 0b7be14f2..0fe275624 100644 --- a/NxWidgets/libnxwidgets/include/cimage.hxx +++ b/NxWidgets/libnxwidgets/include/cimage.hxx @@ -143,16 +143,25 @@ namespace NXWidgets virtual void onClick(nxgl_coord_t x, nxgl_coord_t y); /** - * Raises an action event and redraws the button. + * Raises an action. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. */ - virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y); + virtual void onPreRelease(nxgl_coord_t x, nxgl_coord_t y); /** - * Redraws the button. + * Redraws the image. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + + virtual void onRelease(nxgl_coord_t x, nxgl_coord_t y); + + /** + * Redraws the image. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. diff --git a/NxWidgets/libnxwidgets/include/cnxwidget.hxx b/NxWidgets/libnxwidgets/include/cnxwidget.hxx index 38a66d155..2ca055c1c 100644 --- a/NxWidgets/libnxwidgets/include/cnxwidget.hxx +++ b/NxWidgets/libnxwidgets/include/cnxwidget.hxx @@ -296,9 +296,20 @@ namespace NXWidgets virtual inline void onDoubleClick(nxgl_coord_t x, nxgl_coord_t y) { } /** - * Called when the widget is released. Override this when - * creating new widgets if the widget should exhibit additional - * behaviour when it is released. + * Called just before the widget is released; the widget will be in the + * clicked stated. Override this when creating new widgets if the + * widget should exhibit additional behaviour when it is released. + * + * @param x The x coordinate of the mouse when released. + * @param y The y coordinate of the mouse when released. + */ + + virtual inline void onPreRelease(nxgl_coord_t x, nxgl_coord_t y) { } + + /** + * Called just after the widget is released; the widget will be in the + * released stated. Override this when creating new widgets if the + * widget should exhibit additional behaviour when it is released. * * @param x The x coordinate of the mouse when released. * @param y The y coordinate of the mouse when released. diff --git a/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx b/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx index 451b472f4..dd869c476 100644 --- a/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx +++ b/NxWidgets/libnxwidgets/include/crlepalettebitmap.hxx @@ -40,7 +40,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include diff --git a/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx b/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx index d176d8822..8883fa12d 100644 --- a/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx +++ b/NxWidgets/libnxwidgets/include/cwidgeteventhandler.hxx @@ -270,7 +270,7 @@ namespace NXWidgets virtual void handleDoubleClickEvent(const CWidgetEventArgs &e) { } /** - * Handle a widget action event. + * Handle a widget action event. For CImage, this is a mouse button pre-release event. * * @param e The event data. */ diff --git a/NxWidgets/libnxwidgets/src/cbitmap.cxx b/NxWidgets/libnxwidgets/src/cbitmap.cxx index 875e6daaa..c9c974814 100644 --- a/NxWidgets/libnxwidgets/src/cbitmap.cxx +++ b/NxWidgets/libnxwidgets/src/cbitmap.cxx @@ -70,7 +70,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include diff --git a/NxWidgets/libnxwidgets/src/cbutton.cxx b/NxWidgets/libnxwidgets/src/cbutton.cxx index 66ad3f2c7..429905759 100644 --- a/NxWidgets/libnxwidgets/src/cbutton.cxx +++ b/NxWidgets/libnxwidgets/src/cbutton.cxx @@ -275,15 +275,26 @@ void CButton::onClick(nxgl_coord_t x, nxgl_coord_t y) } /** - * Raises an action event and redraws the button. + * Raises an action. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. */ -void CButton::onRelease(nxgl_coord_t x, nxgl_coord_t y) +void CButton::onPreRelease(nxgl_coord_t x, nxgl_coord_t y) { m_widgetEventHandlers->raiseActionEvent(); +} + +/** + * Redraws the button. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + +void CButton::onRelease(nxgl_coord_t x, nxgl_coord_t y) +{ redraw(); } diff --git a/NxWidgets/libnxwidgets/src/cbuttonarray.cxx b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx index 263a16ce4..642a0a562 100644 --- a/NxWidgets/libnxwidgets/src/cbuttonarray.cxx +++ b/NxWidgets/libnxwidgets/src/cbuttonarray.cxx @@ -546,16 +546,26 @@ void CButtonArray::onClick(nxgl_coord_t x, nxgl_coord_t y) } /** - * Raises an action event and redraws the button. + * Raises an action. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. */ -void CButtonArray::onRelease(nxgl_coord_t x, nxgl_coord_t y) +void CButtonArray::onPreRelease(nxgl_coord_t x, nxgl_coord_t y) { m_widgetEventHandlers->raiseActionEvent(); +} +/** + * Redraws the button. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + +void CButtonArray::onRelease(nxgl_coord_t x, nxgl_coord_t y) +{ // Redraw only the button that was released m_redrawButton = true; diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx index 7d9e0ee4e..30bf7e78b 100644 --- a/NxWidgets/libnxwidgets/src/cimage.cxx +++ b/NxWidgets/libnxwidgets/src/cimage.cxx @@ -70,7 +70,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include @@ -116,12 +116,16 @@ CImage::CImage(CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, { // Save the IBitmap instance - m_bitmap = bitmap; + m_bitmap = bitmap; + + // Not highlighted + + m_highlighted = false; // Position the top/lef corner of the bitmap in the top/left corner of the display - m_origin.x = 0; - m_origin.y = 0; + m_origin.x = 0; + m_origin.y = 0; } /** @@ -385,20 +389,31 @@ void CImage::onClick(nxgl_coord_t x, nxgl_coord_t y) } /** - * Raises an action event and redraws the button. + * Raises an action. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. */ -void CImage::onRelease(nxgl_coord_t x, nxgl_coord_t y) +void CImage::onPreRelease(nxgl_coord_t x, nxgl_coord_t y) { m_widgetEventHandlers->raiseActionEvent(); +} + +/** + * Redraws the image. + * + * @param x The x coordinate of the mouse. + * @param y The y coordinate of the mouse. + */ + +void CImage::onRelease(nxgl_coord_t x, nxgl_coord_t y) +{ redraw(); } /** - * Redraws the button. + * Redraws the image. * * @param x The x coordinate of the mouse. * @param y The y coordinate of the mouse. diff --git a/NxWidgets/libnxwidgets/src/cnxwidget.cxx b/NxWidgets/libnxwidgets/src/cnxwidget.cxx index 66766dca6..ab4a09b4e 100644 --- a/NxWidgets/libnxwidgets/src/cnxwidget.cxx +++ b/NxWidgets/libnxwidgets/src/cnxwidget.cxx @@ -70,7 +70,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include @@ -772,6 +772,17 @@ bool CNxWidget::release(nxgl_coord_t x, nxgl_coord_t y) return false; } + // Notify of the pre-release event. In this event, the widget is still in the + // clicked state. This event is used, for example, by button handlers so + // that the click event is really processed when the button is released + // instead of pressed. The former behavior is needed because the result + // of processing the press may obscure the button and make it impossible + // to receive the release event. + + onPreRelease(x, y); + + // Now mark the widget as NOT clicked and stop draggin actions. + m_flags.clicked = false; stopDragging(x, y); @@ -784,6 +795,9 @@ bool CNxWidget::release(nxgl_coord_t x, nxgl_coord_t y) if (checkCollision(x, y)) { + // Notify of the release event... the widget was NOT dragged outside of + // its original bounding box + onRelease(x, y); // Release occurred within widget; raise release @@ -792,9 +806,12 @@ bool CNxWidget::release(nxgl_coord_t x, nxgl_coord_t y) } else { + // Notify of the release event... the widget WAS dragged outside of + // its original bounding box + onReleaseOutside(x, y); - // Release occurred outside widget; raise release + // Release occurred outside widget; raise release outside event m_widgetEventHandlers->raiseReleaseOutsideEvent(x, y); } diff --git a/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx index 4c781e2c9..99f7fdbba 100644 --- a/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx +++ b/NxWidgets/libnxwidgets/src/crlepalettebitmap.cxx @@ -70,7 +70,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include diff --git a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx index 5ecd8ab22..286c9c46a 100644 --- a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx +++ b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx @@ -36,7 +36,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include diff --git a/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx b/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx index 68230e17a..91722725a 100644 --- a/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx +++ b/NxWidgets/libnxwidgets/src/cwidgeteventhandlerlist.cxx @@ -70,7 +70,7 @@ /**************************************************************************** * Included Files ****************************************************************************/ - + #include #include -- cgit v1.2.3