Browse Source

Add two-color theme to Rack

tags/v0.6.0
Andrew Belt 6 years ago
parent
commit
7178b836d5
4 changed files with 50 additions and 10 deletions
  1. +3
    -3
      include/util/color.hpp
  2. +1
    -0
      include/window.hpp
  3. +1
    -1
      src/app/RackScene.cpp
  4. +45
    -6
      src/window.cpp

+ 3
- 3
include/util/color.hpp View File

@@ -15,19 +15,19 @@ inline NVGcolor colorClip(NVGcolor a) {
}

inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) {
for (int i = 0; i < 4; i++)
for (int i = 0; i < 3; i++)
a.rgba[i] -= b.rgba[i];
return a;
}

inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) {
for (int i = 0; i < 4; i++)
for (int i = 0; i < 3; i++)
a.rgba[i] += b.rgba[i];
return a;
}

inline NVGcolor colorMult(NVGcolor a, float x) {
for (int i = 0; i < 4; i++)
for (int i = 0; i < 3; i++)
a.rgba[i] *= x;
return a;
}


+ 1
- 0
include/window.hpp View File

@@ -43,6 +43,7 @@ void windowSetWindowSize(Vec size);
Vec windowGetWindowPos();
void windowSetWindowPos(Vec pos);
bool windowIsMaximized();
void windowSetTheme(NVGcolor bg, NVGcolor fg);


} // namespace rack

+ 1
- 1
src/app/RackScene.cpp View File

@@ -71,7 +71,7 @@ void RackScene::step() {

// Version popup message
if (!newVersion.empty()) {
std::string versionMessage = stringf("Rack v%s is available.\n\nYou have Rack v%s.\n\nWould you like to download the new version on the website?", newVersion.c_str(), gApplicationVersion.c_str());
std::string versionMessage = stringf("Rack %s is available.\n\nYou have Rack %s.\n\nWould you like to download the new version on the website?", newVersion.c_str(), gApplicationVersion.c_str());
if (osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, versionMessage.c_str())) {
std::thread t(openBrowser, "https://vcvrack.com/");
t.detach();


+ 45
- 6
src/window.cpp View File

@@ -1,6 +1,7 @@
#include "window.hpp"
#include "app.hpp"
#include "asset.hpp"
#include "util/color.hpp"

#include <map>
#include <queue>
@@ -386,12 +387,7 @@ void windowInit() {
bndSetFont(gGuiFont->handle);
// bndSetIconImage(loadImage(assetGlobal("res/icons.png")));

// Blendish style
BNDtheme theme;
theme = *bndGetTheme();
theme.nodeTheme.nodeBackdropColor = theme.menuTheme.innerColor;
theme.nodeTheme.nodeBackdropColor.a = 1.0;
bndSetTheme(theme);
windowSetTheme(nvgRGB(0x40, 0x40, 0x40), nvgRGB(0xf0, 0xf0, 0xf0));
}

void windowDestroy() {
@@ -547,6 +543,49 @@ bool windowIsMaximized() {
return glfwGetWindowAttrib(gWindow, GLFW_MAXIMIZED);
}

void windowSetTheme(NVGcolor bg, NVGcolor fg) {
// Assume dark background and light foreground

BNDwidgetTheme w;
w.outlineColor = bg;
w.itemColor = fg;
w.innerColor = bg;
w.innerSelectedColor = colorPlus(bg, nvgRGB(0x30, 0x30, 0x30));
w.textColor = fg;
w.textSelectedColor = fg;
w.shadeTop = 0;
w.shadeDown = 0;

BNDwidgetTheme sliderW = w;
sliderW.itemColor = bg;
sliderW.innerColor = colorPlus(bg, nvgRGB(0x50, 0x50, 0x50));
sliderW.innerSelectedColor = colorPlus(bg, nvgRGB(0x60, 0x60, 0x60));

BNDwidgetTheme textW = sliderW;
textW.textColor = colorMinus(bg, nvgRGB(0x20, 0x20, 0x20));
textW.textSelectedColor = colorMinus(bg, nvgRGB(0x20, 0x20, 0x20));

BNDwidgetTheme scrollW = w;
scrollW.itemColor = colorPlus(bg, nvgRGB(0x50, 0x50, 0x50));
scrollW.innerColor = bg;

BNDtheme t;
t.backgroundColor = colorPlus(bg, nvgRGB(0x30, 0x30, 0x30));
t.regularTheme = w;
t.toolTheme = w;
t.radioTheme = w;
t.textFieldTheme = textW;
t.optionTheme = w;
t.choiceTheme = w;
t.numberFieldTheme = w;
t.sliderTheme = sliderW;
t.scrollBarTheme = scrollW;
t.tooltipTheme = w;
t.menuTheme = w;
t.menuItemTheme = w;

bndSetTheme(t);
}


////////////////////


Loading…
Cancel
Save