From 10b448a6bc6b74c244915360cf96fb8d96ea1ad0 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 22 Feb 2023 18:24:45 -0500 Subject: [PATCH] Add light and dark rack rails from Pyer. --- include/app/RailWidget.hpp | 1 + res/ComponentLibrary/Rail-dark.svg | 540 ++++++++++++++++++++++++++ res/ComponentLibrary/Rail-light.svg | 564 ++++++++++++++++++++++++++++ src/app/RailWidget.cpp | 25 +- 4 files changed, 1129 insertions(+), 1 deletion(-) create mode 100644 res/ComponentLibrary/Rail-dark.svg create mode 100644 res/ComponentLibrary/Rail-light.svg diff --git a/include/app/RailWidget.hpp b/include/app/RailWidget.hpp index 7535abcb..05ed7f3f 100644 --- a/include/app/RailWidget.hpp +++ b/include/app/RailWidget.hpp @@ -13,6 +13,7 @@ struct RailWidget : widget::TransparentWidget { RailWidget(); ~RailWidget(); + void step() override; void draw(const DrawArgs& args) override; }; diff --git a/res/ComponentLibrary/Rail-dark.svg b/res/ComponentLibrary/Rail-dark.svg new file mode 100644 index 00000000..f1f87530 --- /dev/null +++ b/res/ComponentLibrary/Rail-dark.svg @@ -0,0 +1,540 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/ComponentLibrary/Rail-light.svg b/res/ComponentLibrary/Rail-light.svg new file mode 100644 index 00000000..4a1f50be --- /dev/null +++ b/res/ComponentLibrary/Rail-light.svg @@ -0,0 +1,564 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/RailWidget.cpp b/src/app/RailWidget.cpp index 93816cf1..cd7711b4 100644 --- a/src/app/RailWidget.cpp +++ b/src/app/RailWidget.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace rack { @@ -26,7 +27,6 @@ RailWidget::RailWidget() { addChild(internal->railFb); internal->railSw = new widget::SvgWidget; - internal->railSw->setSvg(window::Svg::load(asset::system("res/ComponentLibrary/Rail.svg"))); internal->railFb->addChild(internal->railSw); } @@ -36,6 +36,29 @@ RailWidget::~RailWidget() { } +void RailWidget::step() { + // Set rail SVG from theme + std::shared_ptr railSvg; + if (settings::uiTheme == "light") { + railSvg = window::Svg::load(asset::system("res/ComponentLibrary/Rail-light.svg")); + } + else if (settings::uiTheme == "dark") { + railSvg = window::Svg::load(asset::system("res/ComponentLibrary/Rail-dark.svg")); + } + else { + // Default + railSvg = window::Svg::load(asset::system("res/ComponentLibrary/Rail.svg")); + } + + if (internal->railSw->svg != railSvg) { + internal->railSw->setSvg(railSvg); + internal->railFb->setDirty(); + } + + TransparentWidget::step(); +} + + void RailWidget::draw(const DrawArgs& args) { if (!internal->railSw->svg) return;