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.

91 lines
2.0KB

  1. #include <ui/common.hpp>
  2. #include <settings.hpp>
  3. namespace rack {
  4. namespace ui {
  5. void init() {
  6. refreshTheme();
  7. }
  8. void destroy() {
  9. }
  10. void setTheme(NVGcolor bg, NVGcolor fg) {
  11. BNDwidgetTheme w;
  12. w.outlineColor = color::lerp(bg, fg, 0.1);
  13. w.itemColor = fg;
  14. w.innerColor = color::lerp(bg, fg, 0.1);
  15. w.innerSelectedColor = color::lerp(bg, fg, 0.2);
  16. w.textColor = fg;
  17. w.textSelectedColor = fg;
  18. w.shadeTop = 0;
  19. w.shadeDown = 0;
  20. BNDtheme t;
  21. t.backgroundColor = bg;
  22. t.regularTheme = w;
  23. t.toolTheme = w;
  24. t.radioTheme = w;
  25. t.textFieldTheme = w;
  26. t.optionTheme = w;
  27. t.choiceTheme = w;
  28. t.numberFieldTheme = w;
  29. t.sliderTheme = w;
  30. t.scrollBarTheme = w;
  31. t.tooltipTheme = w;
  32. t.menuTheme = w;
  33. t.menuItemTheme = w;
  34. // Slider filled background
  35. t.sliderTheme.itemColor = color::lerp(bg, fg, 0.1);
  36. // Slider background
  37. t.sliderTheme.innerColor = color::lerp(bg, fg, 0.4);
  38. t.sliderTheme.innerSelectedColor = color::lerp(bg, fg, 0.6);
  39. // Text field background
  40. t.textFieldTheme.innerColor = color::lerp(bg, fg, 0.7);
  41. t.textFieldTheme.innerSelectedColor = color::lerp(bg, fg, 0.8);
  42. // Text
  43. t.textFieldTheme.textColor = color::lerp(bg, fg, -0.2);
  44. t.textFieldTheme.textSelectedColor = t.textFieldTheme.textColor;
  45. // Placeholder text and highlight background
  46. t.textFieldTheme.itemColor = color::lerp(bg, fg, 0.3);
  47. t.scrollBarTheme.itemColor = color::lerp(bg, fg, 0.4);
  48. t.scrollBarTheme.innerColor = color::lerp(bg, fg, 0.1);
  49. // Menu background
  50. t.menuTheme.innerColor = bg;
  51. // Menu label text
  52. t.menuTheme.textColor = color::lerp(bg, fg, 0.6);
  53. t.menuTheme.textSelectedColor = t.menuTheme.textColor;
  54. // Tooltip background
  55. t.tooltipTheme.innerColor = bg;
  56. bndSetTheme(t);
  57. }
  58. void refreshTheme() {
  59. if (settings::uiTheme == "light") {
  60. setTheme(nvgRGB(0xfb, 0xfb, 0xfb), nvgRGB(0x04, 0x04, 0x04));
  61. }
  62. else if (settings::uiTheme == "dark") {
  63. setTheme(nvgRGB(0x00, 0x00, 0x00), nvgRGB(0xff, 0xff, 0xff));
  64. }
  65. else {
  66. // Default
  67. setTheme(nvgRGB(0x20, 0x20, 0x20), nvgRGB(0xf0, 0xf0, 0xf0));
  68. }
  69. }
  70. } // namespace ui
  71. } // namespace rack