Got a simple GUI layout working for the most part.

This commit is contained in:
Zed A. Shaw 2024-08-22 17:59:53 -04:00
parent 4520e20ab7
commit a13704fe33
3 changed files with 21 additions and 15 deletions

29
gui.cpp
View file

@ -33,10 +33,10 @@ int GUI::main_loop(GameEngine &game, std::function<bool()> runner) {
auto status = Renderer([&] {
return vbox({
paragraph(fmt::format("HP {}", game.hit_points)),
text(fmt::format("HP {}", game.hit_points)),
separator(),
hbox({
text("HP"),
text("HP "),
gauge(game.hit_points / 100.0f),
}),
});
@ -52,20 +52,33 @@ int GUI::main_loop(GameEngine &game, std::function<bool()> runner) {
return vbox(output);
});
auto scrollable_content = Renderer(content,
auto game_stuff = Renderer([&] {
return vbox({
text("Welcome to...Turing's Tarpit!"),
separator(),
hbox({
text("left") | border | flex ,
text("middle") | border | flex,
text("right") | border | flex,
}) | yflex_grow
});
});
auto build_log = Renderer(content,
[&, content] {
return content->Render()
| focusPositionRelative(scroll_x, scroll_y)
| frame | flex;
});
auto component = Renderer(scrollable_content, [&] {
auto component = Renderer(build_log, [&] {
return vbox({
status->Render(),
game_stuff->Render() | flex,
separator(),
scrollable_content->Render() | vscroll_indicator | yframe | size(HEIGHT, LESS_THAN, 20),
}) |
border;
build_log->Render() | vscroll_indicator | yframe | flex,
separator(),
status->Render()
}) | border;
});
component |= CatchEvent([&](Event) -> bool {