redesign, broadcast server crash fix
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include <pu/Plutonium>
|
||||
#include <Theme.hpp>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user