You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2KB

  1. #include "plugin.hpp"
  2. namespace rack {
  3. namespace core {
  4. struct NotesWidget : ModuleWidget {
  5. TextField* textField;
  6. NotesWidget(Module* module) {
  7. setModule(module);
  8. setPanel(APP->window->loadSvg(asset::system("res/Core/Notes.svg")));
  9. addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
  10. addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
  11. addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  12. addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  13. textField = createWidget<LedDisplayTextField>(mm2px(Vec(3.39962, 14.8373)));
  14. textField->box.size = mm2px(Vec(74.480, 102.753));
  15. textField->multiline = true;
  16. addChild(textField);
  17. }
  18. json_t* toJson() override {
  19. json_t* rootJ = ModuleWidget::toJson();
  20. // text
  21. json_object_set_new(rootJ, "text", json_string(textField->text.c_str()));
  22. return rootJ;
  23. }
  24. void fromJson(json_t* rootJ) override {
  25. ModuleWidget::fromJson(rootJ);
  26. // text
  27. json_t* textJ = json_object_get(rootJ, "text");
  28. if (textJ)
  29. textField->text = json_string_value(textJ);
  30. }
  31. };
  32. Model* modelNotes = createModel<Module, NotesWidget>("Notes");
  33. } // namespace core
  34. } // namespace rack