TriZet Posted April 29, 2015 Report Posted April 29, 2015 Hi again! I do some device and I was needed functions for select/deselect item. And for scroll to the item in List.I don't find how it can be do in uGFX. If it can be please say how )) But for now I added this functions.Maybe some people this functions can help too. Or maybe you add them to uGFX to improve functionality. //===============================================================// item - is item to modify// param - TRUE to select, FALSE to deselect//void gwinListSetSelected(GHandle gh, int item, bool_t param) { const gfxQueueASyncItem * qi; int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return; // watch out for an invalid item if (item < 0 || item > (gh2obj->cnt) - 1) return; // If not a multiselect mode - clear previous selected item if (!(gh->flags & GLIST_FLG_MULTISELECT)) { for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { if (qi2li->flags & GLIST_FLG_SELECTED) { qi2li->flags &= ~GLIST_FLG_SELECTED; break; // or without break to deselect all } } } // Find item and set selected or not for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { if (i == item) { if(param == TRUE )qi2li->flags |= GLIST_FLG_SELECTED; else qi2li->flags &= ~GLIST_FLG_SELECTED; break; } } _gwinUpdate(gh);}//===============================================================// item - scrool to himvoid gwinListScroollToItem(GHandle gh, int item) { int iheight, oldtop; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return; // watch out for an invalid item if (item < 0 || item > (gh2obj->cnt) - 1) return; iheight = gdispGetFontMetric(gh->font, fontHeight) + VERTICAL_PADDING; gh2obj->top = iheight * item; if (gh2obj->top >= gh2obj->cnt * iheight - (gh->height-2)) gh2obj->top = gh2obj->cnt * iheight - (gh->height-2) - 1; if (gh2obj->top < 0) gh2obj->top = 0; _gwinUpdate(gh);}//===============================================================
inmarket Posted April 30, 2015 Report Posted April 30, 2015 That will make a very worthwhile addition to the list. I will integrate it into the master.
TriZet Posted April 30, 2015 Author Report Posted April 30, 2015 Great! If I get new ideas, I will write them on the forum.Happy to help improve the uGFX
inmarket Posted April 30, 2015 Report Posted April 30, 2015 Now added to the repository (but altered slightly)
Joel Bodenmann Posted May 2, 2015 Report Posted May 2, 2015 Wow, nice job! Keep up the good work!~ Tectu
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now