Image support
This commit is contained in:
BIN
example/dingus.png
Normal file
BIN
example/dingus.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 514 KiB |
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user