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.

67 lines
2.0KB

  1. //***********************************************************************************************
  2. //Impromptu Modular: Modules for VCV Rack by Marc Boulé
  3. //
  4. //See ./LICENSE.md for all licenses
  5. //***********************************************************************************************
  6. #include "../ImpromptuModular/src/comp/PanelTheme.hpp"
  7. NVGcolor SCHEME_RED_IM = SCHEME_RED;
  8. NVGcolor SCHEME_GREEN_IM = SCHEME_GREEN;
  9. void writeThemeAndContrastAsDefault() {}
  10. void saveThemeAndContrastAsDefault(int, float) {}
  11. void loadThemeAndContrastFromDefault(int* panelTheme, float* panelContrast) {
  12. *panelTheme = rack::settings::preferDarkPanels ? 1 : 0;
  13. *panelContrast = panelContrastDefault;
  14. }
  15. bool isDark(int*) {
  16. return rack::settings::preferDarkPanels;
  17. }
  18. void readThemeAndContrastFromDefault() {}
  19. void createPanelThemeMenu(ui::Menu*, int*, float*, SvgPanel*) {}
  20. void PanelBaseWidget::draw(const DrawArgs& args) {
  21. nvgBeginPath(args.vg);
  22. NVGcolor baseColor;
  23. if (panelContrastSrc) {
  24. baseColor = nvgRGB(*panelContrastSrc, *panelContrastSrc, *panelContrastSrc);
  25. }
  26. else {
  27. baseColor = nvgRGB(panelContrastDefault, panelContrastDefault, panelContrastDefault);
  28. }
  29. nvgFillColor(args.vg, baseColor);
  30. nvgRect(args.vg, 0, 0, box.size.x, box.size.y);
  31. nvgFill(args.vg);
  32. TransparentWidget::draw(args);
  33. }
  34. void InverterWidget::draw(const DrawArgs& args) {
  35. TransparentWidget::draw(args);
  36. if (rack::settings::preferDarkPanels) {
  37. // nvgSave(args.vg);
  38. nvgBeginPath(args.vg);
  39. nvgFillColor(args.vg, SCHEME_WHITE);// this is the source, the current framebuffer is the dest
  40. nvgRect(args.vg, 0, 0, box.size.x, box.size.y);
  41. nvgGlobalCompositeBlendFuncSeparate(args.vg,
  42. NVG_ONE_MINUS_DST_COLOR,// srcRGB
  43. NVG_ZERO,// dstRGB
  44. NVG_ONE_MINUS_DST_COLOR,// srcAlpha
  45. NVG_ONE);// dstAlpha
  46. // blend factor: https://github.com/memononen/nanovg/blob/master/src/nanovg.h#L86
  47. // OpenGL blend doc: https://www.khronos.org/opengl/wiki/Blending
  48. nvgFill(args.vg);
  49. nvgClosePath(args.vg);
  50. // nvgRestore(args.vg);
  51. }
  52. }