From 8fce1a6fcef51f171d5fd9ed381583507b361210 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 23 Oct 2013 16:26:34 +0200 Subject: [PATCH] Added gwinListSetScroll --- include/gwin/list.h | 19 +++++++++++++++++++ releases.txt | 15 +++++++++++---- src/gwin/list.c | 20 +++++++++++++++++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/include/gwin/list.h b/include/gwin/list.h index 05433e87..cba5b137 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -56,6 +56,13 @@ typedef struct GListObject { gfxQueueASync list_head; // The list of items } GListObject; +/** + * @brief Enum to change the behaviour of the scroll area + * + * @note This might be used with @p gwinListSetScroll() + */ +typedef enum scroll_t { scrollAlways, scrollAuto } scroll_t; + #ifdef __cplusplus extern "C" { #endif @@ -85,6 +92,18 @@ extern "C" { */ GHandle gwinListCreate(GListObject *widget, GWidgetInit *pInit, bool_t multiselect); +/** + * @brief Change the behaviour of the scroll area + * + * @note Current possible values: @p scrollAlways and @p scrollAuto + * + * @param[in] gh The widget handle (must be a list handle) + * @param[in] flag The behaviour to be set + * + * @api + */ +void gwinListSetScroll(GHandle gh, scroll_t flag); + /** * @brief Add an item to the list * diff --git a/releases.txt b/releases.txt index f03e31f4..1b10d295 100644 --- a/releases.txt +++ b/releases.txt @@ -2,7 +2,15 @@ *** Releases *** ***************************************************************************** -current release: 1.8 +current release: 2.0 + +*** changes after 1.9 *** +FEATURE: GDISP Streaming +FEATURE: New driver interface for GDISP +FEATURE: Multiple display support +FEATURE: Multiple controller support +FEATURE: Add gdispFlush() for those controllers that need it +FEATURE: Add GDISP_NEED_AUTOFLUSH to automatically flush when required. *** changes after 1.8 *** FEATURE: GWIN list boxes. @@ -13,9 +21,8 @@ FEATURE: SSD1306 driver by user goeck FEATURE: ST7565 driver by user sam0737 FEATURE: ED060SC4 driver by user jpa- FIX: SSD1289 area filling bug fix by user samofab -FEATURE: GDISP Streaming -FEATURE: New driver interface for GDISP -FEATURE: Multiple display support +FEATURE: Added gwinListGetSelectedText() +FEATURE: Added gwinListSetScroll() *** changes after 1.7 *** FEATURE: Rename of the project from ChibiOS/GFX to uGFX diff --git a/src/gwin/list.c b/src/gwin/list.c index cf0bebc4..fe903c16 100644 --- a/src/gwin/list.c +++ b/src/gwin/list.c @@ -37,6 +37,7 @@ // Flags for the GListObject #define GLIST_FLG_MULTISELECT (GWIN_FIRST_CONTROL_FLAG << 0) #define GLIST_FLG_HASIMAGES (GWIN_FIRST_CONTROL_FLAG << 1) +#define GLIST_FLG_SCROLLALWAYS (GWIN_FIRST_CONTROL_FLAG << 2) // Flags on a ListItem. #define GLIST_FLG_SELECTED 0x0001 @@ -93,7 +94,7 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) { x = 1; // the scroll area - if (gw2obj->cnt > (gw->g.height-2) / iheight) { + if (gw2obj->cnt > (gw->g.height-2) / iheight || gw->g.flags & GLIST_FLG_SCROLLALWAYS) { iwidth = gw->g.width - (SCROLLWIDTH+3); gdispFillArea(gw->g.x+iwidth+2, gw->g.y+1, SCROLLWIDTH, gw->g.height-2, gdispBlendColor(ps->fill, gw->pstyle->background, 128)); gdispDrawLine(gw->g.x+iwidth+1, gw->g.y+1, gw->g.x+iwidth+1, gw->g.y+gw->g.height-2, ps->edge); @@ -327,12 +328,29 @@ GHandle gwinListCreate(GListObject* gobj, GWidgetInit* pInit, bool_t multiselect gobj->top = 0; if (multiselect) gobj->w.g.flags |= GLIST_FLG_MULTISELECT; + gobj->w.g.flags |= GLIST_FLG_SCROLLALWAYS; gwinSetVisible(&gobj->w.g, pInit->g.show); return (GHandle)gobj; } +void gwinListSetScroll(GHandle gh, scroll_t flag) { + // is it a valid handle? + if (gh->vmt != (gwinVMT *)&listVMT) + return 0; + + switch (flag) { + case scrollAlways: + ((GListObject*)gh)->w.g.flags |= GLIST_FLG_SCROLLALWAYS; + break; + + case scrollAuto: + ((GListObject*)gh)->w.g.flags &=~ GLIST_FLG_SCROLLALWAYS; + break; + } +} + int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) { ListItem *newItem;