43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
#include <quip.h>
|
|
|
|
int main() {
|
|
bool goingDown = true, goingRight = true;
|
|
Quip::Window window("Quip Window", 800, 600, [&window, &goingDown, &goingRight]() {
|
|
auto* imagewidget = window.getChild("image");
|
|
auto& image = std::get<Quip::Widget::Image>(*imagewidget);
|
|
if (goingDown) {
|
|
image.ypos ++;
|
|
if (image.ypos + image.height > window.height) {
|
|
goingDown = false;
|
|
}
|
|
} else {
|
|
image.ypos --;
|
|
if (image.ypos < 0) {
|
|
goingDown = true;
|
|
}
|
|
}
|
|
if (goingRight) {
|
|
image.xpos ++;
|
|
if (image.xpos + image.width > window.width) {
|
|
goingRight = false;
|
|
}
|
|
} else {
|
|
image.xpos --;
|
|
if (image.xpos < 0) {
|
|
goingRight = true;
|
|
}
|
|
}
|
|
});
|
|
int buttonPresses = 0;
|
|
window.addChild("textLabel", Quip::Widget::TextLabel("Hi there!", 10, 10));
|
|
window.addChild("button", Quip::Widget::Button("Click me!", [&window, &buttonPresses]() {
|
|
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!";
|
|
}
|
|
}, 10, 50));
|
|
window.addChild("image", Quip::Widget::Image("dingus.png", 300, 300, 100, 100));
|
|
return window.run();
|
|
}
|