ewowi / StarBase

Try things out
GNU General Public License v3.0
6 stars 7 forks source link

UserModExample - examples for config/ui #50

Open netmindz opened 2 months ago

netmindz commented 2 months ago

The UserModExample should show how you display a module in the UI that allows you to request values to be saved to the model/config

netmindz commented 1 month ago

We also need a nicer syntax for setting a label of the input than all this

ui->initPassword(parentVar, "pw", "", 32, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
    case f_UIFun:
      ui->setLabel(var, "Password");
      return true;
    default: return false;
  }});
ewoudwijma commented 1 month ago

Agree this is a lot of code overhead. The reason uiFun was added that storing this in the model json will create a very big model and it is only descriptive. So the ui now asks for this by triggering uiFun. so open for better ideas. It is less worse if also other triggers are implemented here (changeFun etc), because it uses the same setup.

note that this whole structure is a way to implement class like functionality. Alternatively each initNumber etc is a (singleton) class with methods like fx.uiFun or fx.changeFun implemented . I did not do that because we have a lot of classes / instances in that case, but maybe reconsider this …