Last active
March 1, 2020 17:16
-
-
Save Tasssadar/e5d5745cb020cb56d32139a52d6f5d41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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