editor_themes.cpp 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  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_GET("interface/theme/accent_color");
  210. Color base_color = EDITOR_GET("interface/theme/base_color");
  211. float contrast = EDITOR_GET("interface/theme/contrast");
  212. float relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
  213. String preset = EDITOR_GET("interface/theme/preset");
  214. bool highlight_tabs = EDITOR_GET("interface/theme/highlight_tabs");
  215. int border_size = EDITOR_GET("interface/theme/border_size");
  216. bool use_gn_headers = EDITOR_GET("interface/theme/use_graph_node_headers");
  217. Color preset_accent_color;
  218. Color preset_base_color;
  219. float preset_contrast = 0;
  220. // Please, use alphabet order if you've added new theme here(After "Default" and "Custom")
  221. if (preset == "Default") {
  222. preset_accent_color = Color::html("#699ce8");
  223. preset_base_color = Color::html("#323b4f");
  224. preset_contrast = default_contrast;
  225. } else if (preset == "Custom") {
  226. accent_color = EDITOR_GET("interface/theme/accent_color");
  227. base_color = EDITOR_GET("interface/theme/base_color");
  228. contrast = EDITOR_GET("interface/theme/contrast");
  229. } else if (preset == "Alien") {
  230. preset_accent_color = Color::html("#1bfe99");
  231. preset_base_color = Color::html("#2f373f");
  232. preset_contrast = 0.25;
  233. } else if (preset == "Arc") {
  234. preset_accent_color = Color::html("#5294e2");
  235. preset_base_color = Color::html("#383c4a");
  236. preset_contrast = 0.25;
  237. } else if (preset == "Godot 2") {
  238. preset_accent_color = Color::html("#86ace2");
  239. preset_base_color = Color::html("#3C3A44");
  240. preset_contrast = 0.25;
  241. } else if (preset == "Grey") {
  242. preset_accent_color = Color::html("#b8e4ff");
  243. preset_base_color = Color::html("#3d3d3d");
  244. preset_contrast = 0.2;
  245. } else if (preset == "Light") {
  246. preset_accent_color = Color::html("#2070ff");
  247. preset_base_color = Color::html("#ffffff");
  248. preset_contrast = 0.08;
  249. } else if (preset == "Solarized (Dark)") {
  250. preset_accent_color = Color::html("#268bd2");
  251. preset_base_color = Color::html("#073642");
  252. preset_contrast = 0.23;
  253. } else if (preset == "Solarized (Light)") {
  254. preset_accent_color = Color::html("#268bd2");
  255. preset_base_color = Color::html("#fdf6e3");
  256. preset_contrast = 0.06;
  257. } else { // Default
  258. preset_accent_color = Color::html("#699ce8");
  259. preset_base_color = Color::html("#323b4f");
  260. preset_contrast = default_contrast;
  261. }
  262. if (preset != "Custom") {
  263. accent_color = preset_accent_color;
  264. base_color = preset_base_color;
  265. contrast = preset_contrast;
  266. EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", accent_color);
  267. EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", base_color);
  268. EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", contrast);
  269. }
  270. EditorSettings::get_singleton()->set_manually("interface/theme/preset", preset);
  271. EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", accent_color);
  272. EditorSettings::get_singleton()->set_manually("interface/theme/base_color", base_color);
  273. EditorSettings::get_singleton()->set_manually("interface/theme/contrast", contrast);
  274. //Colors
  275. bool dark_theme = EditorSettings::get_singleton()->is_dark_theme();
  276. const Color dark_color_1 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast);
  277. const Color dark_color_2 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 1.5);
  278. const Color dark_color_3 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 2);
  279. const Color background_color = dark_color_2;
  280. // white (dark theme) or black (light theme), will be used to generate the rest of the colors
  281. const Color mono_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
  282. const Color contrast_color_1 = base_color.linear_interpolate(mono_color, MAX(contrast, default_contrast));
  283. const Color contrast_color_2 = base_color.linear_interpolate(mono_color, MAX(contrast * 1.5, default_contrast * 1.5));
  284. const Color font_color = mono_color.linear_interpolate(base_color, 0.25);
  285. const Color font_color_hl = mono_color.linear_interpolate(base_color, 0.15);
  286. const Color font_color_disabled = Color(mono_color.r, mono_color.g, mono_color.b, 0.3);
  287. const Color font_color_selection = accent_color * Color(1, 1, 1, 0.4);
  288. const Color color_disabled = mono_color.inverted().linear_interpolate(base_color, 0.7);
  289. const Color color_disabled_bg = mono_color.inverted().linear_interpolate(base_color, 0.9);
  290. const Color separator_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.1);
  291. const Color highlight_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.2);
  292. theme->set_color("accent_color", "Editor", accent_color);
  293. theme->set_color("highlight_color", "Editor", highlight_color);
  294. theme->set_color("base_color", "Editor", base_color);
  295. theme->set_color("dark_color_1", "Editor", dark_color_1);
  296. theme->set_color("dark_color_2", "Editor", dark_color_2);
  297. theme->set_color("dark_color_3", "Editor", dark_color_3);
  298. theme->set_color("contrast_color_1", "Editor", contrast_color_1);
  299. theme->set_color("contrast_color_2", "Editor", contrast_color_2);
  300. theme->set_color("font_color", "Editor", font_color);
  301. theme->set_color("highlighted_font_color", "Editor", font_color_hl);
  302. theme->set_color("disabled_font_color", "Editor", font_color_disabled);
  303. theme->set_color("mono_color", "Editor", mono_color);
  304. Color success_color = Color(0.45, 0.95, 0.5);
  305. Color warning_color = Color(1, 0.87, 0.4);
  306. Color error_color = Color(1, 0.47, 0.42);
  307. Color property_color = font_color.linear_interpolate(Color(0.5, 0.5, 0.5), 0.5);
  308. if (!dark_theme) {
  309. // Darken some colors to be readable on a light background
  310. success_color = success_color.linear_interpolate(mono_color, 0.35);
  311. warning_color = warning_color.linear_interpolate(mono_color, 0.35);
  312. error_color = error_color.linear_interpolate(mono_color, 0.25);
  313. }
  314. theme->set_color("success_color", "Editor", success_color);
  315. theme->set_color("warning_color", "Editor", warning_color);
  316. theme->set_color("error_color", "Editor", error_color);
  317. theme->set_color("property_color", "Editor", property_color);
  318. const int thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
  319. theme->set_constant("scale", "Editor", EDSCALE);
  320. theme->set_constant("thumb_size", "Editor", thumb_size);
  321. theme->set_constant("dark_theme", "Editor", dark_theme);
  322. //Register icons + font
  323. // the resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons
  324. if (p_theme != NULL && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme) {
  325. // register already generated icons
  326. for (int i = 0; i < editor_icons_count; i++) {
  327. theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons"));
  328. }
  329. } else {
  330. editor_register_and_generate_icons(theme, dark_theme, thumb_size);
  331. }
  332. // thumbnail size has changed, so we regenerate the medium sizes
  333. if (p_theme != NULL && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) {
  334. editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true);
  335. }
  336. editor_register_fonts(theme);
  337. // Highlighted tabs and border width
  338. Color tab_color = highlight_tabs ? base_color.linear_interpolate(font_color, contrast) : base_color;
  339. const int border_width = CLAMP(border_size, 0, 3) * EDSCALE;
  340. const int default_margin_size = 4;
  341. const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 3);
  342. // styleboxes
  343. // this is the most commonly used stylebox, variations should be made as duplicate of this
  344. Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size);
  345. style_default->set_border_width_all(border_width);
  346. style_default->set_border_color_all(base_color);
  347. style_default->set_draw_center(true);
  348. // Button and widgets
  349. const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing");
  350. Ref<StyleBoxFlat> style_widget = style_default->duplicate();
  351. style_widget->set_default_margin(MARGIN_LEFT, (extra_spacing + 6) * EDSCALE);
  352. style_widget->set_default_margin(MARGIN_TOP, (extra_spacing + default_margin_size) * EDSCALE);
  353. style_widget->set_default_margin(MARGIN_RIGHT, (extra_spacing + 6) * EDSCALE);
  354. style_widget->set_default_margin(MARGIN_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE);
  355. style_widget->set_bg_color(dark_color_1);
  356. style_widget->set_border_color_all(dark_color_2);
  357. Ref<StyleBoxFlat> style_widget_disabled = style_widget->duplicate();
  358. style_widget_disabled->set_border_color_all(color_disabled);
  359. style_widget_disabled->set_bg_color(color_disabled_bg);
  360. Ref<StyleBoxFlat> style_widget_focus = style_widget->duplicate();
  361. style_widget_focus->set_border_color_all(accent_color);
  362. Ref<StyleBoxFlat> style_widget_pressed = style_widget->duplicate();
  363. style_widget_pressed->set_border_color_all(accent_color);
  364. Ref<StyleBoxFlat> style_widget_hover = style_widget->duplicate();
  365. style_widget_hover->set_border_color_all(contrast_color_1);
  366. // style for windows, popups, etc..
  367. Ref<StyleBoxFlat> style_popup = style_default->duplicate();
  368. const int popup_margin_size = default_margin_size * EDSCALE * 2;
  369. style_popup->set_default_margin(MARGIN_LEFT, popup_margin_size);
  370. style_popup->set_default_margin(MARGIN_TOP, popup_margin_size);
  371. style_popup->set_default_margin(MARGIN_RIGHT, popup_margin_size);
  372. style_popup->set_default_margin(MARGIN_BOTTOM, popup_margin_size);
  373. style_popup->set_border_color_all(contrast_color_1);
  374. style_popup->set_border_width_all(MAX(EDSCALE, border_width));
  375. const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1);
  376. style_popup->set_shadow_color(shadow_color);
  377. style_popup->set_shadow_size(4 * EDSCALE);
  378. Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine));
  379. style_popup_separator->set_color(separator_color);
  380. style_popup_separator->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
  381. style_popup_separator->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
  382. style_popup_separator->set_thickness(MAX(EDSCALE, border_width));
  383. Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine));
  384. style_popup_labeled_separator_left->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
  385. style_popup_labeled_separator_left->set_color(separator_color);
  386. style_popup_labeled_separator_left->set_thickness(MAX(EDSCALE, border_width));
  387. Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine));
  388. style_popup_labeled_separator_right->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
  389. style_popup_labeled_separator_right->set_color(separator_color);
  390. style_popup_labeled_separator_right->set_thickness(MAX(EDSCALE, border_width));
  391. Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size);
  392. // Tabs
  393. const int tab_default_margin_side = 10 * EDSCALE + extra_spacing * EDSCALE;
  394. const int tab_default_margin_vertical = 5 * EDSCALE + extra_spacing * EDSCALE;
  395. Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate();
  396. style_tab_selected->set_border_width_all(border_width);
  397. style_tab_selected->set_border_width(MARGIN_BOTTOM, 0);
  398. style_tab_selected->set_border_color_all(dark_color_3);
  399. style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width);
  400. style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side);
  401. style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side);
  402. style_tab_selected->set_default_margin(MARGIN_BOTTOM, tab_default_margin_vertical);
  403. style_tab_selected->set_default_margin(MARGIN_TOP, tab_default_margin_vertical);
  404. style_tab_selected->set_bg_color(tab_color);
  405. Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate();
  406. style_tab_unselected->set_bg_color(dark_color_1);
  407. style_tab_unselected->set_border_color_all(dark_color_2);
  408. Ref<StyleBoxFlat> style_tab_disabled = style_tab_selected->duplicate();
  409. style_tab_disabled->set_bg_color(color_disabled_bg);
  410. style_tab_disabled->set_border_color_all(color_disabled);
  411. // Editor background
  412. theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size));
  413. // Focus
  414. Ref<StyleBoxFlat> style_focus = style_default->duplicate();
  415. style_focus->set_draw_center(false);
  416. style_focus->set_border_color_all(contrast_color_2);
  417. theme->set_stylebox("Focus", "EditorStyles", style_focus);
  418. // Menu
  419. Ref<StyleBoxFlat> style_menu = style_widget->duplicate();
  420. style_menu->set_draw_center(false);
  421. style_menu->set_border_width_all(0);
  422. theme->set_stylebox("panel", "PanelContainer", style_menu);
  423. theme->set_stylebox("MenuPanel", "EditorStyles", style_menu);
  424. // Script Editor
  425. theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size));
  426. theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0));
  427. // Play button group
  428. theme->set_stylebox("PlayButtonPanel", "EditorStyles", style_empty);
  429. //MenuButton
  430. Ref<StyleBoxFlat> style_menu_hover_border = style_widget->duplicate();
  431. style_menu_hover_border->set_draw_center(false);
  432. style_menu_hover_border->set_border_width_all(0);
  433. style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width);
  434. style_menu_hover_border->set_border_color_all(accent_color);
  435. Ref<StyleBoxFlat> style_menu_hover_bg = style_widget->duplicate();
  436. style_menu_hover_bg->set_border_width_all(0);
  437. style_menu_hover_bg->set_bg_color(dark_color_1);
  438. theme->set_stylebox("normal", "MenuButton", style_menu);
  439. theme->set_stylebox("hover", "MenuButton", style_menu);
  440. theme->set_stylebox("pressed", "MenuButton", style_menu);
  441. theme->set_stylebox("focus", "MenuButton", style_menu);
  442. theme->set_stylebox("disabled", "MenuButton", style_menu);
  443. theme->set_stylebox("normal", "PopupMenu", style_menu);
  444. theme->set_stylebox("hover", "PopupMenu", style_menu_hover_bg);
  445. theme->set_stylebox("pressed", "PopupMenu", style_menu);
  446. theme->set_stylebox("focus", "PopupMenu", style_menu);
  447. theme->set_stylebox("disabled", "PopupMenu", style_menu);
  448. theme->set_stylebox("normal", "ToolButton", style_menu);
  449. theme->set_stylebox("hover", "ToolButton", style_menu);
  450. theme->set_stylebox("pressed", "ToolButton", style_menu);
  451. theme->set_stylebox("focus", "ToolButton", style_menu);
  452. theme->set_stylebox("disabled", "ToolButton", style_menu);
  453. theme->set_color("font_color", "MenuButton", font_color);
  454. theme->set_color("font_color_hover", "MenuButton", font_color_hl);
  455. theme->set_color("font_color", "ToolButton", font_color);
  456. theme->set_color("font_color_hover", "ToolButton", font_color_hl);
  457. theme->set_color("font_color_pressed", "ToolButton", accent_color);
  458. theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border);
  459. // Buttons
  460. theme->set_stylebox("normal", "Button", style_widget);
  461. theme->set_stylebox("hover", "Button", style_widget_hover);
  462. theme->set_stylebox("pressed", "Button", style_widget_pressed);
  463. theme->set_stylebox("focus", "Button", style_widget_focus);
  464. theme->set_stylebox("disabled", "Button", style_widget_disabled);
  465. theme->set_color("font_color", "Button", font_color);
  466. theme->set_color("font_color_hover", "Button", font_color_hl);
  467. theme->set_color("font_color_pressed", "Button", accent_color);
  468. theme->set_color("font_color_disabled", "Button", font_color_disabled);
  469. theme->set_color("icon_color_hover", "Button", font_color_hl);
  470. // make icon color value bigger because icon image is not complete white
  471. 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));
  472. // OptionButton
  473. theme->set_stylebox("normal", "OptionButton", style_widget);
  474. theme->set_stylebox("hover", "OptionButton", style_widget_hover);
  475. theme->set_stylebox("pressed", "OptionButton", style_widget_pressed);
  476. theme->set_stylebox("focus", "OptionButton", style_widget_focus);
  477. theme->set_stylebox("disabled", "OptionButton", style_widget_disabled);
  478. theme->set_color("font_color", "OptionButton", font_color);
  479. theme->set_color("font_color_hover", "OptionButton", font_color_hl);
  480. theme->set_color("font_color_pressed", "OptionButton", accent_color);
  481. theme->set_color("font_color_disabled", "OptionButton", font_color_disabled);
  482. theme->set_color("icon_color_hover", "OptionButton", font_color_hl);
  483. theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons"));
  484. theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE);
  485. theme->set_constant("modulate_arrow", "OptionButton", true);
  486. theme->set_constant("hseparation", "OptionButton", 4 * EDSCALE);
  487. // CheckButton
  488. theme->set_stylebox("normal", "CheckButton", style_menu);
  489. theme->set_stylebox("pressed", "CheckButton", style_menu);
  490. theme->set_stylebox("disabled", "CheckButton", style_menu);
  491. theme->set_stylebox("hover", "CheckButton", style_menu);
  492. theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons"));
  493. theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
  494. theme->set_color("font_color", "CheckButton", font_color);
  495. theme->set_color("font_color_hover", "CheckButton", font_color_hl);
  496. theme->set_color("font_color_pressed", "CheckButton", accent_color);
  497. theme->set_color("font_color_disabled", "CheckButton", font_color_disabled);
  498. theme->set_color("icon_color_hover", "CheckButton", font_color_hl);
  499. theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE);
  500. theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE);
  501. // Checkbox
  502. Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate();
  503. sb_checkbox->set_default_margin(MARGIN_LEFT, default_margin_size * EDSCALE);
  504. sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE);
  505. sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
  506. sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE);
  507. theme->set_stylebox("normal", "CheckBox", sb_checkbox);
  508. theme->set_stylebox("pressed", "CheckBox", sb_checkbox);
  509. theme->set_stylebox("disabled", "CheckBox", sb_checkbox);
  510. theme->set_stylebox("hover", "CheckBox", sb_checkbox);
  511. theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons"));
  512. theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons"));
  513. theme->set_icon("radio_checked", "CheckBox", theme->get_icon("GuiRadioChecked", "EditorIcons"));
  514. theme->set_icon("radio_unchecked", "CheckBox", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
  515. theme->set_color("font_color", "CheckBox", font_color);
  516. theme->set_color("font_color_hover", "CheckBox", font_color_hl);
  517. theme->set_color("font_color_pressed", "CheckBox", accent_color);
  518. theme->set_color("font_color_disabled", "CheckBox", font_color_disabled);
  519. theme->set_color("icon_color_hover", "CheckBox", font_color_hl);
  520. theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE);
  521. theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE);
  522. // PopupMenu
  523. Ref<StyleBoxFlat> style_popup_menu = style_popup;
  524. theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
  525. theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
  526. theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
  527. theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
  528. theme->set_color("font_color", "PopupMenu", font_color);
  529. theme->set_color("font_color_hover", "PopupMenu", font_color_hl);
  530. theme->set_color("font_color_accel", "PopupMenu", font_color_disabled);
  531. theme->set_color("font_color_disabled", "PopupMenu", font_color_disabled);
  532. theme->set_icon("checked", "PopupMenu", theme->get_icon("GuiChecked", "EditorIcons"));
  533. theme->set_icon("unchecked", "PopupMenu", theme->get_icon("GuiUnchecked", "EditorIcons"));
  534. theme->set_icon("radio_checked", "PopupMenu", theme->get_icon("GuiRadioChecked", "EditorIcons"));
  535. theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
  536. theme->set_icon("submenu", "PopupMenu", theme->get_icon("ArrowRight", "EditorIcons"));
  537. theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon("GuiVisibilityHidden", "EditorIcons"));
  538. theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon("GuiVisibilityVisible", "EditorIcons"));
  539. theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
  540. theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
  541. Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1.linear_interpolate(accent_color, 0.08), 2, 0, 2, 2);
  542. sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
  543. sub_inspector_bg->set_border_color(MARGIN_LEFT, accent_color * Color(1, 1, 1, 0.3));
  544. sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2);
  545. sub_inspector_bg->set_border_color(MARGIN_RIGHT, accent_color * Color(1, 1, 1, 0.3));
  546. sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2);
  547. sub_inspector_bg->set_border_color(MARGIN_BOTTOM, accent_color * Color(1, 1, 1, 0.3));
  548. sub_inspector_bg->set_draw_center(true);
  549. theme->set_stylebox("sub_inspector_bg", "Editor", sub_inspector_bg);
  550. theme->set_constant("inspector_margin", "Editor", 8 * EDSCALE);
  551. // Tree & ItemList background
  552. Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate();
  553. style_tree_bg->set_bg_color(dark_color_1);
  554. style_tree_bg->set_border_color_all(dark_color_3);
  555. theme->set_stylebox("bg", "Tree", style_tree_bg);
  556. const Color guide_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.05);
  557. Color relationship_line_color = Color(mono_color.r, mono_color.g, mono_color.b, relationship_line_opacity);
  558. // Tree
  559. theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons"));
  560. theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons"));
  561. theme->set_icon("arrow_up", "Tree", theme->get_icon("GuiTreeArrowUp", "EditorIcons"));
  562. theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
  563. theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
  564. theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons"));
  565. theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons"));
  566. theme->set_icon("select_option", "Tree", theme->get_icon("GuiTreeOption", "EditorIcons"));
  567. theme->set_stylebox("bg_focus", "Tree", style_focus);
  568. theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
  569. theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
  570. theme->set_stylebox("custom_button_hover", "Tree", style_widget);
  571. theme->set_color("custom_button_font_highlight", "Tree", font_color_hl);
  572. theme->set_color("font_color", "Tree", font_color);
  573. theme->set_color("font_color_selected", "Tree", mono_color);
  574. theme->set_color("title_button_color", "Tree", font_color);
  575. theme->set_color("guide_color", "Tree", guide_color);
  576. theme->set_color("relationship_line_color", "Tree", relationship_line_color);
  577. theme->set_color("drop_position_color", "Tree", accent_color);
  578. theme->set_constant("vseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
  579. theme->set_constant("hseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
  580. theme->set_constant("guide_width", "Tree", border_width);
  581. theme->set_constant("item_margin", "Tree", 3 * default_margin_size * EDSCALE);
  582. theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
  583. theme->set_constant("draw_relationship_lines", "Tree", relationship_line_opacity >= 0.01);
  584. theme->set_constant("draw_guides", "Tree", relationship_line_opacity < 0.01);
  585. theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
  586. theme->set_constant("scroll_speed", "Tree", 12);
  587. Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
  588. style_tree_btn->set_bg_color(contrast_color_1);
  589. style_tree_btn->set_border_width_all(0);
  590. theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
  591. Ref<StyleBoxFlat> style_tree_focus = style_default->duplicate();
  592. style_tree_focus->set_bg_color(highlight_color);
  593. style_tree_focus->set_border_width_all(0);
  594. theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
  595. Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
  596. theme->set_stylebox("selected", "Tree", style_tree_selected);
  597. Ref<StyleBoxFlat> style_tree_cursor = style_default->duplicate();
  598. style_tree_cursor->set_draw_center(false);
  599. style_tree_cursor->set_border_width_all(border_width);
  600. style_tree_cursor->set_border_color_all(contrast_color_1);
  601. Ref<StyleBoxFlat> style_tree_title = style_default->duplicate();
  602. style_tree_title->set_bg_color(dark_color_3);
  603. style_tree_title->set_border_width_all(0);
  604. theme->set_stylebox("cursor", "Tree", style_tree_cursor);
  605. theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
  606. theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
  607. theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
  608. theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
  609. Color prop_category_color = dark_color_1.linear_interpolate(mono_color, 0.12);
  610. Color prop_section_color = dark_color_1.linear_interpolate(mono_color, 0.09);
  611. Color prop_subsection_color = dark_color_1.linear_interpolate(mono_color, 0.06);
  612. theme->set_color("prop_category", "Editor", prop_category_color);
  613. theme->set_color("prop_section", "Editor", prop_section_color);
  614. theme->set_color("prop_subsection", "Editor", prop_subsection_color);
  615. theme->set_color("drop_position_color", "Tree", accent_color);
  616. // ItemList
  617. Ref<StyleBoxFlat> style_itemlist_bg = style_default->duplicate();
  618. style_itemlist_bg->set_bg_color(dark_color_1);
  619. style_itemlist_bg->set_border_width_all(border_width);
  620. style_itemlist_bg->set_border_color_all(dark_color_3);
  621. Ref<StyleBoxFlat> style_itemlist_cursor = style_default->duplicate();
  622. style_itemlist_cursor->set_draw_center(false);
  623. style_itemlist_cursor->set_border_width_all(border_width);
  624. style_itemlist_cursor->set_border_color_all(highlight_color);
  625. theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
  626. theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);
  627. theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);
  628. theme->set_stylebox("selected", "ItemList", style_tree_selected);
  629. theme->set_stylebox("bg_focus", "ItemList", style_focus);
  630. theme->set_stylebox("bg", "ItemList", style_itemlist_bg);
  631. theme->set_color("font_color", "ItemList", font_color);
  632. theme->set_color("font_color_selected", "ItemList", mono_color);
  633. theme->set_color("guide_color", "ItemList", guide_color);
  634. theme->set_constant("vseparation", "ItemList", 3 * EDSCALE);
  635. theme->set_constant("hseparation", "ItemList", 3 * EDSCALE);
  636. theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE);
  637. theme->set_constant("line_separation", "ItemList", 3 * EDSCALE);
  638. // Tabs & TabContainer
  639. theme->set_stylebox("tab_fg", "TabContainer", style_tab_selected);
  640. theme->set_stylebox("tab_bg", "TabContainer", style_tab_unselected);
  641. theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
  642. theme->set_stylebox("tab_fg", "Tabs", style_tab_selected);
  643. theme->set_stylebox("tab_bg", "Tabs", style_tab_unselected);
  644. theme->set_stylebox("tab_disabled", "Tabs", style_tab_disabled);
  645. theme->set_color("font_color_fg", "TabContainer", font_color);
  646. theme->set_color("font_color_bg", "TabContainer", font_color_disabled);
  647. theme->set_color("font_color_fg", "Tabs", font_color);
  648. theme->set_color("font_color_bg", "Tabs", font_color_disabled);
  649. theme->set_icon("menu", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
  650. theme->set_icon("menu_hl", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
  651. theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected);
  652. theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected);
  653. theme->set_icon("close", "Tabs", theme->get_icon("GuiClose", "EditorIcons"));
  654. theme->set_stylebox("button_pressed", "Tabs", style_menu);
  655. theme->set_stylebox("button", "Tabs", style_menu);
  656. theme->set_icon("increment", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  657. theme->set_icon("decrement", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  658. theme->set_icon("increment", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  659. theme->set_icon("decrement", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  660. theme->set_icon("increment_highlight", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  661. theme->set_icon("decrement_highlight", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  662. theme->set_icon("increment_highlight", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  663. theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  664. theme->set_constant("hseparation", "Tabs", 4 * EDSCALE);
  665. // Content of each tab
  666. Ref<StyleBoxFlat> style_content_panel = style_default->duplicate();
  667. style_content_panel->set_border_color_all(dark_color_3);
  668. style_content_panel->set_border_width_all(border_width);
  669. // compensate the border
  670. style_content_panel->set_default_margin(MARGIN_TOP, margin_size_extra * EDSCALE);
  671. style_content_panel->set_default_margin(MARGIN_RIGHT, margin_size_extra * EDSCALE);
  672. style_content_panel->set_default_margin(MARGIN_BOTTOM, margin_size_extra * EDSCALE);
  673. style_content_panel->set_default_margin(MARGIN_LEFT, margin_size_extra * EDSCALE);
  674. // this is the stylebox used in 3d and 2d viewports (no borders)
  675. Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate();
  676. style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width * 2);
  677. style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
  678. style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width * 2);
  679. style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width * 2);
  680. theme->set_stylebox("panel", "TabContainer", style_content_panel);
  681. theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
  682. // Separators
  683. theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width));
  684. theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, 0, true));
  685. // Debugger
  686. Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate();
  687. style_panel_debugger->set_border_width(MARGIN_BOTTOM, 0);
  688. theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger);
  689. theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_selected);
  690. theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_unselected);
  691. Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate();
  692. 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);
  693. style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset);
  694. theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top);
  695. // LineEdit
  696. theme->set_stylebox("normal", "LineEdit", style_widget);
  697. theme->set_stylebox("focus", "LineEdit", style_widget_focus);
  698. theme->set_stylebox("read_only", "LineEdit", style_widget_disabled);
  699. theme->set_color("read_only", "LineEdit", font_color_disabled);
  700. theme->set_color("font_color", "LineEdit", font_color);
  701. theme->set_color("font_color_selected", "LineEdit", mono_color);
  702. theme->set_color("cursor_color", "LineEdit", font_color);
  703. theme->set_color("selection_color", "LineEdit", font_color_selection);
  704. theme->set_color("clear_button_color", "LineEdit", font_color);
  705. theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);
  706. // TextEdit
  707. theme->set_stylebox("normal", "TextEdit", style_widget);
  708. theme->set_stylebox("focus", "TextEdit", style_widget_hover);
  709. theme->set_stylebox("read_only", "TextEdit", style_widget_disabled);
  710. theme->set_constant("side_margin", "TabContainer", 0);
  711. theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons"));
  712. theme->set_color("font_color", "TextEdit", font_color);
  713. theme->set_color("caret_color", "TextEdit", font_color);
  714. theme->set_color("selection_color", "TextEdit", font_color_selection);
  715. // H/VSplitContainer
  716. theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1));
  717. theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon("GuiHsplitBg", "EditorIcons"), 1, 1, 1, 1));
  718. theme->set_icon("grabber", "VSplitContainer", theme->get_icon("GuiVsplitter", "EditorIcons"));
  719. theme->set_icon("grabber", "HSplitContainer", theme->get_icon("GuiHsplitter", "EditorIcons"));
  720. theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE);
  721. theme->set_constant("separation", "VSplitContainer", default_margin_size * 2 * EDSCALE);
  722. // Containers
  723. theme->set_constant("separation", "BoxContainer", default_margin_size * EDSCALE);
  724. theme->set_constant("separation", "HBoxContainer", default_margin_size * EDSCALE);
  725. theme->set_constant("separation", "VBoxContainer", default_margin_size * EDSCALE);
  726. theme->set_constant("margin_left", "MarginContainer", 0);
  727. theme->set_constant("margin_top", "MarginContainer", 0);
  728. theme->set_constant("margin_right", "MarginContainer", 0);
  729. theme->set_constant("margin_bottom", "MarginContainer", 0);
  730. theme->set_constant("hseparation", "GridContainer", default_margin_size * EDSCALE);
  731. theme->set_constant("vseparation", "GridContainer", default_margin_size * EDSCALE);
  732. // WindowDialog
  733. Ref<StyleBoxFlat> style_window = style_popup->duplicate();
  734. style_window->set_border_color_all(tab_color);
  735. style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  736. style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE);
  737. theme->set_stylebox("panel", "WindowDialog", style_window);
  738. theme->set_color("title_color", "WindowDialog", font_color);
  739. theme->set_icon("close", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
  740. theme->set_icon("close_highlight", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
  741. theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE);
  742. theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE);
  743. theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE);
  744. theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts"));
  745. // complex window, for now only Editor settings and Project settings
  746. Ref<StyleBoxFlat> style_complex_window = style_window->duplicate();
  747. style_complex_window->set_bg_color(dark_color_2);
  748. style_complex_window->set_border_color_all(highlight_tabs ? tab_color : dark_color_2);
  749. theme->set_stylebox("panel", "EditorSettingsDialog", style_complex_window);
  750. theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window);
  751. theme->set_stylebox("panel", "EditorAbout", style_complex_window);
  752. // HScrollBar
  753. Ref<Texture> empty_icon = memnew(ImageTexture);
  754. theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  755. theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  756. theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  757. theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
  758. theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  759. theme->set_icon("increment", "HScrollBar", empty_icon);
  760. theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
  761. theme->set_icon("decrement", "HScrollBar", empty_icon);
  762. theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
  763. // VScrollBar
  764. theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  765. theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  766. theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  767. theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
  768. theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  769. theme->set_icon("increment", "VScrollBar", empty_icon);
  770. theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
  771. theme->set_icon("decrement", "VScrollBar", empty_icon);
  772. theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
  773. // HSlider
  774. theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
  775. theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
  776. theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2));
  777. theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
  778. // VSlider
  779. theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
  780. theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
  781. theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0));
  782. theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
  783. //RichTextLabel
  784. theme->set_color("default_color", "RichTextLabel", font_color);
  785. theme->set_color("font_color_shadow", "RichTextLabel", Color(0, 0, 0, 0));
  786. theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);
  787. theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);
  788. theme->set_constant("shadow_as_outline", "RichTextLabel", 0 * EDSCALE);
  789. theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
  790. theme->set_stylebox("normal", "RichTextLabel", style_tree_bg);
  791. theme->set_color("headline_color", "EditorHelp", mono_color);
  792. // Panel
  793. theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4));
  794. // Label
  795. theme->set_stylebox("normal", "Label", style_empty);
  796. theme->set_color("font_color", "Label", font_color);
  797. theme->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
  798. theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);
  799. theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);
  800. theme->set_constant("shadow_as_outline", "Label", 0 * EDSCALE);
  801. theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
  802. // LinkButton
  803. theme->set_stylebox("focus", "LinkButton", style_empty);
  804. theme->set_color("font_color", "LinkButton", font_color);
  805. // TooltipPanel
  806. Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate();
  807. float v = MAX(border_size * EDSCALE, 1.0);
  808. style_tooltip->set_default_margin(MARGIN_LEFT, v);
  809. style_tooltip->set_default_margin(MARGIN_TOP, v);
  810. style_tooltip->set_default_margin(MARGIN_RIGHT, v);
  811. style_tooltip->set_default_margin(MARGIN_BOTTOM, v);
  812. style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9));
  813. style_tooltip->set_border_width_all(border_width);
  814. style_tooltip->set_border_color_all(mono_color);
  815. theme->set_color("font_color", "TooltipLabel", font_color.inverted());
  816. theme->set_color("font_color_shadow", "TooltipLabel", mono_color.inverted() * Color(1, 1, 1, 0.1));
  817. theme->set_stylebox("panel", "TooltipPanel", style_tooltip);
  818. // PopupPanel
  819. theme->set_stylebox("panel", "PopupPanel", style_popup);
  820. // SpinBox
  821. theme->set_icon("updown", "SpinBox", theme->get_icon("GuiSpinboxUpdown", "EditorIcons"));
  822. // ProgressBar
  823. theme->set_stylebox("bg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressBar", "EditorIcons"), 4, 4, 4, 4, 0, 0, 0, 0));
  824. theme->set_stylebox("fg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressFill", "EditorIcons"), 6, 6, 6, 6, 2, 1, 2, 1));
  825. theme->set_color("font_color", "ProgressBar", font_color);
  826. // GraphEdit
  827. theme->set_stylebox("bg", "GraphEdit", style_tree_bg);
  828. theme->set_color("grid_major", "GraphEdit", Color(1.0, 1.0, 1.0, 0.15));
  829. theme->set_color("grid_minor", "GraphEdit", Color(1.0, 1.0, 1.0, 0.07));
  830. theme->set_color("activity", "GraphEdit", accent_color);
  831. theme->set_icon("minus", "GraphEdit", theme->get_icon("ZoomLess", "EditorIcons"));
  832. theme->set_icon("more", "GraphEdit", theme->get_icon("ZoomMore", "EditorIcons"));
  833. theme->set_icon("reset", "GraphEdit", theme->get_icon("ZoomReset", "EditorIcons"));
  834. theme->set_icon("snap", "GraphEdit", theme->get_icon("SnapGrid", "EditorIcons"));
  835. theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE);
  836. theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE);
  837. // GraphNode
  838. const float mv = dark_theme ? 0.0 : 1.0;
  839. const float mv2 = 1.0 - mv;
  840. const int gn_margin_side = 28;
  841. Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
  842. graphsb->set_border_width_all(border_width);
  843. graphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  844. Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
  845. graphsbselected->set_border_width_all(border_width);
  846. graphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
  847. graphsbselected->set_shadow_size(8 * EDSCALE);
  848. graphsbselected->set_shadow_color(shadow_color);
  849. Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5);
  850. graphsbcomment->set_border_width_all(border_width);
  851. graphsbcomment->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  852. Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5);
  853. graphsbcommentselected->set_border_width_all(border_width);
  854. graphsbcommentselected->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  855. Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate();
  856. graphsbbreakpoint->set_draw_center(false);
  857. graphsbbreakpoint->set_border_color_all(warning_color);
  858. graphsbbreakpoint->set_shadow_color(warning_color * Color(1.0, 1.0, 1.0, 0.1));
  859. Ref<StyleBoxFlat> graphsbposition = graphsbselected->duplicate();
  860. graphsbposition->set_draw_center(false);
  861. graphsbposition->set_border_color_all(error_color);
  862. graphsbposition->set_shadow_color(error_color * Color(1.0, 1.0, 1.0, 0.2));
  863. Ref<StyleBoxFlat> smgraphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
  864. smgraphsb->set_border_width_all(border_width);
  865. smgraphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9));
  866. Ref<StyleBoxFlat> smgraphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
  867. smgraphsbselected->set_border_width_all(border_width);
  868. smgraphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
  869. smgraphsbselected->set_shadow_size(8 * EDSCALE);
  870. smgraphsbselected->set_shadow_color(shadow_color);
  871. if (use_gn_headers) {
  872. graphsb->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  873. graphsbselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  874. graphsbcomment->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  875. graphsbcommentselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  876. }
  877. theme->set_stylebox("frame", "GraphNode", graphsb);
  878. theme->set_stylebox("selectedframe", "GraphNode", graphsbselected);
  879. theme->set_stylebox("comment", "GraphNode", graphsbcomment);
  880. theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
  881. theme->set_stylebox("breakpoint", "GraphNode", graphsbbreakpoint);
  882. theme->set_stylebox("position", "GraphNode", graphsbposition);
  883. theme->set_stylebox("state_machine_frame", "GraphNode", smgraphsb);
  884. theme->set_stylebox("state_machine_selectedframe", "GraphNode", smgraphsbselected);
  885. Color default_node_color = Color(mv2, mv2, mv2);
  886. theme->set_color("title_color", "GraphNode", default_node_color);
  887. default_node_color.a = 0.7;
  888. theme->set_color("close_color", "GraphNode", default_node_color);
  889. theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE);
  890. theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE);
  891. theme->set_constant("title_offset", "GraphNode", 20 * EDSCALE);
  892. theme->set_constant("close_h_offset", "GraphNode", 20 * EDSCALE);
  893. theme->set_constant("close_offset", "GraphNode", 20 * EDSCALE);
  894. theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
  895. theme->set_icon("close", "GraphNode", theme->get_icon("GuiCloseCustomizable", "EditorIcons"));
  896. theme->set_icon("resizer", "GraphNode", theme->get_icon("GuiResizer", "EditorIcons"));
  897. theme->set_icon("port", "GraphNode", theme->get_icon("GuiGraphNodePort", "EditorIcons"));
  898. // GridContainer
  899. theme->set_constant("vseperation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE);
  900. // FileDialog
  901. theme->set_icon("folder", "FileDialog", theme->get_icon("Folder", "EditorIcons"));
  902. theme->set_color("files_disabled", "FileDialog", font_color_disabled);
  903. // color picker
  904. theme->set_constant("margin", "ColorPicker", popup_margin_size);
  905. theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
  906. theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
  907. theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
  908. theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
  909. theme->set_icon("screen_picker", "ColorPicker", theme->get_icon("ColorPick", "EditorIcons"));
  910. theme->set_icon("add_preset", "ColorPicker", theme->get_icon("Add", "EditorIcons"));
  911. theme->set_icon("preset_bg", "ColorPicker", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
  912. theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
  913. // Information on 3D viewport
  914. Ref<StyleBoxFlat> style_info_3d_viewport = style_default->duplicate();
  915. style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
  916. style_info_3d_viewport->set_border_width_all(0);
  917. theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport);
  918. // adaptive script theme constants
  919. // for comments and elements with lower relevance
  920. const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5);
  921. const float mono_value = mono_color.r;
  922. const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07);
  923. const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14);
  924. const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.7);
  925. // editor main color
  926. const Color main_color = Color::html(dark_theme ? "#57b3ff" : "#0480ff");
  927. const Color symbol_color = Color::html("#5792ff").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  928. const Color keyword_color = Color::html("#ff7185");
  929. const Color basetype_color = Color::html(dark_theme ? "#42ffc2" : "#00c161");
  930. const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5);
  931. const Color comment_color = dim_color;
  932. const Color string_color = Color::html(dark_theme ? "#ffd942" : "#ffd118").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  933. const Color te_background_color = dark_theme ? background_color : base_color;
  934. const Color completion_background_color = dark_theme ? base_color : background_color;
  935. const Color completion_selected_color = alpha1;
  936. const Color completion_existing_color = alpha2;
  937. const Color completion_scroll_color = alpha1;
  938. const Color completion_font_color = font_color;
  939. const Color text_color = font_color;
  940. const Color line_number_color = dim_color;
  941. const Color safe_line_number_color = dim_color * Color(1, 1.2, 1, 1.5);
  942. const Color caret_color = mono_color;
  943. const Color caret_background_color = mono_color.inverted();
  944. const Color text_selected_color = dark_color_3;
  945. const Color selection_color = accent_color * Color(1, 1, 1, 0.35);
  946. const Color brace_mismatch_color = error_color;
  947. const Color current_line_color = alpha1;
  948. const Color line_length_guideline_color = dark_theme ? base_color : background_color;
  949. const Color word_highlighted_color = alpha1;
  950. const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  951. const Color function_color = main_color;
  952. const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6);
  953. const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3);
  954. const Color breakpoint_color = error_color;
  955. const Color code_folding_color = alpha3;
  956. const Color search_result_color = alpha1;
  957. const Color search_result_border_color = alpha3;
  958. EditorSettings *setting = EditorSettings::get_singleton();
  959. String text_editor_color_theme = setting->get("text_editor/theme/color_theme");
  960. if (text_editor_color_theme == "Adaptive") {
  961. setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true);
  962. setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true);
  963. setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true);
  964. setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true);
  965. setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true);
  966. setting->set_initial_value("text_editor/highlighting/string_color", string_color, true);
  967. setting->set_initial_value("text_editor/highlighting/background_color", te_background_color, true);
  968. setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true);
  969. setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true);
  970. setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true);
  971. setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true);
  972. setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
  973. setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
  974. setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
  975. setting->set_initial_value("text_editor/highlighting/safe_line_number_color", safe_line_number_color, true);
  976. setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
  977. setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
  978. setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
  979. setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true);
  980. setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true);
  981. setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true);
  982. setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true);
  983. setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true);
  984. setting->set_initial_value("text_editor/highlighting/number_color", number_color, true);
  985. setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
  986. setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
  987. setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
  988. setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
  989. setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
  990. setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
  991. setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
  992. } else if (text_editor_color_theme == "Default") {
  993. setting->load_text_editor_theme();
  994. }
  995. return theme;
  996. }
  997. Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) {
  998. Ref<Theme> theme;
  999. String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme");
  1000. if (custom_theme != "") {
  1001. theme = ResourceLoader::load(custom_theme);
  1002. }
  1003. if (!theme.is_valid()) {
  1004. theme = create_editor_theme(p_theme);
  1005. }
  1006. return theme;
  1007. }