style.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. enum theme {THEME_BLACK, THEME_WHITE, THEME_RED, THEME_BLUE, THEME_DARK, THEME_DRACULA};
  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. table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
  36. table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
  37. table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
  38. table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
  39. nk_style_from_table(ctx, table);
  40. } else if (theme == THEME_RED) {
  41. table[NK_COLOR_TEXT] = nk_rgba(190, 190, 190, 255);
  42. table[NK_COLOR_WINDOW] = nk_rgba(30, 33, 40, 215);
  43. table[NK_COLOR_HEADER] = nk_rgba(181, 45, 69, 220);
  44. table[NK_COLOR_BORDER] = nk_rgba(51, 55, 67, 255);
  45. table[NK_COLOR_BUTTON] = nk_rgba(181, 45, 69, 255);
  46. table[NK_COLOR_BUTTON_HOVER] = nk_rgba(190, 50, 70, 255);
  47. table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(195, 55, 75, 255);
  48. table[NK_COLOR_TOGGLE] = nk_rgba(51, 55, 67, 255);
  49. table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 60, 60, 255);
  50. table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(181, 45, 69, 255);
  51. table[NK_COLOR_SELECT] = nk_rgba(51, 55, 67, 255);
  52. table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(181, 45, 69, 255);
  53. table[NK_COLOR_SLIDER] = nk_rgba(51, 55, 67, 255);
  54. table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(181, 45, 69, 255);
  55. table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(186, 50, 74, 255);
  56. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(191, 55, 79, 255);
  57. table[NK_COLOR_PROPERTY] = nk_rgba(51, 55, 67, 255);
  58. table[NK_COLOR_EDIT] = nk_rgba(51, 55, 67, 225);
  59. table[NK_COLOR_EDIT_CURSOR] = nk_rgba(190, 190, 190, 255);
  60. table[NK_COLOR_COMBO] = nk_rgba(51, 55, 67, 255);
  61. table[NK_COLOR_CHART] = nk_rgba(51, 55, 67, 255);
  62. table[NK_COLOR_CHART_COLOR] = nk_rgba(170, 40, 60, 255);
  63. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
  64. table[NK_COLOR_SCROLLBAR] = nk_rgba(30, 33, 40, 255);
  65. table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(64, 84, 95, 255);
  66. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(70, 90, 100, 255);
  67. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(75, 95, 105, 255);
  68. table[NK_COLOR_TAB_HEADER] = nk_rgba(181, 45, 69, 220);
  69. table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
  70. table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
  71. table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
  72. table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
  73. nk_style_from_table(ctx, table);
  74. } else if (theme == THEME_BLUE) {
  75. table[NK_COLOR_TEXT] = nk_rgba(20, 20, 20, 255);
  76. table[NK_COLOR_WINDOW] = nk_rgba(202, 212, 214, 215);
  77. table[NK_COLOR_HEADER] = nk_rgba(137, 182, 224, 220);
  78. table[NK_COLOR_BORDER] = nk_rgba(140, 159, 173, 255);
  79. table[NK_COLOR_BUTTON] = nk_rgba(137, 182, 224, 255);
  80. table[NK_COLOR_BUTTON_HOVER] = nk_rgba(142, 187, 229, 255);
  81. table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(147, 192, 234, 255);
  82. table[NK_COLOR_TOGGLE] = nk_rgba(177, 210, 210, 255);
  83. table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(182, 215, 215, 255);
  84. table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(137, 182, 224, 255);
  85. table[NK_COLOR_SELECT] = nk_rgba(177, 210, 210, 255);
  86. table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(137, 182, 224, 255);
  87. table[NK_COLOR_SLIDER] = nk_rgba(177, 210, 210, 255);
  88. table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(137, 182, 224, 245);
  89. table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(142, 188, 229, 255);
  90. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(147, 193, 234, 255);
  91. table[NK_COLOR_PROPERTY] = nk_rgba(210, 210, 210, 255);
  92. table[NK_COLOR_EDIT] = nk_rgba(210, 210, 210, 225);
  93. table[NK_COLOR_EDIT_CURSOR] = nk_rgba(20, 20, 20, 255);
  94. table[NK_COLOR_COMBO] = nk_rgba(210, 210, 210, 255);
  95. table[NK_COLOR_CHART] = nk_rgba(210, 210, 210, 255);
  96. table[NK_COLOR_CHART_COLOR] = nk_rgba(137, 182, 224, 255);
  97. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba( 255, 0, 0, 255);
  98. table[NK_COLOR_SCROLLBAR] = nk_rgba(190, 200, 200, 255);
  99. table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(64, 84, 95, 255);
  100. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(70, 90, 100, 255);
  101. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(75, 95, 105, 255);
  102. table[NK_COLOR_TAB_HEADER] = nk_rgba(156, 193, 220, 255);
  103. table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
  104. table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
  105. table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
  106. table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
  107. nk_style_from_table(ctx, table);
  108. } else if (theme == THEME_DARK) {
  109. table[NK_COLOR_TEXT] = nk_rgba(210, 210, 210, 255);
  110. table[NK_COLOR_WINDOW] = nk_rgba(57, 67, 71, 215);
  111. table[NK_COLOR_HEADER] = nk_rgba(51, 51, 56, 220);
  112. table[NK_COLOR_BORDER] = nk_rgba(46, 46, 46, 255);
  113. table[NK_COLOR_BUTTON] = nk_rgba(48, 83, 111, 255);
  114. table[NK_COLOR_BUTTON_HOVER] = nk_rgba(58, 93, 121, 255);
  115. table[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(63, 98, 126, 255);
  116. table[NK_COLOR_TOGGLE] = nk_rgba(50, 58, 61, 255);
  117. table[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 53, 56, 255);
  118. table[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(48, 83, 111, 255);
  119. table[NK_COLOR_SELECT] = nk_rgba(57, 67, 61, 255);
  120. table[NK_COLOR_SELECT_ACTIVE] = nk_rgba(48, 83, 111, 255);
  121. table[NK_COLOR_SLIDER] = nk_rgba(50, 58, 61, 255);
  122. table[NK_COLOR_SLIDER_CURSOR] = nk_rgba(48, 83, 111, 245);
  123. table[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
  124. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
  125. table[NK_COLOR_PROPERTY] = nk_rgba(50, 58, 61, 255);
  126. table[NK_COLOR_EDIT] = nk_rgba(50, 58, 61, 225);
  127. table[NK_COLOR_EDIT_CURSOR] = nk_rgba(210, 210, 210, 255);
  128. table[NK_COLOR_COMBO] = nk_rgba(50, 58, 61, 255);
  129. table[NK_COLOR_CHART] = nk_rgba(50, 58, 61, 255);
  130. table[NK_COLOR_CHART_COLOR] = nk_rgba(48, 83, 111, 255);
  131. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba(255, 0, 0, 255);
  132. table[NK_COLOR_SCROLLBAR] = nk_rgba(50, 58, 61, 255);
  133. table[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(48, 83, 111, 255);
  134. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
  135. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
  136. table[NK_COLOR_TAB_HEADER] = nk_rgba(48, 83, 111, 255);
  137. table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
  138. table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
  139. table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
  140. table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
  141. nk_style_from_table(ctx, table);
  142. } else if (theme == THEME_DRACULA) {
  143. struct nk_color background = nk_rgba(40, 42, 54, 255);
  144. struct nk_color currentline = nk_rgba(68, 71, 90, 255);
  145. struct nk_color foreground = nk_rgba(248, 248, 242, 255);
  146. struct nk_color comment = nk_rgba(98, 114, 164, 255);
  147. /* struct nk_color cyan = nk_rgba(139, 233, 253, 255); */
  148. /* struct nk_color green = nk_rgba(80, 250, 123, 255); */
  149. /* struct nk_color orange = nk_rgba(255, 184, 108, 255); */
  150. struct nk_color pink = nk_rgba(255, 121, 198, 255);
  151. struct nk_color purple = nk_rgba(189, 147, 249, 255);
  152. /* struct nk_color red = nk_rgba(255, 85, 85, 255); */
  153. /* struct nk_color yellow = nk_rgba(241, 250, 140, 255); */
  154. table[NK_COLOR_TEXT] = foreground;
  155. table[NK_COLOR_WINDOW] = background;
  156. table[NK_COLOR_HEADER] = currentline;
  157. table[NK_COLOR_BORDER] = currentline;
  158. table[NK_COLOR_BUTTON] = currentline;
  159. table[NK_COLOR_BUTTON_HOVER] = comment;
  160. table[NK_COLOR_BUTTON_ACTIVE] = purple;
  161. table[NK_COLOR_TOGGLE] = currentline;
  162. table[NK_COLOR_TOGGLE_HOVER] = comment;
  163. table[NK_COLOR_TOGGLE_CURSOR] = pink;
  164. table[NK_COLOR_SELECT] = currentline;
  165. table[NK_COLOR_SELECT_ACTIVE] = comment;
  166. table[NK_COLOR_SLIDER] = background;
  167. table[NK_COLOR_SLIDER_CURSOR] = currentline;
  168. table[NK_COLOR_SLIDER_CURSOR_HOVER] = comment;
  169. table[NK_COLOR_SLIDER_CURSOR_ACTIVE] = comment;
  170. table[NK_COLOR_PROPERTY] = currentline;
  171. table[NK_COLOR_EDIT] = currentline;
  172. table[NK_COLOR_EDIT_CURSOR] = foreground;
  173. table[NK_COLOR_COMBO] = currentline;
  174. table[NK_COLOR_CHART] = currentline;
  175. table[NK_COLOR_CHART_COLOR] = comment;
  176. table[NK_COLOR_CHART_COLOR_HIGHLIGHT] = purple;
  177. table[NK_COLOR_SCROLLBAR] = background;
  178. table[NK_COLOR_SCROLLBAR_CURSOR] = currentline;
  179. table[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = comment;
  180. table[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = purple;
  181. table[NK_COLOR_TAB_HEADER] = currentline;
  182. table[NK_COLOR_KNOB] = table[NK_COLOR_SLIDER];
  183. table[NK_COLOR_KNOB_CURSOR] = table[NK_COLOR_SLIDER_CURSOR];
  184. table[NK_COLOR_KNOB_CURSOR_HOVER] = table[NK_COLOR_SLIDER_CURSOR_HOVER];
  185. table[NK_COLOR_KNOB_CURSOR_ACTIVE] = table[NK_COLOR_SLIDER_CURSOR_ACTIVE];
  186. nk_style_from_table(ctx, table);
  187. } else {
  188. nk_style_default(ctx);
  189. }
  190. }