-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assigning from int16_t to int8_t #380
Comments
Thanks very much for catching this @en-ot . I’ll look at adding a fix to support larger listbox buffers. |
I recommend to add something like this: XListbox.h ...
/// Callback function for Listbox feedback
typedef bool (*GSLC_CB_XLISTBOX_SEL)(void* pvGui,void* pvElem,int16_t nSel);
typedef bool (*GSLC_CB_XLISTBOX_GETITEM)(void* pvGui, void* pvElem, int16_t nItem, char* pStrItem, uint8_t nStrItemLen);
...
// Callbacks
GSLC_CB_XLISTBOX_SEL pfuncXSel; ///< Callback func ptr for selection update
GSLC_CB_XLISTBOX_GETITEM pfuncXGet;
... XListbox.c: ...
gslc_tsXListbox* pListbox = (gslc_tsXListbox*)gslc_GetXDataFromRef(pGui, pElemRef, GSLC_TYPEX_LISTBOX, __LINE__);
if (!pListbox) return false;
if (pListbox->pfuncXGet) {
bool res = (pListbox->pfuncXGet)((void*)(pGui), (void*)(pElemRef), nItemCurSel, pStrItem, nStrItemLen);
return res;
}
// Ensure user provided valid string
if ((pStrItem == NULL) || (nStrItemLen == 0)) {
// ERROR
return false;
}
... I did it for myself, now I can use listbox for listing full microSD filesystem, passing filename strings from callback while rendering listbox. Edit by ImpulseAdventure: Add code formatting |
Thanks — your item callback sounds like a great idea! If you’d like to submit a PR, that would be great. Otherwise I’ll see what I can do this weekend. Thx |
Sorry, I am new to git / github, I cannot into PR yet. And I am not sure about the quality of my code. Maybe later I'll join, but for now I can only tell the idea. |
Thanks @en-ot -- no worries! I'll create the fix for you and check it in. As for the enhancement for the callback, I'll address that in a second update. |
Fixes to support very large row counts have now been added into the main GUIslice branch. |
I updated my project to new version of GuiSlice, and now it works as it should |
Hello!
Describe the bug
When trying to use Listbox with big data (>256 lines), lines stopped to display.
Instead of 274 (0x112) lines I see only first 18(0x12)
There are assignments from 16-bit variables to 8-bit variables with loss of data.
file XListbox.c
lines 624...626
int8_t nItemTop = pListbox->nItemTop;
int8_t nItemCnt = pListbox->nItemCnt;
int8_t nItemInd;
XListbox.h:
int16_t nItemCnt; ///< Number of items in the list
int16_t nItemTop; ///< Item to show at top of list after scrolling (0 is default)
I suspect there are more of similar bugs in other places.
Device hardware
The text was updated successfully, but these errors were encountered: