style.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. enum theme {THEME_BLACK, THEME_WHITE, THEME_RED, THEME_BLUE, THEME_DARK};
  2. static void
  3. set_style(struct nk_context *ctx, enum theme theme)
  4. {
  5. struct nk_color table[NK_COLOR_COUNT];
  6. if (theme == THEME_WHITE) {
  7. table[NK_COLOR_TEXT] = nk_rgba(70, 70, 70, 255);
  8. table[NK_COLOR_WINDOW] = nk_rgba(175, 175, 175, 255);
  9. table[NK_COLOR_HEADER] = nk_rgba(175, 175, 175, 255);
  10. table[NK_COLOR_BORDER] = nk_rgba(0, 0, 0, 255);
  11. table[NK_COLOR_BUTTON] = nk_rgba(185, 185, 185, 255);
  12. table[NK_COLOR_BUTTON_HOVER] = nk_rgba(170, 170, 170, 255);
  13. table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(160, 160, 160, 255);
  14. table[NK_COLOR_TOGGLE] = nk_rgba(150, 150, 150, 255);
  15. table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(120, 120, 120, 255);
  16. table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(175, 175, 175, 255);
  17. table[NK_COLOR_SELECT] = nk_rgba(190, 190, 190, 255);
  18. table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(175, 175, 175, 255);
  19. table[NK_COLOR_SLIDER] = nk_rgba(190, 190, 190, 255);
  20. table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(80, 80, 80, 255);
  21. table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(70, 70, 70, 255);
  22. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(60, 60, 60, 255);
  23. table[NK_COLOR_PROPERTY] = nk_rgba(175, 175, 175, 255);
  24. table[NK_COLOR_EDIT] = nk_rgba(150, 150, 150, 255);
  25. table[NK_COLOR_EDIT_CURSOR] = nk_rgba(0, 0, 0, 255);
  26. table[NK_COLOR_COMBO] = nk_rgba(175, 175, 175, 255);
  27. table[NK_COLOR_CHART] = nk_rgba(160, 160, 160, 255);
  28. table[NK_COLOR_CHART_COLOR] = nk_rgba(45, 45, 45, 255);
  29. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
  30. table[NK_COLOR_SCROLLBAR] = nk_rgba(180, 180, 180, 255);
  31. table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(140, 140, 140, 255);
  32. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(150, 150, 150, 255);
  33. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(160, 160, 160, 255);
  34. table[NK_COLOR_TAB_HEADER] = nk_rgba(180, 180, 180, 255);
  35. nk_style_from_table(ctx, table);
  36. } else if (theme == THEME_RED) {
  37. table[NK_COLOR_TEXT] = nk_rgba(190, 190, 190, 255);
  38. table[NK_COLOR_WINDOW] = nk_rgba(30, 33, 40, 215);
  39. table[NK_COLOR_HEADER] = nk_rgba(181, 45, 69, 220);
  40. table[NK_COLOR_BORDER] = nk_rgba(51, 55, 67, 255);
  41. table[NK_COLOR_BUTTON] = nk_rgba(181, 45, 69, 255);
  42. table[NK_COLOR_BUTTON_HOVER] = nk_rgba(190, 50, 70, 255);
  43. table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(195, 55, 75, 255);
  44. table[NK_COLOR_TOGGLE] = nk_rgba(51, 55, 67, 255);
  45. table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 60, 60, 255);
  46. table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(181, 45, 69, 255);
  47. table[NK_COLOR_SELECT] = nk_rgba(51, 55, 67, 255);
  48. table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(181, 45, 69, 255);
  49. table[NK_COLOR_SLIDER] = nk_rgba(51, 55, 67, 255);
  50. table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(181, 45, 69, 255);
  51. table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(186, 50, 74, 255);
  52. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(191, 55, 79, 255);
  53. table[NK_COLOR_PROPERTY] = nk_rgba(51, 55, 67, 255);
  54. table[NK_COLOR_EDIT] = nk_rgba(51, 55, 67, 225);
  55. table[NK_COLOR_EDIT_CURSOR] = nk_rgba(190, 190, 190, 255);
  56. table[NK_COLOR_COMBO] = nk_rgba(51, 55, 67, 255);
  57. table[NK_COLOR_CHART] = nk_rgba(51, 55, 67, 255);
  58. table[NK_COLOR_CHART_COLOR] = nk_rgba(170, 40, 60, 255);
  59. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
  60. table[NK_COLOR_SCROLLBAR] = nk_rgba(30, 33, 40, 255);
  61. table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(64, 84, 95, 255);
  62. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(70, 90, 100, 255);
  63. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(75, 95, 105, 255);
  64. table[NK_COLOR_TAB_HEADER] = nk_rgba(181, 45, 69, 220);
  65. nk_style_from_table(ctx, table);
  66. } else if (theme == THEME_BLUE) {
  67. table[NK_COLOR_TEXT] = nk_rgba(20, 20, 20, 255);
  68. table[NK_COLOR_WINDOW] = nk_rgba(202, 212, 214, 215);
  69. table[NK_COLOR_HEADER] = nk_rgba(137, 182, 224, 220);
  70. table[NK_COLOR_BORDER] = nk_rgba(140, 159, 173, 255);
  71. table[NK_COLOR_BUTTON] = nk_rgba(137, 182, 224, 255);
  72. table[NK_COLOR_BUTTON_HOVER] = nk_rgba(142, 187, 229, 255);
  73. table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(147, 192, 234, 255);
  74. table[NK_COLOR_TOGGLE] = nk_rgba(177, 210, 210, 255);
  75. table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(182, 215, 215, 255);
  76. table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(137, 182, 224, 255);
  77. table[NK_COLOR_SELECT] = nk_rgba(177, 210, 210, 255);
  78. table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(137, 182, 224, 255);
  79. table[NK_COLOR_SLIDER] = nk_rgba(177, 210, 210, 255);
  80. table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(137, 182, 224, 245);
  81. table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(142, 188, 229, 255);
  82. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(147, 193, 234, 255);
  83. table[NK_COLOR_PROPERTY] = nk_rgba(210, 210, 210, 255);
  84. table[NK_COLOR_EDIT] = nk_rgba(210, 210, 210, 225);
  85. table[NK_COLOR_EDIT_CURSOR] = nk_rgba(20, 20, 20, 255);
  86. table[NK_COLOR_COMBO] = nk_rgba(210, 210, 210, 255);
  87. table[NK_COLOR_CHART] = nk_rgba(210, 210, 210, 255);
  88. table[NK_COLOR_CHART_COLOR] = nk_rgba(137, 182, 224, 255);
  89. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
  90. table[NK_COLOR_SCROLLBAR] = nk_rgba(190, 200, 200, 255);
  91. table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(64, 84, 95, 255);
  92. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(70, 90, 100, 255);
  93. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(75, 95, 105, 255);
  94. table[NK_COLOR_TAB_HEADER] = nk_rgba(156, 193, 220, 255);
  95. nk_style_from_table(ctx, table);
  96. } else if (theme == THEME_DARK) {
  97. table[NK_COLOR_TEXT] = nk_rgba(210, 210, 210, 255);
  98. table[NK_COLOR_WINDOW] = nk_rgba(57, 67, 71, 215);
  99. table[NK_COLOR_HEADER] = nk_rgba(51, 51, 56, 220);
  100. table[NK_COLOR_BORDER] = nk_rgba(46, 46, 46, 255);
  101. table[NK_COLOR_BUTTON] = nk_rgba(48, 83, 111, 255);
  102. table[NK_COLOR_BUTTON_HOVER] = nk_rgba(58, 93, 121, 255);
  103. table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(63, 98, 126, 255);
  104. table[NK_COLOR_TOGGLE] = nk_rgba(50, 58, 61, 255);
  105. table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 53, 56, 255);
  106. table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(48, 83, 111, 255);
  107. table[NK_COLOR_SELECT] = nk_rgba(57, 67, 61, 255);
  108. table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(48, 83, 111, 255);
  109. table[NK_COLOR_SLIDER] = nk_rgba(50, 58, 61, 255);
  110. table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(48, 83, 111, 245);
  111. table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
  112. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
  113. table[NK_COLOR_PROPERTY] = nk_rgba(50, 58, 61, 255);
  114. table[NK_COLOR_EDIT] = nk_rgba(50, 58, 61, 225);
  115. table[NK_COLOR_EDIT_CURSOR] = nk_rgba(210, 210, 210, 255);
  116. table[NK_COLOR_COMBO] = nk_rgba(50, 58, 61, 255);
  117. table[NK_COLOR_CHART] = nk_rgba(50, 58, 61, 255);
  118. table[NK_COLOR_CHART_COLOR] = nk_rgba(48, 83, 111, 255);
  119. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba(255, 0, 0, 255);
  120. table[NK_COLOR_SCROLLBAR] = nk_rgba(50, 58, 61, 255);
  121. table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(48, 83, 111, 255);
  122. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
  123. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
  124. table[NK_COLOR_TAB_HEADER] = nk_rgba(48, 83, 111, 255);
  125. nk_style_from_table(ctx, table);
  126. } else {
  127. nk_style_default(ctx);
  128. }
  129. }