#pragma once #include #include #include #include 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 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& 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); } } }; }