Browse Source

Add Dark mode to settings and menu bar. Change default cable colors.

tags/v2.0.0
Andrew Belt 5 years ago
parent
commit
e1b14091bd
4 changed files with 34 additions and 4 deletions
  1. +1
    -0
      include/rack.hpp
  2. +4
    -0
      include/settings.hpp
  3. +11
    -0
      src/app/MenuBar.cpp
  4. +18
    -4
      src/settings.cpp

+ 1
- 0
include/rack.hpp View File

@@ -13,6 +13,7 @@
#include <window.hpp> #include <window.hpp>
#include <app.hpp> #include <app.hpp>
#include <midi.hpp> #include <midi.hpp>
#include <settings.hpp>
#include <helpers.hpp> #include <helpers.hpp>
#include <componentlibrary.hpp> #include <componentlibrary.hpp>




+ 4
- 0
include/settings.hpp View File

@@ -42,6 +42,7 @@ extern int threadCount;
extern bool paramTooltip; extern bool paramTooltip;
extern bool cpuMeter; extern bool cpuMeter;
extern bool lockModules; extern bool lockModules;
extern bool darkMode;
extern int frameSwapInterval; extern int frameSwapInterval;
extern float autosavePeriod; extern float autosavePeriod;
extern bool skipLoadOnLaunch; extern bool skipLoadOnLaunch;
@@ -56,6 +57,9 @@ void fromJson(json_t* rootJ);
void save(const std::string& path); void save(const std::string& path);
void load(const std::string& path); void load(const std::string& path);


// Getters, for ensuring API/ABI compatibility for plugins
bool isDarkMode();



} // namespace settings } // namespace settings
} // namespace rack } // namespace rack

+ 11
- 0
src/app/MenuBar.cpp View File

@@ -384,6 +384,12 @@ struct LockModulesItem : ui::MenuItem {
} }
}; };


struct DarkModeItem : ui::MenuItem {
void onAction(const event::Action& e) override {
settings::darkMode ^= true;
}
};

struct FrameRateValueItem : ui::MenuItem { struct FrameRateValueItem : ui::MenuItem {
int frameSwapInterval; int frameSwapInterval;
void onAction(const event::Action& e) override { void onAction(const event::Action& e) override {
@@ -452,6 +458,11 @@ struct ViewButton : MenuButton {
cableTensionSlider->box.size.x = 200.0; cableTensionSlider->box.size.x = 200.0;
menu->addChild(cableTensionSlider); menu->addChild(cableTensionSlider);


DarkModeItem* darkModeItem = new DarkModeItem;
darkModeItem->text = "Dark mode";
darkModeItem->rightText = CHECKMARK(settings::darkMode);
menu->addChild(darkModeItem);

FrameRateItem* frameRateItem = new FrameRateItem; FrameRateItem* frameRateItem = new FrameRateItem;
frameRateItem->text = "Frame rate"; frameRateItem->text = "Frame rate";
frameRateItem->rightText = RIGHT_ARROW; frameRateItem->rightText = RIGHT_ARROW;


+ 18
- 4
src/settings.cpp View File

@@ -30,6 +30,7 @@ int threadCount = 1;
bool paramTooltip = true; bool paramTooltip = true;
bool cpuMeter = false; bool cpuMeter = false;
bool lockModules = false; bool lockModules = false;
bool darkMode = false;
#if defined ARCH_MAC #if defined ARCH_MAC
// Most Mac GPUs can't handle rendering the screen every frame, so use ~30 Hz by default. // Most Mac GPUs can't handle rendering the screen every frame, so use ~30 Hz by default.
int frameSwapInterval = 2; int frameSwapInterval = 2;
@@ -41,10 +42,12 @@ bool skipLoadOnLaunch = false;
std::string patchPath; std::string patchPath;
std::list<std::string> recentPatchPaths; std::list<std::string> recentPatchPaths;
std::vector<NVGcolor> cableColors = { std::vector<NVGcolor> cableColors = {
nvgRGB(0xc9, 0xb7, 0x0e), // yellow
nvgRGB(0x0c, 0x8e, 0x15), // green
nvgRGB(0xc9, 0x18, 0x47), // red
nvgRGB(0x09, 0x86, 0xad), // blue
color::fromHexString("#fc2d5aff"), // red
color::fromHexString("#f9b130ff"), // orange
// color::fromHexString("#f7da31ff"), // yellow
color::fromHexString("#67c12dff"), // green
color::fromHexString("#0f8df4ff"), // blue
color::fromHexString("#8c1889ff"), // purple
}; };
std::map<std::string, std::vector<std::string>> moduleWhitelist = {}; std::map<std::string, std::vector<std::string>> moduleWhitelist = {};


@@ -84,6 +87,8 @@ json_t* toJson() {


json_object_set_new(rootJ, "lockModules", json_boolean(lockModules)); json_object_set_new(rootJ, "lockModules", json_boolean(lockModules));


json_object_set_new(rootJ, "darkMode", json_boolean(darkMode));

json_object_set_new(rootJ, "frameSwapInterval", json_integer(frameSwapInterval)); json_object_set_new(rootJ, "frameSwapInterval", json_integer(frameSwapInterval));


json_object_set_new(rootJ, "autosavePeriod", json_real(autosavePeriod)); json_object_set_new(rootJ, "autosavePeriod", json_real(autosavePeriod));
@@ -186,6 +191,10 @@ void fromJson(json_t* rootJ) {
if (lockModulesJ) if (lockModulesJ)
lockModules = json_boolean_value(lockModulesJ); lockModules = json_boolean_value(lockModulesJ);


json_t* darkModeJ = json_object_get(rootJ, "darkMode");
if (darkModeJ)
darkMode = json_boolean_value(darkModeJ);

json_t* frameSwapIntervalJ = json_object_get(rootJ, "frameSwapInterval"); json_t* frameSwapIntervalJ = json_object_get(rootJ, "frameSwapInterval");
if (frameSwapIntervalJ) if (frameSwapIntervalJ)
frameSwapInterval = json_integer_value(frameSwapIntervalJ); frameSwapInterval = json_integer_value(frameSwapIntervalJ);
@@ -277,5 +286,10 @@ void load(const std::string& path) {
} }




bool isDarkMode() {
return darkMode;
}


} // namespace settings } // namespace settings
} // namespace rack } // namespace rack

Loading…
Cancel
Save