From 57eeb16aba2613c1329eafbf7d7453cd67f2cc69 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 25 Jul 2013 19:15:51 +0200 Subject: list widget - work in progress --- include/gos/linux.h | 1 + include/gwin/list.h | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/gos/linux.h b/include/gos/linux.h index 7529a962..508b2b68 100644 --- a/include/gos/linux.h +++ b/include/gos/linux.h @@ -16,6 +16,7 @@ #if GFX_USE_OS_LINUX #include +#include #include #include diff --git a/include/gwin/list.h b/include/gwin/list.h index 0b525b03..46e32d5c 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -37,13 +37,16 @@ * @brief A list event */ typedef struct GEventGWinList { - GEventType type; // The type of this event (GEVENT_GWIN_LIST) - GHandle list; // THe list that has generated the event + GEventType type; // The type of this event (GEVENT_GWIN_LIST) + GHandle list; // The list + int item; // The item that has been selected (or unselected in a multi-select listbox) } GEventGWinList; // A list window typedef struct GListObject { GWidgetObject w; + int cnt; // Number of items currently in the list (quicker than counting each time) + gfxQueueASync list_head; // The list of items } GListObject; #ifdef __cplusplus @@ -52,6 +55,8 @@ extern "C" { GHandle gwinListCreate(GListObject *widget, GWidgetInit *pInit); +int gwinListAddItem(GHandle gh, const char* item, bool_t useAlloc); + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 1fbbc4d52bed0b8e4f3289bc008b3f0928a6b24f Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 27 Jul 2013 22:25:20 +1000 Subject: Integrate changes from master branch --- include/gos/osx.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/gos/osx.h b/include/gos/osx.h index 2ba1c45d..3f36aaff 100644 --- a/include/gos/osx.h +++ b/include/gos/osx.h @@ -48,7 +48,6 @@ typedef pthread_mutex_t gfxMutex; #define gfxSemSignalI(psem) gfxSemSignal(psem) #define gfxSemCounterI(pSem) ((pSem)->cnt) -#define TRUE 1 #define TIME_IMMEDIATE 0 #define TIME_INFINITE ((delaytime_t)-1) #define MAX_SEMAPHORE_COUNT ((semcount_t)-1) -- cgit v1.2.3 From 40611e264d9fc8b05db05ec4dc410e919af7f98d Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 27 Jul 2013 22:55:32 +0200 Subject: some more list work --- include/gwin/list.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include') diff --git a/include/gwin/list.h b/include/gwin/list.h index 46e32d5c..307226c9 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -57,6 +57,24 @@ GHandle gwinListCreate(GListObject *widget, GWidgetInit *pInit); int gwinListAddItem(GHandle gh, const char* item, bool_t useAlloc); +char* gwinListItemGetText(GHandle gh, int item); + +int gwinListFindText(GHandle gh, const char* text); + +void gwinListItemSetParam(GHandle gh, int item, uint16_t param); + +uint16_t gwinListItemGetParam(GHandle gh, int item); + +void nListDeleteAll(GHandle gh); + +void gwinListItemDelete(GHandle gh, int item); + +int gwinListItemCount(GHandle gh); + +bool_t gwinListItemIsSelected(GHandle gh, int item); + +int gwinListGetSelected(GHandle gh); + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 4e3eacb9f762addc6049e28d39516724ef1beef8 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 28 Jul 2013 03:31:45 +0200 Subject: list widget doxygen --- include/gwin/list.h | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gwin/list.h b/include/gwin/list.h index 307226c9..7355623f 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -53,26 +53,146 @@ typedef struct GListObject { extern "C" { #endif +/** + * @brief Create a list widget + * + * @note The drawing color and the background color get set to the current defaults. If you haven't called + * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are Black and White. + * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then + * there is no default font and text drawing operations will not display anything. + * @note A list remembers its normal drawing state. If there is a window manager then it is automatically + * redrawn if the window is moved or its visibility state is changed. + * @note The list contains no elements after creation. + * @note A slider supports mouse, toggle and dial input. + * @note When assigning a toggle, only one toggle is supported per role. If you try to assign more than + * one toggle to a role, it will forget the previous toggle. Three roles are supported: + * Role 0 = toggle for down, role 1 = toggle for up, role 2 = toggle for select. + * @note When assigning a dial, only one dial is supported. If you try to assign more than one dial, it + * will forget the previous dial. Only dial role 0 is supported. + * + * @param[in] widget The GListObject structure to initialize. If this is NULL, the structure is dynamically allocated. + * @param[in] pInit The initialization parameters to use + * + * @return NULL if there is no resulting drawing area, otherwise a window handle. + * + * @api + */ GHandle gwinListCreate(GListObject *widget, GWidgetInit *pInit); +/** + * @brief Add an item to the list + * + * @note The ID you get returned is not static. If items get removed from the list, the list items get + * reordered. + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] item The string which shall be displayed in the list afterwards + * @param[in] useAlloc If set to TRUE, the string will be dynamically allocated. A static buffer must be passed otherwise + * + * @return The current ID of the item. The ID might change if you remove items from the middle of the list + * + * @api + */ int gwinListAddItem(GHandle gh, const char* item, bool_t useAlloc); +/** + * @brief Get the name behind an item with a given ID + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] item The item ID + * + * @return The string of the list item or NULL on error + * + * @api + */ char* gwinListItemGetText(GHandle gh, int item); +/** + * @brief Get the ID of an item with a given name + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] text The item name + * + * @return The id of the list item or -1 on error + * + * @api + */ int gwinListFindText(GHandle gh, const char* text); +/** + * @brief Set the custom parameter of an item with a given ID + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] item The item ID + * @param[in] param The parameter to be set + * + * @api + */ void gwinListItemSetParam(GHandle gh, int item, uint16_t param); +/** + * @brief Get the custom parameter of an item with a given ID + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] item The item ID + * + * @return The parameter + * + * @api + */ uint16_t gwinListItemGetParam(GHandle gh, int item); -void nListDeleteAll(GHandle gh); +/** + * @brief Delete all the items of the list + * + * @param[in] gh The widget handle (must be a list handle) + * + * @api + */ +void ListDeleteAll(GHandle gh); +/** + * @brief Delete an item from the list + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] item The item ID + * + * @api + */ void gwinListItemDelete(GHandle gh, int item); +/** + * @brief Get the amount of items within the list + * + * @param[in] gh The widget handle (must be a list handle) + * + * @return The amount of items in the list + * + * @api + */ int gwinListItemCount(GHandle gh); +/** + * @brief Check if an item with a given ID is selected + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] item The item ID + * + * @return TRUE if the item is selected, FALSE otherwise + * + * @api + */ bool_t gwinListItemIsSelected(GHandle gh, int item); +/** + * @brief Get the ID of the selected item + * + * @param[in] gh The widget handle (must be a list handle) + * + * @return The ID of the list item + * + * @api + */ int gwinListGetSelected(GHandle gh); #ifdef __cplusplus -- cgit v1.2.3 From 423c28b40e0849838615e575630d8e251f04739b Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 28 Jul 2013 07:04:04 +0200 Subject: cleanup --- include/gwin/list.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/gwin/list.h b/include/gwin/list.h index 7355623f..ba83f24b 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -65,8 +65,8 @@ extern "C" { * @note The list contains no elements after creation. * @note A slider supports mouse, toggle and dial input. * @note When assigning a toggle, only one toggle is supported per role. If you try to assign more than - * one toggle to a role, it will forget the previous toggle. Three roles are supported: - * Role 0 = toggle for down, role 1 = toggle for up, role 2 = toggle for select. + * one toggle to a role, it will forget the previous toggle. Two roles are supported: + * Role 0 = toggle for down, role 1 = toggle for up * @note When assigning a dial, only one dial is supported. If you try to assign more than one dial, it * will forget the previous dial. Only dial role 0 is supported. * -- cgit v1.2.3 From 31f355460248b2d39969590feefc9482e53c451f Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 28 Jul 2013 23:18:59 +0200 Subject: list update --- include/gwin/list.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/gwin/list.h b/include/gwin/list.h index ba83f24b..d28206d9 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -45,6 +45,12 @@ typedef struct GEventGWinList { // A list window typedef struct GListObject { GWidgetObject w; + + #if GINPUT_NEED_TOGGLE + uint16_t t_up; + uint16_t t_dn; + #endif + int cnt; // Number of items currently in the list (quicker than counting each time) gfxQueueASync list_head; // The list of items } GListObject; -- cgit v1.2.3 From 9d2b0b667b9bfb2d8b6969ade0ff0bd8d646d7d7 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 1 Aug 2013 14:52:28 +1000 Subject: Add color blending to GDISP --- include/gdisp/gdisp.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h index ac741d3b..ca1844fd 100644 --- a/include/gdisp/gdisp.h +++ b/include/gdisp/gdisp.h @@ -800,6 +800,19 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); void gdispFillRoundedBox(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color); #endif + +/** + * @brief Blend 2 colors according to the alpha + * @return The combined color + * + * @param[in] fg The foreground color + * @param[in] bg The background color + * @param[in] alpha The alpha value (0-255). 0 is all background, 255 is all foreground. + * + * @api + */ +color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha); + /* Support routine for packed pixel formats */ #if !defined(gdispPackPixels) || defined(__DOXYGEN__) /** -- cgit v1.2.3 From 58b52600138435073803de6844b4adb48b501307 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 1 Aug 2013 14:53:13 +1000 Subject: Update some GQUEUE prototypes --- include/gqueue/gqueue.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/gqueue/gqueue.h b/include/gqueue/gqueue.h index 44a42247..b590846c 100644 --- a/include/gqueue/gqueue.h +++ b/include/gqueue/gqueue.h @@ -206,9 +206,9 @@ bool_t gfxQueueFSyncIsEmpty(gfxQueueFSync *pqueue); * @api * @{ */ -bool_t gfxQueueASyncIsIn(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem); -bool_t gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem); -bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem); +bool_t gfxQueueASyncIsIn(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem); +bool_t gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem); +bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem); /* @} */ /** -- cgit v1.2.3 From b0b35396395c3eadc5a656df995a17b266c4b374 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 1 Aug 2013 14:54:25 +1000 Subject: Update GWIN list. Now supports item and page scrolling. A few bugs fixed. --- include/gwin/list.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gwin/list.h b/include/gwin/list.h index d28206d9..99f5f532 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -52,6 +52,7 @@ typedef struct GListObject { #endif int cnt; // Number of items currently in the list (quicker than counting each time) + int top; // The element at the top of the visible list area gfxQueueASync list_head; // The list of items } GListObject; @@ -111,7 +112,7 @@ int gwinListAddItem(GHandle gh, const char* item, bool_t useAlloc); * * @api */ -char* gwinListItemGetText(GHandle gh, int item); +const char* gwinListItemGetText(GHandle gh, int item); /** * @brief Get the ID of an item with a given name -- cgit v1.2.3