editor_themes.cpp 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488
  1. /**************************************************************************/
  2. /* editor_themes.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 "core/os/os.h"
  33. #include "editor_fonts.h"
  34. #include "editor_icons.gen.h"
  35. #include "editor_scale.h"
  36. #include "editor_settings.h"
  37. #include "modules/modules_enabled.gen.h" // For svg.
  38. #ifdef MODULE_SVG_ENABLED
  39. #include "modules/svg/image_loader_svg.h"
  40. #endif
  41. static Ref<StyleBoxTexture> make_stylebox(Ref<Texture> p_texture, float p_left, float p_top, float p_right, float p_bottom, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1, bool p_draw_center = true) {
  42. Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
  43. style->set_texture(p_texture);
  44. style->set_margin_size(MARGIN_LEFT, p_left * EDSCALE);
  45. style->set_margin_size(MARGIN_RIGHT, p_right * EDSCALE);
  46. style->set_margin_size(MARGIN_BOTTOM, p_bottom * EDSCALE);
  47. style->set_margin_size(MARGIN_TOP, p_top * EDSCALE);
  48. style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
  49. style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
  50. style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
  51. style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
  52. style->set_draw_center(p_draw_center);
  53. return style;
  54. }
  55. 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) {
  56. Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
  57. style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
  58. style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
  59. style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
  60. style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
  61. return style;
  62. }
  63. 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) {
  64. Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
  65. style->set_bg_color(p_color);
  66. style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
  67. style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
  68. style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
  69. style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
  70. return style;
  71. }
  72. 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) {
  73. Ref<StyleBoxLine> style(memnew(StyleBoxLine));
  74. style->set_color(p_color);
  75. style->set_grow_begin(p_grow_begin);
  76. style->set_grow_end(p_grow_end);
  77. style->set_thickness(p_thickness);
  78. style->set_vertical(p_vertical);
  79. return style;
  80. }
  81. static Ref<Texture> flip_icon(Ref<Texture> p_texture, bool p_flip_y = false, bool p_flip_x = false) {
  82. if (!p_flip_y && !p_flip_x) {
  83. return p_texture;
  84. }
  85. Ref<ImageTexture> texture(memnew(ImageTexture));
  86. Ref<Image> img = p_texture->get_data();
  87. img = img->duplicate();
  88. if (p_flip_y) {
  89. img->flip_y();
  90. }
  91. if (p_flip_x) {
  92. img->flip_x();
  93. }
  94. texture->create_from_image(img);
  95. return texture;
  96. }
  97. #ifdef MODULE_SVG_ENABLED
  98. static Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float p_scale = EDSCALE, bool p_force_filter = false) {
  99. Ref<ImageTexture> icon = memnew(ImageTexture);
  100. Ref<Image> img = memnew(Image);
  101. // dumb gizmo check
  102. bool is_gizmo = String(editor_icons_names[p_index]).begins_with("Gizmo");
  103. // Upsample icon generation only if the editor scale isn't an integer multiplier.
  104. // Generating upsampled icons is slower, and the benefit is hardly visible
  105. // with integer editor scales.
  106. const bool upsample = !Math::is_equal_approx(Math::round(p_scale), p_scale);
  107. ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, upsample, p_convert_color);
  108. if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || p_force_filter) {
  109. icon->create_from_image(img); // in this case filter really helps
  110. } else {
  111. icon->create_from_image(img, 0);
  112. }
  113. return icon;
  114. }
  115. #endif
  116. #ifndef ADD_CONVERT_COLOR
  117. #define ADD_CONVERT_COLOR(dictionary, old_color, new_color) dictionary[Color::html(old_color)] = Color::html(new_color)
  118. #endif
  119. float get_gizmo_handle_scale(const String &gizmo_handle_name = "") {
  120. const float scale_gizmo_handles_for_touch = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
  121. if (scale_gizmo_handles_for_touch > 1.0f) {
  122. // The names of the icons that require custom scaling.
  123. static Set<StringName> gizmo_to_scale;
  124. if (gizmo_to_scale.empty()) {
  125. gizmo_to_scale.insert("EditorHandle");
  126. gizmo_to_scale.insert("EditorHandleAdd");
  127. gizmo_to_scale.insert("EditorCurveHandle");
  128. gizmo_to_scale.insert("EditorPathSharpHandle");
  129. gizmo_to_scale.insert("EditorPathSmoothHandle");
  130. }
  131. if (gizmo_to_scale.has(gizmo_handle_name)) {
  132. return EDSCALE * scale_gizmo_handles_for_touch;
  133. }
  134. }
  135. return EDSCALE;
  136. }
  137. 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) {
  138. OS::get_singleton()->benchmark_begin_measure("editor_register_and_generate_icons_" + String((p_only_thumbs ? "with_only_thumbs" : "all")));
  139. #ifdef MODULE_SVG_ENABLED
  140. // The default icon theme is designed to be used for a dark theme.
  141. // This dictionary stores color codes to convert to other colors
  142. // for better readability on a light theme.
  143. Dictionary dark_icon_color_dictionary;
  144. // The names of the icons to never convert, even if one of their colors
  145. // are contained in the dictionary above.
  146. Set<StringName> exceptions;
  147. if (!p_dark_theme) {
  148. // convert color: FROM TO
  149. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e0e0e0", "#5a5a5a"); // common icon color
  150. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffffff", "#414141"); // white
  151. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#b4b4b4", "#363636"); // script darker color
  152. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f9f9f9", "#606060"); // scrollbar grabber highlight color
  153. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#cea4f1", "#a85de9"); // animation
  154. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#fc9c9c", "#cd3838"); // spatial
  155. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5b7f3", "#3d64dd"); // 2d
  156. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#708cea", "#1a3eac"); // 2d dark
  157. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5efac", "#2fa139"); // control
  158. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffdd65", "#ca8a04"); // node warning
  159. // rainbow
  160. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff7070", "#ff2929"); // red
  161. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffeb70", "#ffe337"); // yellow
  162. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#9dff70", "#74ff34"); // green
  163. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#70ffb9", "#2cff98"); // aqua
  164. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#70deff", "#22ccff"); // blue
  165. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#9f70ff", "#702aff"); // purple
  166. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff70ac", "#ff2781"); // pink
  167. // audio gradient
  168. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff8484", "#ff4040"); // red
  169. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e1dc7a", "#d6cf4b"); // yellow
  170. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84ffb1", "#00f010"); // green
  171. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffd684", "#fea900"); // mesh (orange)
  172. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#40a2ff", "#68b6ff"); // shape (blue)
  173. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff8484", "#ff3333"); // remove (red)
  174. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84ffb1", "#00db50"); // add (green)
  175. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84c2ff", "#5caeff"); // selection (blue)
  176. // Animation editor tracks
  177. // The property track icon color is set by the common icon color
  178. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ea9568", "#bd5e2c"); // 3D Transform track
  179. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#66f376", "#16a827"); // Call Method track
  180. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#5792f6", "#236be6"); // Bezier Curve track
  181. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#eae668", "#9f9722"); // Audio Playback track
  182. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#b76ef0", "#9853ce"); // Animation Playback track
  183. // TileSet editor icons
  184. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#fce844", "#aa8d24"); // New Single Tile
  185. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#4490fc", "#0350bd"); // New Autotile
  186. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c9cfd4", "#828f9b"); // New Atlas
  187. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ecbd", "#25e3a0"); // VS variant
  188. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#8da6f0", "#6d8eeb"); // VS bool
  189. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#7dc6ef", "#4fb2e9"); // VS int
  190. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#61daf4", "#27ccf0"); // VS float
  191. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6ba7ec", "#4690e7"); // VS string
  192. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#bd91f1", "#ad76ee"); // VS vector2
  193. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f191a5", "#ee758e"); // VS rect
  194. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e286f0", "#dc6aed"); // VS vector3
  195. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c4ec69", "#96ce1a"); // VS transform2D
  196. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f77070", "#f77070"); // VS plane
  197. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ec69a3", "#ec69a3"); // VS quat
  198. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ee7991", "#ee7991"); // VS aabb
  199. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e3ec69", "#b2bb19"); // VS basis
  200. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f6a86e", "#f49047"); // VS transform
  201. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6993ec", "#6993ec"); // VS path
  202. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ec9a", "#2ce573"); // VS rid
  203. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#79f3e8", "#12d5c3"); // VS object
  204. ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#77edb1", "#57e99f"); // VS dict
  205. exceptions.insert("EditorPivot");
  206. exceptions.insert("EditorHandle");
  207. exceptions.insert("Editor3DHandle");
  208. exceptions.insert("Godot");
  209. exceptions.insert("PanoramaSky");
  210. exceptions.insert("ProceduralSky");
  211. exceptions.insert("EditorControlAnchor");
  212. exceptions.insert("DefaultProjectIcon");
  213. exceptions.insert("GuiCloseCustomizable");
  214. exceptions.insert("GuiGraphNodePort");
  215. exceptions.insert("GuiResizer");
  216. exceptions.insert("ZoomMore");
  217. exceptions.insert("ZoomLess");
  218. exceptions.insert("ZoomReset");
  219. exceptions.insert("LockViewport");
  220. exceptions.insert("GroupViewport");
  221. exceptions.insert("StatusError");
  222. exceptions.insert("StatusSuccess");
  223. exceptions.insert("StatusWarning");
  224. exceptions.insert("OverbrightIndicator");
  225. // Prevents Code Editor icons from changing
  226. exceptions.insert("GuiTab");
  227. exceptions.insert("GuiSpace");
  228. exceptions.insert("GuiEllipsis");
  229. exceptions.insert("TextEditFold");
  230. exceptions.insert("TextEditFolded");
  231. exceptions.insert("TextEditorPlay");
  232. }
  233. // These ones should be converted even if we are using a dark theme.
  234. const Color accent_color = EDITOR_GET("interface/theme/accent_color");
  235. const Color error_color = p_theme->get_color("error_color", "Editor");
  236. const Color success_color = p_theme->get_color("success_color", "Editor");
  237. const Color warning_color = p_theme->get_color("warning_color", "Editor");
  238. dark_icon_color_dictionary[Color::html("#699ce8")] = accent_color;
  239. dark_icon_color_dictionary[Color::html("#ff0000")] = error_color;
  240. dark_icon_color_dictionary[Color::html("#45ff8b")] = success_color;
  241. dark_icon_color_dictionary[Color::html("#dbab09")] = warning_color;
  242. ImageLoaderSVG::set_convert_colors(&dark_icon_color_dictionary);
  243. // Generate icons.
  244. if (!p_only_thumbs) {
  245. for (int i = 0; i < editor_icons_count; i++) {
  246. const String &editor_icon_name = editor_icons_names[i];
  247. const int is_exception = exceptions.has(editor_icon_name);
  248. const Ref<ImageTexture> icon = editor_generate_icon(i, !is_exception, get_gizmo_handle_scale(editor_icon_name));
  249. p_theme->set_icon(editor_icon_name, "EditorIcons", icon);
  250. }
  251. }
  252. // Generate thumbnail icons with the given thumbnail size.
  253. // We don't need filtering when generating at one of the default resolutions.
  254. const bool force_filter = p_thumb_size != 64 && p_thumb_size != 32;
  255. if (p_thumb_size >= 64) {
  256. const float scale = (float)p_thumb_size / 64.0 * EDSCALE;
  257. for (int i = 0; i < editor_bg_thumbs_count; i++) {
  258. const int index = editor_bg_thumbs_indices[i];
  259. const int is_exception = exceptions.has(editor_icons_names[index]);
  260. const Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter);
  261. p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon);
  262. }
  263. } else {
  264. const float scale = (float)p_thumb_size / 32.0 * EDSCALE;
  265. for (int i = 0; i < editor_md_thumbs_count; i++) {
  266. const int index = editor_md_thumbs_indices[i];
  267. const bool is_exception = exceptions.has(editor_icons_names[index]);
  268. const Ref<ImageTexture> icon = editor_generate_icon(index, !p_dark_theme && !is_exception, scale, force_filter);
  269. p_theme->set_icon(editor_icons_names[index], "EditorIcons", icon);
  270. }
  271. }
  272. ImageLoaderSVG::set_convert_colors(nullptr);
  273. #else
  274. WARN_PRINT("SVG support disabled, editor icons won't be rendered.");
  275. #endif
  276. OS::get_singleton()->benchmark_end_measure("editor_register_and_generate_icons_" + String((p_only_thumbs ? "with_only_thumbs" : "all")));
  277. }
  278. Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
  279. OS::get_singleton()->benchmark_begin_measure("create_editor_theme");
  280. Ref<Theme> theme = Ref<Theme>(memnew(Theme));
  281. const float default_contrast = 0.25;
  282. //Theme settings
  283. Color accent_color = EDITOR_GET("interface/theme/accent_color");
  284. Color base_color = EDITOR_GET("interface/theme/base_color");
  285. float contrast = EDITOR_GET("interface/theme/contrast");
  286. float relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
  287. String preset = EDITOR_GET("interface/theme/preset");
  288. bool increase_scrollbar_touch_area = EDITOR_GET("interface/touchscreen/increase_scrollbar_touch_area");
  289. const float gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
  290. bool highlight_tabs = EDITOR_GET("interface/theme/highlight_tabs");
  291. int border_size = EDITOR_GET("interface/theme/border_size");
  292. bool use_gn_headers = EDITOR_GET("interface/theme/use_graph_node_headers");
  293. Color preset_accent_color;
  294. Color preset_base_color;
  295. float preset_contrast = 0;
  296. // Please, use alphabet order if you've added new theme here(After "Default" and "Custom")
  297. if (preset == "Custom") {
  298. accent_color = EDITOR_GET("interface/theme/accent_color");
  299. base_color = EDITOR_GET("interface/theme/base_color");
  300. contrast = EDITOR_GET("interface/theme/contrast");
  301. } else if (preset == "Alien") {
  302. preset_accent_color = Color(0.11, 1.0, 0.6);
  303. preset_base_color = Color(0.18, 0.22, 0.25);
  304. preset_contrast = 0.25;
  305. } else if (preset == "Arc") {
  306. preset_accent_color = Color(0.32, 0.58, 0.89);
  307. preset_base_color = Color(0.22, 0.24, 0.29);
  308. preset_contrast = 0.25;
  309. } else if (preset == "Godot 2") {
  310. preset_accent_color = Color(0.53, 0.67, 0.89);
  311. preset_base_color = Color(0.24, 0.23, 0.27);
  312. preset_contrast = 0.25;
  313. } else if (preset == "Grey") {
  314. preset_accent_color = Color(0.44, 0.73, 0.98);
  315. preset_base_color = Color(0.24, 0.24, 0.24);
  316. preset_contrast = 0.2;
  317. } else if (preset == "Light") {
  318. preset_accent_color = Color(0.13, 0.44, 1.0);
  319. preset_base_color = Color(1, 1, 1);
  320. preset_contrast = 0.08;
  321. } else if (preset == "Solarized (Dark)") {
  322. preset_accent_color = Color(0.15, 0.55, 0.82);
  323. preset_base_color = Color(0.03, 0.21, 0.26);
  324. preset_contrast = 0.23;
  325. } else if (preset == "Solarized (Light)") {
  326. preset_accent_color = Color(0.15, 0.55, 0.82);
  327. preset_base_color = Color(0.99, 0.96, 0.89);
  328. preset_contrast = 0.06;
  329. } else { // Default
  330. preset_accent_color = Color(0.41, 0.61, 0.91);
  331. preset_base_color = Color(0.2, 0.23, 0.31);
  332. preset_contrast = default_contrast;
  333. }
  334. if (preset != "Custom") {
  335. accent_color = preset_accent_color;
  336. base_color = preset_base_color;
  337. contrast = preset_contrast;
  338. EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", accent_color);
  339. EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", base_color);
  340. EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", contrast);
  341. }
  342. EditorSettings::get_singleton()->set_manually("interface/theme/preset", preset);
  343. EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", accent_color);
  344. EditorSettings::get_singleton()->set_manually("interface/theme/base_color", base_color);
  345. EditorSettings::get_singleton()->set_manually("interface/theme/contrast", contrast);
  346. //Colors
  347. bool dark_theme = EditorSettings::get_singleton()->is_dark_theme();
  348. const Color dark_color_1 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast);
  349. const Color dark_color_2 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 1.5);
  350. const Color dark_color_3 = base_color.linear_interpolate(Color(0, 0, 0, 1), contrast * 2);
  351. const Color background_color = dark_color_2;
  352. // white (dark theme) or black (light theme), will be used to generate the rest of the colors
  353. const Color mono_color = dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
  354. const Color contrast_color_1 = base_color.linear_interpolate(mono_color, MAX(contrast, default_contrast));
  355. const Color contrast_color_2 = base_color.linear_interpolate(mono_color, MAX(contrast * 1.5, default_contrast * 1.5));
  356. const Color font_color = mono_color.linear_interpolate(base_color, 0.25);
  357. const Color font_color_hl = mono_color.linear_interpolate(base_color, 0.15);
  358. const Color font_color_focus = mono_color.linear_interpolate(base_color, 0.15);
  359. const Color font_color_disabled = Color(mono_color.r, mono_color.g, mono_color.b, 0.3);
  360. const Color font_color_readonly = Color(mono_color.r, mono_color.g, mono_color.b, 0.65);
  361. const Color font_color_selection = accent_color * Color(1, 1, 1, 0.4);
  362. const Color color_disabled = mono_color.inverted().linear_interpolate(base_color, 0.7);
  363. const Color color_disabled_bg = mono_color.inverted().linear_interpolate(base_color, 0.9);
  364. const Color icon_color_normal = Color(1, 1, 1);
  365. Color icon_color_hover = icon_color_normal * (dark_theme ? 1.15 : 1.45);
  366. icon_color_hover.a = 1.0;
  367. // Make the pressed icon color overbright because icons are not completely white on a dark theme.
  368. // On a light theme, icons are dark, so we need to modulate them with an even brighter color.
  369. Color icon_color_pressed = accent_color * (dark_theme ? 1.15 : 3.5);
  370. icon_color_pressed.a = 1.0;
  371. const Color separator_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.1);
  372. const Color highlight_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.2);
  373. theme->set_color("accent_color", "Editor", accent_color);
  374. theme->set_color("highlight_color", "Editor", highlight_color);
  375. theme->set_color("base_color", "Editor", base_color);
  376. theme->set_color("dark_color_1", "Editor", dark_color_1);
  377. theme->set_color("dark_color_2", "Editor", dark_color_2);
  378. theme->set_color("dark_color_3", "Editor", dark_color_3);
  379. theme->set_color("contrast_color_1", "Editor", contrast_color_1);
  380. theme->set_color("contrast_color_2", "Editor", contrast_color_2);
  381. theme->set_color("box_selection_fill_color", "Editor", accent_color * Color(1, 1, 1, 0.3));
  382. theme->set_color("box_selection_stroke_color", "Editor", accent_color * Color(1, 1, 1, 0.8));
  383. theme->set_color("axis_x_color", "Editor", Color(0.96, 0.20, 0.32));
  384. theme->set_color("axis_y_color", "Editor", Color(0.53, 0.84, 0.01));
  385. theme->set_color("axis_z_color", "Editor", Color(0.16, 0.55, 0.96));
  386. theme->set_color("font_color", "Editor", font_color);
  387. theme->set_color("highlighted_font_color", "Editor", font_color_hl);
  388. theme->set_color("disabled_font_color", "Editor", font_color_disabled);
  389. theme->set_color("mono_color", "Editor", mono_color);
  390. Color success_color = Color(0.45, 0.95, 0.5);
  391. Color warning_color = Color(1, 0.87, 0.4);
  392. Color error_color = Color(1, 0.47, 0.42);
  393. Color property_color = font_color.linear_interpolate(Color(0.5, 0.5, 0.5), 0.5);
  394. if (!dark_theme) {
  395. // Darken some colors to be readable on a light background
  396. success_color = success_color.linear_interpolate(mono_color, 0.35);
  397. warning_color = warning_color.linear_interpolate(mono_color, 0.35);
  398. error_color = error_color.linear_interpolate(mono_color, 0.25);
  399. }
  400. theme->set_color("success_color", "Editor", success_color);
  401. theme->set_color("warning_color", "Editor", warning_color);
  402. theme->set_color("error_color", "Editor", error_color);
  403. theme->set_color("property_color", "Editor", property_color);
  404. const int thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
  405. theme->set_constant("scale", "Editor", EDSCALE);
  406. theme->set_constant("thumb_size", "Editor", thumb_size);
  407. theme->set_constant("dark_theme", "Editor", dark_theme);
  408. theme->set_constant("gizmo_handle_scale", "Editor", gizmo_handle_scale);
  409. //Register icons + font
  410. bool keep_old_icons = false;
  411. if (p_theme != nullptr) {
  412. keep_old_icons = fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 &&
  413. fabs(p_theme->get_constant("gizmo_handle_scale", "Editor") - gizmo_handle_scale) < 0.00001 &&
  414. (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme;
  415. }
  416. // the resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons
  417. if (keep_old_icons) {
  418. // register already generated icons
  419. for (int i = 0; i < editor_icons_count; i++) {
  420. theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons"));
  421. }
  422. } else {
  423. editor_register_and_generate_icons(theme, dark_theme, thumb_size);
  424. }
  425. // thumbnail size has changed, so we regenerate the medium sizes
  426. if (p_theme != nullptr && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) {
  427. editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true);
  428. }
  429. editor_register_fonts(theme);
  430. // Highlighted tabs and border width
  431. Color tab_color = highlight_tabs ? base_color.linear_interpolate(font_color, contrast) : base_color;
  432. // Ensure borders are visible when using an editor scale below 100%.
  433. const int border_width = CLAMP(border_size, 0, 3) * MAX(1, EDSCALE);
  434. const int default_margin_size = 4;
  435. const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 3);
  436. // styleboxes
  437. // this is the most commonly used stylebox, variations should be made as duplicate of this
  438. Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size);
  439. style_default->set_border_width_all(border_width);
  440. style_default->set_border_color(base_color);
  441. style_default->set_draw_center(true);
  442. // Button and widgets
  443. const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing");
  444. Ref<StyleBoxFlat> style_widget = style_default->duplicate();
  445. style_widget->set_default_margin(MARGIN_LEFT, (extra_spacing + 6) * EDSCALE);
  446. style_widget->set_default_margin(MARGIN_TOP, (extra_spacing + default_margin_size) * EDSCALE);
  447. style_widget->set_default_margin(MARGIN_RIGHT, (extra_spacing + 6) * EDSCALE);
  448. style_widget->set_default_margin(MARGIN_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE);
  449. style_widget->set_bg_color(dark_color_1);
  450. style_widget->set_border_color(dark_color_2);
  451. Ref<StyleBoxFlat> style_widget_disabled = style_widget->duplicate();
  452. style_widget_disabled->set_border_color(color_disabled);
  453. style_widget_disabled->set_bg_color(color_disabled_bg);
  454. Ref<StyleBoxFlat> style_widget_focus = style_widget->duplicate();
  455. style_widget_focus->set_border_color(accent_color);
  456. Ref<StyleBoxFlat> style_widget_pressed = style_widget->duplicate();
  457. style_widget_pressed->set_border_color(accent_color);
  458. Ref<StyleBoxFlat> style_widget_hover = style_widget->duplicate();
  459. style_widget_hover->set_border_color(contrast_color_1);
  460. // style for windows, popups, etc..
  461. Ref<StyleBoxFlat> style_popup = style_default->duplicate();
  462. const int popup_margin_size = default_margin_size * EDSCALE * 2;
  463. style_popup->set_default_margin(MARGIN_LEFT, popup_margin_size);
  464. style_popup->set_default_margin(MARGIN_TOP, popup_margin_size);
  465. style_popup->set_default_margin(MARGIN_RIGHT, popup_margin_size);
  466. style_popup->set_default_margin(MARGIN_BOTTOM, popup_margin_size);
  467. style_popup->set_border_color(contrast_color_1);
  468. style_popup->set_border_width_all(MAX(EDSCALE, border_width));
  469. const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1);
  470. style_popup->set_shadow_color(shadow_color);
  471. style_popup->set_shadow_size(4 * EDSCALE);
  472. Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine));
  473. style_popup_separator->set_color(separator_color);
  474. style_popup_separator->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
  475. style_popup_separator->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
  476. style_popup_separator->set_thickness(MAX(EDSCALE, border_width));
  477. Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine));
  478. style_popup_labeled_separator_left->set_grow_begin(popup_margin_size - MAX(EDSCALE, border_width));
  479. style_popup_labeled_separator_left->set_color(separator_color);
  480. style_popup_labeled_separator_left->set_thickness(MAX(EDSCALE, border_width));
  481. Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine));
  482. style_popup_labeled_separator_right->set_grow_end(popup_margin_size - MAX(EDSCALE, border_width));
  483. style_popup_labeled_separator_right->set_color(separator_color);
  484. style_popup_labeled_separator_right->set_thickness(MAX(EDSCALE, border_width));
  485. Ref<StyleBoxEmpty> style_empty = make_empty_stylebox(default_margin_size, default_margin_size, default_margin_size, default_margin_size);
  486. // Tabs
  487. const int tab_default_margin_side = 10 * EDSCALE + extra_spacing * EDSCALE;
  488. const int tab_default_margin_vertical = 5 * EDSCALE + extra_spacing * EDSCALE;
  489. Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate();
  490. style_tab_selected->set_border_width_all(border_width);
  491. style_tab_selected->set_border_width(MARGIN_BOTTOM, 0);
  492. style_tab_selected->set_border_color(dark_color_3);
  493. style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width);
  494. style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side);
  495. style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side);
  496. style_tab_selected->set_default_margin(MARGIN_BOTTOM, tab_default_margin_vertical);
  497. style_tab_selected->set_default_margin(MARGIN_TOP, tab_default_margin_vertical);
  498. style_tab_selected->set_bg_color(tab_color);
  499. Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate();
  500. style_tab_unselected->set_bg_color(dark_color_1);
  501. style_tab_unselected->set_border_color(dark_color_2);
  502. Ref<StyleBoxFlat> style_tab_disabled = style_tab_selected->duplicate();
  503. style_tab_disabled->set_bg_color(color_disabled_bg);
  504. style_tab_disabled->set_border_color(color_disabled);
  505. // Editor background
  506. Color background_color_opaque = background_color;
  507. background_color_opaque.a = 1.0;
  508. theme->set_stylebox("Background", "EditorStyles", make_flat_stylebox(background_color_opaque, default_margin_size, default_margin_size, default_margin_size, default_margin_size));
  509. // Focus
  510. Ref<StyleBoxFlat> style_focus = style_default->duplicate();
  511. style_focus->set_draw_center(false);
  512. style_focus->set_border_color(contrast_color_2);
  513. theme->set_stylebox("Focus", "EditorStyles", style_focus);
  514. // Menu
  515. Ref<StyleBoxFlat> style_menu = style_widget->duplicate();
  516. style_menu->set_draw_center(false);
  517. style_menu->set_border_width_all(0);
  518. theme->set_stylebox("panel", "PanelContainer", style_menu);
  519. theme->set_stylebox("MenuPanel", "EditorStyles", style_menu);
  520. // CanvasItem Editor
  521. Ref<StyleBoxFlat> style_canvas_editor_info = make_flat_stylebox(Color(0.0, 0.0, 0.0, 0.2));
  522. style_canvas_editor_info->set_expand_margin_size_all(4 * EDSCALE);
  523. theme->set_stylebox("CanvasItemInfoOverlay", "EditorStyles", style_canvas_editor_info);
  524. // Script Editor
  525. theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size));
  526. theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0));
  527. // Play button group
  528. theme->set_stylebox("PlayButtonPanel", "EditorStyles", style_empty);
  529. //MenuButton
  530. Ref<StyleBoxFlat> style_menu_hover_border = style_widget->duplicate();
  531. style_menu_hover_border->set_draw_center(false);
  532. style_menu_hover_border->set_border_width_all(0);
  533. style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width);
  534. style_menu_hover_border->set_border_color(accent_color);
  535. Ref<StyleBoxFlat> style_menu_hover_bg = style_widget->duplicate();
  536. style_menu_hover_bg->set_border_width_all(0);
  537. style_menu_hover_bg->set_bg_color(dark_color_1);
  538. theme->set_stylebox("normal", "MenuButton", style_menu);
  539. theme->set_stylebox("hover", "MenuButton", style_menu);
  540. theme->set_stylebox("pressed", "MenuButton", style_menu);
  541. theme->set_stylebox("focus", "MenuButton", style_menu);
  542. theme->set_stylebox("disabled", "MenuButton", style_menu);
  543. theme->set_stylebox("normal", "PopupMenu", style_menu);
  544. theme->set_stylebox("hover", "PopupMenu", style_menu_hover_bg);
  545. theme->set_stylebox("pressed", "PopupMenu", style_menu);
  546. theme->set_stylebox("focus", "PopupMenu", style_menu);
  547. theme->set_stylebox("disabled", "PopupMenu", style_menu);
  548. theme->set_stylebox("normal", "ToolButton", style_menu);
  549. theme->set_stylebox("hover", "ToolButton", style_menu);
  550. theme->set_stylebox("pressed", "ToolButton", style_menu);
  551. theme->set_stylebox("focus", "ToolButton", style_menu);
  552. theme->set_stylebox("disabled", "ToolButton", style_menu);
  553. theme->set_color("font_color", "MenuButton", font_color);
  554. theme->set_color("font_color_hover", "MenuButton", font_color_hl);
  555. theme->set_color("font_color_focus", "MenuButton", font_color_focus);
  556. theme->set_color("font_color", "ToolButton", font_color);
  557. theme->set_color("font_color_hover", "ToolButton", font_color_hl);
  558. theme->set_color("font_color_focus", "ToolButton", font_color_focus);
  559. theme->set_color("font_color_pressed", "ToolButton", accent_color);
  560. theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border);
  561. // Buttons
  562. theme->set_stylebox("normal", "Button", style_widget);
  563. theme->set_stylebox("hover", "Button", style_widget_hover);
  564. theme->set_stylebox("pressed", "Button", style_widget_pressed);
  565. theme->set_stylebox("focus", "Button", style_widget_focus);
  566. theme->set_stylebox("disabled", "Button", style_widget_disabled);
  567. theme->set_color("font_color", "Button", font_color);
  568. theme->set_color("font_color_hover", "Button", font_color_hl);
  569. theme->set_color("font_color_focus", "Button", font_color_focus);
  570. theme->set_color("font_color_pressed", "Button", accent_color);
  571. theme->set_color("font_color_disabled", "Button", font_color_disabled);
  572. theme->set_color("icon_color_normal", "Button", icon_color_normal);
  573. theme->set_color("icon_color_hover", "Button", icon_color_hover);
  574. theme->set_color("icon_color_pressed", "Button", icon_color_pressed);
  575. // OptionButton
  576. theme->set_stylebox("normal", "OptionButton", style_widget);
  577. theme->set_stylebox("hover", "OptionButton", style_widget_hover);
  578. theme->set_stylebox("pressed", "OptionButton", style_widget_pressed);
  579. theme->set_stylebox("focus", "OptionButton", style_widget_focus);
  580. theme->set_stylebox("disabled", "OptionButton", style_widget_disabled);
  581. theme->set_color("font_color", "OptionButton", font_color);
  582. theme->set_color("font_color_hover", "OptionButton", font_color_hl);
  583. theme->set_color("font_color_focus", "OptionButton", font_color_focus);
  584. theme->set_color("font_color_pressed", "OptionButton", accent_color);
  585. theme->set_color("font_color_disabled", "OptionButton", font_color_disabled);
  586. theme->set_color("icon_color_hover", "OptionButton", icon_color_hover);
  587. theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons"));
  588. theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE);
  589. theme->set_constant("modulate_arrow", "OptionButton", true);
  590. theme->set_constant("hseparation", "OptionButton", 4 * EDSCALE);
  591. // CheckButton
  592. theme->set_stylebox("normal", "CheckButton", style_menu);
  593. theme->set_stylebox("pressed", "CheckButton", style_menu);
  594. theme->set_stylebox("disabled", "CheckButton", style_menu);
  595. theme->set_stylebox("hover", "CheckButton", style_menu);
  596. theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons"));
  597. theme->set_icon("on_disabled", "CheckButton", theme->get_icon("GuiToggleOnDisabled", "EditorIcons"));
  598. theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
  599. theme->set_icon("off_disabled", "CheckButton", theme->get_icon("GuiToggleOffDisabled", "EditorIcons"));
  600. theme->set_color("font_color", "CheckButton", font_color);
  601. theme->set_color("font_color_hover", "CheckButton", font_color_hl);
  602. theme->set_color("font_color_focus", "CheckButton", font_color_focus);
  603. theme->set_color("font_color_pressed", "CheckButton", accent_color);
  604. theme->set_color("font_color_disabled", "CheckButton", font_color_disabled);
  605. theme->set_color("icon_color_hover", "CheckButton", icon_color_hover);
  606. theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE);
  607. theme->set_constant("check_vadjust", "CheckButton", 0);
  608. // Checkbox
  609. Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate();
  610. sb_checkbox->set_default_margin(MARGIN_LEFT, default_margin_size * EDSCALE);
  611. sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE);
  612. sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
  613. sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE);
  614. theme->set_stylebox("normal", "CheckBox", sb_checkbox);
  615. theme->set_stylebox("pressed", "CheckBox", sb_checkbox);
  616. theme->set_stylebox("disabled", "CheckBox", sb_checkbox);
  617. theme->set_stylebox("hover", "CheckBox", sb_checkbox);
  618. theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons"));
  619. theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons"));
  620. theme->set_icon("checked_disabled", "CheckBox", theme->get_icon("GuiCheckedDisabled", "EditorIcons"));
  621. theme->set_icon("unchecked_disabled", "CheckBox", theme->get_icon("GuiUncheckedDisabled", "EditorIcons"));
  622. theme->set_icon("radio_checked", "CheckBox", theme->get_icon("GuiRadioChecked", "EditorIcons"));
  623. theme->set_icon("radio_unchecked", "CheckBox", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
  624. theme->set_icon("radio_checked_disabled", "CheckBox", theme->get_icon("GuiRadioCheckedDisabled", "EditorIcons"));
  625. theme->set_icon("radio_unchecked_disabled", "CheckBox", theme->get_icon("GuiRadioUncheckedDisabled", "EditorIcons"));
  626. theme->set_color("font_color", "CheckBox", font_color);
  627. theme->set_color("font_color_hover", "CheckBox", font_color_hl);
  628. theme->set_color("font_color_focus", "CheckBox", font_color_focus);
  629. theme->set_color("font_color_pressed", "CheckBox", accent_color);
  630. theme->set_color("font_color_disabled", "CheckBox", font_color_disabled);
  631. theme->set_color("icon_color_hover", "CheckBox", icon_color_hover);
  632. theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE);
  633. theme->set_constant("check_vadjust", "CheckBox", 0);
  634. // PopupDialog
  635. theme->set_stylebox("panel", "PopupDialog", style_popup);
  636. // PopupMenu
  637. theme->set_stylebox("panel", "PopupMenu", style_popup);
  638. theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
  639. theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
  640. theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
  641. theme->set_color("font_color", "PopupMenu", font_color);
  642. theme->set_color("font_color_hover", "PopupMenu", font_color_hl);
  643. theme->set_color("font_color_accel", "PopupMenu", font_color_disabled);
  644. theme->set_color("font_color_disabled", "PopupMenu", font_color_disabled);
  645. theme->set_color("font_color_separator", "PopupMenu", font_color_disabled);
  646. theme->set_icon("checked", "PopupMenu", theme->get_icon("GuiChecked", "EditorIcons"));
  647. theme->set_icon("unchecked", "PopupMenu", theme->get_icon("GuiUnchecked", "EditorIcons"));
  648. theme->set_icon("radio_checked", "PopupMenu", theme->get_icon("GuiRadioChecked", "EditorIcons"));
  649. theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon("GuiRadioUnchecked", "EditorIcons"));
  650. theme->set_icon("submenu", "PopupMenu", theme->get_icon("ArrowRight", "EditorIcons"));
  651. theme->set_icon("visibility_hidden", "PopupMenu", theme->get_icon("GuiVisibilityHidden", "EditorIcons"));
  652. theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon("GuiVisibilityVisible", "EditorIcons"));
  653. theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
  654. theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
  655. for (int i = 0; i < 16; i++) {
  656. Color si_base_color = accent_color;
  657. float hue_rotate = (i * 2 % 16) / 16.0;
  658. si_base_color.set_hsv(Math::fmod(float(si_base_color.get_h() + hue_rotate), float(1.0)), si_base_color.get_s(), si_base_color.get_v());
  659. si_base_color = accent_color.linear_interpolate(si_base_color, float(EDITOR_GET("docks/property_editor/subresource_hue_tint")));
  660. Ref<StyleBoxFlat> sub_inspector_bg;
  661. sub_inspector_bg = make_flat_stylebox(dark_color_1.linear_interpolate(si_base_color, 0.08), 2, 0, 2, 2);
  662. sub_inspector_bg->set_border_width_all(2);
  663. sub_inspector_bg->set_default_margin(MARGIN_LEFT, 4 * EDSCALE);
  664. sub_inspector_bg->set_default_margin(MARGIN_RIGHT, 4 * EDSCALE);
  665. sub_inspector_bg->set_default_margin(MARGIN_BOTTOM, 4 * EDSCALE);
  666. sub_inspector_bg->set_default_margin(MARGIN_TOP, 4 * EDSCALE);
  667. sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
  668. sub_inspector_bg->set_draw_center(true);
  669. theme->set_stylebox("sub_inspector_bg" + itos(i), "Editor", sub_inspector_bg);
  670. Ref<StyleBoxFlat> bg_color;
  671. bg_color.instance();
  672. bg_color->set_bg_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
  673. bg_color->set_border_width_all(0);
  674. Ref<StyleBoxFlat> bg_color_selected;
  675. bg_color_selected.instance();
  676. bg_color_selected->set_border_width_all(0);
  677. bg_color_selected->set_bg_color(si_base_color * Color(0.8, 0.8, 0.8, 0.8));
  678. theme->set_stylebox("sub_inspector_property_bg" + itos(i), "Editor", bg_color);
  679. theme->set_stylebox("sub_inspector_property_bg_selected" + itos(i), "Editor", bg_color_selected);
  680. }
  681. theme->set_color("sub_inspector_property_color", "Editor", dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
  682. theme->set_constant("sub_inspector_font_offset", "Editor", 4 * EDSCALE);
  683. Ref<StyleBoxFlat> style_property_bg = style_default->duplicate();
  684. style_property_bg->set_bg_color(highlight_color);
  685. style_property_bg->set_border_width_all(0);
  686. theme->set_constant("font_offset", "EditorProperty", 1 * EDSCALE);
  687. theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg);
  688. theme->set_stylebox("bg", "EditorProperty", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty)));
  689. theme->set_constant("vseparation", "EditorProperty", (extra_spacing + default_margin_size) * EDSCALE);
  690. theme->set_color("warning_color", "EditorProperty", warning_color);
  691. theme->set_color("property_color", "EditorProperty", property_color);
  692. theme->set_constant("inspector_margin", "Editor", 8 * EDSCALE);
  693. // Tree & ItemList background
  694. Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate();
  695. style_tree_bg->set_bg_color(dark_color_1);
  696. style_tree_bg->set_border_color(dark_color_3);
  697. theme->set_stylebox("bg", "Tree", style_tree_bg);
  698. const Color guide_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.05);
  699. Color relationship_line_color = Color(mono_color.r, mono_color.g, mono_color.b, relationship_line_opacity);
  700. // Tree
  701. theme->set_icon("checked", "Tree", theme->get_icon("GuiChecked", "EditorIcons"));
  702. theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons"));
  703. theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
  704. theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons"));
  705. theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons"));
  706. theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons"));
  707. theme->set_stylebox("bg_focus", "Tree", style_focus);
  708. theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
  709. theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
  710. theme->set_stylebox("custom_button_hover", "Tree", style_widget);
  711. theme->set_color("custom_button_font_highlight", "Tree", font_color_hl);
  712. theme->set_color("font_color", "Tree", font_color);
  713. theme->set_color("font_color_selected", "Tree", mono_color);
  714. theme->set_color("title_button_color", "Tree", font_color);
  715. theme->set_color("guide_color", "Tree", guide_color);
  716. theme->set_color("relationship_line_color", "Tree", relationship_line_color);
  717. theme->set_color("drop_position_color", "Tree", accent_color);
  718. theme->set_constant("vseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
  719. theme->set_constant("hseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE);
  720. theme->set_constant("item_margin", "Tree", 3 * default_margin_size * EDSCALE);
  721. theme->set_constant("button_margin", "Tree", default_margin_size * EDSCALE);
  722. theme->set_constant("draw_relationship_lines", "Tree", relationship_line_opacity >= 0.01);
  723. theme->set_constant("draw_guides", "Tree", relationship_line_opacity < 0.01);
  724. theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
  725. theme->set_constant("scroll_speed", "Tree", 12);
  726. Ref<StyleBoxFlat> style_tree_btn = style_default->duplicate();
  727. style_tree_btn->set_bg_color(contrast_color_1);
  728. style_tree_btn->set_border_width_all(0);
  729. theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
  730. Ref<StyleBoxFlat> style_tree_hover = style_default->duplicate();
  731. style_tree_hover->set_bg_color(highlight_color * Color(1, 1, 1, 0.4));
  732. style_tree_hover->set_border_width_all(0);
  733. theme->set_stylebox("hover", "Tree", style_tree_hover);
  734. Ref<StyleBoxFlat> style_tree_focus = style_default->duplicate();
  735. style_tree_focus->set_bg_color(highlight_color);
  736. style_tree_focus->set_border_width_all(0);
  737. theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
  738. Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
  739. theme->set_stylebox("selected", "Tree", style_tree_selected);
  740. Ref<StyleBoxFlat> style_tree_cursor = style_default->duplicate();
  741. style_tree_cursor->set_draw_center(false);
  742. style_tree_cursor->set_border_width_all(MAX(1, border_width));
  743. style_tree_cursor->set_border_color(contrast_color_1);
  744. Ref<StyleBoxFlat> style_tree_title = style_default->duplicate();
  745. style_tree_title->set_bg_color(dark_color_3);
  746. style_tree_title->set_border_width_all(0);
  747. theme->set_stylebox("cursor", "Tree", style_tree_cursor);
  748. theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
  749. theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
  750. theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
  751. theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
  752. Color prop_category_color = dark_color_1.linear_interpolate(mono_color, 0.12);
  753. Color prop_section_color = dark_color_1.linear_interpolate(mono_color, 0.09);
  754. Color prop_subsection_color = dark_color_1.linear_interpolate(mono_color, 0.06);
  755. theme->set_color("prop_category", "Editor", prop_category_color);
  756. theme->set_color("prop_section", "Editor", prop_section_color);
  757. theme->set_color("prop_subsection", "Editor", prop_subsection_color);
  758. theme->set_color("drop_position_color", "Tree", accent_color);
  759. // ItemList
  760. Ref<StyleBoxFlat> style_itemlist_bg = style_default->duplicate();
  761. style_itemlist_bg->set_bg_color(dark_color_1);
  762. style_itemlist_bg->set_border_width_all(border_width);
  763. style_itemlist_bg->set_border_color(dark_color_3);
  764. Ref<StyleBoxFlat> style_itemlist_cursor = style_default->duplicate();
  765. style_itemlist_cursor->set_draw_center(false);
  766. style_itemlist_cursor->set_border_width_all(border_width);
  767. style_itemlist_cursor->set_border_color(highlight_color);
  768. theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
  769. theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);
  770. theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);
  771. theme->set_stylebox("selected", "ItemList", style_tree_selected);
  772. theme->set_stylebox("bg_focus", "ItemList", style_focus);
  773. theme->set_stylebox("bg", "ItemList", style_itemlist_bg);
  774. theme->set_color("font_color", "ItemList", font_color);
  775. theme->set_color("font_color_selected", "ItemList", mono_color);
  776. theme->set_color("guide_color", "ItemList", guide_color);
  777. theme->set_constant("vseparation", "ItemList", 3 * EDSCALE);
  778. theme->set_constant("hseparation", "ItemList", 3 * EDSCALE);
  779. theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE);
  780. theme->set_constant("line_separation", "ItemList", 3 * EDSCALE);
  781. // Tabs & TabContainer
  782. theme->set_stylebox("tab_fg", "TabContainer", style_tab_selected);
  783. theme->set_stylebox("tab_bg", "TabContainer", style_tab_unselected);
  784. theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
  785. theme->set_stylebox("tab_fg", "Tabs", style_tab_selected);
  786. theme->set_stylebox("tab_bg", "Tabs", style_tab_unselected);
  787. theme->set_stylebox("tab_disabled", "Tabs", style_tab_disabled);
  788. theme->set_color("font_color_fg", "TabContainer", font_color);
  789. theme->set_color("font_color_bg", "TabContainer", font_color_disabled);
  790. theme->set_color("font_color_fg", "Tabs", font_color);
  791. theme->set_color("font_color_bg", "Tabs", font_color_disabled);
  792. theme->set_icon("menu", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons"));
  793. theme->set_icon("menu_highlight", "TabContainer", theme->get_icon("GuiTabMenuHl", "EditorIcons"));
  794. theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected);
  795. theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected);
  796. theme->set_icon("close", "Tabs", theme->get_icon("GuiClose", "EditorIcons"));
  797. theme->set_stylebox("button_pressed", "Tabs", style_menu);
  798. theme->set_stylebox("button", "Tabs", style_menu);
  799. theme->set_icon("increment", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  800. theme->set_icon("decrement", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  801. theme->set_icon("increment", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons"));
  802. theme->set_icon("decrement", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons"));
  803. theme->set_icon("increment_highlight", "Tabs", theme->get_icon("GuiScrollArrowRightHl", "EditorIcons"));
  804. theme->set_icon("decrement_highlight", "Tabs", theme->get_icon("GuiScrollArrowLeftHl", "EditorIcons"));
  805. theme->set_icon("increment_highlight", "TabContainer", theme->get_icon("GuiScrollArrowRightHl", "EditorIcons"));
  806. theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon("GuiScrollArrowLeftHl", "EditorIcons"));
  807. theme->set_constant("hseparation", "Tabs", 4 * EDSCALE);
  808. // Content of each tab
  809. Ref<StyleBoxFlat> style_content_panel = style_default->duplicate();
  810. style_content_panel->set_border_color(dark_color_3);
  811. style_content_panel->set_border_width_all(border_width);
  812. // compensate the border
  813. style_content_panel->set_default_margin(MARGIN_TOP, margin_size_extra * EDSCALE);
  814. style_content_panel->set_default_margin(MARGIN_RIGHT, margin_size_extra * EDSCALE);
  815. style_content_panel->set_default_margin(MARGIN_BOTTOM, margin_size_extra * EDSCALE);
  816. style_content_panel->set_default_margin(MARGIN_LEFT, margin_size_extra * EDSCALE);
  817. // These styleboxes can be used on tabs against the base color background (e.g. nested tabs).
  818. Ref<StyleBoxFlat> style_tab_selected_odd = style_tab_selected->duplicate();
  819. style_tab_selected_odd->set_bg_color(color_disabled_bg);
  820. theme->set_stylebox("tab_selected_odd", "TabContainer", style_tab_selected_odd);
  821. Ref<StyleBoxFlat> style_content_panel_odd = style_content_panel->duplicate();
  822. style_content_panel_odd->set_bg_color(color_disabled_bg);
  823. theme->set_stylebox("panel_odd", "TabContainer", style_content_panel_odd);
  824. // This stylebox is used in 3d and 2d viewports (no borders).
  825. Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate();
  826. style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width * 2);
  827. style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE);
  828. style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width * 2);
  829. style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width * 2);
  830. theme->set_stylebox("panel", "TabContainer", style_content_panel);
  831. theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp);
  832. // This stylebox is used by preview tabs in the Theme Editor.
  833. Ref<StyleBoxFlat> style_theme_preview_tab = style_tab_selected_odd->duplicate();
  834. style_theme_preview_tab->set_expand_margin_size(MARGIN_BOTTOM, 3 * EDSCALE);
  835. theme->set_stylebox("ThemeEditorPreviewFG", "EditorStyles", style_theme_preview_tab);
  836. Ref<StyleBoxFlat> style_theme_preview_bg_tab = style_tab_unselected->duplicate();
  837. style_theme_preview_bg_tab->set_expand_margin_size(MARGIN_BOTTOM, 2 * EDSCALE);
  838. theme->set_stylebox("ThemeEditorPreviewBG", "EditorStyles", style_theme_preview_bg_tab);
  839. // Separators
  840. theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width));
  841. theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, 0, true));
  842. // Debugger
  843. Ref<StyleBoxFlat> style_panel_debugger = style_content_panel->duplicate();
  844. style_panel_debugger->set_border_width(MARGIN_BOTTOM, 0);
  845. theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger);
  846. theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_selected);
  847. theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_unselected);
  848. Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate();
  849. 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);
  850. style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset);
  851. style_panel_invisible_top->set_default_margin(MARGIN_TOP, 0);
  852. theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top);
  853. // LineEdit
  854. theme->set_stylebox("normal", "LineEdit", style_widget);
  855. theme->set_stylebox("focus", "LineEdit", style_widget_focus);
  856. theme->set_stylebox("read_only", "LineEdit", style_widget_disabled);
  857. theme->set_icon("clear", "LineEdit", theme->get_icon("GuiClose", "EditorIcons"));
  858. theme->set_color("read_only", "LineEdit", font_color_disabled);
  859. theme->set_color("font_color", "LineEdit", font_color);
  860. theme->set_color("font_color_selected", "LineEdit", mono_color);
  861. theme->set_color("font_color_uneditable", "LineEdit", font_color_readonly);
  862. theme->set_color("cursor_color", "LineEdit", font_color);
  863. theme->set_color("selection_color", "LineEdit", font_color_selection);
  864. theme->set_color("clear_button_color", "LineEdit", font_color);
  865. theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);
  866. // TextEdit
  867. theme->set_stylebox("normal", "TextEdit", style_widget);
  868. theme->set_stylebox("focus", "TextEdit", style_widget_hover);
  869. theme->set_stylebox("read_only", "TextEdit", style_widget_disabled);
  870. theme->set_constant("side_margin", "TabContainer", 0);
  871. theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons"));
  872. theme->set_icon("space", "TextEdit", theme->get_icon("GuiSpace", "EditorIcons"));
  873. theme->set_icon("folded", "TextEdit", theme->get_icon("TextEditFolded", "EditorIcons"));
  874. theme->set_icon("fold", "TextEdit", theme->get_icon("TextEditFold", "EditorIcons"));
  875. theme->set_color("font_color", "TextEdit", font_color);
  876. theme->set_color("font_color_readonly", "TextEdit", font_color_readonly);
  877. theme->set_color("caret_color", "TextEdit", font_color);
  878. theme->set_color("selection_color", "TextEdit", font_color_selection);
  879. // H/VSplitContainer
  880. theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1));
  881. theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon("GuiHsplitBg", "EditorIcons"), 1, 1, 1, 1));
  882. theme->set_icon("grabber", "VSplitContainer", theme->get_icon("GuiVsplitter", "EditorIcons"));
  883. theme->set_icon("grabber", "HSplitContainer", theme->get_icon("GuiHsplitter", "EditorIcons"));
  884. theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE);
  885. theme->set_constant("separation", "VSplitContainer", default_margin_size * 2 * EDSCALE);
  886. // Containers
  887. theme->set_constant("separation", "BoxContainer", default_margin_size * EDSCALE);
  888. theme->set_constant("separation", "HBoxContainer", default_margin_size * EDSCALE);
  889. theme->set_constant("separation", "VBoxContainer", default_margin_size * EDSCALE);
  890. theme->set_constant("margin_left", "MarginContainer", 0);
  891. theme->set_constant("margin_top", "MarginContainer", 0);
  892. theme->set_constant("margin_right", "MarginContainer", 0);
  893. theme->set_constant("margin_bottom", "MarginContainer", 0);
  894. theme->set_constant("hseparation", "GridContainer", default_margin_size * EDSCALE);
  895. theme->set_constant("vseparation", "GridContainer", default_margin_size * EDSCALE);
  896. theme->set_constant("hseparation", "FlowContainer", default_margin_size * EDSCALE);
  897. theme->set_constant("vseparation", "FlowContainer", default_margin_size * EDSCALE);
  898. theme->set_constant("hseparation", "HFlowContainer", default_margin_size * EDSCALE);
  899. theme->set_constant("vseparation", "HFlowContainer", default_margin_size * EDSCALE);
  900. theme->set_constant("hseparation", "VFlowContainer", default_margin_size * EDSCALE);
  901. theme->set_constant("vseparation", "VFlowContainer", default_margin_size * EDSCALE);
  902. // WindowDialog
  903. Ref<StyleBoxFlat> style_window = style_popup->duplicate();
  904. style_window->set_border_color(tab_color);
  905. style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  906. style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE);
  907. theme->set_stylebox("panel", "WindowDialog", style_window);
  908. theme->set_color("title_color", "WindowDialog", font_color);
  909. theme->set_icon("close", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
  910. theme->set_icon("close_highlight", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons"));
  911. theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE);
  912. theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE);
  913. theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE);
  914. theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts"));
  915. // complex window, for now only Editor settings and Project settings
  916. Ref<StyleBoxFlat> style_complex_window = style_window->duplicate();
  917. style_complex_window->set_bg_color(dark_color_2);
  918. style_complex_window->set_border_color(highlight_tabs ? tab_color : dark_color_2);
  919. theme->set_stylebox("panel", "EditorSettingsDialog", style_complex_window);
  920. theme->set_stylebox("panel", "ProjectSettingsEditor", style_complex_window);
  921. theme->set_stylebox("panel", "EditorAbout", style_complex_window);
  922. // HScrollBar
  923. Ref<Texture> empty_icon = memnew(ImageTexture);
  924. if (increase_scrollbar_touch_area) {
  925. theme->set_stylebox("scroll", "HScrollBar", make_line_stylebox(separator_color, 50));
  926. } else {
  927. theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  928. }
  929. theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  930. theme->set_stylebox("grabber", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  931. theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
  932. theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  933. theme->set_icon("increment", "HScrollBar", empty_icon);
  934. theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
  935. theme->set_icon("increment_pressed", "HScrollBar", empty_icon);
  936. theme->set_icon("decrement", "HScrollBar", empty_icon);
  937. theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
  938. theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);
  939. // VScrollBar
  940. if (increase_scrollbar_touch_area) {
  941. theme->set_stylebox("scroll", "VScrollBar", make_line_stylebox(separator_color, 50, 1, 1, true));
  942. } else {
  943. theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  944. }
  945. theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
  946. theme->set_stylebox("grabber", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabber", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  947. theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberHl", "EditorIcons"), 5, 5, 5, 5, 2, 2, 2, 2));
  948. theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollGrabberPressed", "EditorIcons"), 6, 6, 6, 6, 2, 2, 2, 2));
  949. theme->set_icon("increment", "VScrollBar", empty_icon);
  950. theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
  951. theme->set_icon("increment_pressed", "VScrollBar", empty_icon);
  952. theme->set_icon("decrement", "VScrollBar", empty_icon);
  953. theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
  954. theme->set_icon("decrement_pressed", "VScrollBar", empty_icon);
  955. // HSlider
  956. theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
  957. theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
  958. theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2));
  959. theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
  960. theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2));
  961. // VSlider
  962. theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons"));
  963. theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons"));
  964. theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0));
  965. theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
  966. theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0));
  967. //RichTextLabel
  968. theme->set_color("default_color", "RichTextLabel", font_color);
  969. theme->set_color("font_color_shadow", "RichTextLabel", Color(0, 0, 0, 0));
  970. theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);
  971. theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);
  972. theme->set_constant("shadow_as_outline", "RichTextLabel", 0);
  973. theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
  974. theme->set_stylebox("normal", "RichTextLabel", style_tree_bg);
  975. theme->set_color("headline_color", "EditorHelp", mono_color);
  976. // Panel
  977. theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4));
  978. // Label
  979. theme->set_stylebox("normal", "Label", style_empty);
  980. theme->set_color("font_color", "Label", font_color);
  981. theme->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
  982. theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);
  983. theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);
  984. theme->set_constant("shadow_as_outline", "Label", 0);
  985. theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
  986. // LinkButton
  987. theme->set_stylebox("focus", "LinkButton", style_empty);
  988. theme->set_color("font_color", "LinkButton", font_color);
  989. theme->set_color("font_color_hover", "LinkButton", font_color_hl);
  990. theme->set_color("font_color_focus", "LinkButton", font_color_focus);
  991. theme->set_color("font_color_pressed", "LinkButton", accent_color);
  992. theme->set_color("font_color_disabled", "LinkButton", font_color_disabled);
  993. // TooltipPanel
  994. Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate();
  995. float v = MAX(border_size * EDSCALE, 1.0);
  996. style_tooltip->set_default_margin(MARGIN_LEFT, v);
  997. style_tooltip->set_default_margin(MARGIN_TOP, v);
  998. style_tooltip->set_default_margin(MARGIN_RIGHT, v);
  999. style_tooltip->set_default_margin(MARGIN_BOTTOM, v);
  1000. style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9));
  1001. style_tooltip->set_border_width_all(border_width);
  1002. style_tooltip->set_border_color(mono_color);
  1003. theme->set_color("font_color", "TooltipLabel", font_color.inverted());
  1004. theme->set_color("font_color_shadow", "TooltipLabel", mono_color.inverted() * Color(1, 1, 1, 0.1));
  1005. theme->set_stylebox("panel", "TooltipPanel", style_tooltip);
  1006. // PopupPanel
  1007. theme->set_stylebox("panel", "PopupPanel", style_popup);
  1008. // SpinBox
  1009. theme->set_icon("updown", "SpinBox", theme->get_icon("GuiSpinboxUpdown", "EditorIcons"));
  1010. // ProgressBar
  1011. theme->set_stylebox("bg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressBar", "EditorIcons"), 4, 4, 4, 4, 0, 0, 0, 0));
  1012. theme->set_stylebox("fg", "ProgressBar", make_stylebox(theme->get_icon("GuiProgressFill", "EditorIcons"), 6, 6, 6, 6, 2, 1, 2, 1));
  1013. theme->set_color("font_color", "ProgressBar", font_color);
  1014. // GraphEdit
  1015. theme->set_stylebox("bg", "GraphEdit", style_tree_bg);
  1016. if (dark_theme) {
  1017. theme->set_color("grid_major", "GraphEdit", Color(1.0, 1.0, 1.0, 0.15));
  1018. theme->set_color("grid_minor", "GraphEdit", Color(1.0, 1.0, 1.0, 0.07));
  1019. } else {
  1020. theme->set_color("grid_major", "GraphEdit", Color(0.0, 0.0, 0.0, 0.15));
  1021. theme->set_color("grid_minor", "GraphEdit", Color(0.0, 0.0, 0.0, 0.07));
  1022. }
  1023. theme->set_color("selection_fill", "GraphEdit", theme->get_color("box_selection_fill_color", "Editor"));
  1024. theme->set_color("selection_stroke", "GraphEdit", theme->get_color("box_selection_stroke_color", "Editor"));
  1025. theme->set_color("activity", "GraphEdit", accent_color);
  1026. theme->set_icon("minus", "GraphEdit", theme->get_icon("ZoomLess", "EditorIcons"));
  1027. theme->set_icon("more", "GraphEdit", theme->get_icon("ZoomMore", "EditorIcons"));
  1028. theme->set_icon("reset", "GraphEdit", theme->get_icon("ZoomReset", "EditorIcons"));
  1029. theme->set_icon("snap", "GraphEdit", theme->get_icon("SnapGrid", "EditorIcons"));
  1030. theme->set_icon("minimap", "GraphEdit", theme->get_icon("GridMinimap", "EditorIcons"));
  1031. theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE);
  1032. theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE);
  1033. // GraphEditMinimap
  1034. Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0);
  1035. style_minimap_bg->set_border_color(dark_color_3);
  1036. style_minimap_bg->set_border_width_all(1);
  1037. theme->set_stylebox("bg", "GraphEditMinimap", style_minimap_bg);
  1038. Ref<StyleBoxFlat> style_minimap_camera;
  1039. Ref<StyleBoxFlat> style_minimap_node;
  1040. if (dark_theme) {
  1041. style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0);
  1042. style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45));
  1043. style_minimap_node = make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0);
  1044. } else {
  1045. style_minimap_camera = make_flat_stylebox(Color(0.38, 0.38, 0.38, 0.2), 0, 0, 0, 0);
  1046. style_minimap_camera->set_border_color(Color(0.38, 0.38, 0.38, 0.45));
  1047. style_minimap_node = make_flat_stylebox(Color(0, 0, 0), 0, 0, 0, 0);
  1048. }
  1049. style_minimap_camera->set_border_width_all(1);
  1050. style_minimap_node->set_corner_radius_all(1);
  1051. theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);
  1052. theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node);
  1053. Ref<Texture> minimap_resizer_icon = theme->get_icon("GuiResizer", "EditorIcons");
  1054. Color minimap_resizer_color;
  1055. if (dark_theme) {
  1056. minimap_resizer_color = Color(1, 1, 1, 0.65);
  1057. } else {
  1058. minimap_resizer_color = Color(0, 0, 0, 0.65);
  1059. }
  1060. theme->set_icon("resizer", "GraphEditMinimap", flip_icon(minimap_resizer_icon, true, true));
  1061. theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color);
  1062. // GraphNode
  1063. const float mv = dark_theme ? 0.0 : 1.0;
  1064. const float mv2 = 1.0 - mv;
  1065. const int gn_margin_side = 28;
  1066. Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
  1067. graphsb->set_border_width_all(border_width);
  1068. graphsb->set_border_color(Color(mv2, mv2, mv2, 0.9));
  1069. Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
  1070. graphsbselected->set_border_width_all(border_width);
  1071. graphsbselected->set_border_color(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
  1072. graphsbselected->set_shadow_size(8 * EDSCALE);
  1073. graphsbselected->set_shadow_color(shadow_color);
  1074. Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5);
  1075. graphsbcomment->set_border_width_all(border_width);
  1076. graphsbcomment->set_border_color(Color(mv2, mv2, mv2, 0.9));
  1077. Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5);
  1078. graphsbcommentselected->set_border_width_all(border_width);
  1079. graphsbcommentselected->set_border_color(Color(mv2, mv2, mv2, 0.9));
  1080. Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate();
  1081. graphsbbreakpoint->set_draw_center(false);
  1082. graphsbbreakpoint->set_border_color(warning_color);
  1083. graphsbbreakpoint->set_shadow_color(warning_color * Color(1.0, 1.0, 1.0, 0.1));
  1084. Ref<StyleBoxFlat> graphsbposition = graphsbselected->duplicate();
  1085. graphsbposition->set_draw_center(false);
  1086. graphsbposition->set_border_color(error_color);
  1087. graphsbposition->set_shadow_color(error_color * Color(1.0, 1.0, 1.0, 0.2));
  1088. Ref<StyleBoxFlat> smgraphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5);
  1089. smgraphsb->set_border_width_all(border_width);
  1090. smgraphsb->set_border_color(Color(mv2, mv2, mv2, 0.9));
  1091. Ref<StyleBoxFlat> smgraphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5);
  1092. smgraphsbselected->set_border_width_all(border_width);
  1093. smgraphsbselected->set_border_color(Color(accent_color.r, accent_color.g, accent_color.b, 0.9));
  1094. smgraphsbselected->set_shadow_size(8 * EDSCALE);
  1095. smgraphsbselected->set_shadow_color(shadow_color);
  1096. if (use_gn_headers) {
  1097. graphsb->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  1098. graphsbselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  1099. graphsbcomment->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  1100. graphsbcommentselected->set_border_width(MARGIN_TOP, 24 * EDSCALE);
  1101. }
  1102. theme->set_stylebox("frame", "GraphNode", graphsb);
  1103. theme->set_stylebox("selectedframe", "GraphNode", graphsbselected);
  1104. theme->set_stylebox("comment", "GraphNode", graphsbcomment);
  1105. theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected);
  1106. theme->set_stylebox("breakpoint", "GraphNode", graphsbbreakpoint);
  1107. theme->set_stylebox("position", "GraphNode", graphsbposition);
  1108. theme->set_stylebox("state_machine_frame", "GraphNode", smgraphsb);
  1109. theme->set_stylebox("state_machine_selectedframe", "GraphNode", smgraphsbselected);
  1110. Color default_node_color = Color(mv2, mv2, mv2);
  1111. theme->set_color("title_color", "GraphNode", default_node_color);
  1112. default_node_color.a = 0.7;
  1113. theme->set_color("close_color", "GraphNode", default_node_color);
  1114. theme->set_color("resizer_color", "GraphNode", default_node_color);
  1115. theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE);
  1116. theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE);
  1117. theme->set_constant("title_offset", "GraphNode", 20 * EDSCALE);
  1118. theme->set_constant("close_h_offset", "GraphNode", 20 * EDSCALE);
  1119. theme->set_constant("close_offset", "GraphNode", 20 * EDSCALE);
  1120. theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
  1121. theme->set_icon("close", "GraphNode", theme->get_icon("GuiCloseCustomizable", "EditorIcons"));
  1122. theme->set_icon("resizer", "GraphNode", theme->get_icon("GuiResizer", "EditorIcons"));
  1123. theme->set_icon("port", "GraphNode", theme->get_icon("GuiGraphNodePort", "EditorIcons"));
  1124. // GridContainer
  1125. theme->set_constant("vseparation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE);
  1126. // FileDialog
  1127. theme->set_icon("folder", "FileDialog", theme->get_icon("Folder", "EditorIcons"));
  1128. theme->set_icon("parent_folder", "FileDialog", theme->get_icon("ArrowUp", "EditorIcons"));
  1129. theme->set_icon("reload", "FileDialog", theme->get_icon("Reload", "EditorIcons"));
  1130. theme->set_icon("toggle_hidden", "FileDialog", theme->get_icon("GuiVisibilityVisible", "EditorIcons"));
  1131. // Use a different color for folder icons to make them easier to distinguish from files.
  1132. // On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color.
  1133. theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).linear_interpolate(accent_color, 0.7));
  1134. theme->set_color("files_disabled", "FileDialog", font_color_disabled);
  1135. // color picker
  1136. theme->set_constant("margin", "ColorPicker", popup_margin_size);
  1137. theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
  1138. theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
  1139. theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
  1140. theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
  1141. theme->set_icon("screen_picker", "ColorPicker", theme->get_icon("ColorPick", "EditorIcons"));
  1142. theme->set_icon("add_preset", "ColorPicker", theme->get_icon("Add", "EditorIcons"));
  1143. theme->set_icon("preset_bg", "ColorPicker", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
  1144. theme->set_icon("overbright_indicator", "ColorPicker", theme->get_icon("OverbrightIndicator", "EditorIcons"));
  1145. theme->set_icon("bg", "ColorPickerButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
  1146. // ColorPresetButton
  1147. Ref<StyleBoxFlat> preset_sb = make_flat_stylebox(Color(1, 1, 1), 2, 2, 2, 2);
  1148. preset_sb->set_anti_aliased(false);
  1149. theme->set_stylebox("preset_fg", "ColorPresetButton", preset_sb);
  1150. theme->set_icon("preset_bg_icon", "ColorPresetButton", theme->get_icon("GuiMiniCheckerboard", "EditorIcons"));
  1151. theme->set_icon("overbright_indicator", "ColorPresetButton", theme->get_icon("OverbrightIndicator", "EditorIcons"));
  1152. // Information on 3D viewport
  1153. Ref<StyleBoxFlat> style_info_3d_viewport = style_default->duplicate();
  1154. style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
  1155. style_info_3d_viewport->set_border_width_all(0);
  1156. theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport);
  1157. // Theme editor.
  1158. theme->set_color("preview_picker_overlay_color", "ThemeEditor", Color(0.1, 0.1, 0.1, 0.25));
  1159. Color theme_preview_picker_bg_color = accent_color;
  1160. theme_preview_picker_bg_color.a = 0.2;
  1161. Ref<StyleBoxFlat> theme_preview_picker_sb = make_flat_stylebox(theme_preview_picker_bg_color, 0, 0, 0, 0);
  1162. theme_preview_picker_sb->set_border_color(accent_color);
  1163. theme_preview_picker_sb->set_border_width_all(1.0 * EDSCALE);
  1164. theme->set_stylebox("preview_picker_overlay", "ThemeEditor", theme_preview_picker_sb);
  1165. Color theme_preview_picker_label_bg_color = accent_color;
  1166. theme_preview_picker_label_bg_color.set_hsv(theme_preview_picker_label_bg_color.get_h(), theme_preview_picker_label_bg_color.get_s(), 0.5);
  1167. Ref<StyleBoxFlat> theme_preview_picker_label_sb = make_flat_stylebox(theme_preview_picker_label_bg_color, 4.0, 1.0, 4.0, 3.0);
  1168. theme->set_stylebox("preview_picker_label", "ThemeEditor", theme_preview_picker_label_sb);
  1169. // adaptive script theme constants
  1170. // for comments and elements with lower relevance
  1171. const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5);
  1172. const float mono_value = mono_color.r;
  1173. const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07);
  1174. const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14);
  1175. const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.27);
  1176. // editor main color
  1177. const Color main_color = dark_theme ? Color(0.34, 0.7, 1.0) : Color(0.02, 0.5, 1.0);
  1178. const Color symbol_color = Color(0.34, 0.57, 1.0).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  1179. const Color keyword_color = Color(1.0, 0.44, 0.52);
  1180. const Color control_flow_keyword_color = dark_theme ? Color(1.0, 0.55, 0.8) : Color(0.8, 0.4, 0.6);
  1181. const Color basetype_color = dark_theme ? Color(0.26, 1.0, 0.76) : Color(0.0, 0.76, 0.38);
  1182. const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.4 : 0.3);
  1183. const Color usertype_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5);
  1184. const Color comment_color = dim_color;
  1185. const Color string_color = (dark_theme ? Color(1.0, 0.85, 0.26) : Color(1.0, 0.82, 0.09)).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  1186. const Color te_background_color = dark_theme ? background_color : base_color;
  1187. const Color completion_background_color = dark_theme ? base_color : background_color;
  1188. const Color completion_selected_color = alpha1;
  1189. const Color completion_existing_color = alpha2;
  1190. const Color completion_scroll_color = Color(mono_value, mono_value, mono_value, 0.29);
  1191. const Color completion_font_color = font_color;
  1192. const Color text_color = font_color;
  1193. const Color line_number_color = dim_color;
  1194. const Color safe_line_number_color = dim_color * Color(1, 1.2, 1, 1.5);
  1195. const Color caret_color = mono_color;
  1196. const Color caret_background_color = mono_color.inverted();
  1197. const Color text_selected_color = dark_color_3;
  1198. const Color selection_color = accent_color * Color(1, 1, 1, 0.35);
  1199. const Color brace_mismatch_color = error_color;
  1200. const Color current_line_color = alpha1;
  1201. const Color line_length_guideline_color = dark_theme ? base_color : background_color;
  1202. const Color word_highlighted_color = alpha1;
  1203. const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3);
  1204. const Color function_color = main_color;
  1205. const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6);
  1206. const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3);
  1207. const Color bookmark_color = Color(0.08, 0.49, 0.98);
  1208. const Color breakpoint_color = error_color;
  1209. const Color executing_line_color = Color(0.2, 0.8, 0.2, 0.4);
  1210. const Color code_folding_color = alpha3;
  1211. const Color search_result_color = alpha1;
  1212. const Color search_result_border_color = Color(0.41, 0.61, 0.91, 0.38);
  1213. EditorSettings *setting = EditorSettings::get_singleton();
  1214. String text_editor_color_theme = setting->get("text_editor/theme/color_theme");
  1215. if (text_editor_color_theme == "Adaptive") {
  1216. setting->set_initial_value("text_editor/highlighting/symbol_color", symbol_color, true);
  1217. setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true);
  1218. setting->set_initial_value("text_editor/highlighting/control_flow_keyword_color", control_flow_keyword_color, true);
  1219. setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true);
  1220. setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true);
  1221. setting->set_initial_value("text_editor/highlighting/user_type_color", usertype_color, true);
  1222. setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true);
  1223. setting->set_initial_value("text_editor/highlighting/string_color", string_color, true);
  1224. setting->set_initial_value("text_editor/highlighting/background_color", te_background_color, true);
  1225. setting->set_initial_value("text_editor/highlighting/completion_background_color", completion_background_color, true);
  1226. setting->set_initial_value("text_editor/highlighting/completion_selected_color", completion_selected_color, true);
  1227. setting->set_initial_value("text_editor/highlighting/completion_existing_color", completion_existing_color, true);
  1228. setting->set_initial_value("text_editor/highlighting/completion_scroll_color", completion_scroll_color, true);
  1229. setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
  1230. setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
  1231. setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
  1232. setting->set_initial_value("text_editor/highlighting/safe_line_number_color", safe_line_number_color, true);
  1233. setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
  1234. setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
  1235. setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
  1236. setting->set_initial_value("text_editor/highlighting/selection_color", selection_color, true);
  1237. setting->set_initial_value("text_editor/highlighting/brace_mismatch_color", brace_mismatch_color, true);
  1238. setting->set_initial_value("text_editor/highlighting/current_line_color", current_line_color, true);
  1239. setting->set_initial_value("text_editor/highlighting/line_length_guideline_color", line_length_guideline_color, true);
  1240. setting->set_initial_value("text_editor/highlighting/word_highlighted_color", word_highlighted_color, true);
  1241. setting->set_initial_value("text_editor/highlighting/number_color", number_color, true);
  1242. setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
  1243. setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
  1244. setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
  1245. setting->set_initial_value("text_editor/highlighting/bookmark_color", bookmark_color, true);
  1246. setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
  1247. setting->set_initial_value("text_editor/highlighting/executing_line_color", executing_line_color, true);
  1248. setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
  1249. setting->set_initial_value("text_editor/highlighting/search_result_color", search_result_color, true);
  1250. setting->set_initial_value("text_editor/highlighting/search_result_border_color", search_result_border_color, true);
  1251. } else if (text_editor_color_theme == "Default") {
  1252. setting->load_text_editor_theme();
  1253. }
  1254. OS::get_singleton()->benchmark_end_measure("create_editor_theme");
  1255. return theme;
  1256. }
  1257. Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) {
  1258. OS::get_singleton()->benchmark_begin_measure("create_custom_theme");
  1259. Ref<Theme> theme = create_editor_theme(p_theme);
  1260. const String custom_theme_path = EditorSettings::get_singleton()->get("interface/theme/custom_theme");
  1261. if (custom_theme_path != "") {
  1262. Ref<Theme> custom_theme = ResourceLoader::load(custom_theme_path);
  1263. if (custom_theme.is_valid()) {
  1264. theme->merge_with(custom_theme);
  1265. }
  1266. }
  1267. OS::get_singleton()->benchmark_end_measure("create_custom_theme");
  1268. return theme;
  1269. }
  1270. Ref<ImageTexture> create_unscaled_default_project_icon() {
  1271. #ifdef MODULE_SVG_ENABLED
  1272. for (int i = 0; i < editor_icons_count; i++) {
  1273. // ESCALE should never affect size of the icon
  1274. if (strcmp(editor_icons_names[i], "DefaultProjectIcon") == 0) {
  1275. return editor_generate_icon(i, false, 1.0);
  1276. }
  1277. }
  1278. #endif
  1279. return Ref<ImageTexture>(memnew(ImageTexture));
  1280. }