Skip to content

Instantly share code, notes, and snippets.

@Tasssadar
Last active March 1, 2020 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tasssadar/e5d5745cb020cb56d32139a52d6f5d41 to your computer and use it in GitHub Desktop.
Save Tasssadar/e5d5745cb020cb56d32139a52d6f5d41 to your computer and use it in GitHub Desktop.
void setup() {
// Na začátku je UI v "builder" módu
UI.button(0, 0, 4, 1, "test")
.color("red")
.background("blue")
.onPress([]() {
printf("pressed!\n");
})
.onRelease([]() {
printf("released!\n");
});
// Každá metoda, až na finish, vrací pořád dokola ten stejný objekt,
// který popisuje jak bude "widget" v UI vypadat.
// finish() vrátí nový objekt, který lze použít k řízení aktuálního stavu widgetu.
// U tlačítka nahoře žádný stav není, nezavolal jsem tam teda finish(), protože
// stavový objekt nepotřebuju. U LEDky chci měnit, jestli svítí, nebo ne.
Led *blue = UI.led(2, 2, 1, 1, "blue")
.finish();
EditText *txt = UI.editText(4, 4, 4, 1, "")
.background("red")
.placeholder("something")
.onChange([](const char *val) {
printf("text: %s\n", val);
})
.finish();
UI.finish();
// Žádné UI. metody už nejde zavolat.
txt->setText("nejaky text");
blue->on();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment