Added gwinListEnableRender()

This commit is contained in:
Joel Bodenmann 2014-04-26 03:27:19 +02:00
parent af3dae4f42
commit 8b4ca72036
4 changed files with 39 additions and 8 deletions

View File

@ -52,10 +52,6 @@ static void createWidgets(void) {
wi.text = "List 2: Smooth scrolling";
ghLabel1 = gwinLabelCreate(NULL, &wi);
// Make list widgets invisible by default as they would issue
// a re-render at every time an item is added
wi.g.show = FALSE;
// The first list widget
wi.g.width = 150;
wi.g.height = 100;
@ -112,6 +108,9 @@ int main(void) {
gwinListAddItem(ghList1, "Item 13", FALSE);
// Add some items to the second list widget
// This time we will disable the render until
// all the items have been added
gwinListEnableRender(ghList2, FALSE);
gwinListAddItem(ghList2, "Item 0", FALSE);
gwinListAddItem(ghList2, "Item 1", FALSE);
gwinListAddItem(ghList2, "Item 2", FALSE);
@ -126,10 +125,7 @@ int main(void) {
gwinListAddItem(ghList2, "Item 11", FALSE);
gwinListAddItem(ghList2, "Item 12", FALSE);
gwinListAddItem(ghList2, "Item 13", FALSE);
// Make all the lists visible
gwinSetVisible(ghList1, TRUE);
gwinSetVisible(ghList2, TRUE);
gwinListEnableRender(ghList2, TRUE);
while(1) {
// Get an Event

View File

@ -23,6 +23,7 @@ FEATURE: Added LGDP4532 driver by user shilow
FEATURE: Support for ChibiOS/RT 3.x
FEATURE: Added gwinProgressbarStop() and gwinProgressbarReset()
FEATURE: Added generic ILI93xx driver by xlh1460
FEATURE: Added gwinListEnableRender()
*** changes after 1.9 ***

View File

@ -41,6 +41,7 @@
#define GLIST_FLG_HASIMAGES (GWIN_FIRST_CONTROL_FLAG << 1)
#define GLIST_FLG_SCROLLALWAYS (GWIN_FIRST_CONTROL_FLAG << 2)
#define GLIST_FLG_SCROLLSMOOTH (GWIN_FIRST_CONTROL_FLAG << 3)
#define GLIST_FLG_ENABLERENDER (GWIN_FIRST_CONTROL_FLAG << 4)
// Flags on a ListItem.
#define GLIST_FLG_SELECTED 0x0001
@ -92,6 +93,11 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
coord_t sy;
#endif
// dont render if render has been disabled
if (!(gw->g.flags & GLIST_FLG_ENABLERENDER)) {
return;
}
ps = (gw->g.flags & GWIN_FLG_ENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled;
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
x = 1;
@ -401,12 +407,26 @@ GHandle gwinGListCreate(GDisplay *g, GListObject* gobj, GWidgetInit* pInit, bool
if (multiselect)
gobj->w.g.flags |= GLIST_FLG_MULTISELECT;
gobj->w.g.flags |= GLIST_FLG_SCROLLALWAYS;
gobj->w.g.flags |= GLIST_FLG_ENABLERENDER;
gwinSetVisible(&gobj->w.g, pInit->g.show);
return (GHandle)gobj;
}
void gwinListEnableRender(GHandle gh, bool_t ena) {
// is it a valid handle?
if (gh->vmt != (gwinVMT *)&listVMT)
return;
if (ena) {
gh->flags |= GLIST_FLG_ENABLERENDER;
gwinRedraw(gh);
} else {
gh->flags &=~ GLIST_FLG_ENABLERENDER;
}
}
void gwinListSetScroll(GHandle gh, scroll_t flag) {
// is it a valid handle?
if (gh->vmt != (gwinVMT *)&listVMT)

View File

@ -102,6 +102,20 @@ extern "C" {
GHandle gwinGListCreate(GDisplay *g, GListObject *widget, GWidgetInit *pInit, bool_t multiselect);
#define gwinListCreate(w, pInit, m) gwinGListCreate(GDISP, w, pInit, m)
/**
* @brief Enable or disable the rendering of the list
*
* @details Usually the list is being re-rendered when an item is added to the list. This can cause
* flickering and performance issues when many items are added at once. This can be prevented
* by temporarely disabling the render using this function.
*
* @param[in] gh The widget handle (must be a list handle)
* @param[in] ena TRUE or FALSE
*
* @api
*/
void gwinListEnableRender(GHandle gh, bool_t ena);
/**
* @brief Change the behaviour of the scroll bar
*