Skip to content
Repos

mologram

C++ 1.6 KB38 lines Opens in site

Directory Raw Download

#include "mologram/ui/ThemeCatalog.hpp"

namespace mologram::ui {
using ttgui::Color;

std::vector<std::string> ThemeCatalog::names() { return {"default", "night", "contrast"}; }

bool ThemeCatalog::apply(ttgui::Config& cfg, const std::string& name) {
  ttgui::Config base = ttgui::Config::defaults();
  cfg.windowColors = base.windowColors;
  cfg.uiColors = base.uiColors;
  if (name == "default") return true;
  if (name == "night") {
    cfg.windowColors["grey"] = {Color::rgb(220, 220, 220), Color::rgb(40, 42, 54)};
    cfg.windowColors["lightblue"] = {Color::rgb(230, 230, 240), Color::rgb(52, 58, 92)};
    cfg.windowColors["white"] = {Color::rgb(230, 230, 230), Color::rgb(30, 31, 40)};
    cfg.windowColors["green"] = {Color::rgb(255, 255, 255), Color::rgb(30, 90, 60)};
    cfg.uiColors["paper"] = Color::rgb(30, 31, 40);
    cfg.uiColors["paperText"] = Color::rgb(225, 225, 235);
    cfg.uiColors["menuPaper"] = Color::rgb(44, 46, 60);
    cfg.uiColors["selection"] = Color::rgb(90, 100, 180);
    cfg.uiColors["selectionText"] = Color::rgb(255, 255, 255);
    return true;
  }
  if (name == "contrast") {
    cfg.windowColors["grey"] = {Color::rgb(255, 255, 255), Color::rgb(0, 0, 0)};
    cfg.windowColors["lightblue"] = {Color::rgb(0, 0, 0), Color::rgb(255, 255, 0)};
    cfg.windowColors["white"] = {Color::rgb(0, 0, 0), Color::rgb(255, 255, 255)};
    cfg.uiColors["paper"] = Color::rgb(0, 0, 0);
    cfg.uiColors["paperText"] = Color::rgb(255, 255, 255);
    cfg.uiColors["selection"] = Color::rgb(255, 255, 0);
    cfg.uiColors["selectionText"] = Color::rgb(0, 0, 0);
    return true;
  }
  return false;
}

}  // namespace mologram::ui
25.0ms