Files
quip/example/example.cpp

18 lines
804 B
C++
Raw Normal View History

2025-11-01 15:54:37 +00:00
#include <quip.h>
int main() {
int buttonPresses = 0;
2025-11-08 12:27:38 +00:00
Quip::Window window("Quip Window", 800, 600);
Quip::Font font("/usr/share/fonts/noto/NotoSans-Regular.ttf", 16);
window.addChild("image", Quip::Widget::Image("dingus.png", 100, 100));
window.addChild("textLabel", Quip::Widget::TextLabel("Hi there!", font));
window.addChild("button", Quip::Widget::Button(Quip::Widget::TextLabel("Click me!", font), [&window, &buttonPresses] {
2025-11-01 15:54:37 +00:00
auto* widget = window.getChild("textLabel");
if (widget && std::holds_alternative<Quip::Widget::TextLabel>(*widget)) {
buttonPresses++;
std::get<Quip::Widget::TextLabel>(*widget).text = "You have clicked the button " + std::to_string(buttonPresses) + " times!";
}
2025-11-08 12:27:38 +00:00
}));
2025-11-01 15:54:37 +00:00
return window.run();
}