Added gwinListEnableRender()
This commit is contained in:
parent
af3dae4f42
commit
8b4ca72036
4 changed files with 39 additions and 8 deletions
|
@ -52,10 +52,6 @@ static void createWidgets(void) {
|
||||||
wi.text = "List 2: Smooth scrolling";
|
wi.text = "List 2: Smooth scrolling";
|
||||||
ghLabel1 = gwinLabelCreate(NULL, &wi);
|
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
|
// The first list widget
|
||||||
wi.g.width = 150;
|
wi.g.width = 150;
|
||||||
wi.g.height = 100;
|
wi.g.height = 100;
|
||||||
|
@ -112,6 +108,9 @@ int main(void) {
|
||||||
gwinListAddItem(ghList1, "Item 13", FALSE);
|
gwinListAddItem(ghList1, "Item 13", FALSE);
|
||||||
|
|
||||||
// Add some items to the second list widget
|
// 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 0", FALSE);
|
||||||
gwinListAddItem(ghList2, "Item 1", FALSE);
|
gwinListAddItem(ghList2, "Item 1", FALSE);
|
||||||
gwinListAddItem(ghList2, "Item 2", FALSE);
|
gwinListAddItem(ghList2, "Item 2", FALSE);
|
||||||
|
@ -126,10 +125,7 @@ int main(void) {
|
||||||
gwinListAddItem(ghList2, "Item 11", FALSE);
|
gwinListAddItem(ghList2, "Item 11", FALSE);
|
||||||
gwinListAddItem(ghList2, "Item 12", FALSE);
|
gwinListAddItem(ghList2, "Item 12", FALSE);
|
||||||
gwinListAddItem(ghList2, "Item 13", FALSE);
|
gwinListAddItem(ghList2, "Item 13", FALSE);
|
||||||
|
gwinListEnableRender(ghList2, TRUE);
|
||||||
// Make all the lists visible
|
|
||||||
gwinSetVisible(ghList1, TRUE);
|
|
||||||
gwinSetVisible(ghList2, TRUE);
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
// Get an Event
|
// Get an Event
|
||||||
|
|
|
@ -23,6 +23,7 @@ FEATURE: Added LGDP4532 driver by user shilow
|
||||||
FEATURE: Support for ChibiOS/RT 3.x
|
FEATURE: Support for ChibiOS/RT 3.x
|
||||||
FEATURE: Added gwinProgressbarStop() and gwinProgressbarReset()
|
FEATURE: Added gwinProgressbarStop() and gwinProgressbarReset()
|
||||||
FEATURE: Added generic ILI93xx driver by xlh1460
|
FEATURE: Added generic ILI93xx driver by xlh1460
|
||||||
|
FEATURE: Added gwinListEnableRender()
|
||||||
|
|
||||||
|
|
||||||
*** changes after 1.9 ***
|
*** changes after 1.9 ***
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#define GLIST_FLG_HASIMAGES (GWIN_FIRST_CONTROL_FLAG << 1)
|
#define GLIST_FLG_HASIMAGES (GWIN_FIRST_CONTROL_FLAG << 1)
|
||||||
#define GLIST_FLG_SCROLLALWAYS (GWIN_FIRST_CONTROL_FLAG << 2)
|
#define GLIST_FLG_SCROLLALWAYS (GWIN_FIRST_CONTROL_FLAG << 2)
|
||||||
#define GLIST_FLG_SCROLLSMOOTH (GWIN_FIRST_CONTROL_FLAG << 3)
|
#define GLIST_FLG_SCROLLSMOOTH (GWIN_FIRST_CONTROL_FLAG << 3)
|
||||||
|
#define GLIST_FLG_ENABLERENDER (GWIN_FIRST_CONTROL_FLAG << 4)
|
||||||
|
|
||||||
// Flags on a ListItem.
|
// Flags on a ListItem.
|
||||||
#define GLIST_FLG_SELECTED 0x0001
|
#define GLIST_FLG_SELECTED 0x0001
|
||||||
|
@ -92,6 +93,11 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
|
||||||
coord_t sy;
|
coord_t sy;
|
||||||
#endif
|
#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;
|
ps = (gw->g.flags & GWIN_FLG_ENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled;
|
||||||
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
|
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
|
||||||
x = 1;
|
x = 1;
|
||||||
|
@ -401,12 +407,26 @@ GHandle gwinGListCreate(GDisplay *g, GListObject* gobj, GWidgetInit* pInit, bool
|
||||||
if (multiselect)
|
if (multiselect)
|
||||||
gobj->w.g.flags |= GLIST_FLG_MULTISELECT;
|
gobj->w.g.flags |= GLIST_FLG_MULTISELECT;
|
||||||
gobj->w.g.flags |= GLIST_FLG_SCROLLALWAYS;
|
gobj->w.g.flags |= GLIST_FLG_SCROLLALWAYS;
|
||||||
|
gobj->w.g.flags |= GLIST_FLG_ENABLERENDER;
|
||||||
|
|
||||||
gwinSetVisible(&gobj->w.g, pInit->g.show);
|
gwinSetVisible(&gobj->w.g, pInit->g.show);
|
||||||
|
|
||||||
return (GHandle)gobj;
|
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) {
|
void gwinListSetScroll(GHandle gh, scroll_t flag) {
|
||||||
// is it a valid handle?
|
// is it a valid handle?
|
||||||
if (gh->vmt != (gwinVMT *)&listVMT)
|
if (gh->vmt != (gwinVMT *)&listVMT)
|
||||||
|
|
|
@ -102,6 +102,20 @@ extern "C" {
|
||||||
GHandle gwinGListCreate(GDisplay *g, GListObject *widget, GWidgetInit *pInit, bool_t multiselect);
|
GHandle gwinGListCreate(GDisplay *g, GListObject *widget, GWidgetInit *pInit, bool_t multiselect);
|
||||||
#define gwinListCreate(w, pInit, m) gwinGListCreate(GDISP, w, pInit, m)
|
#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
|
* @brief Change the behaviour of the scroll bar
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue