editor_themes.cpp 79 KB

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