Browse Source

Added gwinListSetScroll

remotes/origin_old/ugfx_release_2.6
Joel Bodenmann 8 years ago
committed by inmarket
parent
commit
8fce1a6fce
  1. 19
      include/gwin/list.h
  2. 15
      releases.txt
  3. 20
      src/gwin/list.c

19
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
*

15
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

20
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;

Loading…
Cancel
Save