Misc changes related to MediaPlayer. Nothing really significant
This commit is contained in:
parent
b1e7a4e4f8
commit
f5626ea605
6
Kconfig
6
Kconfig
@ -1147,6 +1147,12 @@ config NXWM_MEDIAPLAYER_YSPACING
|
||||
forward, and reverse controls, and the volume slider in units of
|
||||
lines.
|
||||
|
||||
config NXWM_MEDIAPLAYER_VOLUMESTEP
|
||||
int "Media Player Volume Step"
|
||||
default 5
|
||||
---help---
|
||||
This increment in volume, up or down, when the volume bar is clicked.
|
||||
|
||||
config NXWM_MEDIAPLAYER_BORDERS
|
||||
bool "Media Player Button Borders"
|
||||
default n
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,8 +76,8 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <cstdint>
|
||||
#include <cstdbool>
|
||||
|
||||
#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_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.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;
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -39,10 +39,10 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <cstdint>
|
||||
#include <cstdbool>
|
||||
#include <cstring>
|
||||
#include <sched.h>
|
||||
#include <csched>
|
||||
#include <cerrno>
|
||||
|
||||
#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
|
||||
|
@ -644,6 +644,10 @@
|
||||
# define CONFIG_NXWM_MEDIAPLAYER_YSPACING 8
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_MEDIAPLAYER_VOLUMESTEP
|
||||
# define CONFIG_NXWM_MEDIAPLAYER_VOLUMESTEP 5
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NXWM_MEDIAPLAYER_ICON
|
||||
# define CONFIG_NXWM_MEDIAPLAYER_ICON NxWM::g_mediaplayerBitmap
|
||||
#endif
|
||||
|
@ -720,6 +720,7 @@ bool CMediaPlayer::createPlayer(void)
|
||||
m_volume->setMinimumValue(0);
|
||||
m_volume->setMaximumValue(100);
|
||||
m_volume->setValue(15);
|
||||
m_volume->setPageSize(CONFIG_NXWM_MEDIAPLAYER_VOLUMESTEP);
|
||||
|
||||
// Register to get events from the value changes in the volume slider
|
||||
|
||||
@ -1014,12 +1015,19 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
|
||||
|
||||
void CMediaPlayer::setVolumeLevel(void)
|
||||
{
|
||||
// Current volume level values. This is already pre-scaled in the range 0-100
|
||||
// Get the current volume level value. This is already pre-scaled in the
|
||||
// range 0-100
|
||||
|
||||
m_level = m_volume->getValue();
|
||||
int newLevel = m_volume->getValue();
|
||||
|
||||
// Now, provide the new volume setting to the NX Player
|
||||
// Has the volume level changed?
|
||||
|
||||
if (m_level != newLevel)
|
||||
{
|
||||
// Yes.. provide the new volume setting to the NX Player
|
||||
#warning Missing logic
|
||||
m_level = newLevel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -447,7 +447,7 @@ void CTouchscreen::handleMouseInput(struct touch_sample_s *sample)
|
||||
// Was the button up or down?
|
||||
|
||||
uint8_t buttons;
|
||||
if ((sample->point[0].flags & (TOUCH_DOWN|TOUCH_MOVE)) != 0)
|
||||
if ((sample->point[0].flags & (TOUCH_DOWN | TOUCH_MOVE)) != 0)
|
||||
{
|
||||
buttons = NX_MOUSE_LEFTBUTTON;
|
||||
}
|
||||
|
@ -122,7 +122,6 @@ void CWindowMessenger::handleMouseEvent(void)
|
||||
|
||||
work_state_t *state = new work_state_t;
|
||||
state->windowMessenger = this;
|
||||
|
||||
int ret = work_queue(USRWORK, &state->work, &inputWorkCallback, state, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user