Files
NXST/include/nxst/ui/hint_bar.hpp
T
DragonSpirit b2de532bce
CI / Build NRO (push) Failing after 27s
CI / Format check (push) Successful in 11s
CI / Layering check (push) Successful in 1s
finish refactor, add docs and CI
2026-04-27 03:11:25 +03:00

57 lines
1.6 KiB
C++

#pragma once
#include <string>
#include <vector>
#include <pu/Plutonium>
#include <nxst/ui/theme.hpp>
namespace ui {
struct Hint {
std::string glyph;
std::string label;
};
class HintBar {
private:
pu::ui::Layout* parent;
pu::ui::elm::Rectangle::Ref bg;
pu::ui::elm::Rectangle::Ref divider;
std::vector<pu::ui::elm::TextBlock::Ref> labels;
public:
HintBar(pu::ui::Layout* p) : parent(p) {
using namespace theme;
bg = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW, layout::HintH,
color::BgSurface);
divider = pu::ui::elm::Rectangle::New(0, layout::ScreenH - layout::HintH, layout::ScreenW, 1,
color::Divider);
parent->Add(bg);
parent->Add(divider);
}
void SetHints(const std::vector<Hint>& hints) {
using namespace theme;
for (auto& l : labels)
l->SetVisible(false);
labels.clear();
int x = layout::ScreenW - space::lg;
int y = layout::ScreenH - layout::HintH + 18;
for (auto it = hints.rbegin(); it != hints.rend(); ++it) {
std::string text = it->glyph + " " + it->label;
auto tb = pu::ui::elm::TextBlock::New(0, y, text);
tb->SetFont(type::font(type::Label));
tb->SetColor(color::TextSecondary);
int w = tb->GetWidth();
x -= w;
tb->SetX(x);
x -= space::xl;
parent->Add(tb);
labels.push_back(tb);
}
}
};
} // namespace ui