Browse Source

Put ui.hpp in namespace, clean up

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
9d7024232c
9 changed files with 26 additions and 32 deletions
  1. +2
    -0
      include/context.hpp
  2. +0
    -1
      include/helpers.hpp
  3. +0
    -2
      include/settings.hpp
  4. +5
    -4
      include/ui.hpp
  5. +0
    -1
      src/app/LedDisplay.cpp
  6. +0
    -1
      src/app/ModuleWidget.cpp
  7. +6
    -6
      src/main.cpp
  8. +7
    -10
      src/settings.cpp
  9. +6
    -7
      src/ui.cpp

+ 2
- 0
include/context.hpp View File

@@ -19,6 +19,8 @@ struct Context {
Scene *scene = NULL;
Engine *engine = NULL;
Window *window = NULL;

bool skipLoadOnLaunch = false;
};




+ 0
- 1
include/helpers.hpp View File

@@ -141,7 +141,6 @@ TMenuItem *createMenuItem(std::string text, std::string rightText = "") {
return o;
}

// TODO Reevaluate this. Does it belong here?
inline Menu *createMenu() {
Menu *o = new Menu;
o->box.pos = context()->window->mousePos;


+ 0
- 2
include/settings.hpp View File

@@ -6,8 +6,6 @@ namespace rack {
namespace settings {


extern bool gSkipAutosaveOnLaunch;

void save(std::string filename);
void load(std::string filename);



+ 5
- 4
include/ui.hpp View File

@@ -1,15 +1,16 @@
#pragma once
#include "ui/common.hpp"
#include "color.hpp"
#include "window.hpp"


namespace rack {
namespace ui {


void uiInit();
void uiDestroy();
void uiSetTheme(NVGcolor bg, NVGcolor fg);
void init();
void destroy();
void setTheme(NVGcolor bg, NVGcolor fg);


} // namespace ui
} // namespace rack

+ 0
- 1
src/app/LedDisplay.cpp View File

@@ -3,7 +3,6 @@
#include "window.hpp"
#include "event.hpp"
#include "context.hpp"
#include "ui.hpp"


namespace rack {


+ 0
- 1
src/app/ModuleWidget.cpp View File

@@ -6,7 +6,6 @@
#include "app/Scene.hpp"
#include "helpers.hpp"
#include "context.hpp"
#include "ui.hpp"

#include "osdialog.h"



+ 6
- 6
src/main.cpp View File

@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) {
bridgeInit();
keyboard::init();
gamepad::init();
uiInit();
ui::init();
plugin::init(devMode);

// Log environment
@@ -90,11 +90,11 @@ int main(int argc, char *argv[]) {

if (patchFile.empty()) {
// To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded.
bool oldSkipAutosaveOnLaunch = settings::gSkipAutosaveOnLaunch;
settings::gSkipAutosaveOnLaunch = true;
bool oldSkipLoadOnLaunch = context()->skipLoadOnLaunch;
context()->skipLoadOnLaunch = true;
settings::save(asset::user("settings.json"));
settings::gSkipAutosaveOnLaunch = false;
if (oldSkipAutosaveOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) {
context()->skipLoadOnLaunch = false;
if (oldSkipLoadOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) {
context()->scene->rackWidget->lastPath = "";
}
else {
@@ -128,7 +128,7 @@ int main(int argc, char *argv[]) {

// Destroy environment
plugin::destroy();
uiDestroy();
ui::destroy();
bridgeDestroy();
midiDestroy();
logger::destroy();


+ 7
- 10
src/settings.cpp View File

@@ -13,9 +13,6 @@ namespace rack {
namespace settings {


bool gSkipAutosaveOnLaunch = false;


static json_t *settingsToJson() {
// root
json_t *rootJ = json_object();
@@ -63,9 +60,9 @@ static json_t *settingsToJson() {
json_t *lastPathJ = json_string(context()->scene->rackWidget->lastPath.c_str());
json_object_set_new(rootJ, "lastPath", lastPathJ);

// skipAutosaveOnLaunch
if (gSkipAutosaveOnLaunch) {
json_object_set_new(rootJ, "skipAutosaveOnLaunch", json_true());
// skipLoadOnLaunch
if (context()->skipLoadOnLaunch) {
json_object_set_new(rootJ, "skipLoadOnLaunch", json_true());
}

// moduleBrowser
@@ -135,10 +132,10 @@ static void settingsFromJson(json_t *rootJ) {
if (lastPathJ)
context()->scene->rackWidget->lastPath = json_string_value(lastPathJ);

// skipAutosaveOnLaunch
json_t *skipAutosaveOnLaunchJ = json_object_get(rootJ, "skipAutosaveOnLaunch");
if (skipAutosaveOnLaunchJ)
gSkipAutosaveOnLaunch = json_boolean_value(skipAutosaveOnLaunchJ);
// skipLoadOnLaunch
json_t *skipLoadOnLaunchJ = json_object_get(rootJ, "skipLoadOnLaunch");
if (skipLoadOnLaunchJ)
context()->skipLoadOnLaunch = json_boolean_value(skipLoadOnLaunchJ);

// moduleBrowser
json_t *moduleBrowserJ = json_object_get(rootJ, "moduleBrowser");


+ 6
- 7
src/ui.cpp View File

@@ -2,16 +2,17 @@


namespace rack {
namespace ui {


void uiInit(){
uiSetTheme(nvgRGB(0x33, 0x33, 0x33), nvgRGB(0xf0, 0xf0, 0xf0));
void init(){
setTheme(nvgRGB(0x33, 0x33, 0x33), nvgRGB(0xf0, 0xf0, 0xf0));
}

void uiDestroy() {
void destroy() {
}

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

BNDwidgetTheme w;
@@ -58,7 +59,5 @@ void uiSetTheme(NVGcolor bg, NVGcolor fg) {
}


std::shared_ptr<Font> gGuiFont;


} // namespace ui
} // namespace rack

Loading…
Cancel
Save