1111f691c6
Co-authored-by: n.fedorov <mail@nfedorov.dev> Co-committed-by: n.fedorov <mail@nfedorov.dev>
57 lines
1.7 KiB
C++
57 lines
1.7 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
|