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
This commit is contained in:
patacongo 2012-05-15 16:40:43 +00:00
parent 074a88c409
commit 4c27a000d0
20 changed files with 134 additions and 43 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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 onPreRelease(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.
*/
virtual void onRelease(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.

View File

@ -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.

View File

@ -40,7 +40,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>

View File

@ -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.
*/

View File

@ -70,7 +70,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>

View File

@ -275,7 +275,19 @@ 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::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.
@ -283,7 +295,6 @@ void CButton::onClick(nxgl_coord_t x, nxgl_coord_t y)
void CButton::onRelease(nxgl_coord_t x, nxgl_coord_t y)
{
m_widgetEventHandlers->raiseActionEvent();
redraw();
}

View File

@ -546,7 +546,19 @@ 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::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.
@ -554,8 +566,6 @@ void CButtonArray::onClick(nxgl_coord_t x, nxgl_coord_t y)
void CButtonArray::onRelease(nxgl_coord_t x, nxgl_coord_t y)
{
m_widgetEventHandlers->raiseActionEvent();
// Redraw only the button that was released
m_redrawButton = true;

View File

@ -70,7 +70,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
@ -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,7 +389,19 @@ 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::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.
@ -393,12 +409,11 @@ void CImage::onClick(nxgl_coord_t x, nxgl_coord_t y)
void CImage::onRelease(nxgl_coord_t x, nxgl_coord_t y)
{
m_widgetEventHandlers->raiseActionEvent();
redraw();
}
/**
* Redraws the button.
* Redraws the image.
*
* @param x The x coordinate of the mouse.
* @param y The y coordinate of the mouse.

View File

@ -70,7 +70,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
@ -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);
}

View File

@ -70,7 +70,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>

View File

@ -36,7 +36,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>

View File

@ -70,7 +70,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>

View File

@ -96,12 +96,12 @@ namespace NxWM
uint8_t m_flags; /**< Window flags */
/**
* Handle a mouse button click event.
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
*
* @param e The event data.
*/
void handleClickEvent(const NXWidgets::CWidgetEventArgs &e);
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
public:

View File

@ -110,12 +110,12 @@ namespace NxWM
void stopAllApplications(void);
/**
* Handle a mouse button click event.
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
*
* @param e The event data.
*/
void handleClickEvent(const NXWidgets::CWidgetEventArgs &e);
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
public:

View File

@ -209,12 +209,12 @@ namespace NxWM
void hideApplicationWindow(IApplication *app);
/**
* Handle a mouse button click event.
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
*
* @param e The event data.
*/
void handleClickEvent(const NXWidgets::CWidgetEventArgs &e);
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
public:
/**

View File

@ -498,12 +498,12 @@ void CApplicationWindow::clickStopIcon(int index)
#endif
/**
* Handle a mouse button click event.
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
*
* @param e The event data.
*/
void CApplicationWindow::handleClickEvent(const NXWidgets::CWidgetEventArgs &e)
void CApplicationWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
{
// Ignore the event if no callback is registered

View File

@ -36,7 +36,7 @@
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "cwidgetcontrol.hxx"
@ -443,14 +443,14 @@ void CStartWindow::stopAllApplications(void)
}
/**
* Handle a mouse button click event.
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
*
* @param e The event data.
*/
void CStartWindow::handleClickEvent(const NXWidgets::CWidgetEventArgs &e)
void CStartWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
{
// icon was clicked?
// Was an ICON clicked?
for (int i = 0; i < m_slots.size(); i++)
{

View File

@ -1277,14 +1277,14 @@ void CTaskbar::hideApplicationWindow(IApplication *app)
}
/**
* Handle a mouse button click event.
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
*
* @param e The event data.
*/
void CTaskbar::handleClickEvent(const NXWidgets::CWidgetEventArgs &e)
void CTaskbar::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
{
// icon was clicked?
// Was a n ICON clicked?
for (int i = 0; i < m_slots.size(); i++)
{