From 8397d6ca465653b01dd5bee7533e0573f5f6ce9a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 16 Jul 2014 19:20:44 -0600 Subject: Misc changes related to MediaPlayer. Nothing really significant --- NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx | 21 +++- .../libnxwidgets/src/cglyphsliderhorizontal.cxx | 32 +++--- .../src/cglyphsliderhorizontalgrip.cxx | 2 +- NxWidgets/libnxwidgets/src/cnxwidget.cxx | 6 +- NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx | 112 +++++++++++---------- 5 files changed, 98 insertions(+), 75 deletions(-) (limited to 'NxWidgets/libnxwidgets') diff --git a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx index f0afe2c47..69bbd1798 100644 --- a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx +++ b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx @@ -102,9 +102,16 @@ namespace NXWidgets * NX mouse callback */ - struct SMouse +#ifdef CONFIG_NX_XYINPUT + struct SXYInput { + // A touchscreen has no buttons. However, the convention is that + // touchscreen contacts are reported with the LEFT button pressed. + // The loss of contct is reported with no buttons pressed. + #if 0 // Center and right buttons are not used + // But only a mouse has center and right buttons + uint16_t leftPressed : 1; /**< Left button pressed (or touchscreen contact) */ uint16_t centerPressed : 1; /**< Center button pressed (not @@ -143,6 +150,9 @@ namespace NXWidgets uint8_t doubleClick : 1; /**< Left button double click */ uint8_t unused : 3; /**< Padding bits */ #endif + + // These are attributes common to both touchscreen and mouse input devices + nxgl_coord_t x; /**< Current X coordinate of the mouse/touch */ nxgl_coord_t y; /**< Current Y coordinate of @@ -156,6 +166,7 @@ namespace NXWidgets struct timespec leftReleaseTime; /**< Time the left button was released */ }; +#endif /** * State data @@ -181,8 +192,10 @@ namespace NXWidgets * I/O */ - struct SMouse m_mouse; /**< Current pointer +#ifdef CONFIG_NX_XYINPUT + struct SXYInput m_xyinput; /**< Current XY input device state */ +#endif CNxWidget *m_clickedWidget; /**< Pointer to the widget that is clicked. */ CNxWidget *m_focusedWidget; /**< Pointer to the widget @@ -357,11 +370,13 @@ namespace NXWidgets giveBoundsSem(); } +#ifdef CONFIG_NX_XYINPUT /** * Clear all mouse events */ void clearMouseEvents(void); +#endif public: @@ -553,7 +568,7 @@ namespace NXWidgets inline bool doubleClick(void) { - return (bool)m_mouse.doubleClick; + return (bool)m_xyinput.doubleClick; } /** diff --git a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx index b75ff736d..da7150ef7 100644 --- a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx +++ b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontal.cxx @@ -76,8 +76,8 @@ #include -#include -#include +#include +#include #include "cwidgetcontrol.hxx" #include "cglyphsliderhorizontal.hxx" @@ -112,25 +112,25 @@ CGlyphSliderHorizontal::CGlyphSliderHorizontal(CWidgetControl * pWidgetControl, nxwidget_pixel_t fillColor, bool fill) :CNxWidget(pWidgetControl, x, y, width, height, WIDGET_DRAGGABLE) { - m_minimumValue = 0; - m_maximumValue = 0; - m_contentSize = 0; - m_value = 0; - m_minimumGripWidth = 10; - m_pageSize = 1; - m_fillColor = fillColor; - m_fill = fill; - m_barThickness = 8; - - m_flags.permeable = false; - m_flags.borderless = false; + m_minimumValue = 0; + m_maximumValue = 0; + m_contentSize = 0; + m_value = 0; + m_minimumGripWidth = 10; + m_pageSize = 1; + m_fillColor = fillColor; + m_fill = fill; + m_barThickness = 8; + + m_flags.permeable = false; + m_flags.borderless = false; m_flags.doubleClickable = false; // Create grip CRect rect; getClientRect(rect); - m_gutterWidth = rect.getWidth(); + m_gutterWidth = rect.getWidth(); // Create grip @@ -214,7 +214,7 @@ void CGlyphSliderHorizontal::handleDragEvent(const CWidgetEventArgs & e) { // Handle grip events - if ((e.getSource() == m_grip) && (e.getSource() != NULL)) + if (e.getSource() == m_grip && e.getSource() != NULL) { int32_t newValue = getGripValue() >> 16; diff --git a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontalgrip.cxx b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontalgrip.cxx index 6e7be0af2..277a4f276 100644 --- a/NxWidgets/libnxwidgets/src/cglyphsliderhorizontalgrip.cxx +++ b/NxWidgets/libnxwidgets/src/cglyphsliderhorizontalgrip.cxx @@ -167,7 +167,7 @@ void CGlyphSliderHorizontalGrip::onReleaseOutside(nxgl_coord_t x, nxgl_coord_t y */ void CGlyphSliderHorizontalGrip::onDrag(nxgl_coord_t x, nxgl_coord_t y, - nxgl_coord_t vX, nxgl_coord_t vY) + nxgl_coord_t vX, nxgl_coord_t vY) { // Work out where we're moving to diff --git a/NxWidgets/libnxwidgets/src/cnxwidget.cxx b/NxWidgets/libnxwidgets/src/cnxwidget.cxx index 99f7014cc..c0c406dde 100644 --- a/NxWidgets/libnxwidgets/src/cnxwidget.cxx +++ b/NxWidgets/libnxwidgets/src/cnxwidget.cxx @@ -100,7 +100,7 @@ using namespace NXWidgets; /** * Constructor. * - * @param pWidgetControl The controllwing widget for the display + * @param pWidgetControl The controlling widget for the display * @param x The x coordinate of the widget. * @param y The y coordinate of the widget. * @param width The width of the widget. @@ -831,9 +831,9 @@ bool CNxWidget::release(nxgl_coord_t x, nxgl_coord_t y) bool CNxWidget::drag(nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY) { - if ((isEnabled()) && (m_flags.dragging)) + if (isEnabled() && m_flags.dragging) { - if ((vX != 0) || (vY != 0)) + if (vX != 0 || vY != 0) { onDrag(x, y, vX, vY); m_widgetEventHandlers->raiseDragEvent(x, y, vX, vY); diff --git a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx index aab75b84c..989cb5293 100644 --- a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx +++ b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx @@ -39,10 +39,10 @@ #include -#include -#include +#include +#include #include -#include +#include #include #include "nxconfig.hxx" @@ -101,7 +101,9 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style) // Initialize the mouse/touchscreen event and keyboard data structures - memset(&m_mouse, 0, sizeof(struct SMouse)); +#ifdef CONFIG_NX_XYINPUT + memset(&m_xyinput, 0, sizeof(struct SXYInput)); +#endif m_nCh = 0; m_nCc = 0; @@ -453,8 +455,8 @@ void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t b { // Save the mouse X/Y position - m_mouse.x = pos->x; - m_mouse.y = pos->y; + m_xyinput.x = pos->x; + m_xyinput.y = pos->y; // Update button press states @@ -465,41 +467,41 @@ void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t b // Handle left button press events. leftHeld means that the left mouse // button was pressed on the previous sample as well. - if (m_mouse.leftHeld) + if (m_xyinput.leftHeld) { - m_mouse.leftDrag = 1; + m_xyinput.leftDrag = 1; } else { // New left button press - m_mouse.leftPressed = 1; + m_xyinput.leftPressed = 1; - (void)clock_gettime(CLOCK_REALTIME, &m_mouse.leftPressTime); + (void)clock_gettime(CLOCK_REALTIME, &m_xyinput.leftPressTime); // Check for double click event - if (elapsedTime(&m_mouse.leftReleaseTime) <= CONFIG_NXWIDGETS_DOUBLECLICK_TIME) + if (elapsedTime(&m_xyinput.leftReleaseTime) <= CONFIG_NXWIDGETS_DOUBLECLICK_TIME) { - m_mouse.doubleClick = 1; + m_xyinput.doubleClick = 1; } } - m_mouse.leftHeld = 1; + m_xyinput.leftHeld = 1; } else { // Handle left button release events - if (m_mouse.leftHeld) + if (m_xyinput.leftHeld) { // New left button release - m_mouse.leftReleased = 1; - (void)clock_gettime(CLOCK_REALTIME, &m_mouse.leftReleaseTime); + m_xyinput.leftReleased = 1; + (void)clock_gettime(CLOCK_REALTIME, &m_xyinput.leftReleaseTime); } - m_mouse.leftHeld = 0; + m_xyinput.leftHeld = 0; } #if 0 // Center and right buttons not used @@ -508,31 +510,31 @@ void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t b // Handle center button press events. centerHeld means that the center mouse // button was pressed on the previous sample as well. - if (m_mouse.centerHeld) + if (m_xyinput.centerHeld) { - m_mouse.centerDrag = 1; + m_xyinput.centerDrag = 1; } else { // New center button press - m_mouse.centerPressed = 1; + m_xyinput.centerPressed = 1; } - m_mouse.centerHeld = 1; + m_xyinput.centerHeld = 1; } else { // Handle center button release events - if (m_mouse.centerHeld) + if (m_xyinput.centerHeld) { // New center button release - m_mouse.centerReleased = 1; + m_xyinput.centerReleased = 1; } - m_mouse.centerHeld = 0; + m_xyinput.centerHeld = 0; } if ((buttons & NX_MOUSE_RIGHTBUTTON) != 0) @@ -540,31 +542,31 @@ void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t b // Handle right button press events. rightHeld means that the right mouse // button was pressed on the previous sample as well. - if (m_mouse.rightHeld) + if (m_xyinput.rightHeld) { - m_mouse.rightDrag = 1; + m_xyinput.rightDrag = 1; } else { // New right button press - m_mouse.rightPressed = 1; + m_xyinput.rightPressed = 1; } - m_mouse.rightHeld = 1; + m_xyinput.rightHeld = 1; } else { // Handle right button release events - if (m_mouse.rightHeld) + if (m_xyinput.rightHeld) { // New right button release - m_mouse.rightReleased = 1; + m_xyinput.rightReleased = 1; } - m_mouse.rightHeld = 0; + m_xyinput.rightHeld = 0; } #endif @@ -646,7 +648,7 @@ void CWidgetControl::newCursorControlEvent(ECursorControl cursorControl) * that inherits from INxWindow. * 3) The call this method with the static_cast to INxWindow to, * finally, create the CGraphicsPort for this window. - * 4) After that, the fully smartend CWidgetControl instance can + * 4) After that, the fully smartened CWidgetControl instance can * be used to generate additional widgets. * * @param window The instance of INxWindow needed to construct the @@ -684,7 +686,7 @@ void CWidgetControl::copyWidgetStyle(CWidgetStyle *dest, const CWidgetStyle *src } /** - * Return the elapsed time in millisconds + * Return the elapsed time in milliseconds * * @param tp A time in the past from which to compute the elapsed time. * @return The elapsed time since tp @@ -791,17 +793,18 @@ void CWidgetControl::processDeleteQueue(void) bool CWidgetControl::pollMouseEvents(CNxWidget *widget) { +#ifdef CONFIG_NX_XYINPUT bool mouseEvent = true; // Assume that an interesting mouse event occurred // All widgets - if (m_mouse.leftPressed) + if (m_xyinput.leftPressed) { // Handle a new left button press event - handleLeftClick(m_mouse.x, m_mouse.y, widget); + handleLeftClick(m_xyinput.x, m_xyinput.y, widget); } - else if (m_mouse.leftDrag) + else if (m_xyinput.leftDrag) { // The left button is still being held down @@ -809,16 +812,16 @@ bool CWidgetControl::pollMouseEvents(CNxWidget *widget) { // Handle a mouse drag event - m_clickedWidget->drag(m_mouse.x, m_mouse.y, - m_mouse.x - m_mouse.lastX, - m_mouse.y - m_mouse.lastY); + m_clickedWidget->drag(m_xyinput.x, m_xyinput.y, + m_xyinput.x - m_xyinput.lastX, + m_xyinput.y - m_xyinput.lastY); } } else if (m_clickedWidget != (CNxWidget *)NULL) { // Mouse left button release event - m_clickedWidget->release(m_mouse.x, m_mouse.y); + m_clickedWidget->release(m_xyinput.x, m_xyinput.y); } else { @@ -833,9 +836,12 @@ bool CWidgetControl::pollMouseEvents(CNxWidget *widget) // Save the mouse position for the next poll - m_mouse.lastX = m_mouse.x; - m_mouse.lastY = m_mouse.y; + m_xyinput.lastX = m_xyinput.x; + m_xyinput.lastY = m_xyinput.y; return mouseEvent; +#else + return false; +#endif } /** @@ -940,23 +946,25 @@ void CWidgetControl::takeBoundsSem(void) * Clear all mouse events */ +#ifdef CONFIG_NX_XYINPUT void CWidgetControl::clearMouseEvents(void) { // Clear all press and release events once they have been processed - m_mouse.leftPressed = 0; - m_mouse.leftReleased = 0; - m_mouse.leftDrag = 0; + m_xyinput.leftPressed = 0; + m_xyinput.leftReleased = 0; + m_xyinput.leftDrag = 0; #if 0 // Center and right buttons are not used - m_mouse.centerPressed = 0; - m_mouse.centerReleased = 0; - m_mouse.centerDrag = 0; + m_xyinput.centerPressed = 0; + m_xyinput.centerReleased = 0; + m_xyinput.centerDrag = 0; - m_mouse.rightPressed = 0; - m_mouse.rightReleased = 0; - m_mouse.rightDrag = 0; + m_xyinput.rightPressed = 0; + m_xyinput.rightReleased = 0; + m_xyinput.rightDrag = 0; #endif - m_mouse.doubleClick = 0; + m_xyinput.doubleClick = 0; } +#endif -- cgit v1.2.3