Image support

This commit is contained in:
2025-11-02 17:48:43 +00:00
parent 93ba953738
commit 9aae7b6173
5 changed files with 77 additions and 11 deletions

View File

@@ -1,7 +1,33 @@
#include <quip.h>
int main() {
Quip::Window window("Quip Window", 800, 600);
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]() {
@@ -11,5 +37,6 @@ int main() {
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();
}