Repos
C++
836 B29 lines Opens in site
Directory
Raw
Download
#include "mologram/ui/HelpOverlay.hpp"
#include "mologram/ActionRegistry.hpp"
namespace mologram::ui {
using namespace ttgui;
std::vector<std::vector<std::string>> HelpOverlay::rows(const Config& cfg) {
std::vector<std::vector<std::string>> r;
for (const auto& a : ActionRegistry::all()) r.push_back({a.menu, cfg.keyFor(a.id), a.id});
return r;
}
Window* HelpOverlay::open(Application& app, const Config& cfg) {
Window* win = app.wm.createWindow("Keys", "lightblue", {6, 2, 64, 24});
win->appName = "HelpOverlay";
win->modal = true;
auto* t = new Table();
t->cfg = &app.cfg;
t->headers = {"Action", "Key", "Id"};
t->colWidths = {28, 16, 16};
t->rows = rows(cfg);
win->setContent(std::unique_ptr<Widget>(t));
t->bounds = win->contentRect();
app.setFocused(t);
return win;
}
} // namespace mologram::ui