editor_themes.cpp 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. /*************************************************************************/
  2. /* editor_themes.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "editor_themes.h"
  31. #include "core/io/resource_loader.h"
  32. #include "editor_fonts.h"
  33. #include "editor_icons.gen.h"
  34. #include "editor_scale.h"
  35. #include "editor_settings.h"
  36. #include "modules/svg/image_loader_svg.h"
  37. static Ref<StyleBoxTexture> make_stylebox(Ref<Texture> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) {
  38. Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
  39. style->set_texture(p_texture);
  40. style->set_margin_size(MARGIN_LEFT, p_left * EDSCALE);
  41. style->set_margin_size(MARGIN_RIGHT, p_right * EDSCALE);
  42. style->set_margin_size(MARGIN_BOTTOM, p_botton * EDSCALE);
  43. style->set_margin_size(MARGIN_TOP, p_top * EDSCALE);
  44. style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
  45. style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
  46. style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * EDSCALE);
  47. style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
  48. style->set_draw_center(p_draw_center);
  49. return style;
  50. }
  51. static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
  52. Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
  53. style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
  54. style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
  55. style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
  56. style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
  57. return style;
  58. }
  59. static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
  60. Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
  61. style->set_bg_color(p_color);
  62. style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
  63. style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
  64. style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
  65. style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
  66. return style;
  67. }
  68. static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1, float p_grow_begin = 1, float p_grow_end = 1, bool p_vertical = false) {
  69. Ref<StyleBoxLine> style(memnew(StyleBoxLine));
  70. style->set_color(p_color);
  71. style->set_grow_begin(p_grow_begin);
  72. style->set_grow_end(p_grow_end);
  73. style->set_thickness(p_thickness);
  74. style->set_vertical(p_vertical);
  75. return style;
  76. }
  77. Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float p_scale = EDSCALE, bool p_force_filter = false) {
  78. Ref<ImageTexture> icon = memnew(ImageTexture);
  79. Ref<Image> img = memnew(Image);
  80. // dumb gizmo check
  81. bool is_gizmo = String(editor_icons_names[p_index]).begins_with("Gizmo");
  82. ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, true, p_convert_color);
  83. if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || p_force_filter)
  84. icon->create_from_image(img); // in this case filter really helps
  85. else
  86. icon->create_from_image(img, 0);
  87. return icon;
  88. }
  89. #ifndef ADD_CONVERT_COLOR
  90. #define ADD_CONVERT_COLOR(dictionary, old_color, new_color) dictionary[Color::html(old_color)] = Color::html(new_color)
  91. #endif
  92. void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = true, int p_thumb_size = 32, bool p_only_thumbs = false) {
  93. #ifdef SVG_ENABLED
  94. Dictionary dark_icon_color_dictionary;
  95. if (!p_dark_theme) {
  96. //convert color: FROM TO
  97. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e0e0e0", "#4f4f4f"); // common icon color
  98. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffffff", "#000000"); // white
  99. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#b4b4b4", "#000000"); // script darker color
  100. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#cea4f1", "#bb6dff"); // animation
  101. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#fc9c9c", "#ff5f5f"); // spatial
  102. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5b7f3", "#6d90ff"); // 2d
  103. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#708cea", "#0843ff"); // 2d dark
  104. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5efac", "#29d739"); // control
  105. // rainbow
  106. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff7070", "#ff2929"); // red
  107. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffeb70", "#ffe337"); // yellow
  108. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#9dff70", "#74ff34"); // green
  109. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#70ffb9", "#2cff98"); // aqua
  110. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#70deff", "#22ccff"); // blue
  111. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#9f70ff", "#702aff"); // purple
  112. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff70ac", "#ff2781"); // pink
  113. // audio gradient
  114. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff8484", "#ff4040"); // red
  115. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e1dc7a", "#d6cf4b"); // yellow
  116. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84ffb1", "#00f010"); // green
  117. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffd684", "#fea900"); // mesh (orange)
  118. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#40a2ff", "#68b6ff"); // shape (blue)
  119. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff8484", "#ff3333"); // remove (red)
  120. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84ffb1", "#00db50"); // add (green)
  121. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84c2ff", "#5caeff"); // selection (blue)
  122. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ea686c", "#e3383d"); // key xform (red)
  123. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ecbd", "#25e3a0"); // VS variant
  124. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#8da6f0", "#6d8eeb"); // VS bool
  125. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#7dc6ef", "#4fb2e9"); // VS int
  126. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#61daf4", "#27ccf0"); // VS float
  127. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6ba7ec", "#4690e7"); // VS string
  128. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#bd91f1", "#ad76ee"); // VS vector2
  129. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f191a5", "#ee758e"); // VS rect
  130. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e286f0", "#dc6aed"); // VS vector3
  131. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c4ec69", "#96ce1a"); // VS transform2D
  132. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f77070", "#f77070"); // VS plane
  133. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ec69a3", "#ec69a3"); // VS quat
  134. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ee7991", "#ee7991"); // VS aabb
  135. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e3ec69", "#b2bb19"); // VS basis
  136. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f6a86e", "#f49047"); // VS transform
  137. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6993ec", "#6993ec"); // VS path
  138. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ec9a", "#2ce573"); // VS rid
  139. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#79f3e8", "#12d5c3"); // VS object
  140. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#77edb1", "#57e99f"); // VS dict
  141. }
  142. // these ones should be converted even if we are using a dark theme
  143. const Color error_color = p_theme->get_color("error_color", "Editor");
  144. const Color success_color = p_theme->get_color("success_color", "Editor");
  145. const Color warning_color = p_theme->get_color("warning_color", "Editor");
  146. dark_icon_color_dictionary[Color::html("#ff0000")] = error_color;
  147. dark_icon_color_dictionary[Color::html("#45ff8b")] = success_color;
  148. dark_icon_color_dictionary[Color::html("#dbab09")] = warning_color;
  149. List<String> exceptions;
  150. exceptions.push_back("EditorPivot");
  151. exceptions.push_back("EditorHandle");
  152. exceptions.push_back("Editor3DHandle");
  153. exceptions.push_back("Godot");
  154. exceptions.push_back("PanoramaSky");
  155. exceptions.push_back("ProceduralSky");
  156. exceptions.push_back("EditorControlAnchor");
  157. exceptions.push_back("DefaultProjectIcon");
  158. exceptions.push_back("GuiCloseCustomizable");
  159. exceptions.push_back("GuiGraphNodePort");
  160. exceptions.push_back("GuiResizer");
  161. exceptions.push_back("ZoomMore");
  162. exceptions.push_back("ZoomLess");
  163. exceptions.push_back("ZoomReset");
  164. exceptions.push_back("LockViewport");
  165. exceptions.push_back("GroupViewport");
  166. exceptions.push_back("StatusError");
  167. exceptions.push_back("StatusSuccess");
  168. exceptions.push_back("StatusWarning");
  169. exceptions.push_back("NodeWarning");
  170. ImageLoaderSVG::set_convert_colors(&dark_icon_color_dictionary);
  171. // generate icons
  172. if (!p_only_thumbs)
  173. for (int i = 0; i < editor_icons_count; i++) {
  174. List<String>::Element *is_exception = exceptions.find(editor_icons_names[i]);
  175. if (is_exception) exceptions.erase(is_exception);
  176. Ref<ImageTexture> icon = editor_generate_icon(i, !is_exception);
  177. p_theme->set_icon(editor_icons_names[i], "EditorIcons", icon);
  178. }
  179. // generate thumb files with the given thumb size
  180. bool force_filter = !(p_thumb_size == 64 && p_thumb_size == 32); // we don't need filter with original resolution
  181. if (p_thumb_size >= 64) {
  182. float scale = (float)p_thumb_size / 64.0 * EDSCALE;
  183. for (int i = 0; i < editor_bg_thumbs_count; i++) {
  184. int index = editor_bg_thumbs_indices[i];
  185. List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]);
  186. if (is_exception) exceptions.erase(is_exception);
  187. Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter);
  188. p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon);
  189. }
  190. } else {
  191. float scale = (float)p_thumb_size / 32.0 * EDSCALE;
  192. for (int i = 0; i < editor_md_thumbs_count; i++) {
  193. int index = editor_md_thumbs_indices[i];
  194. List<String>::Element *is_exception = exceptions.find(editor_icons_names[index]);
  195. if (is_exception) exceptions.erase(is_exception);
  196. Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter);
  197. p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon);
  198. }
  199. }
  200. ImageLoaderSVG::set_convert_colors(NULL);
  201. #else
  202. print_line("SVG support disabled, editor icons won't be rendered.");
  203. #endif
  204. }
  205. Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
  206. Ref<Theme> theme = Ref<Theme>(memnew(Theme));
  207. const float default_contrast = 0.25;
  208. //Theme settings
  209. Color accent_color = EDITOR_DEF("interface/theme/accent_color", Color::html("#699ce8"));
  210. Color base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#323b4f"));
  211. float contrast = EDITOR_DEF("interface/theme/contrast", default_contrast);
  212. String preset = EDITOR_DEF("interface/theme/preset", "Default");
  213. bool highlight_tabs = EDITOR_DEF("interface/theme/highlight_tabs", false);
  214. int border_size = EDITOR_DEF("interface/theme/border_size", 1);
  215. bool use_gn_headers = EDITOR_DEF("interface/theme/use_graph_node_headers", false);
  216. Color preset_accent_color;
  217. Color preset_base_color;
  218. float preset_contrast = 0;
  219. // Please, use alphabet order if you've added new theme here(After "Default" and "Custom")
  220. if (preset == "Default") {
  221. preset_accent_color = Color::html("#699ce8");
  222. preset_base_color = Color::html("#323b4f");
  223. preset_contrast = default_contrast;
  224. } else if (preset == "Custom") {
  225. accent_color = EDITOR_DEF("interface/theme/accent_color", Color::html("#699ce8"));
  226. base_color = EDITOR_DEF("interface/theme/base_color", Color::html("#323b4f"));
  227. contrast = EDITOR_DEF("interface/theme/contrast", default_contrast);
  228. } else if (preset == "Alien") {
  229. preset_accent_color = Color::html("#1bfe99");
  230. preset_base_color = Color::html("#2f373f");
  231. preset_contrast = 0.25;
  232. } else if (preset == "Arc") {
  233. preset_accent_color = Color::html("#5294e2");
  234. preset_base_color = Color::html("#383c4a");
  235. preset_contrast = 0.25;
  236. } else if (preset == "Godot 2") {
  237. preset_accent_color = Color::html("#86ace2");
  238. preset_base_color = Color::html("#3C3A44");
  239. preset_contrast = 0.25;
  240. } else if (preset == "Grey") {
  241. preset_accent_color = Color::html("#b8e4ff");
  242. preset_base_color = Color::html("#3d3d3d");
  243. preset_contrast = 0.2;
  244. } else if (preset == "Light") {
  245. preset_accent_color = Color::html("#2070ff");
  246. preset_base_color = Color::html("#ffffff");
  247. preset_contrast = 0.08;
  248. } else if (preset == "Solarized (Dark)") {
  249. preset_accent_color = Color::html("#268bd2");
  250. preset_base_color = Color::html("#073642");
  251. preset_contrast = 0.15;
  252. } else if (preset == "Solarized (Light)") {
  253. preset_accent_color = Color::html("#268bd2");
  254. preset_base_color = Color::html("#fdf6e3");
  255. preset_contrast = 0.06;
  256. } else { // Default
  257. preset_accent_color = Color::html("#699ce8");
  258. preset_base_color = Color::html("#323b4f");
  259. preset_contrast = default_contrast;
  260. }
  261. if (preset != "Custom") {
  262. accent_color = preset_accent_color;
  263. base_color = preset_base_color;
  264. contrast = preset_contrast;
  265. EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", accent_color);
  266. EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", base_color);
  267. EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", contrast);
  268. }
  269. EditorSettings::get_singleton()->set_manually("interface/theme/preset", preset);
  270. EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", accent_color);
  271. EditorSettings::get_singleton()->set_manually("interface/theme/base_color", base_color);
  272. EditorSettings::get_singleton()->set_manually("interface/theme/contrast", contrast);
  273. //Colors
  274. bool dark_theme = EditorSettings::get_singleton()->is_dark_theme();
  275. const Color dark_color_1 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast);
  276. const Color dark_color_2 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 1.5);
  277. const Color dark_color_3 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 2);
  278. const Color background_color = dark_color_2;
  279. // white (dark theme) or black (light theme), will be used to generate the rest of the colors
  280. const Color mono_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
  281. const Color contrast_color_1 = base_color.linear_interpolate(mono_color, MAX(contrast, default_contrast));
  282. const Color contrast_color_2 = base_color.linear_interpolate(mono_color, MAX(contrast * 1.5, default_contrast * 1.5));
  283. const Color font_color = mono_color.linear_interpolate(base_color, 0.25);
  284. const Color font_color_hl = mono_color.linear_interpolate(base_color, 0.15);
  285. const Color font_color_disabled = Color(mono_color.r, mono_color.g, mono_color.b, 0.3);
  286. const Color font_color_selection = Color::html("#7d7d7d");
  287. const Color color_disabled = mono_color.inverted().linear_interpolate(base_color, 0.7);
  288. const Color color_disabled_bg = mono_color.inverted().linear_interpolate(base_color, 0.9);
  289. const Color separator_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.1);
  290. const Color highlight_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.2);
  291. theme->set_color("accent_color", "Editor", accent_color);
  292. theme->set_color("highlight_color", "Editor", highlight_color);
  293. theme->set_color("base_color", "Editor", base_color);
  294. theme->set_color("dark_color_1", "Editor", dark_color_1);
  295. theme->set_color("dark_color_2", "Editor", dark_color_2);
  296. theme->set_color("dark_color_3", "Editor", dark_color_3);
  297. theme->set_color("contrast_color_1", "Editor", contrast_color_1);
  298. theme->set_color("contrast_color_2", "Editor", contrast_color_2);
  299. theme->set_color("font_color", "Editor", font_color);
  300. theme->set_color("highlighted_font_color", "Editor", font_color_hl);
  301. theme->set_color("disabled_font_color", "Editor", font_color_disabled);
  302. theme->set_color("mono_color", "Editor", mono_color);
  303. Color success_color = Color(0.45, 0.95, 0.5);
  304. Color warning_color = Color(1, 0.87, 0.4);
  305. Color error_color = Color(1, 0.47, 0.42);
  306. Color property_color = font_color.linear_interpolate(Color(0.5, 0.5, 0.5), 0.5);
  307. if (!dark_theme) {
  308. // Darken some colors to be readable on a light background
  309. success_color = success_color.linear_interpolate(mono_color, 0.35);
  310. warning_color = warning_color.linear_interpolate(mono_color, 0.35);
  311. error_color = error_color.linear_interpolate(mono_color, 0.25);
  312. }
  313. theme->set_color("success_color", "Editor", success_color);
  314. theme->set_color("warning_color", "Editor", warning_color);
  315. theme->set_color("error_color", "Editor", error_color);
  316. theme->set_color("property_color", "Editor", property_color);
  317. const int thumb_size = EDITOR_DEF("filesystem/file_dialog/thumbnail_size", 64);
  318. theme->set_constant("scale", "Editor", EDSCALE);
  319. theme->set_constant("thumb_size", "Editor", thumb_size);
  320. theme->set_constant("dark_theme", "Editor", dark_theme);
  321. //Register icons + font
  322. // the resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons
  323. if (p_theme != NULL && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme) {
  324. // register already generated icons
  325. for (int i = 0; i < editor_icons_count; i++) {
  326. theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons"));
  327. }
  328. } else {
  329. editor_register_and_generate_icons(theme, dark_theme, thumb_size);
  330. }
  331. // thumbnail size has changed, so we regenerate the medium sizes
  332. if (p_theme != NULL && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) {
  333. editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true);
  334. }
  335. editor_register_fonts(theme);
  336. // Highlighted tabs and border width
  337. Color tab_color = highlight_tabs ? base_color.linear_interpolate(font_color, contrast) : base_color;
  338. const int border_width = CLAMP(border_size, 0, 3) * EDSCALE;
  339. const int default_margin_size = 4;
  340. const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 3);
  341. // styleboxes
  342. // this is the most commonly used stylebox, variations should be made as duplicate of this
  343. Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size);
  344. style_default->set_border_width_all(border_width);
  345. style_default->set_border_color_all(base_color);
  346. style_default->set_draw_center(true);
  347. // Button and widgets
  348. const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing");
  349. Ref<StyleBoxFlat> style_widget = style_default->duplicate();
  350. style_widget->set_default_margin(MARGIN_LEFT, (extra_spacing + 6) * EDSCALE);
  351. style_widget->set_default_margin(MARGIN_TOP, (extra_spacing + default_margin_size) * EDSCALE);
  352. style_widget->set_default_margin(MARGIN_RIGHT, (extra_spacing + 6) * EDSCALE);
  353. style_widget->set_default_margin(MARGIN_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE);
  354. style_widget->set_bg_color(dark_color_1);
  355. style_widget->set_border_color_all(dark_color_2);
  356. Ref<StyleBoxFlat> style_widget_disabled = style_widget->duplicate();
  357. style_widget_disabled->set_border_color_all(color_disabled);
  358. style_widget_disabled->set_bg_color(color_disabled_bg);
  359. Ref<StyleBoxFlat> style_widget_focus = style_widget->duplicate();
  360. style_widget_focus->set_border_color_all(accent_color);
  361. Ref<StyleBoxFlat> style_widget_pressed = style_widget->duplicate();
  362. style_widget_pressed->set_border_color_all(accent_color);
  363. Ref<StyleBoxFlat> style_widget_hover = style_widget->duplicate();
  364. style_widget_hover->set_border_color_all(contrast_color_1);
  365. // style for windows, popups, etc..
  366. Ref<StyleBoxFlat> style_popup = style_default->duplicate();
  367. const int popup_margin_size = default_margin_size * EDSCALE * 2;
  368. style_popup->set_default_margin(MARGIN_LEFT, popup_margin_size);
  369. style_popup->set_default_margin(MARGIN_TOP, popup_margin_size);
  370. style_popup->set_default_margin(MARGIN_RIGHT, popup_margin_size);
  371. style_popup->set_default_margin(MARGIN_BOTTOM, popup_margin_size);
  372. style_popup->set_border_color_all(contrast_color_1);
  373. style_popup->set_border_width_all(MAX(EDSCALE, border_width));
  374. const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1);
  375. style_popup->set_shadow_color(shadow_color);
  376. style_popup->set_shadow_size(4 * EDSCALE);
  377. Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine));
  378. style_popup_separator->set_color(separator_color);
  379. style_popup_separator->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
  380. style_popup_separator->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
  381. style_popup_separator->set_thickness(MAX(EDSCALE, border_width));
  382. Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine));
  383. style_popup_labeled_separator_left->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
  384. style_popup_labeled_separator_left->set_color(separator_color);
  385. style_popup_labeled_separator_left->set_thickness(MAX(EDSCALE, border_width));
  386. Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine));
  387. style_popup_labeled_separator_right->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
  388. style_popup_labeled_separator_right->set_color(separator_color);
  389. style_popup_labeled_separator_right->set_thickness(MAX(EDSCALE, border_width));
  390. Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size);
  391. // Tabs
  392. const int tab_default_margin_side = 10 * EDSCALE + extra_spacing * EDSCALE;
  393. const int tab_default_margin_vertical = 5 * EDSCALE + extra_spacing * EDSCALE;
  394. Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate();
  395. style_tab_selected->set_border_width_all(border_width);
  396. style_tab_selected->set_border_width(MARGIN_BOTTOM, 0);
  397. style_tab_selected->set_border_color_all(dark_color_3);
  398. style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width);
  399. style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side);
  400. style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side);
  401. style_tab_selected->set_default_margin(MARGIN_BOTTOM, tab_default_margin_vertical);
  402. style_tab_selected->set_default_margin(MARGIN_TOP, tab_default_margin_vertical);
  403. style_tab_selected->set_bg_color(tab_color);
  404. Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate();
  405. style_tab_unselected->set_bg_color(dark_color_1);
  406. style_tab_unselected->set_border_color_all(dark_color_2);
  407. // Editor background
  408. theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size));
  409. // Focus
  410. Ref<StyleBoxFlat> style_focus = style_default->duplicate();
  411. style_focus->set_draw_center(false);
  412. style_focus->set_border_color_all(contrast_color_2);
  413. theme->set_stylebox("Focus", "EditorStyles", style_focus);
  414. // Menu
  415. Ref<StyleBoxFlat> style_menu = style_widget->duplicate();
  416. style_menu->set_draw_center(false);
  417. style_menu->set_border_width_all(0);
  418. theme->set_stylebox("panel", "PanelContainer", style_menu);
  419. theme->set_stylebox("MenuPanel", "EditorStyles", style_menu);
  420. // Script Editor
  421. theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size));
  422. theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0));
  423. // Play button group
  424. theme->set_stylebox("PlayButtonPanel", "EditorStyles", style_empty);
  425. //MenuButton
  426. Ref<StyleBoxFlat> style_menu_hover_border = style_widget->duplicate();
  427. style_menu_hover_border->set_draw_center(false);
  428. style_menu_hover_border->set_border_width_all(0);
  429. style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width);
  430. style_menu_hover_border->set_border_color_all(accent_color);
  431. Ref<StyleBoxFlat> style_menu_hover_bg = style_widget->duplicate();
  432. style_menu_hover_bg->set_border_width_all(0);
  433. style_menu_hover_bg->set_bg_color(dark_color_1);
  434. theme->set_stylebox("normal", "MenuButton", style_menu);
  435. theme->set_stylebox("hover", "MenuButton", style_menu);
  436. theme->set_stylebox("pressed", "MenuButton", style_menu);
  437. theme->set_stylebox("focus", "MenuButton", style_menu);
  438. theme->set_stylebox("disabled", "MenuButton", style_menu);
  439. theme->set_stylebox("normal", "PopupMenu", style_menu);
  440. theme->set_stylebox("hover", "PopupMenu", style_menu_hover_bg);
  441. theme->set_stylebox("pressed", "PopupMenu", style_menu);
  442. theme->set_stylebox("focus", "PopupMenu", style_menu);
  443. theme->set_stylebox("disabled", "PopupMenu", style_menu);
  444. theme->set_stylebox("normal", "ToolButton", style_menu);
  445. theme->set_stylebox("hover", "ToolButton", style_menu);
  446. theme->set_stylebox("pressed", "ToolButton", style_menu);
  447. theme->set_stylebox("focus", "ToolButton", style_menu);
  448. theme->set_stylebox("disabled", "ToolButton", style_menu);
  449. theme->set_color("font_color", "MenuButton", font_color);
  450. theme->set_color("font_color_hover", "MenuButton", font_color_hl);
  451. theme->set_color("font_color", "ToolButton", font_color);
  452. theme->set_color("font_color_hover", "ToolButton", font_color_hl);
  453. theme->set_color("font_color_pressed", "ToolButton", accent_color);
  454. theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border);
  455. // Buttons
  456. theme->set_stylebox("normal", "Button", style_widget);
  457. theme->set_stylebox("hover", "Button", style_widget_hover);
  458. theme->set_stylebox("pressed", "Button", style_widget_pressed);
  459. theme->set_stylebox("focus", "Button", style_widget_focus);
  460. theme->set_stylebox("disabled", "Button", style_widget_disabled);
  461. theme->set_color("font_color", "Button", font_color);
  462. theme->set_color("font_color_hover", "Button", font_color_hl);
  463. theme->set_color("font_color_pressed", "Button", accent_color);
  464. theme->set_color("font_color_disabled", "Button", font_color_disabled);
  465. theme->set_color("icon_color_hover", "Button", font_color_hl);
  466. // make icon color value bigger because icon image is not complete white
  467. theme->set_color("icon_color_pressed", "Button", Color(accent_color.r * 1.15, accent_color.g * 1.15, accent_color.b * 1.15, accent_color.a));
  468. // OptionButton
  469. theme->set_stylebox("normal", "OptionButton", style_widget);
  470. theme->set_stylebox("hover", "OptionButton", style_widget_hover);
  471. theme->set_stylebox("pressed", "OptionButton", style_widget_pressed);
  472. theme->set_stylebox("focus", "OptionButton", style_widget_focus);
  473. theme->set_stylebox("disabled", "OptionButton", style_widget_disabled);
  474. theme->set_color("font_color", "OptionButton", font_color);
  475. theme->set_color("font_color_hover", "OptionButton", font_color_hl);
  476. theme->set_color("font_color_pressed", "OptionButton", accent_color);
  477. theme->set_color("font_color_disabled", "OptionButton", font_color_disabled);
  478. theme->set_color("icon_color_hover", "OptionButton", font_color_hl);
  479. theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons"));
  480. theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE);
  481. theme->set_constant("modulate_arrow", "OptionButton", true);
  482. theme->set_constant("hseparation", "OptionButton", 4 * EDSCALE);
  483. // CheckButton
  484. theme->set_stylebox("normal", "CheckButton", style_menu);
  485. theme->set_stylebox("pressed", "CheckButton", style_menu);
  486. theme->set_stylebox("disabled", "CheckButton", style_menu);
  487. theme->set_stylebox("hover", "CheckButton", style_menu);
  488. theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons"));
  489. theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
  490. theme->set_color("font_color", "CheckButton", font_color);
  491. theme->set_color("font_color_hover", "CheckButton", font_color_hl);
  492. theme->set_color("font_color_pressed", "CheckButton", accent_color);
  493. theme->set_color("font_color_disabled", "CheckButton", font_color_disabled);
  494. theme->set_color("icon_color_hover", "CheckButton", font_color_hl);
  495. theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE);
  496. theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE);
  497. // Checkbox
  498. Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate();
  499. sb_checkbox->set_default_margin(MARGIN_LEFT, default_margin_size * EDSCALE);
  500. sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE);
  501. sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
  502. sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE);
  503. theme->set_stylebox("normal", "CheckBox", sb_checkbox);
  504. theme->set_stylebox("pressed", "CheckBox", sb_checkbox);
  505. theme->set_stylebox("disabled", "CheckBox", sb_checkbox);
  506. theme->set_stylebox("hover", "CheckBox", sb_checkbox);
  507. theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons"));
  508. theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons"));
  509. theme->set_icon("radio_checked", "CheckBox", theme->get_icon("GuiRadioChecked", "EditorIcons"));
  510. theme->set_icon("radio_unchecked", "CheckBox", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
  511. theme->set_color("font_color", "CheckBox", font_color);
  512. theme->set_color("font_color_hover", "CheckBox", font_color_hl);
  513. theme->set_color("font_color_pressed", "CheckBox", accent_color);
  514. theme->set_color("font_color_disabled", "CheckBox", font_color_disabled);
  515. theme->set_color("icon_color_hover", "CheckBox", font_color_hl);
  516. theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE);
  517. theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE);
  518. // PopupMenu
  519. Ref<StyleBoxFlat> style_popup_menu = style_popup;
  520. theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
  521. theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
  522. theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
  523. theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
  524. theme->set_color("font_color", "PopupMenu", font_color);
  525. theme->set_color("font_color_hover", "PopupMenu", font_color_hl);
  526. theme->set_color("font_color_accel", "PopupMenu", font_color_disabled);
  527. theme->set_color("font_color_disabled", "PopupMenu", font_color_disabled);
  528. theme->set_icon("checked", "PopupMenu", theme->get_icon("GuiChecked", "EditorIcons"));
  529. theme->set_icon("unchecked", "PopupMenu", theme->get_icon("GuiUnchecked", "EditorIcons"));
  530. theme->set_icon("radio_checked", "PopupMenu", theme->get_icon("GuiRadioChecked", "EditorIcons"));
  531. theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
  532. theme->set_icon("submenu", "PopupMenu", theme->get_icon("ArrowRight", "EditorIcons"));
  533. theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon("GuiVisibilityHidden", "EditorIcons"));
  534. theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon("GuiVisibilityVisible", "EditorIcons"));
  535. theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
  536. theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
  537. Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1, 2, 0, 0, 0);
  538. sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
  539. sub_inspector_bg->set_border_color(MARGIN_LEFT, accent_color * Color(1, 1, 1, 0.3));
  540. sub_inspector_bg->set_draw_center(true);
  541. theme->set_stylebox("sub_inspector_bg", "Editor", sub_inspector_bg);
  542. theme->set_constant("inspector_margin", "Editor", 8 * EDSCALE);
  543. // Tree & ItemList background
  544. Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate();
  545. style_tree_bg->set_bg_color(dark_color_1);
  546. style_tree_bg->set_border_color_all(dark_color_3);
  547. theme->set_stylebox("bg", "Tree", style_tree_bg);
  548. const Color guide_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.05);
  549. // Tree
  550. theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons"));
  551. theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons"));
  552. theme->set_icon("arrow_up", "Tree", theme->get_icon("GuiTreeArrowUp", "EditorIcons"));
  553. theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
  554. theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
  555. theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons"));
  556. theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons"));
  557. theme->set_icon("select_option", "Tree", theme->get_icon("GuiTreeOption", "EditorIcons"));
  558. theme->set_stylebox("bg_focus", "Tree", style_focus);
  559. theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
  560. theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
  561. theme->set_stylebox("custom_button_hover", "Tree", style_widget);
  562. theme->set_color("custom_button_font_highlight", "Tree", font_color_hl);
  563. theme->set_color("font_color", "Tree", font_color);
  564. theme->set_color("font_color_selected", "Tree", mono_color);
  565. theme->set_color("title_button_color", "Tree", font_color);
  566. theme->set_color("guide_color", "Tree", guide_color);
  567. theme->set_color("drop_position_color", "Tree", accent_color);
  568. theme->set_constant("vseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
  569. theme->set_constant("hseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
  570. theme->set_constant("guide_width", "Tree", border_width);
  571. theme->set_constant("item_margin", "Tree", 3 * default_margin_size * EDSCALE);
  572. theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
  573. theme->set_constant("draw_relationship_lines", "Tree", 0);
  574. theme->set_constant("scroll_border", "Tree", default_margin_size * EDSCALE);
  575. theme->set_constant("scroll_speed", "Tree", 12);
  576. Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
  577. style_tree_btn->set_bg_color(contrast_color_1);
  578. style_tree_btn->set_border_width_all(0);
  579. theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
  580. Ref<StyleBoxFlat> style_tree_focus = style_default->duplicate();
  581. style_tree_focus->set_bg_color(highlight_color);
  582. style_tree_focus->set_border_width_all(0);
  583. theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
  584. Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
  585. theme->set_stylebox("selected", "Tree", style_tree_selected);
  586. Ref<StyleBoxFlat> style_tree_cursor = style_default->duplicate();
  587. style_tree_cursor->set_draw_center(false);
  588. style_tree_cursor->set_border_width_all(border_width);
  589. style_tree_cursor->set_border_color_all(contrast_color_1);
  590. Ref<StyleBoxFlat> style_tree_title = style_default->duplicate();
  591. style_tree_title->set_bg_color(dark_color_3);
  592. style_tree_title->set_border_width_all(0);
  593. theme->set_stylebox("cursor", "Tree", style_tree_cursor);
  594. theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
  595. theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
  596. theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
  597. theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
  598. Color prop_category_color = dark_color_1.linear_interpolate(mono_color, 0.12);
  599. Color prop_section_color = dark_color_1.linear_interpolate(mono_color, 0.09);
  600. Color prop_subsection_color = dark_color_1.linear_interpolate(mono_color, 0.06);
  601. theme->set_color("prop_category", "Editor", prop_category_color);
  602. theme->set_color("prop_section", "Editor", prop_section_color);
  603. theme->set_color("prop_subsection", "Editor", prop_subsection_color);
  604. theme->set_color("drop_position_color", "Tree", accent_color);
  605. // ItemList
  606. Ref<StyleBoxFlat> style_itemlist_bg = style_default->duplicate();
  607. style_itemlist_bg->set_bg_color(dark_color_1);
  608. style_itemlist_bg->set_border_width_all(border_width);
  609. style_itemlist_bg->set_border_color_all(dark_color_3);
  610. Ref<StyleBoxFlat> style_itemlist_cursor = style_default->duplicate();
  611. style_itemlist_cursor->set_draw_center(false);
  612. style_itemlist_cursor->set_border_width_all(border_width);
  613. style_itemlist_cursor->set_border_color_all(highlight_color);
  614. theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
  615. theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);
  616. theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);
  617. theme->set_stylebox("selected", "ItemList", style_tree_selected);
  618. theme->set_stylebox("bg_focus", "ItemList", style_focus);
  619. theme->set_stylebox("bg", "ItemList", style_itemlist_bg);
  620. theme->set_color("font_color", "ItemList", font_color);
  621. theme->set_color("font_color_selected", "ItemList", mono_color);
  622. theme->set_color("guide_color", "ItemList", guide_color);
  623. theme->set_constant("vseparation", "ItemList", 3 * EDSCALE);
  624. theme->set_constant("hseparation", "ItemList", 3 * EDSCALE);
  625. theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE);
  626. theme->set_constant("line_separation", "ItemList", 3 * EDSCALE);
  627. // Tabs & TabContainer
  628. theme->set_stylebox("tab_fg", "TabContainer", style_tab_selected);
  629. theme->set_stylebox("tab_bg", "TabContainer", style_tab_unselected);
  630. theme->set_stylebox("tab_fg", "Tabs", style_tab_selected);
  631. theme->set_stylebox("tab_bg", "Tabs", style_tab_unselected);
  632. theme->set_color("font_color_fg", "TabContainer", font_color);
  633. theme->set_color("font_color_bg", "TabContainer", font_color_disabled);
  634. theme->set_color("font_color_fg", "Tabs", font_color);
  635. theme->set_color("font_color_bg", "Tabs", font_color_disabled);
  636. theme->set_icon("menu", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
  637. theme->set_icon("menu_hl", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
  638. theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected);
  639. theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected);
  640. theme->set_icon("close", "Tabs", theme->get_icon("GuiClose", "EditorIcons"));
  641. theme->set_stylebox("button_pressed", "Tabs", style_menu);
  642. theme->set_stylebox("button", "Tabs", style_menu);
  643. theme->set_icon("increment", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  644. theme->set_icon("decrement", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  645. theme->set_icon("increment", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  646. theme->set_icon("decrement", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  647. theme->set_icon("increment_highlight", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  648. theme->set_icon("decrement_highlight", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  649. theme->set_icon("increment_highlight", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  650. theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  651. theme->set_constant("hseparation", "Tabs", 4 * EDSCALE);
  652. // Content of each tab
  653. Ref<StyleBoxFlat> style_content_panel = style_default->duplicate();
  654. style_content_panel->set_border_color_all(dark_color_3);
  655. style_content_panel->set_border_width_all(border_width);
  656. // compensate the border
  657. style_content_panel->set_default_margin(MARGIN_TOP, margin_size_extra * EDSCALE);
  658. style_content_panel->set_default_margin(MARGIN_RIGHT, margin_size_extra * EDSCALE);
  659. style_content_panel->set_default_margin(MARGIN_BOTTOM, margin_size_extra * EDSCALE);
  660. style_content_panel->set_default_margin(MARGIN_LEFT, margin_size_extra * EDSCALE);
  661. // this is the stylebox used in 3d and 2d viewports (no borders)
  662. Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate();
  663. style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width * 2);
  664. style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
  665. style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width * 2);
  666. style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width * 2);
  667. theme->set_stylebox("panel", "TabContainer", style_content_panel);
  668. theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
  669. // Separators
  670. theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width));
  671. theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, 0, true));
  672. // Debugger
  673. Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate();
  674. style_panel_debugger->set_border_width(MARGIN_BOTTOM, 0);
  675. theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger);
  676. theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_selected);
  677. theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_unselected);
  678. Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate();
  679. int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height() + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP);
  680. style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset);
  681. theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top);
  682. // LineEdit
  683. theme->set_stylebox("normal", "LineEdit", style_widget);
  684. theme->set_stylebox("focus", "LineEdit", style_widget_focus);
  685. theme->set_stylebox("read_only", "LineEdit", style_widget_disabled);
  686. theme->set_color("read_only", "LineEdit", font_color_disabled);
  687. theme->set_color("font_color", "LineEdit", font_color);
  688. theme->set_color("cursor_color", "LineEdit", font_color);
  689. theme->set_color("selection_color", "LineEdit", font_color_selection);
  690. theme->set_color("clear_button_color", "LineEdit", font_color);
  691. theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);
  692. // TextEdit
  693. theme->set_stylebox("normal", "TextEdit", style_widget);
  694. theme->set_stylebox("focus", "TextEdit", style_widget_hover);
  695. theme->set_stylebox("read_only", "TextEdit", style_widget_disabled);
  696. theme->set_constant("side_margin", "TabContainer", 0);
  697. theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons"));
  698. theme->set_color("font_color", "TextEdit", font_color);
  699. theme->set_color("caret_color", "TextEdit", highlight_color);
  700. theme->set_color("selection_color", "TextEdit", font_color_selection);
  701. // H/VSplitContainer
  702. theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1));
  703. theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon("GuiHsplitBg", "EditorIcons"), 1, 1, 1, 1));
  704. theme->set_icon("grabber", "VSplitContainer", theme->get_icon("GuiVsplitter", "EditorIcons"));
  705. theme->set_icon("grabber", "HSplitContainer", theme->get_icon("GuiHsplitter", "EditorIcons"));
  706. theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE);
  707. theme->set_constant("separation", "VSplitContainer", default_margin_size * 2 * EDSCALE);
  708. // Containers
  709. theme->set_constant("separation", "BoxContainer", default_margin_size * EDSCALE);
  710. theme->set_constant("separation", "HBoxContainer", default_margin_size * EDSCALE);
  711. theme->set_constant("separation", "VBoxContainer", default_margin_size * EDSCALE);
  712. theme->set_constant("margin_left", "MarginContainer", 0);
  713. theme->set_constant("margin_top", "MarginContainer", 0);
  714. theme->set_constant("margin_right", "MarginContainer", 0);
  715. theme->set_constant("margin_bottom", "MarginContainer", 0);
  716. theme->set_constant("hseparation", "GridContainer", default_margin_size * EDSCALE);
  717. theme->set_constant("vseparation", "GridContainer", default_margin_size * EDSCALE);
  718. // WindowDialog
  719. Ref<StyleBoxFlat> style_window = style_popup->duplicate();
  720. style_window->set_border_color_all(tab_color);
  721. style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  722. style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE);
  723. theme->set_stylebox("panel", "WindowDialog", style_window);
  724. theme->set_color("title_color", "WindowDialog", font_color);
  725. theme->set_icon("close", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
  726. theme->set_icon("close_highlight", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
  727. theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE);
  728. theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE);
  729. theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE);
  730. theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts"));
  731. // complex window, for now only Editor settings and Project settings
  732. Ref<StyleBoxFlat> style_complex_window = style_window->duplicate();
  733. style_complex_window->set_bg_color(dark_color_2);
  734. style_complex_window->set_border_color_all(highlight_tabs ? tab_color : dark_color_2);
  735. theme->set_stylebox("panel", "EditorSettingsDialog", style_complex_window);
  736. theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window);
  737. theme->set_stylebox("panel", "EditorAbout", style_complex_window);
  738. // HScrollBar
  739. Ref<Texture> empty_icon = memnew(ImageTexture);
  740. theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  741. theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  742. theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  743. theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
  744. theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  745. theme->set_icon("increment", "HScrollBar", empty_icon);
  746. theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
  747. theme->set_icon("decrement", "HScrollBar", empty_icon);
  748. theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
  749. // VScrollBar
  750. theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  751. theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  752. theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  753. theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
  754. theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  755. theme->set_icon("increment", "VScrollBar", empty_icon);
  756. theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
  757. theme->set_icon("decrement", "VScrollBar", empty_icon);
  758. theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
  759. // HSlider
  760. theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
  761. theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
  762. theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2));
  763. theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
  764. // VSlider
  765. theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
  766. theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
  767. theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0));
  768. theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
  769. //RichTextLabel
  770. theme->set_color("default_color", "RichTextLabel", font_color);
  771. theme->set_color("font_color_shadow", "RichTextLabel", Color(0, 0, 0, 0));
  772. theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);
  773. theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);
  774. theme->set_constant("shadow_as_outline", "RichTextLabel", 0 * EDSCALE);
  775. theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
  776. theme->set_stylebox("normal", "RichTextLabel", style_tree_bg);
  777. theme->set_color("headline_color", "EditorHelp", mono_color);
  778. // Panel
  779. theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4));
  780. // Label
  781. theme->set_stylebox("normal", "Label", style_empty);
  782. theme->set_color("font_color", "Label", font_color);
  783. theme->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
  784. theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);
  785. theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);
  786. theme->set_constant("shadow_as_outline", "Label", 0 * EDSCALE);
  787. theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
  788. // LinkButton
  789. theme->set_stylebox("focus", "LinkButton", style_empty);
  790. theme->set_color("font_color", "LinkButton", font_color);
  791. // TooltipPanel
  792. Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate();
  793. float v = MAX(border_size * EDSCALE, 1.0);
  794. style_tooltip->set_default_margin(MARGIN_LEFT, v);
  795. style_tooltip->set_default_margin(MARGIN_TOP, v);
  796. style_tooltip->set_default_margin(MARGIN_RIGHT, v);
  797. style_tooltip->set_default_margin(MARGIN_BOTTOM, v);
  798. style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9));
  799. style_tooltip->set_border_width_all(border_width);
  800. style_tooltip->set_border_color_all(mono_color);
  801. theme->set_color("font_color", "TooltipLabel", font_color.inverted());
  802. theme->set_color("font_color_shadow", "TooltipLabel", mono_color.inverted() * Color(1, 1, 1, 0.1));
  803. theme->set_stylebox("panel", "TooltipPanel", style_tooltip);
  804. // PopupPanel
  805. theme->set_stylebox("panel", "PopupPanel", style_popup);
  806. // SpinBox
  807. theme->set_icon("updown", "SpinBox", theme->get_icon("GuiSpinboxUpdown", "EditorIcons"));
  808. // ProgressBar
  809. theme->set_stylebox("bg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressBar", "EditorIcons"), 4, 4, 4, 4, 0, 0, 0, 0));
  810. theme->set_stylebox("fg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressFill", "EditorIcons"), 6, 6, 6, 6, 2, 1, 2, 1));
  811. theme->set_color("font_color", "ProgressBar", font_color);
  812. // GraphEdit
  813. theme->set_stylebox("bg", "GraphEdit", style_tree_bg);
  814. theme->set_color("grid_major", "GraphEdit", Color(1.0, 1.0, 1.0, 0.15));
  815. theme->set_color("grid_minor", "GraphEdit", Color(1.0, 1.0, 1.0, 0.07));
  816. theme->set_color("activity", "GraphEdit", accent_color);
  817. theme->set_icon("minus", "GraphEdit", theme->get_icon("ZoomLess", "EditorIcons"));
  818. theme->set_icon("more", "GraphEdit", theme->get_icon("ZoomMore", "EditorIcons"));
  819. theme->set_icon("reset", "GraphEdit", theme->get_icon("ZoomReset", "EditorIcons"));
  820. theme->set_icon("snap", "GraphEdit", theme->get_icon("SnapGrid", "EditorIcons"));
  821. theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE);
  822. theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE);
  823. // GraphNode
  824. const float mv = dark_theme ? 0.0 : 1.0;
  825. const float mv2 = 1.0 - mv;
  826. const int gn_margin_side = 28;
  827. Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
  828. graphsb->set_border_width_all(border_width);
  829. graphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  830. Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
  831. graphsbselected->set_border_width_all(border_width);
  832. graphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
  833. graphsbselected->set_shadow_size(8 * EDSCALE);
  834. graphsbselected->set_shadow_color(shadow_color);
  835. Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5);
  836. graphsbcomment->set_border_width_all(border_width);
  837. graphsbcomment->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  838. Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5);
  839. graphsbcommentselected->set_border_width_all(border_width);
  840. graphsbcommentselected->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  841. Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate();
  842. graphsbbreakpoint->set_draw_center(false);
  843. graphsbbreakpoint->set_border_color_all(warning_color);
  844. graphsbbreakpoint->set_shadow_color(warning_color * Color(1.0, 1.0, 1.0, 0.1));
  845. Ref<StyleBoxFlat> graphsbposition = graphsbselected->duplicate();
  846. graphsbposition->set_draw_center(false);
  847. graphsbposition->set_border_color_all(error_color);
  848. graphsbposition->set_shadow_color(error_color * Color(1.0, 1.0, 1.0, 0.2));
  849. Ref<StyleBoxFlat> smgraphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
  850. smgraphsb->set_border_width_all(border_width);
  851. smgraphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  852. Ref<StyleBoxFlat> smgraphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
  853. smgraphsbselected->set_border_width_all(border_width);
  854. smgraphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
  855. smgraphsbselected->set_shadow_size(8 * EDSCALE);
  856. smgraphsbselected->set_shadow_color(shadow_color);
  857. if (use_gn_headers) {
  858. graphsb->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  859. graphsbselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  860. graphsbcomment->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  861. graphsbcommentselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  862. }
  863. theme->set_stylebox("frame", "GraphNode", graphsb);
  864. theme->set_stylebox("selectedframe", "GraphNode", graphsbselected);
  865. theme->set_stylebox("comment", "GraphNode", graphsbcomment);
  866. theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
  867. theme->set_stylebox("breakpoint", "GraphNode", graphsbbreakpoint);
  868. theme->set_stylebox("position", "GraphNode", graphsbposition);
  869. theme->set_stylebox("state_machine_frame", "GraphNode", smgraphsb);
  870. theme->set_stylebox("state_machine_selectedframe", "GraphNode", smgraphsbselected);
  871. Color default_node_color = Color(mv2, mv2, mv2);
  872. theme->set_color("title_color", "GraphNode", default_node_color);
  873. default_node_color.a = 0.7;
  874. theme->set_color("close_color", "GraphNode", default_node_color);
  875. theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE);
  876. theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE);
  877. theme->set_constant("title_offset", "GraphNode", 20 * EDSCALE);
  878. theme->set_constant("close_h_offset", "GraphNode", 20 * EDSCALE);
  879. theme->set_constant("close_offset", "GraphNode", 20 * EDSCALE);
  880. theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
  881. theme->set_icon("close", "GraphNode", theme->get_icon("GuiCloseCustomizable", "EditorIcons"));
  882. theme->set_icon("resizer", "GraphNode", theme->get_icon("GuiResizer", "EditorIcons"));
  883. theme->set_icon("port", "GraphNode", theme->get_icon("GuiGraphNodePort", "EditorIcons"));
  884. // GridContainer
  885. theme->set_constant("vseperation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE);
  886. // FileDialog
  887. theme->set_icon("folder", "FileDialog", theme->get_icon("Folder", "EditorIcons"));
  888. theme->set_color("files_disabled", "FileDialog", font_color_disabled);
  889. // color picker
  890. theme->set_constant("margin", "ColorPicker", popup_margin_size);
  891. theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
  892. theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
  893. theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
  894. theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
  895. theme->set_icon("screen_picker", "ColorPicker", theme->get_icon("ColorPick", "EditorIcons"));
  896. theme->set_icon("add_preset", "ColorPicker", theme->get_icon("Add", "EditorIcons"));
  897. theme->set_icon("preset_bg", "ColorPicker", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
  898. theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
  899. // Information on 3D viewport
  900. Ref<StyleBoxFlat> style_info_3d_viewport = style_default->duplicate();
  901. style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
  902. style_info_3d_viewport->set_border_width_all(0);
  903. theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport);
  904. // adaptive script theme constants
  905. // for comments and elements with lower relevance
  906. const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5);
  907. const float mono_value = mono_color.r;
  908. const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07);
  909. const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14);
  910. const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.7);
  911. // editor main color
  912. const Color main_color = Color::html(dark_theme ? "#57b3ff" : "#0480ff");
  913. const Color symbol_color = Color::html("#5792ff").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  914. const Color keyword_color = Color::html("#ff7185");
  915. const Color basetype_color = Color::html(dark_theme ? "#42ffc2" : "#00c161");
  916. const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5);
  917. const Color comment_color = dim_color;
  918. const Color string_color = Color::html(dark_theme ? "#ffd942" : "#ffd118").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  919. const Color te_background_color = dark_theme ? background_color : base_color;
  920. const Color completion_background_color = dark_theme ? base_color : background_color;
  921. const Color completion_selected_color = alpha1;
  922. const Color completion_existing_color = alpha2;
  923. const Color completion_scroll_color = alpha1;
  924. const Color completion_font_color = font_color;
  925. const Color text_color = font_color;
  926. const Color line_number_color = dim_color;
  927. const Color safe_line_number_color = dim_color * Color(1, 1.2, 1, 1.5);
  928. const Color caret_color = mono_color;
  929. const Color caret_background_color = mono_color.inverted();
  930. const Color text_selected_color = dark_color_3;
  931. const Color selection_color = alpha2;
  932. const Color brace_mismatch_color = error_color;
  933. const Color current_line_color = alpha1;
  934. const Color line_length_guideline_color = dark_theme ? base_color : background_color;
  935. const Color word_highlighted_color = alpha1;
  936. const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  937. const Color function_color = main_color;
  938. const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6);
  939. const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3);
  940. const Color breakpoint_color = error_color;
  941. const Color code_folding_color = alpha3;
  942. const Color search_result_color = alpha1;
  943. const Color search_result_border_color = alpha3;
  944. EditorSettings *setting = EditorSettings::get_singleton();
  945. String text_editor_color_theme = setting->get("text_editor/theme/color_theme");
  946. if (text_editor_color_theme == "Adaptive") {
  947. setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true);
  948. setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true);
  949. setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true);
  950. setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true);
  951. setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true);
  952. setting->set_initial_value("text_editor/highlighting/string_color", string_color, true);
  953. setting->set_initial_value("text_editor/highlighting/background_color", te_background_color, true);
  954. setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true);
  955. setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true);
  956. setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true);
  957. setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true);
  958. setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
  959. setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
  960. setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
  961. setting->set_initial_value("text_editor/highlighting/safe_line_number_color", safe_line_number_color, true);
  962. setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
  963. setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
  964. setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
  965. setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true);
  966. setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true);
  967. setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true);
  968. setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true);
  969. setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true);
  970. setting->set_initial_value("text_editor/highlighting/number_color", number_color, true);
  971. setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
  972. setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
  973. setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
  974. setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
  975. setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
  976. setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
  977. setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
  978. } else if (text_editor_color_theme == "Default") {
  979. setting->load_text_editor_theme();
  980. }
  981. return theme;
  982. }
  983. Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) {
  984. Ref<Theme> theme;
  985. String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme");
  986. if (custom_theme != "") {
  987. theme = ResourceLoader::load(custom_theme);
  988. }
  989. if (!theme.is_valid()) {
  990. theme = create_editor_theme(p_theme);
  991. }
  992. return theme;
  993. }