Adding gwinSetFocus() and gwinGetFocus()
This commit is contained in:
parent
37a088efb7
commit
3ba3be201c
@ -9,6 +9,8 @@ FEATURE: Added GFXSINGLEMAKE=yes|no to the ugfx makefile to compile ugfx as a si
|
||||
FEATURE: New board STM32F746G-Discovery
|
||||
FEATURE: New gdisp driver STM32LTDC
|
||||
FEATURE: Better support for Raw32 platforms
|
||||
FEATURE: Implementing widget focusing. See gwinSetFocus() and gwinGetFocus()
|
||||
|
||||
|
||||
*** Release 2.3 ***
|
||||
FEATURE: Added more events to the slider widget
|
||||
|
@ -547,6 +547,31 @@ extern "C" {
|
||||
*/
|
||||
GHandle gwinGetNextWindow(GHandle gh);
|
||||
|
||||
/**
|
||||
* @brief Set the focus to a specific widget
|
||||
*
|
||||
* @details The widget that is currently in focus is the widget that
|
||||
* receives mouse and keyboard events.
|
||||
* Passing NULL will remove the focus from any widget.
|
||||
*
|
||||
* @param[in] gh The widget handle. Non-widget handles will be ignored.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gwinSetFocus(GHandle gh);
|
||||
|
||||
/**
|
||||
* @brief Get the widget that is currently in focus
|
||||
*
|
||||
* @details The widget that is currently in focus is the widget that
|
||||
* receives mouse and keyboard events.
|
||||
*
|
||||
* @return The handle of the widget that is currently in focus. May be NULL.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
GHandle gwinGetFocus(void);
|
||||
|
||||
/**
|
||||
* @brief Set a window or widget to flash
|
||||
*
|
||||
|
@ -162,7 +162,7 @@
|
||||
extern const GWindowManager GNullWindowManager;
|
||||
GWindowManager * _GWINwm;
|
||||
bool_t _gwinFlashState;
|
||||
|
||||
static GHandle _widgetInFocus;
|
||||
static gfxSem gwinsem;
|
||||
static gfxQueueASync _GWINList;
|
||||
#if GWIN_NEED_FLASHING
|
||||
@ -184,6 +184,8 @@ static volatile uint8_t RedrawPending;
|
||||
|
||||
void _gwmInit(void)
|
||||
{
|
||||
_widgetInFocus = 0;
|
||||
|
||||
gfxSemInit(&gwinsem, 1, 1);
|
||||
gfxQueueASyncInit(&_GWINList);
|
||||
#if GWIN_NEED_FLASHING
|
||||
@ -571,6 +573,25 @@ GHandle gwinGetNextWindow(GHandle gh) {
|
||||
return gh ? (GHandle)gfxQueueASyncNext(&gh->wmq) : (GHandle)gfxQueueASyncPeek(&_GWINList);
|
||||
}
|
||||
|
||||
void gwinSetFocus(GHandle gh) {
|
||||
// Passing NULL removes the focus from any widget
|
||||
if (gh == 0) {
|
||||
_widgetInFocus = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Only accept widgets
|
||||
if (!gwinIsWidget(gh)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_widgetInFocus = gh;
|
||||
}
|
||||
|
||||
GHandle gwinGetFocus(void) {
|
||||
return _widgetInFocus;
|
||||
}
|
||||
|
||||
#if GWIN_NEED_FLASHING
|
||||
static void FlashTimerFn(void *param) {
|
||||
GHandle gh;
|
||||
|
Loading…
Reference in New Issue
Block a user