Browse Source

Implement Notes panel redesign by Pyer.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
d95878b7dc
2 changed files with 19 additions and 18 deletions
  1. +0
    -8
      src/app/LedDisplay.cpp
  2. +19
    -10
      src/core/Notes.cpp

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

@@ -149,14 +149,6 @@ LedDisplayTextField::LedDisplayTextField() {


void LedDisplayTextField::draw(const DrawArgs& args) {
// Background
if (bgColor.a > 0.0) {
nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 5.0);
nvgFillColor(args.vg, nvgRGB(0x00, 0x00, 0x00));
nvgFill(args.vg);
}

Widget::draw(args);
}



+ 19
- 10
src/core/Notes.cpp View File

@@ -14,9 +14,9 @@ struct NotesModule : Module {
dirty = true;
}

/** Legacy for <=v1 patches */
void fromJson(json_t* rootJ) override {
Module::fromJson(rootJ);
// In <1.0, module used "text" property at root level.
json_t* textJ = json_object_get(rootJ, "text");
if (textJ)
text = json_string_value(textJ);
@@ -42,22 +42,32 @@ struct NotesTextField : LedDisplayTextField {
NotesModule* module;

void step() override {
TextField::step();
LedDisplayTextField::step();
if (module && module->dirty) {
setText(module->text);
module->dirty = false;
}
}

void onChange(const ChangeEvent& e) override {
if (module)
module->text = text;
module->text = getText();
}
};


struct NotesWidget : ModuleWidget {
NotesTextField* textField;
struct NotesDisplay : LedDisplay {
void setModule(NotesModule* module) {
NotesTextField* textField = createWidget<NotesTextField>(Vec(0, 0));
textField->box.size = box.size;
textField->multiline = true;
textField->module = module;
addChild(textField);
}
};


struct NotesWidget : ModuleWidget {
NotesWidget(NotesModule* module) {
setModule(module);
setPanel(Svg::load(asset::system("res/Core/Notes.svg")));
@@ -67,11 +77,10 @@ struct NotesWidget : ModuleWidget {
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

textField = createWidget<NotesTextField>(mm2px(Vec(3.39962, 14.8373)));
textField->box.size = mm2px(Vec(74.480, 102.753));
textField->multiline = true;
textField->module = dynamic_cast<NotesModule*>(module);
addChild(textField);
NotesDisplay* notesDisplay = createWidget<NotesDisplay>(mm2px(Vec(0.0, 12.869)));
notesDisplay->box.size = mm2px(Vec(81.28, 105.567));
notesDisplay->setModule(module);
addChild(notesDisplay);
}
};



Loading…
Cancel
Save