ImpulseAdventure / GUIslice-Builder

Cross-platform drag & drop GUI builder for GUIslice
Other
166 stars 35 forks source link

Doesn't clean code on GuiSlice Builder if you add and remove some controls #152

Closed lbarcella closed 3 years ago

lbarcella commented 3 years ago

Hi, try this...

Put on your screen a text input control or number input control and generate code. Next remove it and generate one more time

In you code generate remain previous instruction and build on CPU fail

Check this function, because remain dirty.

bool CbKeypad(void pvGui, void pvElemRef, int16_t nState, void pvData) { gslc_tsGui pGui = (gslc_tsGui)pvGui; gslc_tsElemRef pElemRef = (gslc_tsElemRef)(pvElemRef); gslc_tsElem pElem = gslc_GetElemFromRef(pGui,pElemRef);

// From the pvData we can get the ID element that is ready. int16_t nTargetElemId = gslc_ElemXKeyPadDataTargetIdGet(pGui, pvData); if (nState == XKEYPAD_CB_STATE_DONE) { // User clicked on Enter to leave popup // - If we have a popup active, pass the return value directly to // the corresponding value field switch (nTargetElemId) { //<Keypad Enums !Start!> //<Keypad Enums !End!> case E_ELEM_TEXTINPUT4: gslc_ElemXKeyPadInputGet(pGui, m_pElemInTxt4, pvData); gslc_PopupHide(&m_gui); break; case E_ELEM_TEXTINPUT5: gslc_ElemXKeyPadInputGet(pGui, m_pElemInTxt5, pvData); gslc_PopupHide(&m_gui); break; case E_ELEM_TEXTINPUT6: gslc_ElemXKeyPadInputGet(pGui, m_pElemInTxt6, pvData); gslc_PopupHide(&m_gui); break; //<Keypad Enums !End!>

Thank you all !

Pconti31 commented 3 years ago

@lbarcella Yes, this is just how the builder is implemented. This is documented in the Builder's User Guide. Only Button callback are currently supported. Fully documented in the Builder's user Guide - Appendix E - Case Statement Generation.

I have been supporting button callback cleanup because: First because Buttons are the most heavily used feature. Second, you can turn features on/off at any time like jump to page or present a popup or rename its enum. Third even doing just this has been a nightmare for support. Most of my bugs come from this callback cleanup.

Note that the button callback cleanup has really only recently worked for version 0.16.b005 and higher. Earlier versions, not so much.

Now all callbacks are inside your .ino file not the header. The header is deleted and re-created each code generation but your .ino file I need to parse so you don't lose code you have added which happens to be really hard to do when you coding in Java without a C++ parser under you. However, it turns out to be really easy for you to hand edit your own code to remove obsolete code.

I'll consider an enhancement for a future version. Anyone in the community that wants to add code to handle this case can make a pull request and I would be happy to accept the contribution.

I'm also sure @ImpulseAdventure will move this request to the Builder's repository since support is easier that way. Paul--

lbarcella commented 3 years ago

Thank you Paolo for your answer. I'm happy to use your library... very good job.

Pconti31 commented 3 years ago

This is working in Release 0.16.b010