editor_theme_manager.cpp 177 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943
  1. /**************************************************************************/
  2. /* editor_theme_manager.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_theme_manager.h"
  31. #include "core/error/error_macros.h"
  32. #include "core/io/resource_loader.h"
  33. #include "editor/editor_string_names.h"
  34. #include "editor/file_system/editor_paths.h"
  35. #include "editor/settings/editor_settings.h"
  36. #include "editor/themes/editor_color_map.h"
  37. #include "editor/themes/editor_fonts.h"
  38. #include "editor/themes/editor_icons.h"
  39. #include "editor/themes/editor_scale.h"
  40. #include "editor/themes/editor_theme.h"
  41. #include "scene/gui/graph_edit.h"
  42. #include "scene/resources/image_texture.h"
  43. #include "scene/resources/style_box_flat.h"
  44. #include "scene/resources/style_box_line.h"
  45. #include "scene/resources/style_box_texture.h"
  46. #include "scene/resources/svg_texture.h"
  47. #include "scene/resources/texture.h"
  48. // Theme configuration.
  49. uint32_t EditorThemeManager::ThemeConfiguration::hash() {
  50. uint32_t hash = hash_murmur3_one_float(EDSCALE);
  51. // Basic properties.
  52. hash = hash_murmur3_one_32(preset.hash(), hash);
  53. hash = hash_murmur3_one_32(spacing_preset.hash(), hash);
  54. hash = hash_murmur3_one_32(base_color.to_rgba32(), hash);
  55. hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);
  56. hash = hash_murmur3_one_float(contrast, hash);
  57. hash = hash_murmur3_one_float(icon_saturation, hash);
  58. // Extra properties.
  59. hash = hash_murmur3_one_32(base_spacing, hash);
  60. hash = hash_murmur3_one_32(extra_spacing, hash);
  61. hash = hash_murmur3_one_32(border_width, hash);
  62. hash = hash_murmur3_one_32(corner_radius, hash);
  63. hash = hash_murmur3_one_32((int)draw_extra_borders, hash);
  64. hash = hash_murmur3_one_float(relationship_line_opacity, hash);
  65. hash = hash_murmur3_one_32(thumb_size, hash);
  66. hash = hash_murmur3_one_32(class_icon_size, hash);
  67. hash = hash_murmur3_one_32((int)enable_touch_optimizations, hash);
  68. hash = hash_murmur3_one_float(gizmo_handle_scale, hash);
  69. hash = hash_murmur3_one_32(color_picker_button_height, hash);
  70. hash = hash_murmur3_one_float(subresource_hue_tint, hash);
  71. hash = hash_murmur3_one_float(default_contrast, hash);
  72. // Generated properties.
  73. hash = hash_murmur3_one_32((int)dark_theme, hash);
  74. return hash;
  75. }
  76. uint32_t EditorThemeManager::ThemeConfiguration::hash_fonts() {
  77. uint32_t hash = hash_murmur3_one_float(EDSCALE);
  78. // TODO: Implement the hash based on what editor_register_fonts() uses.
  79. return hash;
  80. }
  81. uint32_t EditorThemeManager::ThemeConfiguration::hash_icons() {
  82. uint32_t hash = hash_murmur3_one_float(EDSCALE);
  83. hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);
  84. hash = hash_murmur3_one_float(icon_saturation, hash);
  85. hash = hash_murmur3_one_32(thumb_size, hash);
  86. hash = hash_murmur3_one_float(gizmo_handle_scale, hash);
  87. hash = hash_murmur3_one_32((int)dark_theme, hash);
  88. return hash;
  89. }
  90. // Benchmarks.
  91. int EditorThemeManager::benchmark_run = 0;
  92. String EditorThemeManager::get_benchmark_key() {
  93. if (benchmark_run == 0) {
  94. return "EditorTheme (Startup)";
  95. }
  96. return vformat("EditorTheme (Run %d)", benchmark_run);
  97. }
  98. // Generation helper methods.
  99. Ref<StyleBoxTexture> make_stylebox(Ref<Texture2D> 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) {
  100. Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
  101. style->set_texture(p_texture);
  102. style->set_texture_margin_individual(p_left * EDSCALE, p_top * EDSCALE, p_right * EDSCALE, p_bottom * EDSCALE);
  103. style->set_content_margin_individual((p_left + p_margin_left) * EDSCALE, (p_top + p_margin_top) * EDSCALE, (p_right + p_margin_right) * EDSCALE, (p_bottom + p_margin_bottom) * EDSCALE);
  104. style->set_draw_center(p_draw_center);
  105. return style;
  106. }
  107. 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) {
  108. Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
  109. style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);
  110. return style;
  111. }
  112. 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, int p_corner_width = 0) {
  113. Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
  114. style->set_bg_color(p_color);
  115. // Adjust level of detail based on the corners' effective sizes.
  116. style->set_corner_detail(Math::ceil(0.8 * p_corner_width * EDSCALE));
  117. style->set_corner_radius_all(p_corner_width * EDSCALE);
  118. style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);
  119. // Work around issue about antialiased edges being blurrier (GH-35279).
  120. style->set_anti_aliased(false);
  121. return style;
  122. }
  123. 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) {
  124. Ref<StyleBoxLine> style(memnew(StyleBoxLine));
  125. style->set_color(p_color);
  126. style->set_grow_begin(p_grow_begin);
  127. style->set_grow_end(p_grow_end);
  128. style->set_thickness(p_thickness);
  129. style->set_vertical(p_vertical);
  130. return style;
  131. }
  132. // Theme generation and population routines.
  133. Ref<EditorTheme> EditorThemeManager::_create_base_theme(const Ref<EditorTheme> &p_old_theme) {
  134. OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Create Base Theme");
  135. Ref<EditorTheme> theme = memnew(EditorTheme);
  136. ThemeConfiguration config = _create_theme_config(theme);
  137. theme->set_generated_hash(config.hash());
  138. theme->set_generated_fonts_hash(config.hash_fonts());
  139. theme->set_generated_icons_hash(config.hash_icons());
  140. print_verbose(vformat("EditorTheme: Generating new theme for the config '%d'.", theme->get_generated_hash()));
  141. _create_shared_styles(theme, config);
  142. // Register icons.
  143. {
  144. OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Icons");
  145. // External functions, see editor_icons.cpp.
  146. editor_configure_icons(config.dark_theme);
  147. // If settings are comparable to the old theme, then just copy existing icons over.
  148. // Otherwise, regenerate them.
  149. bool keep_old_icons = (p_old_theme.is_valid() && theme->get_generated_icons_hash() == p_old_theme->get_generated_icons_hash());
  150. if (keep_old_icons) {
  151. print_verbose("EditorTheme: Can keep old icons, copying.");
  152. editor_copy_icons(theme, p_old_theme);
  153. } else {
  154. print_verbose("EditorTheme: Generating new icons.");
  155. editor_register_icons(theme, config.dark_theme, config.icon_saturation, config.thumb_size, config.gizmo_handle_scale);
  156. }
  157. OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Icons");
  158. }
  159. // Register fonts.
  160. {
  161. OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Fonts");
  162. // TODO: Check if existing font definitions from the old theme are usable and copy them.
  163. // External function, see editor_fonts.cpp.
  164. print_verbose("EditorTheme: Generating new fonts.");
  165. editor_register_fonts(theme);
  166. OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Fonts");
  167. }
  168. // TODO: Check if existing style definitions from the old theme are usable and copy them.
  169. print_verbose("EditorTheme: Generating new styles.");
  170. _populate_standard_styles(theme, config);
  171. _populate_editor_styles(theme, config);
  172. _populate_text_editor_styles(theme, config);
  173. _populate_visual_shader_styles(theme, config);
  174. OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Create Base Theme");
  175. return theme;
  176. }
  177. EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(const Ref<EditorTheme> &p_theme) {
  178. ThemeConfiguration config;
  179. // Basic properties.
  180. config.preset = EDITOR_GET("interface/theme/preset");
  181. config.spacing_preset = EDITOR_GET("interface/theme/spacing_preset");
  182. config.base_color = EDITOR_GET("interface/theme/base_color");
  183. config.accent_color = EDITOR_GET("interface/theme/accent_color");
  184. config.contrast = EDITOR_GET("interface/theme/contrast");
  185. config.icon_saturation = EDITOR_GET("interface/theme/icon_saturation");
  186. // Extra properties.
  187. config.base_spacing = EDITOR_GET("interface/theme/base_spacing");
  188. config.extra_spacing = EDITOR_GET("interface/theme/additional_spacing");
  189. // Ensure borders are visible when using an editor scale below 100%.
  190. config.border_width = CLAMP((int)EDITOR_GET("interface/theme/border_size"), 0, 2) * MAX(1, EDSCALE);
  191. config.corner_radius = CLAMP((int)EDITOR_GET("interface/theme/corner_radius"), 0, 6);
  192. config.draw_extra_borders = EDITOR_GET("interface/theme/draw_extra_borders");
  193. config.relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
  194. config.thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
  195. config.class_icon_size = 16 * EDSCALE;
  196. config.enable_touch_optimizations = EDITOR_GET("interface/touchscreen/enable_touch_optimizations");
  197. config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
  198. config.color_picker_button_height = 28 * EDSCALE;
  199. config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint");
  200. config.default_contrast = 0.3; // Make sure to keep this in sync with the editor settings definition.
  201. // Handle main theme preset.
  202. {
  203. const bool follow_system_theme = EDITOR_GET("interface/theme/follow_system_theme");
  204. const bool use_system_accent_color = EDITOR_GET("interface/theme/use_system_accent_color");
  205. DisplayServer *display_server = DisplayServer::get_singleton();
  206. Color system_base_color = display_server->get_base_color();
  207. Color system_accent_color = display_server->get_accent_color();
  208. if (follow_system_theme) {
  209. String dark_theme = "Default";
  210. String light_theme = "Light";
  211. config.preset = light_theme; // Assume light theme if we can't detect system theme attributes.
  212. if (system_base_color == Color(0, 0, 0, 0)) {
  213. if (display_server->is_dark_mode_supported() && display_server->is_dark_mode()) {
  214. config.preset = dark_theme;
  215. }
  216. } else {
  217. if (system_base_color.get_luminance() < 0.5) {
  218. config.preset = dark_theme;
  219. }
  220. }
  221. }
  222. if (config.preset != "Custom") {
  223. Color preset_accent_color;
  224. Color preset_base_color;
  225. float preset_contrast = 0;
  226. bool preset_draw_extra_borders = false;
  227. // Please use alphabetical order if you're adding a new theme here.
  228. if (config.preset == "Breeze Dark") {
  229. preset_accent_color = Color(0.26, 0.76, 1.00);
  230. preset_base_color = Color(0.24, 0.26, 0.28);
  231. preset_contrast = config.default_contrast;
  232. } else if (config.preset == "Godot 2") {
  233. preset_accent_color = Color(0.53, 0.67, 0.89);
  234. preset_base_color = Color(0.24, 0.23, 0.27);
  235. preset_contrast = config.default_contrast;
  236. } else if (config.preset == "Gray") {
  237. preset_accent_color = Color(0.44, 0.73, 0.98);
  238. preset_base_color = Color(0.24, 0.24, 0.24);
  239. preset_contrast = config.default_contrast;
  240. } else if (config.preset == "Light") {
  241. preset_accent_color = Color(0.18, 0.50, 1.00);
  242. preset_base_color = Color(0.9, 0.9, 0.9);
  243. // A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".
  244. preset_contrast = -0.06;
  245. } else if (config.preset == "Solarized (Dark)") {
  246. preset_accent_color = Color(0.15, 0.55, 0.82);
  247. preset_base_color = Color(0.03, 0.21, 0.26);
  248. preset_contrast = 0.23;
  249. } else if (config.preset == "Solarized (Light)") {
  250. preset_accent_color = Color(0.15, 0.55, 0.82);
  251. preset_base_color = Color(0.89, 0.86, 0.79);
  252. // A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".
  253. preset_contrast = -0.06;
  254. } else if (config.preset == "Black (OLED)") {
  255. preset_accent_color = Color(0.45, 0.75, 1.0);
  256. preset_base_color = Color(0, 0, 0);
  257. // The contrast rate value is irrelevant on a fully black theme.
  258. preset_contrast = 0.0;
  259. preset_draw_extra_borders = true;
  260. } else { // Default
  261. preset_accent_color = Color(0.44, 0.73, 0.98);
  262. preset_base_color = Color(0.21, 0.24, 0.29);
  263. preset_contrast = config.default_contrast;
  264. }
  265. config.accent_color = preset_accent_color;
  266. config.base_color = preset_base_color;
  267. config.contrast = preset_contrast;
  268. config.draw_extra_borders = preset_draw_extra_borders;
  269. EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", config.accent_color);
  270. EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", config.base_color);
  271. EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", config.contrast);
  272. EditorSettings::get_singleton()->set_initial_value("interface/theme/draw_extra_borders", config.draw_extra_borders);
  273. }
  274. if (follow_system_theme && system_base_color != Color(0, 0, 0, 0)) {
  275. config.base_color = system_base_color;
  276. config.preset = "Custom";
  277. }
  278. if (use_system_accent_color && system_accent_color != Color(0, 0, 0, 0)) {
  279. config.accent_color = system_accent_color;
  280. config.preset = "Custom";
  281. }
  282. // Enforce values in case they were adjusted or overridden.
  283. EditorSettings::get_singleton()->set_manually("interface/theme/preset", config.preset);
  284. EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", config.accent_color);
  285. EditorSettings::get_singleton()->set_manually("interface/theme/base_color", config.base_color);
  286. EditorSettings::get_singleton()->set_manually("interface/theme/contrast", config.contrast);
  287. EditorSettings::get_singleton()->set_manually("interface/theme/draw_extra_borders", config.draw_extra_borders);
  288. }
  289. // Handle theme spacing preset.
  290. {
  291. if (config.spacing_preset != "Custom") {
  292. int preset_base_spacing = 0;
  293. int preset_extra_spacing = 0;
  294. Size2 preset_dialogs_buttons_min_size;
  295. if (config.spacing_preset == "Compact") {
  296. preset_base_spacing = 0;
  297. preset_extra_spacing = 4;
  298. preset_dialogs_buttons_min_size = Size2(90, 26);
  299. } else if (config.spacing_preset == "Spacious") {
  300. preset_base_spacing = 6;
  301. preset_extra_spacing = 2;
  302. preset_dialogs_buttons_min_size = Size2(112, 36);
  303. } else { // Default
  304. preset_base_spacing = 4;
  305. preset_extra_spacing = 0;
  306. preset_dialogs_buttons_min_size = Size2(105, 34);
  307. }
  308. config.base_spacing = preset_base_spacing;
  309. config.extra_spacing = preset_extra_spacing;
  310. config.dialogs_buttons_min_size = preset_dialogs_buttons_min_size;
  311. EditorSettings::get_singleton()->set_initial_value("interface/theme/base_spacing", config.base_spacing);
  312. EditorSettings::get_singleton()->set_initial_value("interface/theme/additional_spacing", config.extra_spacing);
  313. }
  314. // Enforce values in case they were adjusted or overridden.
  315. EditorSettings::get_singleton()->set_manually("interface/theme/spacing_preset", config.spacing_preset);
  316. EditorSettings::get_singleton()->set_manually("interface/theme/base_spacing", config.base_spacing);
  317. EditorSettings::get_singleton()->set_manually("interface/theme/additional_spacing", config.extra_spacing);
  318. }
  319. // Generated properties.
  320. config.dark_theme = is_dark_theme();
  321. config.base_margin = config.base_spacing;
  322. config.increased_margin = config.base_spacing + config.extra_spacing;
  323. config.separation_margin = (config.base_spacing + config.extra_spacing / 2) * EDSCALE;
  324. config.popup_margin = config.base_margin * 2.4 * EDSCALE;
  325. // Make sure content doesn't stick to window decorations; this can be fixed in future with layout changes.
  326. config.window_border_margin = MAX(1, config.base_margin * 2);
  327. config.top_bar_separation = config.base_margin * 2 * EDSCALE;
  328. // Force the v_separation to be even so that the spacing on top and bottom is even.
  329. // If the vsep is odd and cannot be split into 2 even groups (of pixels), then it will be lopsided.
  330. // We add 2 to the vsep to give it some extra spacing which looks a bit more modern (see Windows, for example).
  331. const int separation_base = config.increased_margin + 6;
  332. config.forced_even_separation = separation_base + (separation_base % 2);
  333. return config;
  334. }
  335. void EditorThemeManager::_create_shared_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
  336. // Colors.
  337. {
  338. // Base colors.
  339. p_theme->set_color("base_color", EditorStringName(Editor), p_config.base_color);
  340. p_theme->set_color("accent_color", EditorStringName(Editor), p_config.accent_color);
  341. // White (dark theme) or black (light theme), will be used to generate the rest of the colors
  342. p_config.mono_color = p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
  343. // Ensure base colors are in the 0..1 luminance range to avoid 8-bit integer overflow or text rendering issues.
  344. // Some places in the editor use 8-bit integer colors.
  345. p_config.dark_color_1 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast).clamp();
  346. p_config.dark_color_2 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 1.5).clamp();
  347. p_config.dark_color_3 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 2).clamp();
  348. p_config.contrast_color_1 = p_config.base_color.lerp(p_config.mono_color, MAX(p_config.contrast, p_config.default_contrast));
  349. p_config.contrast_color_2 = p_config.base_color.lerp(p_config.mono_color, MAX(p_config.contrast * 1.5, p_config.default_contrast * 1.5));
  350. p_config.highlight_color = Color(p_config.accent_color.r, p_config.accent_color.g, p_config.accent_color.b, 0.275);
  351. p_config.highlight_disabled_color = p_config.highlight_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.5);
  352. p_config.success_color = Color(0.45, 0.95, 0.5);
  353. p_config.warning_color = Color(1, 0.87, 0.4);
  354. p_config.error_color = Color(1, 0.47, 0.42);
  355. if (!p_config.dark_theme) {
  356. // Darken some colors to be readable on a light background.
  357. p_config.success_color = p_config.success_color.lerp(p_config.mono_color, 0.35);
  358. p_config.warning_color = Color(0.82, 0.56, 0.1);
  359. p_config.error_color = Color(0.8, 0.22, 0.22);
  360. }
  361. p_theme->set_color("mono_color", EditorStringName(Editor), p_config.mono_color);
  362. p_theme->set_color("dark_color_1", EditorStringName(Editor), p_config.dark_color_1);
  363. p_theme->set_color("dark_color_2", EditorStringName(Editor), p_config.dark_color_2);
  364. p_theme->set_color("dark_color_3", EditorStringName(Editor), p_config.dark_color_3);
  365. p_theme->set_color("contrast_color_1", EditorStringName(Editor), p_config.contrast_color_1);
  366. p_theme->set_color("contrast_color_2", EditorStringName(Editor), p_config.contrast_color_2);
  367. p_theme->set_color("highlight_color", EditorStringName(Editor), p_config.highlight_color);
  368. p_theme->set_color("highlight_disabled_color", EditorStringName(Editor), p_config.highlight_disabled_color);
  369. p_theme->set_color("success_color", EditorStringName(Editor), p_config.success_color);
  370. p_theme->set_color("warning_color", EditorStringName(Editor), p_config.warning_color);
  371. p_theme->set_color("error_color", EditorStringName(Editor), p_config.error_color);
  372. #ifndef DISABLE_DEPRECATED // Used before 4.3.
  373. p_theme->set_color("disabled_highlight_color", EditorStringName(Editor), p_config.highlight_disabled_color);
  374. #endif
  375. // Only used when the Draw Extra Borders editor setting is enabled.
  376. p_config.extra_border_color_1 = Color(0.5, 0.5, 0.5);
  377. p_config.extra_border_color_2 = p_config.dark_theme ? Color(0.3, 0.3, 0.3) : Color(0.7, 0.7, 0.7);
  378. p_theme->set_color("extra_border_color_1", EditorStringName(Editor), p_config.extra_border_color_1);
  379. p_theme->set_color("extra_border_color_2", EditorStringName(Editor), p_config.extra_border_color_2);
  380. // Font colors.
  381. p_config.font_color = p_config.mono_color.lerp(p_config.base_color, 0.25);
  382. p_config.font_focus_color = p_config.mono_color.lerp(p_config.base_color, 0.125);
  383. p_config.font_hover_color = p_config.mono_color.lerp(p_config.base_color, 0.125);
  384. p_config.font_pressed_color = p_config.accent_color;
  385. p_config.font_hover_pressed_color = p_config.font_hover_color.lerp(p_config.accent_color, 0.74);
  386. p_config.font_disabled_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.35);
  387. p_config.font_readonly_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.65);
  388. p_config.font_placeholder_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.5);
  389. p_config.font_outline_color = Color(0, 0, 0, 0);
  390. p_theme->set_color(SceneStringName(font_color), EditorStringName(Editor), p_config.font_color);
  391. p_theme->set_color("font_focus_color", EditorStringName(Editor), p_config.font_focus_color);
  392. p_theme->set_color("font_hover_color", EditorStringName(Editor), p_config.font_hover_color);
  393. p_theme->set_color("font_pressed_color", EditorStringName(Editor), p_config.font_pressed_color);
  394. p_theme->set_color("font_hover_pressed_color", EditorStringName(Editor), p_config.font_hover_pressed_color);
  395. p_theme->set_color("font_disabled_color", EditorStringName(Editor), p_config.font_disabled_color);
  396. p_theme->set_color("font_readonly_color", EditorStringName(Editor), p_config.font_readonly_color);
  397. p_theme->set_color("font_placeholder_color", EditorStringName(Editor), p_config.font_placeholder_color);
  398. p_theme->set_color("font_outline_color", EditorStringName(Editor), p_config.font_outline_color);
  399. #ifndef DISABLE_DEPRECATED // Used before 4.3.
  400. p_theme->set_color("readonly_font_color", EditorStringName(Editor), p_config.font_readonly_color);
  401. p_theme->set_color("disabled_font_color", EditorStringName(Editor), p_config.font_disabled_color);
  402. p_theme->set_color("readonly_color", EditorStringName(Editor), p_config.font_readonly_color);
  403. p_theme->set_color("highlighted_font_color", EditorStringName(Editor), p_config.font_hover_color); // Closest equivalent.
  404. #endif
  405. // Icon colors.
  406. p_config.icon_normal_color = Color(1, 1, 1);
  407. p_config.icon_focus_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.45);
  408. p_config.icon_focus_color.a = 1.0;
  409. p_config.icon_hover_color = p_config.icon_focus_color;
  410. // Make the pressed icon color overbright because icons are not completely white on a dark theme.
  411. // On a light theme, icons are dark, so we need to modulate them with an even brighter color.
  412. p_config.icon_pressed_color = p_config.accent_color * (p_config.dark_theme ? 1.15 : 3.5);
  413. p_config.icon_pressed_color.a = 1.0;
  414. p_config.icon_disabled_color = Color(p_config.icon_normal_color, 0.4);
  415. p_theme->set_color("icon_normal_color", EditorStringName(Editor), p_config.icon_normal_color);
  416. p_theme->set_color("icon_focus_color", EditorStringName(Editor), p_config.icon_focus_color);
  417. p_theme->set_color("icon_hover_color", EditorStringName(Editor), p_config.icon_hover_color);
  418. p_theme->set_color("icon_pressed_color", EditorStringName(Editor), p_config.icon_pressed_color);
  419. p_theme->set_color("icon_disabled_color", EditorStringName(Editor), p_config.icon_disabled_color);
  420. // Additional GUI colors.
  421. p_config.shadow_color = Color(0, 0, 0, p_config.dark_theme ? 0.3 : 0.1);
  422. p_config.selection_color = p_config.accent_color * Color(1, 1, 1, 0.4);
  423. p_config.disabled_border_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.7);
  424. p_config.disabled_bg_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.9);
  425. p_config.separator_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.1);
  426. p_theme->set_color("selection_color", EditorStringName(Editor), p_config.selection_color);
  427. p_theme->set_color("disabled_border_color", EditorStringName(Editor), p_config.disabled_border_color);
  428. p_theme->set_color("disabled_bg_color", EditorStringName(Editor), p_config.disabled_bg_color);
  429. p_theme->set_color("separator_color", EditorStringName(Editor), p_config.separator_color);
  430. // Additional editor colors.
  431. p_theme->set_color("box_selection_fill_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.3));
  432. p_theme->set_color("box_selection_stroke_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.8));
  433. p_theme->set_color("axis_x_color", EditorStringName(Editor), Color(0.96, 0.20, 0.32));
  434. p_theme->set_color("axis_y_color", EditorStringName(Editor), Color(0.53, 0.84, 0.01));
  435. p_theme->set_color("axis_z_color", EditorStringName(Editor), Color(0.16, 0.55, 0.96));
  436. p_theme->set_color("axis_w_color", EditorStringName(Editor), Color(0.55, 0.55, 0.55));
  437. const float prop_color_saturation = p_config.accent_color.get_s() * 0.75;
  438. const float prop_color_value = p_config.accent_color.get_v();
  439. p_theme->set_color("property_color_x", EditorStringName(Editor), Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
  440. p_theme->set_color("property_color_y", EditorStringName(Editor), Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
  441. p_theme->set_color("property_color_z", EditorStringName(Editor), Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
  442. p_theme->set_color("property_color_w", EditorStringName(Editor), Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
  443. // Special colors for rendering methods.
  444. p_theme->set_color("forward_plus_color", EditorStringName(Editor), Color::hex(0x5d8c3fff));
  445. p_theme->set_color("mobile_color", EditorStringName(Editor), Color::hex(0xa5557dff));
  446. p_theme->set_color("gl_compatibility_color", EditorStringName(Editor), Color::hex(0x5586a4ff));
  447. if (p_config.dark_theme) {
  448. p_theme->set_color("highend_color", EditorStringName(Editor), Color(1.0, 0.0, 0.0));
  449. } else {
  450. p_theme->set_color("highend_color", EditorStringName(Editor), Color::hex(0xad1128ff));
  451. }
  452. }
  453. // Constants.
  454. {
  455. // Can't save single float in theme, so using Color.
  456. p_theme->set_color("icon_saturation", EditorStringName(Editor), Color(p_config.icon_saturation, p_config.icon_saturation, p_config.icon_saturation));
  457. // Controls may rely on the scale for their internal drawing logic.
  458. p_theme->set_default_base_scale(EDSCALE);
  459. p_theme->set_constant("scale", EditorStringName(Editor), EDSCALE);
  460. p_theme->set_constant("thumb_size", EditorStringName(Editor), p_config.thumb_size);
  461. p_theme->set_constant("class_icon_size", EditorStringName(Editor), p_config.class_icon_size);
  462. p_theme->set_constant("color_picker_button_height", EditorStringName(Editor), p_config.color_picker_button_height);
  463. p_theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), p_config.gizmo_handle_scale);
  464. p_theme->set_constant("base_margin", EditorStringName(Editor), p_config.base_margin);
  465. p_theme->set_constant("increased_margin", EditorStringName(Editor), p_config.increased_margin);
  466. p_theme->set_constant("window_border_margin", EditorStringName(Editor), p_config.window_border_margin);
  467. p_theme->set_constant("top_bar_separation", EditorStringName(Editor), p_config.top_bar_separation);
  468. p_theme->set_constant("dark_theme", EditorStringName(Editor), p_config.dark_theme);
  469. }
  470. // Styleboxes.
  471. {
  472. // This is the basic stylebox, used as a base for most other styleboxes (through `duplicate()`).
  473. p_config.base_style = make_flat_stylebox(p_config.base_color, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.corner_radius);
  474. p_config.base_style->set_border_width_all(p_config.border_width);
  475. p_config.base_style->set_border_color(p_config.base_color);
  476. p_config.base_empty_style = make_empty_stylebox(p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
  477. // Button styles.
  478. {
  479. p_config.widget_margin = Vector2(p_config.increased_margin + 2, p_config.increased_margin + 1) * EDSCALE;
  480. p_config.button_style = p_config.base_style->duplicate();
  481. p_config.button_style->set_content_margin_individual(p_config.widget_margin.x, p_config.widget_margin.y, p_config.widget_margin.x, p_config.widget_margin.y);
  482. p_config.button_style->set_bg_color(p_config.dark_color_1);
  483. if (p_config.draw_extra_borders) {
  484. p_config.button_style->set_border_width_all(Math::round(EDSCALE));
  485. p_config.button_style->set_border_color(p_config.extra_border_color_1);
  486. } else {
  487. p_config.button_style->set_border_color(p_config.dark_color_2);
  488. }
  489. p_config.button_style_disabled = p_config.button_style->duplicate();
  490. p_config.button_style_disabled->set_bg_color(p_config.disabled_bg_color);
  491. if (p_config.draw_extra_borders) {
  492. p_config.button_style_disabled->set_border_color(p_config.extra_border_color_2);
  493. } else {
  494. p_config.button_style_disabled->set_border_color(p_config.disabled_border_color);
  495. }
  496. p_config.button_style_focus = p_config.button_style->duplicate();
  497. p_config.button_style_focus->set_draw_center(false);
  498. p_config.button_style_focus->set_border_width_all(Math::round(2 * MAX(1, EDSCALE)));
  499. p_config.button_style_focus->set_border_color(p_config.accent_color);
  500. p_config.button_style_pressed = p_config.button_style->duplicate();
  501. p_config.button_style_pressed->set_bg_color(p_config.dark_color_1.darkened(0.125));
  502. p_config.button_style_hover = p_config.button_style->duplicate();
  503. p_config.button_style_hover->set_bg_color(p_config.mono_color * Color(1, 1, 1, 0.11));
  504. if (p_config.draw_extra_borders) {
  505. p_config.button_style_hover->set_border_color(p_config.extra_border_color_1);
  506. } else {
  507. p_config.button_style_hover->set_border_color(p_config.mono_color * Color(1, 1, 1, 0.05));
  508. }
  509. }
  510. // Windows and popups.
  511. {
  512. p_config.popup_style = p_config.base_style->duplicate();
  513. p_config.popup_style->set_content_margin_all(p_config.popup_margin);
  514. p_config.popup_style->set_border_color(p_config.contrast_color_1);
  515. p_config.popup_style->set_shadow_color(p_config.shadow_color);
  516. p_config.popup_style->set_shadow_size(4 * EDSCALE);
  517. // Popups are separate windows by default in the editor. Windows currently don't support per-pixel transparency
  518. // in 4.0, and even if it was, it may not always work in practice (e.g. running with compositing disabled).
  519. p_config.popup_style->set_corner_radius_all(0);
  520. p_config.popup_border_style = p_config.popup_style->duplicate();
  521. p_config.popup_border_style->set_content_margin_all(MAX(Math::round(EDSCALE), p_config.border_width) + 2 + (p_config.base_margin * 1.5) * EDSCALE);
  522. // Always display a border for popups like PopupMenus so they can be distinguished from their background.
  523. p_config.popup_border_style->set_border_width_all(MAX(Math::round(EDSCALE), p_config.border_width));
  524. if (p_config.draw_extra_borders) {
  525. p_config.popup_border_style->set_border_color(p_config.extra_border_color_2);
  526. } else {
  527. p_config.popup_border_style->set_border_color(p_config.dark_color_2);
  528. }
  529. p_config.window_style = p_config.popup_style->duplicate();
  530. p_config.window_style->set_border_color(p_config.base_color);
  531. p_config.window_style->set_border_width(SIDE_TOP, 24 * EDSCALE);
  532. p_config.window_style->set_expand_margin(SIDE_TOP, 24 * EDSCALE);
  533. // Prevent corner artifacts between window title and body.
  534. p_config.dialog_style = p_config.base_style->duplicate();
  535. p_config.dialog_style->set_corner_radius(CORNER_TOP_LEFT, 0);
  536. p_config.dialog_style->set_corner_radius(CORNER_TOP_RIGHT, 0);
  537. p_config.dialog_style->set_content_margin_all(p_config.popup_margin);
  538. // Prevent visible line between window title and body.
  539. p_config.dialog_style->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE);
  540. }
  541. // Panels.
  542. {
  543. p_config.panel_container_style = p_config.button_style->duplicate();
  544. p_config.panel_container_style->set_draw_center(false);
  545. p_config.panel_container_style->set_border_width_all(0);
  546. // Content panel for tabs and similar containers.
  547. // Compensate for the border.
  548. const int content_panel_margin = p_config.base_margin * EDSCALE + p_config.border_width;
  549. p_config.content_panel_style = p_config.base_style->duplicate();
  550. p_config.content_panel_style->set_border_color(p_config.dark_color_3);
  551. p_config.content_panel_style->set_border_width_all(p_config.border_width);
  552. p_config.content_panel_style->set_border_width(Side::SIDE_TOP, 0);
  553. p_config.content_panel_style->set_corner_radius(CORNER_TOP_LEFT, 0);
  554. p_config.content_panel_style->set_corner_radius(CORNER_TOP_RIGHT, 0);
  555. p_config.content_panel_style->set_content_margin_individual(content_panel_margin, 2 * EDSCALE + content_panel_margin, content_panel_margin, content_panel_margin);
  556. // Trees and similarly inset panels.
  557. p_config.tree_panel_style = p_config.base_style->duplicate();
  558. // Make Trees easier to distinguish from other controls by using a darker background color.
  559. p_config.tree_panel_style->set_bg_color(p_config.dark_color_1.lerp(p_config.dark_color_2, 0.5));
  560. if (p_config.draw_extra_borders) {
  561. p_config.tree_panel_style->set_border_width_all(Math::round(EDSCALE));
  562. p_config.tree_panel_style->set_border_color(p_config.extra_border_color_2);
  563. } else {
  564. p_config.tree_panel_style->set_border_color(p_config.dark_color_3);
  565. }
  566. }
  567. }
  568. }
  569. void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
  570. // Panels.
  571. {
  572. // Panel.
  573. p_theme->set_stylebox(SceneStringName(panel), "Panel", make_flat_stylebox(p_config.dark_color_1, 6, 4, 6, 4, p_config.corner_radius));
  574. // PanelContainer.
  575. p_theme->set_stylebox(SceneStringName(panel), "PanelContainer", p_config.panel_container_style);
  576. // TooltipPanel & TooltipLabel.
  577. {
  578. // TooltipPanel is also used for custom tooltips, while TooltipLabel
  579. // is only relevant for default tooltips.
  580. p_theme->set_color(SceneStringName(font_color), "TooltipLabel", p_config.font_hover_color);
  581. p_theme->set_color("font_shadow_color", "TooltipLabel", Color(0, 0, 0, 0));
  582. Ref<StyleBoxFlat> style_tooltip = p_config.popup_style->duplicate();
  583. style_tooltip->set_shadow_size(0);
  584. style_tooltip->set_content_margin_all(p_config.base_margin * EDSCALE * 0.5);
  585. style_tooltip->set_bg_color(p_config.dark_color_3 * Color(0.8, 0.8, 0.8, 0.9));
  586. style_tooltip->set_border_width_all(0);
  587. p_theme->set_stylebox(SceneStringName(panel), "TooltipPanel", style_tooltip);
  588. }
  589. // PopupPanel
  590. p_theme->set_stylebox(SceneStringName(panel), "PopupPanel", p_config.popup_border_style);
  591. }
  592. // Buttons.
  593. {
  594. // Button.
  595. p_theme->set_stylebox(CoreStringName(normal), "Button", p_config.button_style);
  596. p_theme->set_stylebox(SceneStringName(hover), "Button", p_config.button_style_hover);
  597. p_theme->set_stylebox(SceneStringName(pressed), "Button", p_config.button_style_pressed);
  598. p_theme->set_stylebox("focus", "Button", p_config.button_style_focus);
  599. p_theme->set_stylebox("disabled", "Button", p_config.button_style_disabled);
  600. p_theme->set_color(SceneStringName(font_color), "Button", p_config.font_color);
  601. p_theme->set_color("font_hover_color", "Button", p_config.font_hover_color);
  602. p_theme->set_color("font_hover_pressed_color", "Button", p_config.font_hover_pressed_color);
  603. p_theme->set_color("font_focus_color", "Button", p_config.font_focus_color);
  604. p_theme->set_color("font_pressed_color", "Button", p_config.font_pressed_color);
  605. p_theme->set_color("font_disabled_color", "Button", p_config.font_disabled_color);
  606. p_theme->set_color("font_outline_color", "Button", p_config.font_outline_color);
  607. p_theme->set_color("icon_normal_color", "Button", p_config.icon_normal_color);
  608. p_theme->set_color("icon_hover_color", "Button", p_config.icon_hover_color);
  609. p_theme->set_color("icon_focus_color", "Button", p_config.icon_focus_color);
  610. p_theme->set_color("icon_hover_pressed_color", "Button", p_config.icon_pressed_color);
  611. p_theme->set_color("icon_pressed_color", "Button", p_config.icon_pressed_color);
  612. p_theme->set_color("icon_disabled_color", "Button", p_config.icon_disabled_color);
  613. p_theme->set_constant("h_separation", "Button", 4 * EDSCALE);
  614. p_theme->set_constant("outline_size", "Button", 0);
  615. p_theme->set_constant("align_to_largest_stylebox", "Button", 1); // Enabled.
  616. // MenuButton.
  617. p_theme->set_stylebox(CoreStringName(normal), "MenuButton", p_config.panel_container_style);
  618. p_theme->set_stylebox(SceneStringName(hover), "MenuButton", p_config.button_style_hover);
  619. p_theme->set_stylebox(SceneStringName(pressed), "MenuButton", p_config.panel_container_style);
  620. p_theme->set_stylebox("focus", "MenuButton", p_config.panel_container_style);
  621. p_theme->set_stylebox("disabled", "MenuButton", p_config.panel_container_style);
  622. p_theme->set_color(SceneStringName(font_color), "MenuButton", p_config.font_color);
  623. p_theme->set_color("font_hover_color", "MenuButton", p_config.font_hover_color);
  624. p_theme->set_color("font_hover_pressed_color", "MenuButton", p_config.font_hover_pressed_color);
  625. p_theme->set_color("font_focus_color", "MenuButton", p_config.font_focus_color);
  626. p_theme->set_color("font_outline_color", "MenuButton", p_config.font_outline_color);
  627. p_theme->set_constant("outline_size", "MenuButton", 0);
  628. // MenuBar.
  629. p_theme->set_stylebox(CoreStringName(normal), "MenuBar", p_config.button_style);
  630. p_theme->set_stylebox(SceneStringName(hover), "MenuBar", p_config.button_style_hover);
  631. p_theme->set_stylebox(SceneStringName(pressed), "MenuBar", p_config.button_style_pressed);
  632. p_theme->set_stylebox("disabled", "MenuBar", p_config.button_style_disabled);
  633. p_theme->set_color(SceneStringName(font_color), "MenuBar", p_config.font_color);
  634. p_theme->set_color("font_hover_color", "MenuBar", p_config.font_hover_color);
  635. p_theme->set_color("font_hover_pressed_color", "MenuBar", p_config.font_hover_pressed_color);
  636. p_theme->set_color("font_focus_color", "MenuBar", p_config.font_focus_color);
  637. p_theme->set_color("font_pressed_color", "MenuBar", p_config.font_pressed_color);
  638. p_theme->set_color("font_disabled_color", "MenuBar", p_config.font_disabled_color);
  639. p_theme->set_color("font_outline_color", "MenuBar", p_config.font_outline_color);
  640. p_theme->set_color("icon_normal_color", "MenuBar", p_config.icon_normal_color);
  641. p_theme->set_color("icon_hover_color", "MenuBar", p_config.icon_hover_color);
  642. p_theme->set_color("icon_focus_color", "MenuBar", p_config.icon_focus_color);
  643. p_theme->set_color("icon_pressed_color", "MenuBar", p_config.icon_pressed_color);
  644. p_theme->set_color("icon_disabled_color", "MenuBar", p_config.icon_disabled_color);
  645. p_theme->set_constant("h_separation", "MenuBar", 4 * EDSCALE);
  646. p_theme->set_constant("outline_size", "MenuBar", 0);
  647. // OptionButton.
  648. {
  649. Ref<StyleBoxFlat> option_button_focus_style = p_config.button_style_focus->duplicate();
  650. Ref<StyleBoxFlat> option_button_normal_style = p_config.button_style->duplicate();
  651. Ref<StyleBoxFlat> option_button_hover_style = p_config.button_style_hover->duplicate();
  652. Ref<StyleBoxFlat> option_button_pressed_style = p_config.button_style_pressed->duplicate();
  653. Ref<StyleBoxFlat> option_button_disabled_style = p_config.button_style_disabled->duplicate();
  654. option_button_focus_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
  655. option_button_normal_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
  656. option_button_hover_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
  657. option_button_pressed_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
  658. option_button_disabled_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
  659. p_theme->set_stylebox("focus", "OptionButton", option_button_focus_style);
  660. p_theme->set_stylebox(CoreStringName(normal), "OptionButton", p_config.button_style);
  661. p_theme->set_stylebox(SceneStringName(hover), "OptionButton", p_config.button_style_hover);
  662. p_theme->set_stylebox(SceneStringName(pressed), "OptionButton", p_config.button_style_pressed);
  663. p_theme->set_stylebox("disabled", "OptionButton", p_config.button_style_disabled);
  664. p_theme->set_stylebox("normal_mirrored", "OptionButton", option_button_normal_style);
  665. p_theme->set_stylebox("hover_mirrored", "OptionButton", option_button_hover_style);
  666. p_theme->set_stylebox("pressed_mirrored", "OptionButton", option_button_pressed_style);
  667. p_theme->set_stylebox("disabled_mirrored", "OptionButton", option_button_disabled_style);
  668. p_theme->set_color(SceneStringName(font_color), "OptionButton", p_config.font_color);
  669. p_theme->set_color("font_hover_color", "OptionButton", p_config.font_hover_color);
  670. p_theme->set_color("font_hover_pressed_color", "OptionButton", p_config.font_hover_pressed_color);
  671. p_theme->set_color("font_focus_color", "OptionButton", p_config.font_focus_color);
  672. p_theme->set_color("font_pressed_color", "OptionButton", p_config.font_pressed_color);
  673. p_theme->set_color("font_disabled_color", "OptionButton", p_config.font_disabled_color);
  674. p_theme->set_color("font_outline_color", "OptionButton", p_config.font_outline_color);
  675. p_theme->set_color("icon_normal_color", "OptionButton", p_config.icon_normal_color);
  676. p_theme->set_color("icon_hover_color", "OptionButton", p_config.icon_hover_color);
  677. p_theme->set_color("icon_focus_color", "OptionButton", p_config.icon_focus_color);
  678. p_theme->set_color("icon_pressed_color", "OptionButton", p_config.icon_pressed_color);
  679. p_theme->set_color("icon_disabled_color", "OptionButton", p_config.icon_disabled_color);
  680. p_theme->set_icon("arrow", "OptionButton", p_theme->get_icon(SNAME("GuiOptionArrow"), EditorStringName(EditorIcons)));
  681. p_theme->set_constant("arrow_margin", "OptionButton", p_config.widget_margin.x - 2 * EDSCALE);
  682. p_theme->set_constant("modulate_arrow", "OptionButton", true);
  683. p_theme->set_constant("h_separation", "OptionButton", 4 * EDSCALE);
  684. p_theme->set_constant("outline_size", "OptionButton", 0);
  685. }
  686. // CheckButton.
  687. p_theme->set_stylebox(CoreStringName(normal), "CheckButton", p_config.panel_container_style);
  688. p_theme->set_stylebox(SceneStringName(pressed), "CheckButton", p_config.panel_container_style);
  689. p_theme->set_stylebox("disabled", "CheckButton", p_config.panel_container_style);
  690. p_theme->set_stylebox(SceneStringName(hover), "CheckButton", p_config.panel_container_style);
  691. p_theme->set_stylebox("hover_pressed", "CheckButton", p_config.panel_container_style);
  692. p_theme->set_icon("checked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOn"), EditorStringName(EditorIcons)));
  693. p_theme->set_icon("checked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabled"), EditorStringName(EditorIcons)));
  694. p_theme->set_icon("unchecked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOff"), EditorStringName(EditorIcons)));
  695. p_theme->set_icon("unchecked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabled"), EditorStringName(EditorIcons)));
  696. p_theme->set_icon("checked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnMirrored"), EditorStringName(EditorIcons)));
  697. p_theme->set_icon("checked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), EditorStringName(EditorIcons)));
  698. p_theme->set_icon("unchecked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffMirrored"), EditorStringName(EditorIcons)));
  699. p_theme->set_icon("unchecked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), EditorStringName(EditorIcons)));
  700. p_theme->set_color(SceneStringName(font_color), "CheckButton", p_config.font_color);
  701. p_theme->set_color("font_hover_color", "CheckButton", p_config.font_hover_color);
  702. p_theme->set_color("font_hover_pressed_color", "CheckButton", p_config.font_hover_pressed_color);
  703. p_theme->set_color("font_focus_color", "CheckButton", p_config.font_focus_color);
  704. p_theme->set_color("font_pressed_color", "CheckButton", p_config.font_pressed_color);
  705. p_theme->set_color("font_disabled_color", "CheckButton", p_config.font_disabled_color);
  706. p_theme->set_color("font_outline_color", "CheckButton", p_config.font_outline_color);
  707. p_theme->set_color("icon_normal_color", "CheckButton", p_config.icon_normal_color);
  708. p_theme->set_color("icon_hover_color", "CheckButton", p_config.icon_hover_color);
  709. p_theme->set_color("icon_focus_color", "CheckButton", p_config.icon_focus_color);
  710. p_theme->set_color("icon_pressed_color", "CheckButton", p_config.icon_pressed_color);
  711. p_theme->set_color("icon_disabled_color", "CheckButton", p_config.icon_disabled_color);
  712. p_theme->set_constant("h_separation", "CheckButton", 8 * EDSCALE);
  713. p_theme->set_constant("check_v_offset", "CheckButton", 0);
  714. p_theme->set_constant("outline_size", "CheckButton", 0);
  715. // CheckBox.
  716. {
  717. Ref<StyleBoxFlat> checkbox_style = p_config.panel_container_style->duplicate();
  718. p_theme->set_stylebox(CoreStringName(normal), "CheckBox", checkbox_style);
  719. p_theme->set_stylebox(SceneStringName(pressed), "CheckBox", checkbox_style);
  720. p_theme->set_stylebox("disabled", "CheckBox", checkbox_style);
  721. p_theme->set_stylebox(SceneStringName(hover), "CheckBox", checkbox_style);
  722. p_theme->set_stylebox("hover_pressed", "CheckBox", checkbox_style);
  723. p_theme->set_icon("checked", "CheckBox", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
  724. p_theme->set_icon("unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
  725. p_theme->set_icon("radio_checked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons)));
  726. p_theme->set_icon("radio_unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons)));
  727. p_theme->set_icon("checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
  728. p_theme->set_icon("unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
  729. p_theme->set_icon("radio_checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons)));
  730. p_theme->set_icon("radio_unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons)));
  731. p_theme->set_color(SceneStringName(font_color), "CheckBox", p_config.font_color);
  732. p_theme->set_color("font_hover_color", "CheckBox", p_config.font_hover_color);
  733. p_theme->set_color("font_hover_pressed_color", "CheckBox", p_config.font_hover_pressed_color);
  734. p_theme->set_color("font_focus_color", "CheckBox", p_config.font_focus_color);
  735. p_theme->set_color("font_pressed_color", "CheckBox", p_config.font_pressed_color);
  736. p_theme->set_color("font_disabled_color", "CheckBox", p_config.font_disabled_color);
  737. p_theme->set_color("font_outline_color", "CheckBox", p_config.font_outline_color);
  738. p_theme->set_color("icon_normal_color", "CheckBox", p_config.icon_normal_color);
  739. p_theme->set_color("icon_hover_color", "CheckBox", p_config.icon_hover_color);
  740. p_theme->set_color("icon_focus_color", "CheckBox", p_config.icon_focus_color);
  741. p_theme->set_color("icon_pressed_color", "CheckBox", p_config.icon_pressed_color);
  742. p_theme->set_color("icon_disabled_color", "CheckBox", p_config.icon_disabled_color);
  743. p_theme->set_constant("h_separation", "CheckBox", 8 * EDSCALE);
  744. p_theme->set_constant("check_v_offset", "CheckBox", 0);
  745. p_theme->set_constant("outline_size", "CheckBox", 0);
  746. }
  747. // LinkButton.
  748. p_theme->set_stylebox("focus", "LinkButton", p_config.base_empty_style);
  749. p_theme->set_color(SceneStringName(font_color), "LinkButton", p_config.font_color);
  750. p_theme->set_color("font_hover_color", "LinkButton", p_config.font_hover_color);
  751. p_theme->set_color("font_hover_pressed_color", "LinkButton", p_config.font_hover_pressed_color);
  752. p_theme->set_color("font_focus_color", "LinkButton", p_config.font_focus_color);
  753. p_theme->set_color("font_pressed_color", "LinkButton", p_config.font_pressed_color);
  754. p_theme->set_color("font_disabled_color", "LinkButton", p_config.font_disabled_color);
  755. p_theme->set_color("font_outline_color", "LinkButton", p_config.font_outline_color);
  756. p_theme->set_constant("outline_size", "LinkButton", 0);
  757. }
  758. // Tree & ItemList.
  759. {
  760. Ref<StyleBoxFlat> style_tree_focus = p_config.base_style->duplicate();
  761. style_tree_focus->set_bg_color(p_config.highlight_color);
  762. style_tree_focus->set_border_width_all(0);
  763. Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
  764. const Color guide_color = p_config.mono_color * Color(1, 1, 1, 0.05);
  765. // Tree.
  766. {
  767. p_theme->set_icon("checked", "Tree", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
  768. p_theme->set_icon("checked_disabled", "Tree", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
  769. p_theme->set_icon("indeterminate", "Tree", p_theme->get_icon(SNAME("GuiIndeterminate"), EditorStringName(EditorIcons)));
  770. p_theme->set_icon("indeterminate_disabled", "Tree", p_theme->get_icon(SNAME("GuiIndeterminateDisabled"), EditorStringName(EditorIcons)));
  771. p_theme->set_icon("unchecked", "Tree", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
  772. p_theme->set_icon("unchecked_disabled", "Tree", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
  773. p_theme->set_icon("arrow", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons)));
  774. p_theme->set_icon("arrow_collapsed", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons)));
  775. p_theme->set_icon("arrow_collapsed_mirrored", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons)));
  776. p_theme->set_icon("updown", "Tree", p_theme->get_icon(SNAME("GuiTreeUpdown"), EditorStringName(EditorIcons)));
  777. p_theme->set_icon("select_arrow", "Tree", p_theme->get_icon(SNAME("GuiDropdown"), EditorStringName(EditorIcons)));
  778. p_theme->set_stylebox(SceneStringName(panel), "Tree", p_config.tree_panel_style);
  779. p_theme->set_stylebox("focus", "Tree", p_config.button_style_focus);
  780. p_theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
  781. p_theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
  782. p_theme->set_stylebox("custom_button_hover", "Tree", p_config.button_style);
  783. p_theme->set_color("custom_button_font_highlight", "Tree", p_config.font_hover_color);
  784. p_theme->set_color(SceneStringName(font_color), "Tree", p_config.font_color);
  785. p_theme->set_color("font_hovered_color", "Tree", p_config.mono_color);
  786. p_theme->set_color("font_hovered_dimmed_color", "Tree", p_config.font_color);
  787. p_theme->set_color("font_hovered_selected_color", "Tree", p_config.mono_color);
  788. p_theme->set_color("font_selected_color", "Tree", p_config.mono_color);
  789. p_theme->set_color("font_disabled_color", "Tree", p_config.font_disabled_color);
  790. p_theme->set_color("font_outline_color", "Tree", p_config.font_outline_color);
  791. p_theme->set_color("title_button_color", "Tree", p_config.font_color);
  792. p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);
  793. p_theme->set_constant("v_separation", "Tree", p_config.separation_margin);
  794. p_theme->set_constant("h_separation", "Tree", (p_config.increased_margin + 2) * EDSCALE);
  795. p_theme->set_constant("guide_width", "Tree", p_config.border_width);
  796. p_theme->set_constant("item_margin", "Tree", MAX(3 * p_config.increased_margin * EDSCALE, 12 * EDSCALE));
  797. p_theme->set_constant("inner_item_margin_top", "Tree", p_config.separation_margin);
  798. p_theme->set_constant("inner_item_margin_bottom", "Tree", p_config.separation_margin);
  799. p_theme->set_constant("inner_item_margin_left", "Tree", p_config.increased_margin * EDSCALE);
  800. p_theme->set_constant("inner_item_margin_right", "Tree", p_config.increased_margin * EDSCALE);
  801. p_theme->set_constant("button_margin", "Tree", p_config.base_margin * EDSCALE);
  802. p_theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
  803. p_theme->set_constant("scroll_speed", "Tree", 12);
  804. p_theme->set_constant("outline_size", "Tree", 0);
  805. p_theme->set_constant("scrollbar_margin_left", "Tree", 0);
  806. p_theme->set_constant("scrollbar_margin_top", "Tree", 0);
  807. p_theme->set_constant("scrollbar_margin_right", "Tree", 0);
  808. p_theme->set_constant("scrollbar_margin_bottom", "Tree", 0);
  809. p_theme->set_constant("scrollbar_h_separation", "Tree", 1 * EDSCALE);
  810. p_theme->set_constant("scrollbar_v_separation", "Tree", 1 * EDSCALE);
  811. Color relationship_line_color = p_config.mono_color * Color(1, 1, 1, p_config.relationship_line_opacity);
  812. p_theme->set_constant("draw_guides", "Tree", p_config.relationship_line_opacity < 0.01);
  813. p_theme->set_color("guide_color", "Tree", guide_color);
  814. int relationship_line_width = 1;
  815. Color parent_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.45, 0.0, 1.0));
  816. Color children_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.25, 0.0, 1.0));
  817. p_theme->set_constant("draw_relationship_lines", "Tree", p_config.relationship_line_opacity >= 0.01);
  818. p_theme->set_constant("relationship_line_width", "Tree", relationship_line_width);
  819. p_theme->set_constant("parent_hl_line_width", "Tree", relationship_line_width * 2);
  820. p_theme->set_constant("children_hl_line_width", "Tree", relationship_line_width);
  821. p_theme->set_constant("parent_hl_line_margin", "Tree", relationship_line_width * 3);
  822. p_theme->set_color("relationship_line_color", "Tree", relationship_line_color);
  823. p_theme->set_color("parent_hl_line_color", "Tree", parent_line_color);
  824. p_theme->set_color("children_hl_line_color", "Tree", children_line_color);
  825. p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);
  826. Ref<StyleBoxFlat> style_tree_btn = p_config.base_style->duplicate();
  827. style_tree_btn->set_bg_color(p_config.highlight_color);
  828. style_tree_btn->set_border_width_all(0);
  829. p_theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
  830. Ref<StyleBoxFlat> style_tree_hover = p_config.base_style->duplicate();
  831. style_tree_hover->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.4));
  832. style_tree_hover->set_border_width_all(0);
  833. p_theme->set_stylebox("hovered", "Tree", style_tree_hover);
  834. p_theme->set_stylebox("button_hover", "Tree", style_tree_hover);
  835. Ref<StyleBoxFlat> style_tree_hover_dimmed = p_config.base_style->duplicate();
  836. style_tree_hover_dimmed->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.2));
  837. style_tree_hover_dimmed->set_border_width_all(0);
  838. p_theme->set_stylebox("hovered_dimmed", "Tree", style_tree_hover_dimmed);
  839. Ref<StyleBoxFlat> style_tree_hover_selected = style_tree_selected->duplicate();
  840. style_tree_hover_selected->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 1.2));
  841. style_tree_hover_selected->set_border_width_all(0);
  842. p_theme->set_stylebox("hovered_selected", "Tree", style_tree_hover_selected);
  843. p_theme->set_stylebox("hovered_selected_focus", "Tree", style_tree_hover_selected);
  844. p_theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
  845. p_theme->set_stylebox("selected", "Tree", style_tree_selected);
  846. Ref<StyleBoxFlat> style_tree_cursor = p_config.base_style->duplicate();
  847. style_tree_cursor->set_draw_center(false);
  848. style_tree_cursor->set_border_width_all(MAX(1, p_config.border_width));
  849. style_tree_cursor->set_border_color(p_config.contrast_color_1);
  850. Ref<StyleBoxFlat> style_tree_title = p_config.base_style->duplicate();
  851. style_tree_title->set_bg_color(p_config.dark_color_3);
  852. style_tree_title->set_border_width_all(0);
  853. p_theme->set_stylebox("cursor", "Tree", style_tree_cursor);
  854. p_theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
  855. p_theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
  856. p_theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
  857. p_theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
  858. }
  859. // ItemList.
  860. {
  861. Ref<StyleBoxFlat> style_itemlist_bg = p_config.base_style->duplicate();
  862. style_itemlist_bg->set_content_margin_all(p_config.separation_margin);
  863. style_itemlist_bg->set_bg_color(p_config.dark_color_1);
  864. if (p_config.draw_extra_borders) {
  865. style_itemlist_bg->set_border_width_all(Math::round(EDSCALE));
  866. style_itemlist_bg->set_border_color(p_config.extra_border_color_2);
  867. } else {
  868. style_itemlist_bg->set_border_width_all(p_config.border_width);
  869. style_itemlist_bg->set_border_color(p_config.dark_color_3);
  870. }
  871. Ref<StyleBoxFlat> style_itemlist_cursor = p_config.base_style->duplicate();
  872. style_itemlist_cursor->set_draw_center(false);
  873. style_itemlist_cursor->set_border_width_all(MAX(1 * EDSCALE, p_config.border_width));
  874. style_itemlist_cursor->set_border_color(p_config.highlight_color);
  875. Ref<StyleBoxFlat> style_itemlist_hover = style_tree_selected->duplicate();
  876. style_itemlist_hover->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.3));
  877. style_itemlist_hover->set_border_width_all(0);
  878. Ref<StyleBoxFlat> style_itemlist_hover_selected = style_tree_selected->duplicate();
  879. style_itemlist_hover_selected->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 1.2));
  880. style_itemlist_hover_selected->set_border_width_all(0);
  881. p_theme->set_stylebox(SceneStringName(panel), "ItemList", style_itemlist_bg);
  882. p_theme->set_stylebox("focus", "ItemList", p_config.button_style_focus);
  883. p_theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
  884. p_theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);
  885. p_theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);
  886. p_theme->set_stylebox("selected", "ItemList", style_tree_selected);
  887. p_theme->set_stylebox("hovered", "ItemList", style_itemlist_hover);
  888. p_theme->set_stylebox("hovered_selected", "ItemList", style_itemlist_hover_selected);
  889. p_theme->set_stylebox("hovered_selected_focus", "ItemList", style_itemlist_hover_selected);
  890. p_theme->set_color(SceneStringName(font_color), "ItemList", p_config.font_color);
  891. p_theme->set_color("font_hovered_color", "ItemList", p_config.mono_color);
  892. p_theme->set_color("font_hovered_selected_color", "ItemList", p_config.mono_color);
  893. p_theme->set_color("font_selected_color", "ItemList", p_config.mono_color);
  894. p_theme->set_color("font_outline_color", "ItemList", p_config.font_outline_color);
  895. p_theme->set_color("guide_color", "ItemList", Color(1, 1, 1, 0));
  896. p_theme->set_constant("v_separation", "ItemList", p_config.forced_even_separation * EDSCALE);
  897. p_theme->set_constant("h_separation", "ItemList", (p_config.increased_margin + 2) * EDSCALE);
  898. p_theme->set_constant("icon_margin", "ItemList", (p_config.increased_margin + 2) * EDSCALE);
  899. p_theme->set_constant(SceneStringName(line_separation), "ItemList", p_config.separation_margin);
  900. p_theme->set_constant("outline_size", "ItemList", 0);
  901. }
  902. }
  903. // TabBar & TabContainer.
  904. {
  905. Ref<StyleBoxFlat> style_tab_base = p_config.button_style->duplicate();
  906. style_tab_base->set_border_width_all(0);
  907. // Don't round the top corners to avoid creating a small blank space between the tabs and the main panel.
  908. // This also makes the top highlight look better.
  909. style_tab_base->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  910. style_tab_base->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  911. // When using a border width greater than 0, visually line up the left of the selected tab with the underlying panel.
  912. style_tab_base->set_expand_margin(SIDE_LEFT, -p_config.border_width);
  913. style_tab_base->set_content_margin(SIDE_LEFT, p_config.widget_margin.x + 5 * EDSCALE);
  914. style_tab_base->set_content_margin(SIDE_RIGHT, p_config.widget_margin.x + 5 * EDSCALE);
  915. style_tab_base->set_content_margin(SIDE_BOTTOM, p_config.widget_margin.y);
  916. style_tab_base->set_content_margin(SIDE_TOP, p_config.widget_margin.y);
  917. Ref<StyleBoxFlat> style_tab_selected = style_tab_base->duplicate();
  918. style_tab_selected->set_bg_color(p_config.base_color);
  919. // Add a highlight line at the top of the selected tab.
  920. style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE));
  921. // Make the highlight line prominent, but not too prominent as to not be distracting.
  922. Color tab_highlight = p_config.dark_color_2.lerp(p_config.accent_color, 0.75);
  923. style_tab_selected->set_border_color(tab_highlight);
  924. style_tab_selected->set_corner_radius_all(0);
  925. Ref<StyleBoxFlat> style_tab_hovered = style_tab_base->duplicate();
  926. style_tab_hovered->set_bg_color(p_config.dark_color_1.lerp(p_config.base_color, 0.4));
  927. // Hovered tab has a subtle highlight between normal and selected states.
  928. style_tab_hovered->set_corner_radius_all(0);
  929. Ref<StyleBoxFlat> style_tab_unselected = style_tab_base->duplicate();
  930. style_tab_unselected->set_expand_margin(SIDE_BOTTOM, 0);
  931. style_tab_unselected->set_bg_color(p_config.dark_color_1);
  932. // Add some spacing between unselected tabs to make them easier to distinguish from each other
  933. style_tab_unselected->set_border_color(Color(0, 0, 0, 0));
  934. Ref<StyleBoxFlat> style_tab_disabled = style_tab_base->duplicate();
  935. style_tab_disabled->set_expand_margin(SIDE_BOTTOM, 0);
  936. style_tab_disabled->set_bg_color(p_config.disabled_bg_color);
  937. style_tab_disabled->set_border_color(p_config.disabled_bg_color);
  938. Ref<StyleBoxFlat> style_tab_focus = p_config.button_style_focus->duplicate();
  939. Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius * EDSCALE);
  940. style_tabbar_background->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  941. style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  942. p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background);
  943. p_theme->set_stylebox(SceneStringName(panel), "TabContainer", p_config.content_panel_style);
  944. p_theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected);
  945. p_theme->set_stylebox("tab_hovered", "TabContainer", style_tab_hovered);
  946. p_theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected);
  947. p_theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
  948. p_theme->set_stylebox("tab_focus", "TabContainer", style_tab_focus);
  949. p_theme->set_stylebox("tab_selected", "TabBar", style_tab_selected);
  950. p_theme->set_stylebox("tab_hovered", "TabBar", style_tab_hovered);
  951. p_theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected);
  952. p_theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled);
  953. p_theme->set_stylebox("tab_focus", "TabBar", style_tab_focus);
  954. p_theme->set_stylebox("button_pressed", "TabBar", p_config.panel_container_style);
  955. p_theme->set_stylebox("button_highlight", "TabBar", p_config.panel_container_style);
  956. p_theme->set_color("font_selected_color", "TabContainer", p_config.font_color);
  957. p_theme->set_color("font_hovered_color", "TabContainer", p_config.font_color);
  958. p_theme->set_color("font_unselected_color", "TabContainer", p_config.font_disabled_color);
  959. p_theme->set_color("font_outline_color", "TabContainer", p_config.font_outline_color);
  960. p_theme->set_color("font_selected_color", "TabBar", p_config.font_color);
  961. p_theme->set_color("font_hovered_color", "TabBar", p_config.font_color);
  962. p_theme->set_color("font_unselected_color", "TabBar", p_config.font_disabled_color);
  963. p_theme->set_color("font_outline_color", "TabBar", p_config.font_outline_color);
  964. p_theme->set_color("drop_mark_color", "TabContainer", tab_highlight);
  965. p_theme->set_color("drop_mark_color", "TabBar", tab_highlight);
  966. p_theme->set_icon("menu", "TabContainer", p_theme->get_icon(SNAME("GuiTabMenu"), EditorStringName(EditorIcons)));
  967. p_theme->set_icon("menu_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiTabMenuHl"), EditorStringName(EditorIcons)));
  968. p_theme->set_icon("close", "TabBar", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
  969. p_theme->set_icon("increment", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons)));
  970. p_theme->set_icon("decrement", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons)));
  971. p_theme->set_icon("increment", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons)));
  972. p_theme->set_icon("decrement", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons)));
  973. p_theme->set_icon("increment_highlight", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons)));
  974. p_theme->set_icon("decrement_highlight", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons)));
  975. p_theme->set_icon("increment_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons)));
  976. p_theme->set_icon("decrement_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons)));
  977. p_theme->set_icon("drop_mark", "TabContainer", p_theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons)));
  978. p_theme->set_icon("drop_mark", "TabBar", p_theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons)));
  979. p_theme->set_constant("side_margin", "TabContainer", 0);
  980. p_theme->set_constant("outline_size", "TabContainer", 0);
  981. p_theme->set_constant("h_separation", "TabBar", 4 * EDSCALE);
  982. p_theme->set_constant("outline_size", "TabBar", 0);
  983. }
  984. // Separators.
  985. p_theme->set_stylebox("separator", "HSeparator", make_line_stylebox(p_config.separator_color, MAX(Math::round(EDSCALE), p_config.border_width)));
  986. p_theme->set_stylebox("separator", "VSeparator", make_line_stylebox(p_config.separator_color, MAX(Math::round(EDSCALE), p_config.border_width), 0, 0, true));
  987. // LineEdit & TextEdit.
  988. {
  989. Ref<StyleBoxFlat> text_editor_style = p_config.button_style->duplicate();
  990. // Don't round the bottom corners to make the line look sharper.
  991. text_editor_style->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  992. text_editor_style->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  993. if (p_config.draw_extra_borders) {
  994. text_editor_style->set_border_width_all(Math::round(EDSCALE));
  995. text_editor_style->set_border_color(p_config.extra_border_color_1);
  996. } else {
  997. // Add a bottom line to make LineEdits more visible, especially in sectioned inspectors
  998. // such as the Project Settings.
  999. text_editor_style->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
  1000. text_editor_style->set_border_color(p_config.dark_color_2);
  1001. }
  1002. Ref<StyleBoxFlat> text_editor_disabled_style = text_editor_style->duplicate();
  1003. text_editor_disabled_style->set_border_color(p_config.disabled_border_color);
  1004. text_editor_disabled_style->set_bg_color(p_config.disabled_bg_color);
  1005. // LineEdit.
  1006. p_theme->set_stylebox(CoreStringName(normal), "LineEdit", text_editor_style);
  1007. p_theme->set_stylebox("focus", "LineEdit", p_config.button_style_focus);
  1008. p_theme->set_stylebox("read_only", "LineEdit", text_editor_disabled_style);
  1009. p_theme->set_icon("clear", "LineEdit", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
  1010. p_theme->set_color(SceneStringName(font_color), "LineEdit", p_config.font_color);
  1011. p_theme->set_color("font_selected_color", "LineEdit", p_config.mono_color);
  1012. p_theme->set_color("font_uneditable_color", "LineEdit", p_config.font_readonly_color);
  1013. p_theme->set_color("font_placeholder_color", "LineEdit", p_config.font_placeholder_color);
  1014. p_theme->set_color("font_outline_color", "LineEdit", p_config.font_outline_color);
  1015. p_theme->set_color("caret_color", "LineEdit", p_config.font_color);
  1016. p_theme->set_color("selection_color", "LineEdit", p_config.selection_color);
  1017. p_theme->set_color("clear_button_color", "LineEdit", p_config.font_color);
  1018. p_theme->set_color("clear_button_color_pressed", "LineEdit", p_config.accent_color);
  1019. p_theme->set_constant("minimum_character_width", "LineEdit", 4);
  1020. p_theme->set_constant("outline_size", "LineEdit", 0);
  1021. p_theme->set_constant("caret_width", "LineEdit", 1);
  1022. // TextEdit.
  1023. p_theme->set_stylebox(CoreStringName(normal), "TextEdit", text_editor_style);
  1024. p_theme->set_stylebox("focus", "TextEdit", p_config.button_style_focus);
  1025. p_theme->set_stylebox("read_only", "TextEdit", text_editor_disabled_style);
  1026. p_theme->set_icon("tab", "TextEdit", p_theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons)));
  1027. p_theme->set_icon("space", "TextEdit", p_theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons)));
  1028. p_theme->set_color(SceneStringName(font_color), "TextEdit", p_config.font_color);
  1029. p_theme->set_color("font_readonly_color", "TextEdit", p_config.font_readonly_color);
  1030. p_theme->set_color("font_placeholder_color", "TextEdit", p_config.font_placeholder_color);
  1031. p_theme->set_color("font_outline_color", "TextEdit", p_config.font_outline_color);
  1032. p_theme->set_color("caret_color", "TextEdit", p_config.font_color);
  1033. p_theme->set_color("selection_color", "TextEdit", p_config.selection_color);
  1034. p_theme->set_color("background_color", "TextEdit", Color(0, 0, 0, 0));
  1035. p_theme->set_constant("line_spacing", "TextEdit", 4 * EDSCALE);
  1036. p_theme->set_constant("outline_size", "TextEdit", 0);
  1037. p_theme->set_constant("caret_width", "TextEdit", 1);
  1038. }
  1039. // Containers.
  1040. {
  1041. p_theme->set_constant("separation", "BoxContainer", p_config.separation_margin);
  1042. p_theme->set_constant("separation", "HBoxContainer", p_config.separation_margin);
  1043. p_theme->set_constant("separation", "VBoxContainer", p_config.separation_margin);
  1044. p_theme->set_constant("margin_left", "MarginContainer", 0);
  1045. p_theme->set_constant("margin_top", "MarginContainer", 0);
  1046. p_theme->set_constant("margin_right", "MarginContainer", 0);
  1047. p_theme->set_constant("margin_bottom", "MarginContainer", 0);
  1048. p_theme->set_constant("h_separation", "GridContainer", p_config.separation_margin);
  1049. p_theme->set_constant("v_separation", "GridContainer", p_config.separation_margin);
  1050. p_theme->set_constant("h_separation", "FlowContainer", p_config.separation_margin);
  1051. p_theme->set_constant("v_separation", "FlowContainer", p_config.separation_margin);
  1052. p_theme->set_constant("h_separation", "HFlowContainer", p_config.separation_margin);
  1053. p_theme->set_constant("v_separation", "HFlowContainer", p_config.separation_margin);
  1054. p_theme->set_constant("h_separation", "VFlowContainer", p_config.separation_margin);
  1055. p_theme->set_constant("v_separation", "VFlowContainer", p_config.separation_margin);
  1056. // SplitContainer.
  1057. p_theme->set_icon("h_grabber", "SplitContainer", p_theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons)));
  1058. p_theme->set_icon("v_grabber", "SplitContainer", p_theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons)));
  1059. p_theme->set_icon("grabber", "VSplitContainer", p_theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons)));
  1060. p_theme->set_icon("grabber", "HSplitContainer", p_theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons)));
  1061. p_theme->set_constant("separation", "SplitContainer", p_config.separation_margin);
  1062. p_theme->set_constant("separation", "HSplitContainer", p_config.separation_margin);
  1063. p_theme->set_constant("separation", "VSplitContainer", p_config.separation_margin);
  1064. p_theme->set_constant("minimum_grab_thickness", "SplitContainer", p_config.increased_margin * EDSCALE);
  1065. p_theme->set_constant("minimum_grab_thickness", "HSplitContainer", p_config.increased_margin * EDSCALE);
  1066. p_theme->set_constant("minimum_grab_thickness", "VSplitContainer", p_config.increased_margin * EDSCALE);
  1067. // GridContainer.
  1068. p_theme->set_constant("v_separation", "GridContainer", Math::round(p_config.widget_margin.y - 2 * EDSCALE));
  1069. // FoldableContainer
  1070. Ref<StyleBoxFlat> foldable_container_title = make_flat_stylebox(p_config.dark_color_1.darkened(0.125), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
  1071. foldable_container_title->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  1072. foldable_container_title->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  1073. p_theme->set_stylebox("title_panel", "FoldableContainer", foldable_container_title);
  1074. Ref<StyleBoxFlat> foldable_container_hover = make_flat_stylebox(p_config.dark_color_1.lerp(p_config.base_color, 0.4), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
  1075. foldable_container_hover->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  1076. foldable_container_hover->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  1077. p_theme->set_stylebox("title_hover_panel", "FoldableContainer", foldable_container_hover);
  1078. p_theme->set_stylebox("title_collapsed_panel", "FoldableContainer", make_flat_stylebox(p_config.dark_color_1.darkened(0.125), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin));
  1079. p_theme->set_stylebox("title_collapsed_hover_panel", "FoldableContainer", make_flat_stylebox(p_config.dark_color_1.lerp(p_config.base_color, 0.4), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin));
  1080. Ref<StyleBoxFlat> foldable_container_panel = make_flat_stylebox(p_config.dark_color_1, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
  1081. foldable_container_panel->set_corner_radius(CORNER_TOP_LEFT, 0);
  1082. foldable_container_panel->set_corner_radius(CORNER_TOP_RIGHT, 0);
  1083. p_theme->set_stylebox(SceneStringName(panel), "FoldableContainer", foldable_container_panel);
  1084. p_theme->set_stylebox("focus", "FoldableContainer", p_config.button_style_focus);
  1085. p_theme->set_font(SceneStringName(font), "FoldableContainer", p_theme->get_font(SceneStringName(font), SNAME("HeaderSmall")));
  1086. p_theme->set_font_size(SceneStringName(font_size), "FoldableContainer", p_theme->get_font_size(SceneStringName(font_size), SNAME("HeaderSmall")));
  1087. p_theme->set_color(SceneStringName(font_color), "FoldableContainer", p_config.font_color);
  1088. p_theme->set_color("hover_font_color", "FoldableContainer", p_config.font_hover_color);
  1089. p_theme->set_color("collapsed_font_color", "FoldableContainer", p_config.font_pressed_color);
  1090. p_theme->set_color("font_outline_color", "FoldableContainer", p_config.font_outline_color);
  1091. p_theme->set_icon("expanded_arrow", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons)));
  1092. p_theme->set_icon("expanded_arrow_mirrored", "FoldableContainer", p_theme->get_icon(SNAME("GuiArrowUp"), EditorStringName(EditorIcons)));
  1093. p_theme->set_icon("folded_arrow", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons)));
  1094. p_theme->set_icon("folded_arrow_mirrored", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons)));
  1095. p_theme->set_constant("outline_size", "FoldableContainer", 0);
  1096. p_theme->set_constant("h_separation", "FoldableContainer", p_config.separation_margin);
  1097. }
  1098. // Window and dialogs.
  1099. {
  1100. // Window.
  1101. p_theme->set_stylebox("embedded_border", "Window", p_config.window_style);
  1102. p_theme->set_stylebox("embedded_unfocused_border", "Window", p_config.window_style);
  1103. p_theme->set_color("title_color", "Window", p_config.font_color);
  1104. p_theme->set_icon("close", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
  1105. p_theme->set_icon("close_pressed", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
  1106. p_theme->set_constant("close_h_offset", "Window", 22 * EDSCALE);
  1107. p_theme->set_constant("close_v_offset", "Window", 20 * EDSCALE);
  1108. p_theme->set_constant("title_height", "Window", 24 * EDSCALE);
  1109. p_theme->set_constant("resize_margin", "Window", 4 * EDSCALE);
  1110. p_theme->set_font("title_font", "Window", p_theme->get_font(SNAME("title"), EditorStringName(EditorFonts)));
  1111. p_theme->set_font_size("title_font_size", "Window", p_theme->get_font_size(SNAME("title_size"), EditorStringName(EditorFonts)));
  1112. // AcceptDialog.
  1113. p_theme->set_stylebox(SceneStringName(panel), "AcceptDialog", p_config.dialog_style);
  1114. p_theme->set_constant("buttons_separation", "AcceptDialog", 8 * EDSCALE);
  1115. // Make buttons with short texts such as "OK" easier to click/tap.
  1116. p_theme->set_constant("buttons_min_width", "AcceptDialog", p_config.dialogs_buttons_min_size.x * EDSCALE);
  1117. p_theme->set_constant("buttons_min_height", "AcceptDialog", p_config.dialogs_buttons_min_size.y * EDSCALE);
  1118. // FileDialog.
  1119. p_theme->set_icon("folder", "FileDialog", p_theme->get_icon(SNAME("Folder"), EditorStringName(EditorIcons)));
  1120. p_theme->set_icon("parent_folder", "FileDialog", p_theme->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)));
  1121. p_theme->set_icon("back_folder", "FileDialog", p_theme->get_icon(SNAME("Back"), EditorStringName(EditorIcons)));
  1122. p_theme->set_icon("forward_folder", "FileDialog", p_theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons)));
  1123. p_theme->set_icon("reload", "FileDialog", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));
  1124. p_theme->set_icon("toggle_hidden", "FileDialog", p_theme->get_icon(SNAME("GuiVisibilityVisible"), EditorStringName(EditorIcons)));
  1125. p_theme->set_icon("create_folder", "FileDialog", p_theme->get_icon(SNAME("FolderCreate"), EditorStringName(EditorIcons)));
  1126. // Use a different color for folder icons to make them easier to distinguish from files.
  1127. // On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color.
  1128. p_theme->set_color("folder_icon_color", "FileDialog", (p_config.dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(p_config.accent_color, 0.7));
  1129. p_theme->set_color("file_disabled_color", "FileDialog", p_config.font_disabled_color);
  1130. // PopupDialog.
  1131. p_theme->set_stylebox(SceneStringName(panel), "PopupDialog", p_config.popup_style);
  1132. // PopupMenu.
  1133. {
  1134. Ref<StyleBoxFlat> style_popup_menu = p_config.popup_border_style->duplicate();
  1135. // Use 1 pixel for the sides, since if 0 is used, the highlight of hovered items is drawn
  1136. // on top of the popup border. This causes a 'gap' in the panel border when an item is highlighted,
  1137. // and it looks weird. 1px solves this.
  1138. style_popup_menu->set_content_margin_individual(Math::round(EDSCALE), 2 * EDSCALE, Math::round(EDSCALE), 2 * EDSCALE);
  1139. p_theme->set_stylebox(SceneStringName(panel), "PopupMenu", style_popup_menu);
  1140. Ref<StyleBoxFlat> style_menu_hover = p_config.button_style_hover->duplicate();
  1141. // Don't use rounded corners for hover highlights since the StyleBox touches the PopupMenu's edges.
  1142. style_menu_hover->set_corner_radius_all(0);
  1143. p_theme->set_stylebox(SceneStringName(hover), "PopupMenu", style_menu_hover);
  1144. Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine));
  1145. style_popup_separator->set_color(p_config.separator_color);
  1146. style_popup_separator->set_grow_begin(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
  1147. style_popup_separator->set_grow_end(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
  1148. style_popup_separator->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));
  1149. Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine));
  1150. style_popup_labeled_separator_left->set_grow_begin(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
  1151. style_popup_labeled_separator_left->set_color(p_config.separator_color);
  1152. style_popup_labeled_separator_left->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));
  1153. Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine));
  1154. style_popup_labeled_separator_right->set_grow_end(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
  1155. style_popup_labeled_separator_right->set_color(p_config.separator_color);
  1156. style_popup_labeled_separator_right->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));
  1157. p_theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
  1158. p_theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
  1159. p_theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
  1160. p_theme->set_color(SceneStringName(font_color), "PopupMenu", p_config.font_color);
  1161. p_theme->set_color("font_hover_color", "PopupMenu", p_config.font_hover_color);
  1162. p_theme->set_color("font_accelerator_color", "PopupMenu", p_config.font_disabled_color);
  1163. p_theme->set_color("font_disabled_color", "PopupMenu", p_config.font_disabled_color);
  1164. p_theme->set_color("font_separator_color", "PopupMenu", p_config.font_disabled_color);
  1165. p_theme->set_color("font_outline_color", "PopupMenu", p_config.font_outline_color);
  1166. p_theme->set_icon("checked", "PopupMenu", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
  1167. p_theme->set_icon("unchecked", "PopupMenu", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
  1168. p_theme->set_icon("radio_checked", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons)));
  1169. p_theme->set_icon("radio_unchecked", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons)));
  1170. p_theme->set_icon("checked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
  1171. p_theme->set_icon("unchecked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
  1172. p_theme->set_icon("radio_checked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons)));
  1173. p_theme->set_icon("radio_unchecked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons)));
  1174. p_theme->set_icon("submenu", "PopupMenu", p_theme->get_icon(SNAME("ArrowRight"), EditorStringName(EditorIcons)));
  1175. p_theme->set_icon("submenu_mirrored", "PopupMenu", p_theme->get_icon(SNAME("ArrowLeft"), EditorStringName(EditorIcons)));
  1176. p_theme->set_constant("v_separation", "PopupMenu", p_config.forced_even_separation * EDSCALE);
  1177. p_theme->set_constant("outline_size", "PopupMenu", 0);
  1178. p_theme->set_constant("item_start_padding", "PopupMenu", p_config.separation_margin);
  1179. p_theme->set_constant("item_end_padding", "PopupMenu", p_config.separation_margin);
  1180. }
  1181. }
  1182. // Sliders and scrollbars.
  1183. {
  1184. Ref<Texture2D> empty_icon = memnew(ImageTexture);
  1185. // HScrollBar.
  1186. if (p_config.enable_touch_optimizations) {
  1187. p_theme->set_stylebox("scroll", "HScrollBar", make_line_stylebox(p_config.separator_color, 50));
  1188. } else {
  1189. p_theme->set_stylebox("scroll", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, -5, 1, -5, 1));
  1190. }
  1191. p_theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
  1192. p_theme->set_stylebox("grabber", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
  1193. p_theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
  1194. p_theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
  1195. p_theme->set_icon("increment", "HScrollBar", empty_icon);
  1196. p_theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
  1197. p_theme->set_icon("increment_pressed", "HScrollBar", empty_icon);
  1198. p_theme->set_icon("decrement", "HScrollBar", empty_icon);
  1199. p_theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
  1200. p_theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);
  1201. // VScrollBar.
  1202. if (p_config.enable_touch_optimizations) {
  1203. p_theme->set_stylebox("scroll", "VScrollBar", make_line_stylebox(p_config.separator_color, 50, 1, 1, true));
  1204. } else {
  1205. p_theme->set_stylebox("scroll", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, -5, 1, -5));
  1206. }
  1207. p_theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
  1208. p_theme->set_stylebox("grabber", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
  1209. p_theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
  1210. p_theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
  1211. p_theme->set_icon("increment", "VScrollBar", empty_icon);
  1212. p_theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
  1213. p_theme->set_icon("increment_pressed", "VScrollBar", empty_icon);
  1214. p_theme->set_icon("decrement", "VScrollBar", empty_icon);
  1215. p_theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
  1216. p_theme->set_icon("decrement_pressed", "VScrollBar", empty_icon);
  1217. // Slider
  1218. const int background_margin = MAX(2, p_config.base_margin / 2);
  1219. // HSlider.
  1220. p_theme->set_icon("grabber_highlight", "HSlider", p_theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons)));
  1221. p_theme->set_icon("grabber", "HSlider", p_theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons)));
  1222. p_theme->set_stylebox("slider", "HSlider", make_flat_stylebox(p_config.dark_color_3, 0, background_margin, 0, background_margin, p_config.corner_radius));
  1223. p_theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(p_config.contrast_color_1, 0, background_margin, 0, background_margin, p_config.corner_radius));
  1224. p_theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(p_config.contrast_color_1, 0, background_margin, 0, background_margin));
  1225. p_theme->set_constant("center_grabber", "HSlider", 0);
  1226. p_theme->set_constant("grabber_offset", "HSlider", 0);
  1227. // VSlider.
  1228. p_theme->set_icon("grabber", "VSlider", p_theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons)));
  1229. p_theme->set_icon("grabber_highlight", "VSlider", p_theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons)));
  1230. p_theme->set_stylebox("slider", "VSlider", make_flat_stylebox(p_config.dark_color_3, background_margin, 0, background_margin, 0, p_config.corner_radius));
  1231. p_theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(p_config.contrast_color_1, background_margin, 0, background_margin, 0, p_config.corner_radius));
  1232. p_theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(p_config.contrast_color_1, background_margin, 0, background_margin, 0));
  1233. p_theme->set_constant("center_grabber", "VSlider", 0);
  1234. p_theme->set_constant("grabber_offset", "VSlider", 0);
  1235. }
  1236. // Labels.
  1237. {
  1238. // RichTextLabel.
  1239. p_theme->set_stylebox(CoreStringName(normal), "RichTextLabel", p_config.tree_panel_style);
  1240. p_theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
  1241. p_theme->set_color("default_color", "RichTextLabel", p_config.font_color);
  1242. p_theme->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0));
  1243. p_theme->set_color("font_outline_color", "RichTextLabel", p_config.font_outline_color);
  1244. p_theme->set_color("selection_color", "RichTextLabel", p_config.selection_color);
  1245. p_theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);
  1246. p_theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);
  1247. p_theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * EDSCALE);
  1248. p_theme->set_constant("outline_size", "RichTextLabel", 0);
  1249. // Label.
  1250. p_theme->set_stylebox(CoreStringName(normal), "Label", p_config.base_empty_style);
  1251. p_theme->set_stylebox("focus", "Label", p_config.button_style_focus);
  1252. p_theme->set_color(SceneStringName(font_color), "Label", p_config.font_color);
  1253. p_theme->set_color("font_shadow_color", "Label", Color(0, 0, 0, 0));
  1254. p_theme->set_color("font_outline_color", "Label", p_config.font_outline_color);
  1255. p_theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);
  1256. p_theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);
  1257. p_theme->set_constant("shadow_outline_size", "Label", 1 * EDSCALE);
  1258. p_theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
  1259. p_theme->set_constant("outline_size", "Label", 0);
  1260. }
  1261. // SpinBox.
  1262. {
  1263. Ref<Texture2D> empty_icon = memnew(ImageTexture);
  1264. p_theme->set_icon("updown", "SpinBox", empty_icon);
  1265. p_theme->set_icon("up", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
  1266. p_theme->set_icon("up_hover", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
  1267. p_theme->set_icon("up_pressed", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
  1268. p_theme->set_icon("up_disabled", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
  1269. p_theme->set_icon("down", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
  1270. p_theme->set_icon("down_hover", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
  1271. p_theme->set_icon("down_pressed", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
  1272. p_theme->set_icon("down_disabled", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
  1273. p_theme->set_stylebox("up_background", "SpinBox", make_empty_stylebox());
  1274. p_theme->set_stylebox("up_background_hovered", "SpinBox", p_config.button_style_hover);
  1275. p_theme->set_stylebox("up_background_pressed", "SpinBox", p_config.button_style_pressed);
  1276. p_theme->set_stylebox("up_background_disabled", "SpinBox", make_empty_stylebox());
  1277. p_theme->set_stylebox("down_background", "SpinBox", make_empty_stylebox());
  1278. p_theme->set_stylebox("down_background_hovered", "SpinBox", p_config.button_style_hover);
  1279. p_theme->set_stylebox("down_background_pressed", "SpinBox", p_config.button_style_pressed);
  1280. p_theme->set_stylebox("down_background_disabled", "SpinBox", make_empty_stylebox());
  1281. p_theme->set_color("up_icon_modulate", "SpinBox", p_config.font_color);
  1282. p_theme->set_color("up_hover_icon_modulate", "SpinBox", p_config.font_hover_color);
  1283. p_theme->set_color("up_pressed_icon_modulate", "SpinBox", p_config.font_pressed_color);
  1284. p_theme->set_color("up_disabled_icon_modulate", "SpinBox", p_config.font_disabled_color);
  1285. p_theme->set_color("down_icon_modulate", "SpinBox", p_config.font_color);
  1286. p_theme->set_color("down_hover_icon_modulate", "SpinBox", p_config.font_hover_color);
  1287. p_theme->set_color("down_pressed_icon_modulate", "SpinBox", p_config.font_pressed_color);
  1288. p_theme->set_color("down_disabled_icon_modulate", "SpinBox", p_config.font_disabled_color);
  1289. p_theme->set_stylebox("field_and_buttons_separator", "SpinBox", make_empty_stylebox());
  1290. p_theme->set_stylebox("up_down_buttons_separator", "SpinBox", make_empty_stylebox());
  1291. p_theme->set_constant("buttons_vertical_separation", "SpinBox", 0);
  1292. p_theme->set_constant("field_and_buttons_separation", "SpinBox", 2);
  1293. p_theme->set_constant("buttons_width", "SpinBox", 16);
  1294. #ifndef DISABLE_DEPRECATED
  1295. p_theme->set_constant("set_min_buttons_width_from_icons", "SpinBox", 1);
  1296. #endif
  1297. }
  1298. // ProgressBar.
  1299. p_theme->set_stylebox("background", "ProgressBar", make_stylebox(p_theme->get_icon(SNAME("GuiProgressBar"), EditorStringName(EditorIcons)), 4, 4, 4, 4, 0, 0, 0, 0));
  1300. p_theme->set_stylebox("fill", "ProgressBar", make_stylebox(p_theme->get_icon(SNAME("GuiProgressFill"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 2, 1, 2, 1));
  1301. p_theme->set_color(SceneStringName(font_color), "ProgressBar", p_config.font_color);
  1302. p_theme->set_color("font_outline_color", "ProgressBar", p_config.font_outline_color);
  1303. p_theme->set_constant("outline_size", "ProgressBar", 0);
  1304. // GraphEdit and related nodes.
  1305. {
  1306. // GraphEdit.
  1307. p_theme->set_stylebox(SceneStringName(panel), "GraphEdit", p_config.tree_panel_style);
  1308. p_theme->set_stylebox("panel_focus", "GraphEdit", p_config.button_style_focus);
  1309. p_theme->set_stylebox("menu_panel", "GraphEdit", make_flat_stylebox(p_config.dark_color_1 * Color(1, 1, 1, 0.6), 4, 2, 4, 2, 3));
  1310. float grid_base_brightness = p_config.dark_theme ? 1.0 : 0.0;
  1311. GraphEdit::GridPattern grid_pattern = (GraphEdit::GridPattern) int(EDITOR_GET("editors/visual_editors/grid_pattern"));
  1312. switch (grid_pattern) {
  1313. case GraphEdit::GRID_PATTERN_LINES:
  1314. p_theme->set_color("grid_major", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.10));
  1315. p_theme->set_color("grid_minor", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.05));
  1316. break;
  1317. case GraphEdit::GRID_PATTERN_DOTS:
  1318. p_theme->set_color("grid_major", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.07));
  1319. p_theme->set_color("grid_minor", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.07));
  1320. break;
  1321. default:
  1322. WARN_PRINT("Unknown grid pattern.");
  1323. break;
  1324. }
  1325. p_theme->set_color("selection_fill", "GraphEdit", p_theme->get_color(SNAME("box_selection_fill_color"), EditorStringName(Editor)));
  1326. p_theme->set_color("selection_stroke", "GraphEdit", p_theme->get_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)));
  1327. p_theme->set_color("activity", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));
  1328. p_theme->set_color("connection_hover_tint_color", "GraphEdit", p_config.dark_theme ? Color(0, 0, 0, 0.3) : Color(1, 1, 1, 0.3));
  1329. p_theme->set_constant("connection_hover_thickness", "GraphEdit", 0);
  1330. p_theme->set_color("connection_valid_target_tint_color", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1, 0.4) : Color(0, 0, 0, 0.4));
  1331. p_theme->set_color("connection_rim_color", "GraphEdit", p_config.tree_panel_style->get_bg_color());
  1332. p_theme->set_icon("zoom_out", "GraphEdit", p_theme->get_icon(SNAME("ZoomLess"), EditorStringName(EditorIcons)));
  1333. p_theme->set_icon("zoom_in", "GraphEdit", p_theme->get_icon(SNAME("ZoomMore"), EditorStringName(EditorIcons)));
  1334. p_theme->set_icon("zoom_reset", "GraphEdit", p_theme->get_icon(SNAME("ZoomReset"), EditorStringName(EditorIcons)));
  1335. p_theme->set_icon("grid_toggle", "GraphEdit", p_theme->get_icon(SNAME("GridToggle"), EditorStringName(EditorIcons)));
  1336. p_theme->set_icon("minimap_toggle", "GraphEdit", p_theme->get_icon(SNAME("GridMinimap"), EditorStringName(EditorIcons)));
  1337. p_theme->set_icon("snapping_toggle", "GraphEdit", p_theme->get_icon(SNAME("SnapGrid"), EditorStringName(EditorIcons)));
  1338. p_theme->set_icon("layout", "GraphEdit", p_theme->get_icon(SNAME("GridLayout"), EditorStringName(EditorIcons)));
  1339. // GraphEditMinimap.
  1340. {
  1341. Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0);
  1342. style_minimap_bg->set_border_color(p_config.dark_color_3);
  1343. style_minimap_bg->set_border_width_all(1);
  1344. p_theme->set_stylebox(SceneStringName(panel), "GraphEditMinimap", style_minimap_bg);
  1345. Ref<StyleBoxFlat> style_minimap_camera;
  1346. Ref<StyleBoxFlat> style_minimap_node;
  1347. if (p_config.dark_theme) {
  1348. style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0);
  1349. style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45));
  1350. style_minimap_node = make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0);
  1351. } else {
  1352. style_minimap_camera = make_flat_stylebox(Color(0.38, 0.38, 0.38, 0.2), 0, 0, 0, 0);
  1353. style_minimap_camera->set_border_color(Color(0.38, 0.38, 0.38, 0.45));
  1354. style_minimap_node = make_flat_stylebox(Color(0, 0, 0), 0, 0, 0, 0);
  1355. }
  1356. style_minimap_camera->set_border_width_all(1);
  1357. style_minimap_node->set_anti_aliased(false);
  1358. p_theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);
  1359. p_theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node);
  1360. const Color minimap_resizer_color = p_config.dark_theme ? Color(1, 1, 1, 0.65) : Color(0, 0, 0, 0.65);
  1361. p_theme->set_icon("resizer", "GraphEditMinimap", p_theme->get_icon(SNAME("GuiResizerTopLeft"), EditorStringName(EditorIcons)));
  1362. p_theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color);
  1363. }
  1364. // GraphElement, GraphNode & GraphFrame.
  1365. {
  1366. const int gn_margin_top = 2;
  1367. const int gn_margin_side = 2;
  1368. const int gn_margin_bottom = 2;
  1369. const int gn_corner_radius = 3;
  1370. const Color gn_bg_color = p_config.dark_theme ? p_config.dark_color_3 : p_config.dark_color_1.lerp(p_config.mono_color, 0.09);
  1371. const Color gn_selected_border_color = p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
  1372. const Color gn_frame_bg = gn_bg_color.lerp(p_config.tree_panel_style->get_bg_color(), 0.3);
  1373. const bool high_contrast_borders = p_config.draw_extra_borders && p_config.dark_theme;
  1374. Ref<StyleBoxFlat> gn_panel_style = make_flat_stylebox(gn_frame_bg, gn_margin_side, gn_margin_top, gn_margin_side, gn_margin_bottom, p_config.corner_radius);
  1375. gn_panel_style->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);
  1376. gn_panel_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
  1377. gn_panel_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
  1378. gn_panel_style->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));
  1379. gn_panel_style->set_corner_radius_individual(0, 0, gn_corner_radius * EDSCALE, gn_corner_radius * EDSCALE);
  1380. gn_panel_style->set_anti_aliased(true);
  1381. Ref<StyleBoxFlat> gn_panel_selected_style = gn_panel_style->duplicate();
  1382. gn_panel_selected_style->set_bg_color(p_config.dark_theme ? gn_bg_color.lightened(0.15) : gn_bg_color.darkened(0.15));
  1383. gn_panel_selected_style->set_border_width(SIDE_TOP, 0);
  1384. gn_panel_selected_style->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);
  1385. gn_panel_selected_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
  1386. gn_panel_selected_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
  1387. gn_panel_selected_style->set_border_color(gn_selected_border_color);
  1388. const int gn_titlebar_margin_top = 8;
  1389. const int gn_titlebar_margin_side = 12;
  1390. const int gn_titlebar_margin_bottom = 8;
  1391. Ref<StyleBoxFlat> gn_titlebar_style = make_flat_stylebox(gn_bg_color, gn_titlebar_margin_side, gn_titlebar_margin_top, gn_titlebar_margin_side, gn_titlebar_margin_bottom, p_config.corner_radius);
  1392. gn_titlebar_style->set_border_width(SIDE_TOP, 2 * EDSCALE);
  1393. gn_titlebar_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
  1394. gn_titlebar_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
  1395. gn_titlebar_style->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));
  1396. gn_titlebar_style->set_expand_margin(SIDE_TOP, 2 * EDSCALE);
  1397. gn_titlebar_style->set_corner_radius_individual(gn_corner_radius * EDSCALE, gn_corner_radius * EDSCALE, 0, 0);
  1398. gn_titlebar_style->set_anti_aliased(true);
  1399. Ref<StyleBoxFlat> gn_titlebar_selected_style = gn_titlebar_style->duplicate();
  1400. gn_titlebar_selected_style->set_border_color(gn_selected_border_color);
  1401. gn_titlebar_selected_style->set_border_width(SIDE_TOP, 2 * EDSCALE);
  1402. gn_titlebar_selected_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
  1403. gn_titlebar_selected_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
  1404. gn_titlebar_selected_style->set_expand_margin(SIDE_TOP, 2 * EDSCALE);
  1405. Color gn_decoration_color = p_config.dark_color_1.inverted();
  1406. // GraphElement.
  1407. p_theme->set_stylebox(SceneStringName(panel), "GraphElement", gn_panel_style);
  1408. p_theme->set_stylebox("panel_selected", "GraphElement", gn_panel_selected_style);
  1409. p_theme->set_stylebox("titlebar", "GraphElement", gn_titlebar_style);
  1410. p_theme->set_stylebox("titlebar_selected", "GraphElement", gn_titlebar_selected_style);
  1411. p_theme->set_color("resizer_color", "GraphElement", gn_decoration_color);
  1412. p_theme->set_icon("resizer", "GraphElement", p_theme->get_icon(SNAME("GuiResizer"), EditorStringName(EditorIcons)));
  1413. // GraphNode.
  1414. Ref<StyleBoxEmpty> gn_slot_style = make_empty_stylebox(12, 0, 12, 0);
  1415. p_theme->set_stylebox(SceneStringName(panel), "GraphNode", gn_panel_style);
  1416. p_theme->set_stylebox("panel_selected", "GraphNode", gn_panel_selected_style);
  1417. p_theme->set_stylebox("panel_focus", "GraphNode", p_config.button_style_focus);
  1418. p_theme->set_stylebox("titlebar", "GraphNode", gn_titlebar_style);
  1419. p_theme->set_stylebox("titlebar_selected", "GraphNode", gn_titlebar_selected_style);
  1420. p_theme->set_stylebox("slot", "GraphNode", gn_slot_style);
  1421. p_theme->set_stylebox("slot_selected", "GraphNode", p_config.button_style_focus);
  1422. p_theme->set_color("resizer_color", "GraphNode", gn_decoration_color);
  1423. p_theme->set_constant("port_h_offset", "GraphNode", 1);
  1424. p_theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
  1425. Ref<SVGTexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
  1426. // The true size is 24x24 This is necessary for sharp port icons at high zoom levels in GraphEdit (up to ~200%).
  1427. port_icon->set_size_override(Size2(12, 12));
  1428. p_theme->set_icon("port", "GraphNode", port_icon);
  1429. // GraphNode's title Label.
  1430. p_theme->set_type_variation("GraphNodeTitleLabel", "Label");
  1431. p_theme->set_stylebox(CoreStringName(normal), "GraphNodeTitleLabel", make_empty_stylebox(0, 0, 0, 0));
  1432. p_theme->set_color("font_shadow_color", "GraphNodeTitleLabel", p_config.shadow_color);
  1433. p_theme->set_constant("shadow_outline_size", "GraphNodeTitleLabel", 4);
  1434. p_theme->set_constant("shadow_offset_x", "GraphNodeTitleLabel", 0);
  1435. p_theme->set_constant("shadow_offset_y", "GraphNodeTitleLabel", 1);
  1436. p_theme->set_constant("line_spacing", "GraphNodeTitleLabel", 3 * EDSCALE);
  1437. // GraphFrame.
  1438. const int gf_corner_width = 7 * EDSCALE;
  1439. const int gf_border_width = 2 * MAX(1, EDSCALE);
  1440. Ref<StyleBoxFlat> graphframe_sb = make_flat_stylebox(Color(0.0, 0.0, 0.0, 0.2), gn_margin_side, gn_margin_side, gn_margin_side, gn_margin_bottom, gf_corner_width);
  1441. graphframe_sb->set_expand_margin(SIDE_TOP, 38 * EDSCALE);
  1442. graphframe_sb->set_border_width_all(gf_border_width);
  1443. graphframe_sb->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));
  1444. graphframe_sb->set_shadow_size(8 * EDSCALE);
  1445. graphframe_sb->set_shadow_color(Color(p_config.shadow_color, p_config.shadow_color.a * 0.25));
  1446. graphframe_sb->set_anti_aliased(true);
  1447. Ref<StyleBoxFlat> graphframe_sb_selected = graphframe_sb->duplicate();
  1448. graphframe_sb_selected->set_border_color(gn_selected_border_color);
  1449. p_theme->set_stylebox(SceneStringName(panel), "GraphFrame", graphframe_sb);
  1450. p_theme->set_stylebox("panel_selected", "GraphFrame", graphframe_sb_selected);
  1451. p_theme->set_stylebox("titlebar", "GraphFrame", make_empty_stylebox(4, 4, 4, 4));
  1452. p_theme->set_stylebox("titlebar_selected", "GraphFrame", make_empty_stylebox(4, 4, 4, 4));
  1453. p_theme->set_color("resizer_color", "GraphFrame", gn_decoration_color);
  1454. // GraphFrame's title Label.
  1455. p_theme->set_type_variation("GraphFrameTitleLabel", "Label");
  1456. p_theme->set_stylebox(CoreStringName(normal), "GraphFrameTitleLabel", memnew(StyleBoxEmpty));
  1457. p_theme->set_font_size(SceneStringName(font_size), "GraphFrameTitleLabel", 22 * EDSCALE);
  1458. p_theme->set_color(SceneStringName(font_color), "GraphFrameTitleLabel", Color(1, 1, 1));
  1459. p_theme->set_color("font_shadow_color", "GraphFrameTitleLabel", Color(0, 0, 0, 0));
  1460. p_theme->set_color("font_outline_color", "GraphFrameTitleLabel", Color(1, 1, 1));
  1461. p_theme->set_constant("shadow_offset_x", "GraphFrameTitleLabel", 1 * EDSCALE);
  1462. p_theme->set_constant("shadow_offset_y", "GraphFrameTitleLabel", 1 * EDSCALE);
  1463. p_theme->set_constant("outline_size", "GraphFrameTitleLabel", 0);
  1464. p_theme->set_constant("shadow_outline_size", "GraphFrameTitleLabel", 1 * EDSCALE);
  1465. p_theme->set_constant("line_spacing", "GraphFrameTitleLabel", 3 * EDSCALE);
  1466. }
  1467. // VisualShader reroute node.
  1468. {
  1469. Ref<StyleBox> vs_reroute_panel_style = make_empty_stylebox();
  1470. Ref<StyleBox> vs_reroute_titlebar_style = vs_reroute_panel_style->duplicate();
  1471. vs_reroute_titlebar_style->set_content_margin_all(16 * EDSCALE);
  1472. p_theme->set_stylebox(SceneStringName(panel), "VSRerouteNode", vs_reroute_panel_style);
  1473. p_theme->set_stylebox("panel_selected", "VSRerouteNode", vs_reroute_panel_style);
  1474. p_theme->set_stylebox("titlebar", "VSRerouteNode", vs_reroute_titlebar_style);
  1475. p_theme->set_stylebox("titlebar_selected", "VSRerouteNode", vs_reroute_titlebar_style);
  1476. p_theme->set_stylebox("slot", "VSRerouteNode", make_empty_stylebox());
  1477. p_theme->set_color("drag_background", "VSRerouteNode", p_config.dark_theme ? Color(0.19, 0.21, 0.24) : Color(0.8, 0.8, 0.8));
  1478. p_theme->set_color("selected_rim_color", "VSRerouteNode", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));
  1479. }
  1480. }
  1481. // ColorPicker and related nodes.
  1482. {
  1483. // ColorPicker.
  1484. p_config.circle_style_focus = p_config.button_style_focus->duplicate();
  1485. p_config.circle_style_focus->set_corner_radius_all(256 * EDSCALE);
  1486. p_config.circle_style_focus->set_corner_detail(32 * EDSCALE);
  1487. p_theme->set_constant("margin", "ColorPicker", p_config.base_margin);
  1488. p_theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
  1489. p_theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
  1490. p_theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
  1491. p_theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
  1492. p_theme->set_constant("center_slider_grabbers", "ColorPicker", 1);
  1493. p_theme->set_stylebox("sample_focus", "ColorPicker", p_config.button_style_focus);
  1494. p_theme->set_stylebox("picker_focus_rectangle", "ColorPicker", p_config.button_style_focus);
  1495. p_theme->set_stylebox("picker_focus_circle", "ColorPicker", p_config.circle_style_focus);
  1496. p_theme->set_color("focused_not_editing_cursor_color", "ColorPicker", p_config.highlight_color);
  1497. p_theme->set_icon("screen_picker", "ColorPicker", p_theme->get_icon(SNAME("ColorPick"), EditorStringName(EditorIcons)));
  1498. p_theme->set_icon("shape_circle", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeCircle"), EditorStringName(EditorIcons)));
  1499. p_theme->set_icon("shape_rect", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeRectangle"), EditorStringName(EditorIcons)));
  1500. p_theme->set_icon("shape_rect_wheel", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeRectangleWheel"), EditorStringName(EditorIcons)));
  1501. p_theme->set_icon("add_preset", "ColorPicker", p_theme->get_icon(SNAME("Add"), EditorStringName(EditorIcons)));
  1502. p_theme->set_icon("sample_bg", "ColorPicker", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
  1503. p_theme->set_icon("sample_revert", "ColorPicker", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));
  1504. p_theme->set_icon("overbright_indicator", "ColorPicker", p_theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons)));
  1505. p_theme->set_icon("bar_arrow", "ColorPicker", p_theme->get_icon(SNAME("ColorPickerBarArrow"), EditorStringName(EditorIcons)));
  1506. p_theme->set_icon("picker_cursor", "ColorPicker", p_theme->get_icon(SNAME("PickerCursor"), EditorStringName(EditorIcons)));
  1507. p_theme->set_icon("picker_cursor_bg", "ColorPicker", p_theme->get_icon(SNAME("PickerCursorBg"), EditorStringName(EditorIcons)));
  1508. p_theme->set_icon("color_script", "ColorPicker", p_theme->get_icon(SNAME("Script"), EditorStringName(EditorIcons)));
  1509. // ColorPickerButton.
  1510. p_theme->set_icon("bg", "ColorPickerButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
  1511. // ColorPresetButton.
  1512. p_theme->set_stylebox("preset_fg", "ColorPresetButton", make_flat_stylebox(Color(1, 1, 1), 2, 2, 2, 2, 2));
  1513. p_theme->set_icon("preset_bg", "ColorPresetButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
  1514. p_theme->set_icon("overbright_indicator", "ColorPresetButton", p_theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons)));
  1515. }
  1516. }
  1517. void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
  1518. // Project manager.
  1519. {
  1520. p_theme->set_stylebox("project_list", "ProjectManager", p_config.tree_panel_style);
  1521. p_theme->set_constant("sidebar_button_icon_separation", "ProjectManager", int(6 * EDSCALE));
  1522. p_theme->set_icon("browse_folder", "ProjectManager", p_theme->get_icon(SNAME("FolderBrowse"), EditorStringName(EditorIcons)));
  1523. p_theme->set_icon("browse_file", "ProjectManager", p_theme->get_icon(SNAME("FileBrowse"), EditorStringName(EditorIcons)));
  1524. // ProjectTag.
  1525. {
  1526. p_theme->set_type_variation("ProjectTagButton", "Button");
  1527. Ref<StyleBoxFlat> tag = p_config.button_style->duplicate();
  1528. tag->set_bg_color(p_config.dark_theme ? tag->get_bg_color().lightened(0.2) : tag->get_bg_color().darkened(0.2));
  1529. tag->set_corner_radius(CORNER_TOP_LEFT, 0);
  1530. tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  1531. tag->set_corner_radius(CORNER_TOP_RIGHT, 4);
  1532. tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);
  1533. p_theme->set_stylebox(CoreStringName(normal), "ProjectTagButton", tag);
  1534. tag = p_config.button_style_hover->duplicate();
  1535. tag->set_corner_radius(CORNER_TOP_LEFT, 0);
  1536. tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  1537. tag->set_corner_radius(CORNER_TOP_RIGHT, 4);
  1538. tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);
  1539. p_theme->set_stylebox(SceneStringName(hover), "ProjectTagButton", tag);
  1540. tag = p_config.button_style_pressed->duplicate();
  1541. tag->set_corner_radius(CORNER_TOP_LEFT, 0);
  1542. tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  1543. tag->set_corner_radius(CORNER_TOP_RIGHT, 4);
  1544. tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);
  1545. p_theme->set_stylebox(SceneStringName(pressed), "ProjectTagButton", tag);
  1546. }
  1547. }
  1548. // Editor and main screen.
  1549. {
  1550. // Editor background.
  1551. Color background_color_opaque = p_config.dark_color_2;
  1552. background_color_opaque.a = 1.0;
  1553. p_theme->set_color("background", EditorStringName(Editor), background_color_opaque);
  1554. p_theme->set_stylebox("Background", EditorStringName(EditorStyles), make_flat_stylebox(background_color_opaque, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin));
  1555. Ref<StyleBoxFlat> editor_panel_foreground = p_config.base_style->duplicate();
  1556. editor_panel_foreground->set_corner_radius_all(0);
  1557. p_theme->set_stylebox("PanelForeground", EditorStringName(EditorStyles), editor_panel_foreground);
  1558. // Editor focus.
  1559. p_theme->set_stylebox("Focus", EditorStringName(EditorStyles), p_config.button_style_focus);
  1560. Ref<StyleBoxFlat> style_widget_focus_viewport = p_config.button_style_focus->duplicate();
  1561. // Use a less opaque color to be less distracting for the 2D and 3D editor viewports.
  1562. style_widget_focus_viewport->set_border_color(p_config.accent_color * Color(1, 1, 1, 0.5));
  1563. p_theme->set_stylebox("FocusViewport", EditorStringName(EditorStyles), style_widget_focus_viewport);
  1564. Ref<StyleBoxFlat> style_widget_scroll_container = p_config.button_style_focus->duplicate();
  1565. p_theme->set_stylebox("focus", "ScrollContainer", style_widget_scroll_container);
  1566. // This stylebox is used in 3d and 2d viewports (no borders).
  1567. Ref<StyleBoxFlat> style_content_panel_vp = p_config.content_panel_style->duplicate();
  1568. style_content_panel_vp->set_content_margin_individual(p_config.border_width * 2, p_config.base_margin * EDSCALE, p_config.border_width * 2, p_config.border_width * 2);
  1569. p_theme->set_stylebox("Content", EditorStringName(EditorStyles), style_content_panel_vp);
  1570. // 3D/Spatial editor.
  1571. Ref<StyleBoxFlat> style_info_3d_viewport = p_config.base_style->duplicate();
  1572. style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
  1573. style_info_3d_viewport->set_border_width_all(0);
  1574. p_theme->set_stylebox("Information3dViewport", EditorStringName(EditorStyles), style_info_3d_viewport);
  1575. // 2D and 3D contextual toolbar.
  1576. // Use a custom stylebox to make contextual menu items stand out from the rest.
  1577. // This helps with editor usability as contextual menu items change when selecting nodes,
  1578. // even though it may not be immediately obvious at first.
  1579. Ref<StyleBoxFlat> toolbar_stylebox = memnew(StyleBoxFlat);
  1580. toolbar_stylebox->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));
  1581. toolbar_stylebox->set_anti_aliased(false);
  1582. // Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
  1583. toolbar_stylebox->set_border_color(p_config.accent_color);
  1584. toolbar_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
  1585. toolbar_stylebox->set_content_margin(SIDE_BOTTOM, 0);
  1586. toolbar_stylebox->set_expand_margin_individual(4 * EDSCALE, 2 * EDSCALE, 4 * EDSCALE, 4 * EDSCALE);
  1587. p_theme->set_stylebox("ContextualToolbar", EditorStringName(EditorStyles), toolbar_stylebox);
  1588. // Script editor.
  1589. p_theme->set_stylebox("ScriptEditorPanel", EditorStringName(EditorStyles), make_empty_stylebox(p_config.base_margin, 0, p_config.base_margin, p_config.base_margin));
  1590. p_theme->set_stylebox("ScriptEditorPanelFloating", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
  1591. p_theme->set_stylebox("ScriptEditor", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
  1592. // Game view.
  1593. p_theme->set_type_variation("GamePanel", "Panel");
  1594. Ref<StyleBoxFlat> game_panel = p_theme->get_stylebox(SceneStringName(panel), SNAME("Panel"))->duplicate();
  1595. game_panel->set_corner_radius_all(0);
  1596. p_theme->set_stylebox(SceneStringName(panel), "GamePanel", game_panel);
  1597. // Main menu.
  1598. Ref<StyleBoxFlat> menu_transparent_style = p_config.button_style->duplicate();
  1599. menu_transparent_style->set_bg_color(Color(1, 1, 1, 0));
  1600. menu_transparent_style->set_border_width_all(0);
  1601. Ref<StyleBoxFlat> main_screen_button_hover = p_config.button_style_hover->duplicate();
  1602. for (int i = 0; i < 4; i++) {
  1603. menu_transparent_style->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
  1604. main_screen_button_hover->set_content_margin((Side)i, p_config.button_style_hover->get_content_margin((Side)i));
  1605. }
  1606. p_theme->set_stylebox(CoreStringName(normal), "MainScreenButton", menu_transparent_style);
  1607. p_theme->set_stylebox("normal_mirrored", "MainScreenButton", menu_transparent_style);
  1608. p_theme->set_stylebox(SceneStringName(pressed), "MainScreenButton", menu_transparent_style);
  1609. p_theme->set_stylebox("pressed_mirrored", "MainScreenButton", menu_transparent_style);
  1610. p_theme->set_stylebox(SceneStringName(hover), "MainScreenButton", main_screen_button_hover);
  1611. p_theme->set_stylebox("hover_mirrored", "MainScreenButton", main_screen_button_hover);
  1612. p_theme->set_stylebox("hover_pressed", "MainScreenButton", main_screen_button_hover);
  1613. p_theme->set_stylebox("hover_pressed_mirrored", "MainScreenButton", main_screen_button_hover);
  1614. p_theme->set_type_variation("MainMenuBar", "FlatMenuButton");
  1615. p_theme->set_stylebox(CoreStringName(normal), "MainMenuBar", menu_transparent_style);
  1616. p_theme->set_stylebox(SceneStringName(pressed), "MainMenuBar", main_screen_button_hover);
  1617. p_theme->set_stylebox(SceneStringName(hover), "MainMenuBar", main_screen_button_hover);
  1618. p_theme->set_stylebox("hover_pressed", "MainMenuBar", main_screen_button_hover);
  1619. // Run bar.
  1620. p_theme->set_type_variation("RunBarButton", "FlatMenuButton");
  1621. p_theme->set_stylebox("disabled", "RunBarButton", menu_transparent_style);
  1622. p_theme->set_stylebox(SceneStringName(pressed), "RunBarButton", menu_transparent_style);
  1623. p_theme->set_type_variation("RunBarButtonMovieMakerDisabled", "RunBarButton");
  1624. p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.7));
  1625. p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));
  1626. p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.9));
  1627. p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));
  1628. p_theme->set_type_variation("RunBarButtonMovieMakerEnabled", "RunBarButton");
  1629. p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.7));
  1630. p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));
  1631. p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.9));
  1632. p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));
  1633. // Bottom panel.
  1634. Ref<StyleBoxFlat> style_bottom_panel = p_config.content_panel_style->duplicate();
  1635. style_bottom_panel->set_corner_radius_all(p_config.corner_radius * EDSCALE);
  1636. p_theme->set_stylebox("BottomPanel", EditorStringName(EditorStyles), style_bottom_panel);
  1637. p_theme->set_type_variation("BottomPanelButton", "FlatMenuButton");
  1638. p_theme->set_stylebox(CoreStringName(normal), "BottomPanelButton", menu_transparent_style);
  1639. p_theme->set_stylebox(SceneStringName(pressed), "BottomPanelButton", menu_transparent_style);
  1640. p_theme->set_stylebox("hover_pressed", "BottomPanelButton", main_screen_button_hover);
  1641. p_theme->set_stylebox(SceneStringName(hover), "BottomPanelButton", main_screen_button_hover);
  1642. // Don't tint the icon even when in "pressed" state.
  1643. p_theme->set_color("icon_pressed_color", "BottomPanelButton", Color(1, 1, 1, 1));
  1644. Color icon_hover_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.0);
  1645. icon_hover_color.a = 1.0;
  1646. p_theme->set_color("icon_hover_color", "BottomPanelButton", icon_hover_color);
  1647. p_theme->set_color("icon_hover_pressed_color", "BottomPanelButton", icon_hover_color);
  1648. // Audio bus.
  1649. p_theme->set_stylebox("normal", "EditorAudioBus", style_bottom_panel);
  1650. p_theme->set_stylebox("master", "EditorAudioBus", p_config.button_style_disabled);
  1651. p_theme->set_stylebox("focus", "EditorAudioBus", p_config.button_style_focus);
  1652. }
  1653. // Editor GUI widgets.
  1654. {
  1655. // EditorSpinSlider.
  1656. p_theme->set_color("label_color", "EditorSpinSlider", p_config.font_color);
  1657. p_theme->set_color("read_only_label_color", "EditorSpinSlider", p_config.font_readonly_color);
  1658. Ref<StyleBoxFlat> editor_spin_label_bg = p_config.base_style->duplicate();
  1659. editor_spin_label_bg->set_bg_color(p_config.dark_color_3);
  1660. editor_spin_label_bg->set_border_width_all(0);
  1661. p_theme->set_stylebox("label_bg", "EditorSpinSlider", editor_spin_label_bg);
  1662. // TODO Use separate arrows instead like on SpinBox. Planned for a different PR.
  1663. p_theme->set_icon("updown", "EditorSpinSlider", p_theme->get_icon(SNAME("GuiSpinboxUpdown"), EditorStringName(EditorIcons)));
  1664. p_theme->set_icon("updown_disabled", "EditorSpinSlider", p_theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), EditorStringName(EditorIcons)));
  1665. // Launch Pad and Play buttons.
  1666. Ref<StyleBoxFlat> style_launch_pad = make_flat_stylebox(p_config.dark_color_1, 2 * EDSCALE, 0, 2 * EDSCALE, 0, p_config.corner_radius);
  1667. style_launch_pad->set_corner_radius_all(p_config.corner_radius * EDSCALE);
  1668. p_theme->set_stylebox("LaunchPadNormal", EditorStringName(EditorStyles), style_launch_pad);
  1669. Ref<StyleBoxFlat> style_launch_pad_movie = style_launch_pad->duplicate();
  1670. style_launch_pad_movie->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));
  1671. style_launch_pad_movie->set_border_color(p_config.accent_color);
  1672. style_launch_pad_movie->set_border_width_all(Math::round(2 * EDSCALE));
  1673. p_theme->set_stylebox("LaunchPadMovieMode", EditorStringName(EditorStyles), style_launch_pad_movie);
  1674. Ref<StyleBoxFlat> style_launch_pad_recovery_mode = style_launch_pad->duplicate();
  1675. style_launch_pad_recovery_mode->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));
  1676. style_launch_pad_recovery_mode->set_border_color(p_config.warning_color);
  1677. style_launch_pad_recovery_mode->set_border_width_all(Math::round(2 * EDSCALE));
  1678. p_theme->set_stylebox("LaunchPadRecoveryMode", EditorStringName(EditorStyles), style_launch_pad_recovery_mode);
  1679. p_theme->set_stylebox("MovieWriterButtonNormal", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
  1680. Ref<StyleBoxFlat> style_write_movie_button = p_config.button_style_pressed->duplicate();
  1681. style_write_movie_button->set_bg_color(p_config.accent_color);
  1682. style_write_movie_button->set_corner_radius_all(p_config.corner_radius * EDSCALE);
  1683. style_write_movie_button->set_content_margin(SIDE_TOP, 0);
  1684. style_write_movie_button->set_content_margin(SIDE_BOTTOM, 0);
  1685. style_write_movie_button->set_content_margin(SIDE_LEFT, 0);
  1686. style_write_movie_button->set_content_margin(SIDE_RIGHT, 0);
  1687. style_write_movie_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
  1688. p_theme->set_stylebox("MovieWriterButtonPressed", EditorStringName(EditorStyles), style_write_movie_button);
  1689. // Profiler autostart indicator panel.
  1690. Ref<StyleBoxFlat> style_profiler_autostart = style_launch_pad->duplicate();
  1691. style_profiler_autostart->set_bg_color(Color(1, 0.867, 0.396));
  1692. p_theme->set_type_variation("ProfilerAutostartIndicator", "Button");
  1693. p_theme->set_stylebox(CoreStringName(normal), "ProfilerAutostartIndicator", style_profiler_autostart);
  1694. p_theme->set_stylebox(SceneStringName(pressed), "ProfilerAutostartIndicator", style_profiler_autostart);
  1695. p_theme->set_stylebox("hover", "ProfilerAutostartIndicator", style_profiler_autostart);
  1696. // Recovery mode button style
  1697. Ref<StyleBoxFlat> style_recovery_mode_button = p_config.button_style_pressed->duplicate();
  1698. style_recovery_mode_button->set_bg_color(p_config.warning_color);
  1699. style_recovery_mode_button->set_corner_radius_all(p_config.corner_radius * EDSCALE);
  1700. style_recovery_mode_button->set_content_margin_all(0);
  1701. // Recovery mode button is implicitly styled from the panel's background.
  1702. // So, remove any existing borders. (e.g. from draw_extra_borders config)
  1703. style_recovery_mode_button->set_border_width_all(0);
  1704. style_recovery_mode_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
  1705. p_theme->set_stylebox("RecoveryModeButton", EditorStringName(EditorStyles), style_recovery_mode_button);
  1706. }
  1707. // Standard GUI variations.
  1708. {
  1709. // Custom theme type for MarginContainer with 4px margins.
  1710. p_theme->set_type_variation("MarginContainer4px", "MarginContainer");
  1711. p_theme->set_constant("margin_left", "MarginContainer4px", 4 * EDSCALE);
  1712. p_theme->set_constant("margin_top", "MarginContainer4px", 4 * EDSCALE);
  1713. p_theme->set_constant("margin_right", "MarginContainer4px", 4 * EDSCALE);
  1714. p_theme->set_constant("margin_bottom", "MarginContainer4px", 4 * EDSCALE);
  1715. // Header LinkButton variation.
  1716. p_theme->set_type_variation("HeaderSmallLink", "LinkButton");
  1717. p_theme->set_font(SceneStringName(font), "HeaderSmallLink", p_theme->get_font(SceneStringName(font), SNAME("HeaderSmall")));
  1718. p_theme->set_font_size(SceneStringName(font_size), "HeaderSmallLink", p_theme->get_font_size(SceneStringName(font_size), SNAME("HeaderSmall")));
  1719. // Flat button variations.
  1720. {
  1721. Ref<StyleBoxEmpty> style_flat_button = make_empty_stylebox();
  1722. Ref<StyleBoxFlat> style_flat_button_hover = p_config.button_style_hover->duplicate();
  1723. Ref<StyleBoxFlat> style_flat_button_pressed = p_config.button_style_pressed->duplicate();
  1724. for (int i = 0; i < 4; i++) {
  1725. style_flat_button->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
  1726. style_flat_button_hover->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
  1727. style_flat_button_pressed->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
  1728. }
  1729. Color flat_pressed_color = p_config.dark_color_1.lightened(0.24).lerp(p_config.accent_color, 0.2) * Color(0.8, 0.8, 0.8, 0.85);
  1730. if (p_config.dark_theme) {
  1731. flat_pressed_color = p_config.dark_color_1.lerp(p_config.accent_color, 0.12) * Color(0.6, 0.6, 0.6, 0.85);
  1732. }
  1733. style_flat_button_pressed->set_bg_color(flat_pressed_color);
  1734. p_theme->set_stylebox(CoreStringName(normal), SceneStringName(FlatButton), style_flat_button);
  1735. p_theme->set_stylebox(SceneStringName(hover), SceneStringName(FlatButton), style_flat_button_hover);
  1736. p_theme->set_stylebox(SceneStringName(pressed), SceneStringName(FlatButton), style_flat_button_pressed);
  1737. p_theme->set_stylebox("disabled", SceneStringName(FlatButton), style_flat_button);
  1738. p_theme->set_stylebox(CoreStringName(normal), "FlatMenuButton", style_flat_button);
  1739. p_theme->set_stylebox(SceneStringName(hover), "FlatMenuButton", style_flat_button_hover);
  1740. p_theme->set_stylebox(SceneStringName(pressed), "FlatMenuButton", style_flat_button_pressed);
  1741. p_theme->set_stylebox("disabled", "FlatMenuButton", style_flat_button);
  1742. // Variation for Editor Log filter buttons.
  1743. p_theme->set_type_variation("EditorLogFilterButton", "Button");
  1744. // When pressed, don't tint the icons with the accent color, just leave them normal.
  1745. p_theme->set_color("icon_pressed_color", "EditorLogFilterButton", p_config.icon_normal_color);
  1746. // When unpressed, dim the icons.
  1747. Color icon_normal_color = Color(p_config.icon_normal_color, (p_config.dark_theme ? 0.4 : 0.8));
  1748. p_theme->set_color("icon_normal_color", "EditorLogFilterButton", icon_normal_color);
  1749. Color icon_hover_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.0);
  1750. icon_hover_color.a = 1.0;
  1751. p_theme->set_color("icon_hover_color", "EditorLogFilterButton", icon_hover_color);
  1752. p_theme->set_color("icon_hover_pressed_color", "EditorLogFilterButton", icon_hover_color);
  1753. // When pressed, add a small bottom border to the buttons to better show their active state,
  1754. // similar to active tabs.
  1755. Ref<StyleBoxFlat> editor_log_button_pressed = style_flat_button_pressed->duplicate();
  1756. editor_log_button_pressed->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);
  1757. editor_log_button_pressed->set_border_color(p_config.accent_color);
  1758. if (!p_config.dark_theme) {
  1759. editor_log_button_pressed->set_bg_color(flat_pressed_color.lightened(0.5));
  1760. }
  1761. p_theme->set_stylebox(CoreStringName(normal), "EditorLogFilterButton", style_flat_button);
  1762. p_theme->set_stylebox(SceneStringName(hover), "EditorLogFilterButton", style_flat_button_hover);
  1763. p_theme->set_stylebox(SceneStringName(pressed), "EditorLogFilterButton", editor_log_button_pressed);
  1764. }
  1765. // Buttons styles that stand out against the panel background (e.g. AssetLib).
  1766. {
  1767. p_theme->set_type_variation("PanelBackgroundButton", "Button");
  1768. Ref<StyleBoxFlat> panel_button_style = p_config.button_style->duplicate();
  1769. panel_button_style->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.08));
  1770. Ref<StyleBoxFlat> panel_button_style_hover = p_config.button_style_hover->duplicate();
  1771. panel_button_style_hover->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.16));
  1772. Ref<StyleBoxFlat> panel_button_style_pressed = p_config.button_style_pressed->duplicate();
  1773. panel_button_style_pressed->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.20));
  1774. Ref<StyleBoxFlat> panel_button_style_disabled = p_config.button_style_disabled->duplicate();
  1775. panel_button_style_disabled->set_bg_color(p_config.disabled_bg_color);
  1776. p_theme->set_stylebox(CoreStringName(normal), "PanelBackgroundButton", panel_button_style);
  1777. p_theme->set_stylebox(SceneStringName(hover), "PanelBackgroundButton", panel_button_style_hover);
  1778. p_theme->set_stylebox(SceneStringName(pressed), "PanelBackgroundButton", panel_button_style_pressed);
  1779. p_theme->set_stylebox("disabled", "PanelBackgroundButton", panel_button_style_disabled);
  1780. }
  1781. // Top bar selectors.
  1782. {
  1783. p_theme->set_type_variation("TopBarOptionButton", "OptionButton");
  1784. p_theme->set_font(SceneStringName(font), "TopBarOptionButton", p_theme->get_font(SNAME("bold"), EditorStringName(EditorFonts)));
  1785. p_theme->set_font_size(SceneStringName(font_size), "TopBarOptionButton", p_theme->get_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)));
  1786. }
  1787. // Complex editor windows.
  1788. {
  1789. Ref<StyleBoxFlat> style_complex_window = p_config.window_style->duplicate();
  1790. style_complex_window->set_bg_color(p_config.dark_color_2);
  1791. style_complex_window->set_border_color(p_config.dark_color_2);
  1792. p_theme->set_stylebox(SceneStringName(panel), "EditorSettingsDialog", style_complex_window);
  1793. p_theme->set_stylebox(SceneStringName(panel), "ProjectSettingsEditor", style_complex_window);
  1794. p_theme->set_stylebox(SceneStringName(panel), "EditorAbout", style_complex_window);
  1795. }
  1796. // InspectorActionButton.
  1797. {
  1798. p_theme->set_type_variation("InspectorActionButton", "Button");
  1799. const float action_extra_margin = 32 * EDSCALE;
  1800. p_theme->set_constant("h_separation", "InspectorActionButton", action_extra_margin);
  1801. Color color_inspector_action = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);
  1802. color_inspector_action.a = 0.5;
  1803. Ref<StyleBoxFlat> style_inspector_action = p_config.button_style->duplicate();
  1804. style_inspector_action->set_bg_color(color_inspector_action);
  1805. style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
  1806. p_theme->set_stylebox(CoreStringName(normal), "InspectorActionButton", style_inspector_action);
  1807. style_inspector_action = p_config.button_style->duplicate();
  1808. style_inspector_action->set_bg_color(color_inspector_action);
  1809. style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
  1810. p_theme->set_stylebox("normal_mirrored", "InspectorActionButton", style_inspector_action);
  1811. style_inspector_action = p_config.button_style_hover->duplicate();
  1812. style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
  1813. p_theme->set_stylebox(SceneStringName(hover), "InspectorActionButton", style_inspector_action);
  1814. style_inspector_action = p_config.button_style_hover->duplicate();
  1815. style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
  1816. p_theme->set_stylebox("hover_mirrored", "InspectorActionButton", style_inspector_action);
  1817. style_inspector_action = p_config.button_style_pressed->duplicate();
  1818. style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
  1819. p_theme->set_stylebox(SceneStringName(pressed), "InspectorActionButton", style_inspector_action);
  1820. style_inspector_action = p_config.button_style_pressed->duplicate();
  1821. style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
  1822. p_theme->set_stylebox("pressed_mirrored", "InspectorActionButton", style_inspector_action);
  1823. style_inspector_action = p_config.button_style_disabled->duplicate();
  1824. style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
  1825. p_theme->set_stylebox("disabled", "InspectorActionButton", style_inspector_action);
  1826. style_inspector_action = p_config.button_style_disabled->duplicate();
  1827. style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
  1828. p_theme->set_stylebox("disabled_mirrored", "InspectorActionButton", style_inspector_action);
  1829. }
  1830. // Buttons in material previews.
  1831. {
  1832. const Color dim_light_color = p_config.icon_normal_color.darkened(0.24);
  1833. const Color dim_light_highlighted_color = p_config.icon_normal_color.darkened(0.18);
  1834. Ref<StyleBox> sb_empty_borderless = make_empty_stylebox();
  1835. p_theme->set_type_variation("PreviewLightButton", "Button");
  1836. // When pressed, don't use the accent color tint. When unpressed, dim the icon.
  1837. p_theme->set_color("icon_normal_color", "PreviewLightButton", dim_light_color);
  1838. p_theme->set_color("icon_focus_color", "PreviewLightButton", dim_light_color);
  1839. p_theme->set_color("icon_pressed_color", "PreviewLightButton", p_config.icon_normal_color);
  1840. p_theme->set_color("icon_hover_pressed_color", "PreviewLightButton", p_config.icon_normal_color);
  1841. // Unpressed icon is dim, so use a dim highlight.
  1842. p_theme->set_color("icon_hover_color", "PreviewLightButton", dim_light_highlighted_color);
  1843. p_theme->set_stylebox(CoreStringName(normal), "PreviewLightButton", sb_empty_borderless);
  1844. p_theme->set_stylebox(SceneStringName(hover), "PreviewLightButton", sb_empty_borderless);
  1845. p_theme->set_stylebox("focus", "PreviewLightButton", sb_empty_borderless);
  1846. p_theme->set_stylebox(SceneStringName(pressed), "PreviewLightButton", sb_empty_borderless);
  1847. }
  1848. // TabContainerOdd variation.
  1849. {
  1850. // Can be used on tabs against the base color background (e.g. nested tabs).
  1851. p_theme->set_type_variation("TabContainerOdd", "TabContainer");
  1852. Ref<StyleBoxFlat> style_tab_selected_odd = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->duplicate();
  1853. style_tab_selected_odd->set_bg_color(p_config.disabled_bg_color);
  1854. p_theme->set_stylebox("tab_selected", "TabContainerOdd", style_tab_selected_odd);
  1855. Ref<StyleBoxFlat> style_content_panel_odd = p_config.content_panel_style->duplicate();
  1856. style_content_panel_odd->set_bg_color(p_config.disabled_bg_color);
  1857. p_theme->set_stylebox(SceneStringName(panel), "TabContainerOdd", style_content_panel_odd);
  1858. }
  1859. // EditorValidationPanel.
  1860. p_theme->set_stylebox(SceneStringName(panel), "EditorValidationPanel", p_config.tree_panel_style);
  1861. // Secondary trees and item lists.
  1862. p_theme->set_type_variation("TreeSecondary", "Tree");
  1863. p_theme->set_type_variation("ItemListSecondary", "ItemList");
  1864. }
  1865. // Editor inspector.
  1866. {
  1867. // Panel.
  1868. Ref<StyleBoxFlat> editor_inspector_panel = p_config.tree_panel_style->duplicate();
  1869. editor_inspector_panel->set_border_width_all(0);
  1870. editor_inspector_panel->set_content_margin_all(0);
  1871. p_theme->set_stylebox(SceneStringName(panel), "EditorInspector", editor_inspector_panel);
  1872. // Vertical separation between inspector categories and sections.
  1873. p_theme->set_constant("v_separation", "EditorInspector", 0);
  1874. // EditorProperty.
  1875. Ref<StyleBoxFlat> style_property_bg = p_config.base_style->duplicate();
  1876. style_property_bg->set_bg_color(p_config.highlight_color);
  1877. style_property_bg->set_border_width_all(0);
  1878. Ref<StyleBoxFlat> style_property_child_bg = p_config.base_style->duplicate();
  1879. style_property_child_bg->set_bg_color(p_config.dark_color_2);
  1880. style_property_child_bg->set_border_width_all(0);
  1881. p_theme->set_stylebox("bg", "EditorProperty", memnew(StyleBoxEmpty));
  1882. p_theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg);
  1883. p_theme->set_stylebox("child_bg", "EditorProperty", style_property_child_bg);
  1884. p_theme->set_constant("font_offset", "EditorProperty", 8 * EDSCALE);
  1885. p_theme->set_constant("v_separation", "EditorProperty", p_config.increased_margin * EDSCALE);
  1886. const Color property_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5);
  1887. const Color readonly_color = property_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.25);
  1888. const Color readonly_warning_color = p_config.error_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.25);
  1889. p_theme->set_color("property_color", "EditorProperty", property_color);
  1890. p_theme->set_color("readonly_color", "EditorProperty", readonly_color);
  1891. p_theme->set_color("warning_color", "EditorProperty", p_config.warning_color);
  1892. p_theme->set_color("readonly_warning_color", "EditorProperty", readonly_warning_color);
  1893. Ref<StyleBoxFlat> style_property_group_note = p_config.base_style->duplicate();
  1894. Color property_group_note_color = p_config.accent_color;
  1895. property_group_note_color.a = 0.1;
  1896. style_property_group_note->set_bg_color(property_group_note_color);
  1897. p_theme->set_stylebox("bg_group_note", "EditorProperty", style_property_group_note);
  1898. // EditorInspectorSection.
  1899. Color inspector_section_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.35);
  1900. p_theme->set_color(SceneStringName(font_color), "EditorInspectorSection", inspector_section_color);
  1901. Color inspector_indent_color = p_config.accent_color;
  1902. inspector_indent_color.a = 0.2;
  1903. Ref<StyleBoxFlat> inspector_indent_style = make_flat_stylebox(inspector_indent_color, 2.0 * EDSCALE, 0, 2.0 * EDSCALE, 0);
  1904. p_theme->set_stylebox("indent_box", "EditorInspectorSection", inspector_indent_style);
  1905. p_theme->set_constant("indent_size", "EditorInspectorSection", 6.0 * EDSCALE);
  1906. p_theme->set_constant("h_separation", "EditorInspectorSection", 2.0 * EDSCALE);
  1907. Color prop_category_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);
  1908. Color prop_section_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.09);
  1909. Color prop_subsection_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.06);
  1910. p_theme->set_color("prop_category", EditorStringName(Editor), prop_category_color);
  1911. p_theme->set_color("prop_section", EditorStringName(Editor), prop_section_color);
  1912. p_theme->set_color("prop_subsection", EditorStringName(Editor), prop_subsection_color);
  1913. #ifndef DISABLE_DEPRECATED // Used before 4.3.
  1914. p_theme->set_color("property_color", EditorStringName(Editor), prop_category_color);
  1915. #endif
  1916. // EditorInspectorCategory.
  1917. Ref<StyleBoxFlat> category_bg = p_config.base_style->duplicate();
  1918. category_bg->set_bg_color(prop_category_color);
  1919. category_bg->set_border_color(prop_category_color);
  1920. category_bg->set_content_margin_all(0);
  1921. p_theme->set_stylebox("bg", "EditorInspectorCategory", category_bg);
  1922. p_theme->set_constant("inspector_margin", EditorStringName(Editor), 12 * EDSCALE);
  1923. // Colored EditorProperty.
  1924. for (int i = 0; i < 16; i++) {
  1925. Color si_base_color = p_config.accent_color;
  1926. float hue_rotate = (i * 2 % 16) / 16.0;
  1927. 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());
  1928. si_base_color = p_config.accent_color.lerp(si_base_color, p_config.subresource_hue_tint);
  1929. // Sub-inspector background.
  1930. Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();
  1931. sub_inspector_bg->set_bg_color(p_config.dark_color_1.lerp(si_base_color, 0.08));
  1932. sub_inspector_bg->set_border_width_all(2 * EDSCALE);
  1933. sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
  1934. sub_inspector_bg->set_content_margin_all(4 * EDSCALE);
  1935. sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);
  1936. sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);
  1937. p_theme->set_stylebox("sub_inspector_bg" + itos(i + 1), EditorStringName(EditorStyles), sub_inspector_bg);
  1938. // EditorProperty background while it has a sub-inspector open.
  1939. Ref<StyleBoxFlat> bg_color = make_flat_stylebox(si_base_color * Color(0.7, 0.7, 0.7, 0.8), 0, 0, 0, 0, p_config.corner_radius);
  1940. bg_color->set_anti_aliased(false);
  1941. bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  1942. bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  1943. p_theme->set_stylebox("sub_inspector_property_bg" + itos(i + 1), EditorStringName(EditorStyles), bg_color);
  1944. // Dictionary editor add item.
  1945. // Expand to the left and right by 4px to compensate for the dictionary editor margins.
  1946. Color style_dictionary_bg_color = p_config.dark_color_3.lerp(si_base_color, 0.08);
  1947. Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(style_dictionary_bg_color, 0, 4, 0, 4, p_config.corner_radius);
  1948. style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);
  1949. style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
  1950. p_theme->set_stylebox("DictionaryAddItem" + itos(i + 1), EditorStringName(EditorStyles), style_dictionary_add_item);
  1951. }
  1952. Color si_base_color = p_config.accent_color;
  1953. // Sub-inspector background.
  1954. Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();
  1955. sub_inspector_bg->set_bg_color(Color(1, 1, 1, 0));
  1956. sub_inspector_bg->set_border_width_all(2 * EDSCALE);
  1957. sub_inspector_bg->set_border_color(p_config.dark_color_1.lerp(si_base_color, 0.15));
  1958. sub_inspector_bg->set_content_margin_all(4 * EDSCALE);
  1959. sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);
  1960. sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);
  1961. p_theme->set_stylebox("sub_inspector_bg0", EditorStringName(EditorStyles), sub_inspector_bg);
  1962. // Sub-inspector background no border.
  1963. Ref<StyleBoxFlat> sub_inspector_bg_no_border = p_config.base_style->duplicate();
  1964. sub_inspector_bg_no_border->set_content_margin_all(2 * EDSCALE);
  1965. sub_inspector_bg_no_border->set_bg_color(p_config.dark_color_2.lerp(p_config.dark_color_3, 0.15));
  1966. p_theme->set_stylebox("sub_inspector_bg_no_border", EditorStringName(EditorStyles), sub_inspector_bg_no_border);
  1967. // EditorProperty background while it has a sub-inspector open.
  1968. Ref<StyleBoxFlat> bg_color = make_flat_stylebox(p_config.dark_color_1.lerp(si_base_color, 0.15), 0, 0, 0, 0, p_config.corner_radius);
  1969. bg_color->set_anti_aliased(false);
  1970. bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  1971. bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  1972. p_theme->set_stylebox("sub_inspector_property_bg0", EditorStringName(EditorStyles), bg_color);
  1973. p_theme->set_color("sub_inspector_property_color", EditorStringName(EditorStyles), p_config.dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
  1974. // Dictionary editor.
  1975. // Expand to the left and right by 4px to compensate for the dictionary editor margins.
  1976. Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(prop_subsection_color, 0, 4, 0, 4, p_config.corner_radius);
  1977. style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);
  1978. style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
  1979. p_theme->set_stylebox("DictionaryAddItem0", EditorStringName(EditorStyles), style_dictionary_add_item);
  1980. }
  1981. // Animation Editor.
  1982. {
  1983. // Timeline general.
  1984. p_theme->set_constant("timeline_v_separation", "AnimationTrackEditor", 0);
  1985. p_theme->set_constant("track_v_separation", "AnimationTrackEditor", 0);
  1986. // AnimationTimelineEdit.
  1987. // "primary" is used for integer timeline values, "secondary" for decimals.
  1988. Ref<StyleBoxFlat> style_time_unavailable = make_flat_stylebox(p_config.dark_color_2, 0, 0, 0, 0, 0);
  1989. Ref<StyleBoxFlat> style_time_available = make_flat_stylebox(p_config.font_color * Color(1, 1, 1, 0.2), 0, 0, 0, 0, 0);
  1990. p_theme->set_stylebox("time_unavailable", "AnimationTimelineEdit", style_time_unavailable);
  1991. p_theme->set_stylebox("time_available", "AnimationTimelineEdit", style_time_available);
  1992. p_theme->set_color("v_line_primary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));
  1993. p_theme->set_color("v_line_secondary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));
  1994. p_theme->set_color("h_line_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));
  1995. p_theme->set_color("font_primary_color", "AnimationTimelineEdit", p_config.font_color);
  1996. p_theme->set_color("font_secondary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.5));
  1997. p_theme->set_constant("v_line_primary_margin", "AnimationTimelineEdit", 0);
  1998. p_theme->set_constant("v_line_secondary_margin", "AnimationTimelineEdit", 0);
  1999. p_theme->set_constant("v_line_primary_width", "AnimationTimelineEdit", 1 * EDSCALE);
  2000. p_theme->set_constant("v_line_secondary_width", "AnimationTimelineEdit", 1 * EDSCALE);
  2001. p_theme->set_constant("text_primary_margin", "AnimationTimelineEdit", 3 * EDSCALE);
  2002. p_theme->set_constant("text_secondary_margin", "AnimationTimelineEdit", 3 * EDSCALE);
  2003. // AnimationTrackEdit.
  2004. Ref<StyleBoxFlat> style_animation_track_odd = make_flat_stylebox(Color(0.5, 0.5, 0.5, 0.05), 0, 0, 0, 0, p_config.corner_radius);
  2005. Ref<StyleBoxFlat> style_animation_track_hover = make_flat_stylebox(Color(0.5, 0.5, 0.5, 0.1), 0, 0, 0, 0, p_config.corner_radius);
  2006. p_theme->set_stylebox("odd", "AnimationTrackEdit", style_animation_track_odd);
  2007. p_theme->set_stylebox(SceneStringName(hover), "AnimationTrackEdit", style_animation_track_hover);
  2008. p_theme->set_stylebox("focus", "AnimationTrackEdit", p_config.button_style_focus);
  2009. p_theme->set_color("h_line_color", "AnimationTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));
  2010. p_theme->set_constant("h_separation", "AnimationTrackEdit", (p_config.increased_margin + 2) * EDSCALE);
  2011. p_theme->set_constant("outer_margin", "AnimationTrackEdit", p_config.increased_margin * 6 * EDSCALE);
  2012. // AnimationTrackEditGroup.
  2013. Ref<StyleBoxFlat> style_animation_track_header = make_flat_stylebox(p_config.dark_color_2 * Color(1, 1, 1, 0.6), p_config.increased_margin * 3, 0, 0, 0, p_config.corner_radius);
  2014. p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header);
  2015. p_theme->set_color("h_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));
  2016. p_theme->set_color("v_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));
  2017. p_theme->set_constant("h_separation", "AnimationTrackEditGroup", (p_config.increased_margin + 2) * EDSCALE);
  2018. p_theme->set_constant("v_separation", "AnimationTrackEditGroup", 0);
  2019. // AnimationBezierTrackEdit.
  2020. p_theme->set_color("focus_color", "AnimationBezierTrackEdit", p_config.accent_color * Color(1, 1, 1, 0.7));
  2021. p_theme->set_color("track_focus_color", "AnimationBezierTrackEdit", p_config.accent_color * Color(1, 1, 1, 0.5));
  2022. p_theme->set_color("h_line_color", "AnimationBezierTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));
  2023. p_theme->set_color("v_line_color", "AnimationBezierTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));
  2024. p_theme->set_constant("h_separation", "AnimationBezierTrackEdit", (p_config.increased_margin + 2) * EDSCALE);
  2025. p_theme->set_constant("v_separation", "AnimationBezierTrackEdit", p_config.forced_even_separation * EDSCALE);
  2026. }
  2027. // Editor help.
  2028. {
  2029. Ref<StyleBoxFlat> style_editor_help = p_config.base_style->duplicate();
  2030. style_editor_help->set_bg_color(p_config.dark_color_2);
  2031. style_editor_help->set_border_color(p_config.dark_color_3);
  2032. p_theme->set_stylebox("background", "EditorHelp", style_editor_help);
  2033. const Color kbd_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5);
  2034. p_theme->set_color("title_color", "EditorHelp", p_config.accent_color);
  2035. p_theme->set_color("headline_color", "EditorHelp", p_config.mono_color);
  2036. p_theme->set_color("text_color", "EditorHelp", p_config.font_color);
  2037. p_theme->set_color("comment_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));
  2038. p_theme->set_color("symbol_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));
  2039. p_theme->set_color("value_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));
  2040. p_theme->set_color("qualifier_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.8));
  2041. p_theme->set_color("type_color", "EditorHelp", p_config.accent_color.lerp(p_config.font_color, 0.5));
  2042. p_theme->set_color("override_color", "EditorHelp", p_config.warning_color);
  2043. p_theme->set_color("selection_color", "EditorHelp", p_config.selection_color);
  2044. p_theme->set_color("link_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.8));
  2045. p_theme->set_color("code_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.6));
  2046. p_theme->set_color("kbd_color", "EditorHelp", p_config.accent_color.lerp(kbd_color, 0.6));
  2047. p_theme->set_color("code_bg_color", "EditorHelp", p_config.dark_color_3);
  2048. p_theme->set_color("kbd_bg_color", "EditorHelp", p_config.dark_color_1);
  2049. p_theme->set_color("param_bg_color", "EditorHelp", p_config.dark_color_1);
  2050. p_theme->set_constant(SceneStringName(line_separation), "EditorHelp", Math::round(6 * EDSCALE));
  2051. p_theme->set_constant("table_h_separation", "EditorHelp", 16 * EDSCALE);
  2052. p_theme->set_constant("table_v_separation", "EditorHelp", 6 * EDSCALE);
  2053. p_theme->set_constant("text_highlight_h_padding", "EditorHelp", 1 * EDSCALE);
  2054. p_theme->set_constant("text_highlight_v_padding", "EditorHelp", 2 * EDSCALE);
  2055. }
  2056. // EditorHelpBitTitle.
  2057. {
  2058. Ref<StyleBoxFlat> style = p_config.tree_panel_style->duplicate();
  2059. style->set_bg_color(p_config.dark_theme ? style->get_bg_color().lightened(0.04) : style->get_bg_color().darkened(0.04));
  2060. style->set_border_color(p_config.dark_theme ? style->get_border_color().lightened(0.04) : style->get_border_color().darkened(0.04));
  2061. style->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
  2062. style->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
  2063. p_theme->set_type_variation("EditorHelpBitTitle", "RichTextLabel");
  2064. p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitTitle", style);
  2065. }
  2066. // EditorHelpBitContent.
  2067. {
  2068. Ref<StyleBoxFlat> style = p_config.tree_panel_style->duplicate();
  2069. style->set_corner_radius(CORNER_TOP_LEFT, 0);
  2070. style->set_corner_radius(CORNER_TOP_RIGHT, 0);
  2071. p_theme->set_type_variation("EditorHelpBitContent", "RichTextLabel");
  2072. p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitContent", style);
  2073. }
  2074. // Asset Library.
  2075. p_theme->set_stylebox("bg", "AssetLib", p_config.base_empty_style);
  2076. p_theme->set_stylebox(SceneStringName(panel), "AssetLib", p_config.content_panel_style);
  2077. p_theme->set_color("status_color", "AssetLib", Color(0.5, 0.5, 0.5)); // FIXME: Use a defined color instead.
  2078. p_theme->set_icon("dismiss", "AssetLib", p_theme->get_icon(SNAME("Close"), EditorStringName(EditorIcons)));
  2079. // Debugger.
  2080. {
  2081. Ref<StyleBoxFlat> debugger_panel_style = p_config.content_panel_style->duplicate();
  2082. debugger_panel_style->set_border_width(SIDE_BOTTOM, 0);
  2083. p_theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), debugger_panel_style);
  2084. // This pattern of get_font()->get_height(get_font_size()) is used quite a lot and is very verbose.
  2085. // FIXME: Introduce Theme::get_font_height() / Control::get_theme_font_height() / Window::get_theme_font_height().
  2086. const int offset_i1 = p_theme->get_font(SNAME("tab_selected"), SNAME("TabContainer"))->get_height(p_theme->get_font_size(SNAME("tab_selected"), SNAME("TabContainer")));
  2087. const int offset_i2 = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height;
  2088. const int offset_i3 = p_theme->get_stylebox(SceneStringName(panel), SNAME("TabContainer"))->get_content_margin(SIDE_TOP);
  2089. const int invisible_top_offset = offset_i1 + offset_i2 + offset_i3;
  2090. Ref<StyleBoxFlat> invisible_top_panel_style = p_config.content_panel_style->duplicate();
  2091. invisible_top_panel_style->set_expand_margin(SIDE_TOP, -invisible_top_offset);
  2092. invisible_top_panel_style->set_content_margin(SIDE_TOP, 0);
  2093. p_theme->set_stylebox("BottomPanelDebuggerOverride", EditorStringName(EditorStyles), invisible_top_panel_style);
  2094. }
  2095. // Resource and node editors.
  2096. {
  2097. // TextureRegion editor.
  2098. Ref<StyleBoxFlat> style_texture_region_bg = p_config.tree_panel_style->duplicate();
  2099. style_texture_region_bg->set_content_margin_all(0);
  2100. p_theme->set_stylebox("TextureRegionPreviewBG", EditorStringName(EditorStyles), style_texture_region_bg);
  2101. p_theme->set_stylebox("TextureRegionPreviewFG", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
  2102. // Theme editor.
  2103. {
  2104. p_theme->set_color("preview_picker_overlay_color", "ThemeEditor", Color(0.1, 0.1, 0.1, 0.25));
  2105. Color theme_preview_picker_bg_color = p_config.accent_color;
  2106. theme_preview_picker_bg_color.a = 0.2;
  2107. Ref<StyleBoxFlat> theme_preview_picker_sb = make_flat_stylebox(theme_preview_picker_bg_color, 0, 0, 0, 0);
  2108. theme_preview_picker_sb->set_border_color(p_config.accent_color);
  2109. theme_preview_picker_sb->set_border_width_all(1.0 * EDSCALE);
  2110. p_theme->set_stylebox("preview_picker_overlay", "ThemeEditor", theme_preview_picker_sb);
  2111. Color theme_preview_picker_label_bg_color = p_config.accent_color;
  2112. theme_preview_picker_label_bg_color.set_v(0.5);
  2113. Ref<StyleBoxFlat> theme_preview_picker_label_sb = make_flat_stylebox(theme_preview_picker_label_bg_color, 4.0, 1.0, 4.0, 3.0);
  2114. p_theme->set_stylebox("preview_picker_label", "ThemeEditor", theme_preview_picker_label_sb);
  2115. Ref<StyleBoxFlat> style_theme_preview_tab = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainerOdd"))->duplicate();
  2116. style_theme_preview_tab->set_expand_margin(SIDE_BOTTOM, 5 * EDSCALE);
  2117. p_theme->set_stylebox("ThemeEditorPreviewFG", EditorStringName(EditorStyles), style_theme_preview_tab);
  2118. Ref<StyleBoxFlat> style_theme_preview_bg_tab = p_theme->get_stylebox(SNAME("tab_unselected"), SNAME("TabContainer"))->duplicate();
  2119. style_theme_preview_bg_tab->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE);
  2120. p_theme->set_stylebox("ThemeEditorPreviewBG", EditorStringName(EditorStyles), style_theme_preview_bg_tab);
  2121. }
  2122. // VisualShader editor.
  2123. p_theme->set_stylebox("label_style", "VShaderEditor", make_empty_stylebox(4, 6, 4, 6));
  2124. // StateMachine graph.
  2125. {
  2126. p_theme->set_stylebox(SceneStringName(panel), "GraphStateMachine", p_config.tree_panel_style);
  2127. p_theme->set_stylebox("error_panel", "GraphStateMachine", p_config.tree_panel_style);
  2128. p_theme->set_color("error_color", "GraphStateMachine", p_config.error_color);
  2129. const int sm_margin_side = 10 * EDSCALE;
  2130. const int sm_margin_bottom = 2;
  2131. const Color sm_bg_color = p_config.dark_theme ? p_config.dark_color_3 : p_config.dark_color_1.lerp(p_config.mono_color, 0.09);
  2132. Ref<StyleBoxFlat> sm_node_style = make_flat_stylebox(p_config.dark_color_3 * Color(1, 1, 1, 0.7), sm_margin_side, 24 * EDSCALE, sm_margin_side, sm_margin_bottom, p_config.corner_radius);
  2133. sm_node_style->set_border_width_all(p_config.border_width);
  2134. sm_node_style->set_border_color(sm_bg_color);
  2135. Ref<StyleBoxFlat> sm_node_selected_style = make_flat_stylebox(sm_bg_color * Color(1, 1, 1, 0.9), sm_margin_side, 24 * EDSCALE, sm_margin_side, sm_margin_bottom, p_config.corner_radius);
  2136. sm_node_selected_style->set_border_width_all(2 * EDSCALE + p_config.border_width);
  2137. sm_node_selected_style->set_border_color(p_config.accent_color * Color(1, 1, 1, 0.9));
  2138. sm_node_selected_style->set_shadow_size(8 * EDSCALE);
  2139. sm_node_selected_style->set_shadow_color(p_config.shadow_color);
  2140. Ref<StyleBoxFlat> sm_node_playing_style = sm_node_selected_style->duplicate();
  2141. sm_node_playing_style->set_border_color(p_config.warning_color);
  2142. sm_node_playing_style->set_shadow_color(p_config.warning_color * Color(1, 1, 1, 0.2));
  2143. sm_node_playing_style->set_draw_center(false);
  2144. p_theme->set_stylebox("node_frame", "GraphStateMachine", sm_node_style);
  2145. p_theme->set_stylebox("node_frame_selected", "GraphStateMachine", sm_node_selected_style);
  2146. p_theme->set_stylebox("node_frame_playing", "GraphStateMachine", sm_node_playing_style);
  2147. Ref<StyleBoxFlat> sm_node_start_style = sm_node_style->duplicate();
  2148. sm_node_start_style->set_border_width_all(1 * EDSCALE);
  2149. sm_node_start_style->set_border_color(p_config.success_color.lightened(0.24));
  2150. p_theme->set_stylebox("node_frame_start", "GraphStateMachine", sm_node_start_style);
  2151. Ref<StyleBoxFlat> sm_node_end_style = sm_node_style->duplicate();
  2152. sm_node_end_style->set_border_width_all(1 * EDSCALE);
  2153. sm_node_end_style->set_border_color(p_config.error_color);
  2154. p_theme->set_stylebox("node_frame_end", "GraphStateMachine", sm_node_end_style);
  2155. p_theme->set_font("node_title_font", "GraphStateMachine", p_theme->get_font(SceneStringName(font), SNAME("Label")));
  2156. p_theme->set_font_size("node_title_font_size", "GraphStateMachine", p_theme->get_font_size(SceneStringName(font_size), SNAME("Label")));
  2157. p_theme->set_color("node_title_font_color", "GraphStateMachine", p_config.font_color);
  2158. p_theme->set_color("transition_color", "GraphStateMachine", p_config.font_color);
  2159. p_theme->set_color("transition_disabled_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.2));
  2160. p_theme->set_color("transition_icon_color", "GraphStateMachine", Color(1, 1, 1));
  2161. p_theme->set_color("transition_icon_disabled_color", "GraphStateMachine", Color(1, 1, 1, 0.2));
  2162. p_theme->set_color("highlight_color", "GraphStateMachine", p_config.accent_color);
  2163. p_theme->set_color("highlight_disabled_color", "GraphStateMachine", p_config.accent_color * Color(1, 1, 1, 0.6));
  2164. p_theme->set_color("focus_color", "GraphStateMachine", p_config.accent_color);
  2165. p_theme->set_color("guideline_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3));
  2166. p_theme->set_color("playback_color", "GraphStateMachine", p_config.font_color);
  2167. p_theme->set_color("playback_background_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3));
  2168. }
  2169. }
  2170. }
  2171. void _load_text_editor_theme() {
  2172. EditorSettings *settings = EditorSettings::get_singleton();
  2173. const String theme_name = settings->get_setting("text_editor/theme/color_theme");
  2174. ERR_FAIL_COND(EditorSettings::is_default_text_editor_theme(theme_name.get_file().to_lower()));
  2175. const String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(theme_name + ".tet");
  2176. Ref<ConfigFile> cf;
  2177. cf.instantiate();
  2178. Error err = cf->load(theme_path);
  2179. ERR_FAIL_COND_MSG(err != OK, vformat("Failed to load text editor theme file '%s': %s", theme_name, error_names[err]));
  2180. const PackedStringArray keys = cf->get_section_keys("color_theme");
  2181. for (const String &key : keys) {
  2182. const String setting_key = "text_editor/theme/highlighting/" + key;
  2183. // Don't load if it's not an actual setting, or if it isn't a color setting.
  2184. if (!settings->has_setting(setting_key) || !key.contains("color")) {
  2185. continue;
  2186. }
  2187. const String val = cf->get_value("color_theme", key);
  2188. // Make sure it is actually a color.
  2189. if (val.is_valid_html_color()) {
  2190. const Color color_value = Color::html(val);
  2191. // Change manually to prevent settings_changed spam.
  2192. settings->set_initial_value(setting_key, color_value);
  2193. settings->set_manually(setting_key, color_value);
  2194. }
  2195. }
  2196. // If it doesn't load a setting just use what is currently loaded.
  2197. }
  2198. void EditorThemeManager::_populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
  2199. const String text_editor_color_theme = EDITOR_GET("text_editor/theme/color_theme");
  2200. const bool is_default_theme = text_editor_color_theme == "Default";
  2201. const bool is_godot2_theme = text_editor_color_theme == "Godot 2";
  2202. const bool is_custom_theme = text_editor_color_theme == "Custom";
  2203. if (is_default_theme || is_godot2_theme || is_custom_theme) {
  2204. HashMap<StringName, Color> colors;
  2205. if (is_default_theme || is_custom_theme) {
  2206. // Adaptive colors for comments and elements with lower relevance.
  2207. const Color dim_color = Color(p_config.font_color, 0.5);
  2208. const float mono_value = p_config.mono_color.r;
  2209. const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07);
  2210. const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14);
  2211. const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.27);
  2212. // Syntax highlight token colors.
  2213. colors["text_editor/theme/highlighting/symbol_color"] = p_config.dark_theme ? Color(0.67, 0.79, 1) : Color(0, 0, 0.61);
  2214. colors["text_editor/theme/highlighting/keyword_color"] = p_config.dark_theme ? Color(1.0, 0.44, 0.52) : Color(0.9, 0.135, 0.51);
  2215. colors["text_editor/theme/highlighting/control_flow_keyword_color"] = p_config.dark_theme ? Color(1.0, 0.55, 0.8) : Color(0.743, 0.12, 0.8);
  2216. colors["text_editor/theme/highlighting/base_type_color"] = p_config.dark_theme ? Color(0.26, 1.0, 0.76) : Color(0, 0.6, 0.2);
  2217. colors["text_editor/theme/highlighting/engine_type_color"] = p_config.dark_theme ? Color(0.56, 1, 0.86) : Color(0.11, 0.55, 0.4);
  2218. colors["text_editor/theme/highlighting/user_type_color"] = p_config.dark_theme ? Color(0.78, 1, 0.93) : Color(0.18, 0.45, 0.4);
  2219. colors["text_editor/theme/highlighting/comment_color"] = p_config.dark_theme ? dim_color : Color(0.08, 0.08, 0.08, 0.5);
  2220. colors["text_editor/theme/highlighting/doc_comment_color"] = p_config.dark_theme ? Color(0.6, 0.7, 0.8, 0.8) : Color(0.15, 0.15, 0.4, 0.7);
  2221. colors["text_editor/theme/highlighting/string_color"] = p_config.dark_theme ? Color(1, 0.93, 0.63) : Color(0.6, 0.42, 0);
  2222. // Use the brightest background color on a light theme (which generally uses a negative contrast rate).
  2223. colors["text_editor/theme/highlighting/background_color"] = p_config.dark_theme ? p_config.dark_color_2 : p_config.dark_color_3;
  2224. colors["text_editor/theme/highlighting/completion_background_color"] = p_config.dark_theme ? p_config.base_color : p_config.dark_color_2;
  2225. colors["text_editor/theme/highlighting/completion_selected_color"] = alpha1;
  2226. colors["text_editor/theme/highlighting/completion_existing_color"] = alpha2;
  2227. // Same opacity as the scroll grabber editor icon.
  2228. colors["text_editor/theme/highlighting/completion_scroll_color"] = Color(mono_value, mono_value, mono_value, 0.29);
  2229. colors["text_editor/theme/highlighting/completion_scroll_hovered_color"] = Color(mono_value, mono_value, mono_value, 0.4);
  2230. colors["text_editor/theme/highlighting/completion_font_color"] = p_config.font_color;
  2231. colors["text_editor/theme/highlighting/text_color"] = p_config.font_color;
  2232. colors["text_editor/theme/highlighting/line_number_color"] = dim_color;
  2233. colors["text_editor/theme/highlighting/safe_line_number_color"] = p_config.dark_theme ? (dim_color * Color(1, 1.2, 1, 1.5)) : Color(0, 0.4, 0, 0.75);
  2234. colors["text_editor/theme/highlighting/caret_color"] = p_config.mono_color;
  2235. colors["text_editor/theme/highlighting/caret_background_color"] = p_config.mono_color.inverted();
  2236. colors["text_editor/theme/highlighting/text_selected_color"] = Color(0, 0, 0, 0);
  2237. colors["text_editor/theme/highlighting/selection_color"] = p_config.selection_color;
  2238. colors["text_editor/theme/highlighting/brace_mismatch_color"] = p_config.dark_theme ? p_config.error_color : Color(1, 0.08, 0, 1);
  2239. colors["text_editor/theme/highlighting/current_line_color"] = alpha1;
  2240. colors["text_editor/theme/highlighting/line_length_guideline_color"] = p_config.dark_theme ? p_config.base_color : p_config.dark_color_2;
  2241. colors["text_editor/theme/highlighting/word_highlighted_color"] = alpha1;
  2242. colors["text_editor/theme/highlighting/number_color"] = p_config.dark_theme ? Color(0.63, 1, 0.88) : Color(0, 0.55, 0.28, 1);
  2243. colors["text_editor/theme/highlighting/function_color"] = p_config.dark_theme ? Color(0.34, 0.7, 1.0) : Color(0, 0.225, 0.9, 1);
  2244. colors["text_editor/theme/highlighting/member_variable_color"] = p_config.dark_theme ? Color(0.34, 0.7, 1.0).lerp(p_config.mono_color, 0.6) : Color(0, 0.4, 0.68, 1);
  2245. colors["text_editor/theme/highlighting/mark_color"] = Color(p_config.error_color.r, p_config.error_color.g, p_config.error_color.b, 0.3);
  2246. colors["text_editor/theme/highlighting/warning_color"] = Color(p_config.warning_color.r, p_config.warning_color.g, p_config.warning_color.b, 0.15);
  2247. colors["text_editor/theme/highlighting/bookmark_color"] = Color(0.08, 0.49, 0.98);
  2248. colors["text_editor/theme/highlighting/breakpoint_color"] = p_config.dark_theme ? p_config.error_color : Color(1, 0.27, 0.2, 1);
  2249. colors["text_editor/theme/highlighting/executing_line_color"] = Color(0.98, 0.89, 0.27);
  2250. colors["text_editor/theme/highlighting/code_folding_color"] = alpha3;
  2251. colors["text_editor/theme/highlighting/folded_code_region_color"] = Color(0.68, 0.46, 0.77, 0.2);
  2252. colors["text_editor/theme/highlighting/search_result_color"] = alpha1;
  2253. colors["text_editor/theme/highlighting/search_result_border_color"] = p_config.dark_theme ? Color(0.41, 0.61, 0.91, 0.38) : Color(0, 0.4, 1, 0.38);
  2254. if (p_config.dark_theme) {
  2255. colors["text_editor/theme/highlighting/gdscript/function_definition_color"] = Color(0.4, 0.9, 1.0);
  2256. colors["text_editor/theme/highlighting/gdscript/global_function_color"] = Color(0.64, 0.64, 0.96);
  2257. colors["text_editor/theme/highlighting/gdscript/node_path_color"] = Color(0.72, 0.77, 0.49);
  2258. colors["text_editor/theme/highlighting/gdscript/node_reference_color"] = Color(0.39, 0.76, 0.35);
  2259. colors["text_editor/theme/highlighting/gdscript/annotation_color"] = Color(1.0, 0.7, 0.45);
  2260. colors["text_editor/theme/highlighting/gdscript/string_name_color"] = Color(1.0, 0.76, 0.65);
  2261. colors["text_editor/theme/highlighting/comment_markers/critical_color"] = Color(0.77, 0.35, 0.35);
  2262. colors["text_editor/theme/highlighting/comment_markers/warning_color"] = Color(0.72, 0.61, 0.48);
  2263. colors["text_editor/theme/highlighting/comment_markers/notice_color"] = Color(0.56, 0.67, 0.51);
  2264. } else {
  2265. colors["text_editor/theme/highlighting/gdscript/function_definition_color"] = Color(0, 0.6, 0.6);
  2266. colors["text_editor/theme/highlighting/gdscript/global_function_color"] = Color(0.36, 0.18, 0.72);
  2267. colors["text_editor/theme/highlighting/gdscript/node_path_color"] = Color(0.18, 0.55, 0);
  2268. colors["text_editor/theme/highlighting/gdscript/node_reference_color"] = Color(0.0, 0.5, 0);
  2269. colors["text_editor/theme/highlighting/gdscript/annotation_color"] = Color(0.8, 0.37, 0);
  2270. colors["text_editor/theme/highlighting/gdscript/string_name_color"] = Color(0.8, 0.56, 0.45);
  2271. colors["text_editor/theme/highlighting/comment_markers/critical_color"] = Color(0.8, 0.14, 0.14);
  2272. colors["text_editor/theme/highlighting/comment_markers/warning_color"] = Color(0.75, 0.39, 0.03);
  2273. colors["text_editor/theme/highlighting/comment_markers/notice_color"] = Color(0.24, 0.54, 0.09);
  2274. }
  2275. } else if (is_godot2_theme) {
  2276. colors = EditorSettings::get_godot2_text_editor_theme();
  2277. }
  2278. EditorSettings *settings = EditorSettings::get_singleton();
  2279. for (const KeyValue<StringName, Color> &setting : colors) {
  2280. settings->set_initial_value(setting.key, setting.value);
  2281. if (is_default_theme || is_godot2_theme) {
  2282. settings->set_manually(setting.key, setting.value);
  2283. }
  2284. }
  2285. } else {
  2286. // Custom user theme.
  2287. _load_text_editor_theme();
  2288. }
  2289. // Now theme is loaded, apply it to CodeEdit.
  2290. p_theme->set_font(SceneStringName(font), "CodeEdit", p_theme->get_font(SNAME("source"), EditorStringName(EditorFonts)));
  2291. p_theme->set_font_size(SceneStringName(font_size), "CodeEdit", p_theme->get_font_size(SNAME("source_size"), EditorStringName(EditorFonts)));
  2292. /* clang-format off */
  2293. p_theme->set_icon("tab", "CodeEdit", p_theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons)));
  2294. p_theme->set_icon("space", "CodeEdit", p_theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons)));
  2295. p_theme->set_icon("folded", "CodeEdit", p_theme->get_icon(SNAME("CodeFoldedRightArrow"), EditorStringName(EditorIcons)));
  2296. p_theme->set_icon("can_fold", "CodeEdit", p_theme->get_icon(SNAME("CodeFoldDownArrow"), EditorStringName(EditorIcons)));
  2297. p_theme->set_icon("folded_code_region", "CodeEdit", p_theme->get_icon(SNAME("CodeRegionFoldedRightArrow"), EditorStringName(EditorIcons)));
  2298. p_theme->set_icon("can_fold_code_region", "CodeEdit", p_theme->get_icon(SNAME("CodeRegionFoldDownArrow"), EditorStringName(EditorIcons)));
  2299. p_theme->set_icon("executing_line", "CodeEdit", p_theme->get_icon(SNAME("TextEditorPlay"), EditorStringName(EditorIcons)));
  2300. p_theme->set_icon("breakpoint", "CodeEdit", p_theme->get_icon(SNAME("Breakpoint"), EditorStringName(EditorIcons)));
  2301. /* clang-format on */
  2302. p_theme->set_constant("line_spacing", "CodeEdit", EDITOR_GET("text_editor/appearance/whitespace/line_spacing"));
  2303. const Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color");
  2304. Ref<StyleBoxFlat> code_edit_stylebox = make_flat_stylebox(background_color, p_config.widget_margin.x, p_config.widget_margin.y, p_config.widget_margin.x, p_config.widget_margin.y, p_config.corner_radius);
  2305. p_theme->set_stylebox(CoreStringName(normal), "CodeEdit", code_edit_stylebox);
  2306. p_theme->set_stylebox("read_only", "CodeEdit", code_edit_stylebox);
  2307. p_theme->set_stylebox("focus", "CodeEdit", memnew(StyleBoxEmpty));
  2308. p_theme->set_color("background_color", "CodeEdit", Color(0, 0, 0, 0)); // Unset any color, we use a stylebox.
  2309. /* clang-format off */
  2310. p_theme->set_color("completion_background_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_background_color"));
  2311. p_theme->set_color("completion_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_selected_color"));
  2312. p_theme->set_color("completion_existing_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_existing_color"));
  2313. p_theme->set_color("completion_scroll_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_scroll_color"));
  2314. p_theme->set_color("completion_scroll_hovered_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_scroll_hovered_color"));
  2315. p_theme->set_color(SceneStringName(font_color), "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_color"));
  2316. p_theme->set_color("line_number_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_number_color"));
  2317. p_theme->set_color("caret_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/caret_color"));
  2318. p_theme->set_color("font_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_selected_color"));
  2319. p_theme->set_color("selection_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/selection_color"));
  2320. p_theme->set_color("brace_mismatch_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/brace_mismatch_color"));
  2321. p_theme->set_color("current_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/current_line_color"));
  2322. p_theme->set_color("line_length_guideline_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_length_guideline_color"));
  2323. p_theme->set_color("word_highlighted_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/word_highlighted_color"));
  2324. p_theme->set_color("bookmark_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/bookmark_color"));
  2325. p_theme->set_color("breakpoint_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/breakpoint_color"));
  2326. p_theme->set_color("executing_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/executing_line_color"));
  2327. p_theme->set_color("code_folding_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/code_folding_color"));
  2328. p_theme->set_color("folded_code_region_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/folded_code_region_color"));
  2329. p_theme->set_color("search_result_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_color"));
  2330. p_theme->set_color("search_result_border_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_border_color"));
  2331. /* clang-format on */
  2332. }
  2333. void EditorThemeManager::_populate_visual_shader_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
  2334. EditorSettings *ed_settings = EditorSettings::get_singleton();
  2335. String visual_shader_color_theme = ed_settings->get("editors/visual_editors/color_theme");
  2336. if (visual_shader_color_theme == "Default") {
  2337. // Connection type colors
  2338. ed_settings->set_initial_value("editors/visual_editors/connection_colors/scalar_color", Color(0.55, 0.55, 0.55), true);
  2339. ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector2_color", Color(0.44, 0.43, 0.64), true);
  2340. ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector3_color", Color(0.337, 0.314, 0.71), true);
  2341. ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector4_color", Color(0.7, 0.65, 0.147), true);
  2342. ed_settings->set_initial_value("editors/visual_editors/connection_colors/boolean_color", Color(0.243, 0.612, 0.349), true);
  2343. ed_settings->set_initial_value("editors/visual_editors/connection_colors/transform_color", Color(0.71, 0.357, 0.64), true);
  2344. ed_settings->set_initial_value("editors/visual_editors/connection_colors/sampler_color", Color(0.659, 0.4, 0.137), true);
  2345. // Node category colors (used for the node headers)
  2346. ed_settings->set_initial_value("editors/visual_editors/category_colors/output_color", Color(0.26, 0.10, 0.15), true);
  2347. ed_settings->set_initial_value("editors/visual_editors/category_colors/color_color", Color(0.5, 0.5, 0.1), true);
  2348. ed_settings->set_initial_value("editors/visual_editors/category_colors/conditional_color", Color(0.208, 0.522, 0.298), true);
  2349. ed_settings->set_initial_value("editors/visual_editors/category_colors/input_color", Color(0.502, 0.2, 0.204), true);
  2350. ed_settings->set_initial_value("editors/visual_editors/category_colors/scalar_color", Color(0.1, 0.5, 0.6), true);
  2351. ed_settings->set_initial_value("editors/visual_editors/category_colors/textures_color", Color(0.5, 0.3, 0.1), true);
  2352. ed_settings->set_initial_value("editors/visual_editors/category_colors/transform_color", Color(0.5, 0.3, 0.5), true);
  2353. ed_settings->set_initial_value("editors/visual_editors/category_colors/utility_color", Color(0.2, 0.2, 0.2), true);
  2354. ed_settings->set_initial_value("editors/visual_editors/category_colors/vector_color", Color(0.2, 0.2, 0.5), true);
  2355. ed_settings->set_initial_value("editors/visual_editors/category_colors/special_color", Color(0.098, 0.361, 0.294), true);
  2356. ed_settings->set_initial_value("editors/visual_editors/category_colors/particle_color", Color(0.12, 0.358, 0.8), true);
  2357. } else if (visual_shader_color_theme == "Legacy") {
  2358. // Connection type colors
  2359. ed_settings->set_initial_value("editors/visual_editors/connection_colors/scalar_color", Color(0.38, 0.85, 0.96), true);
  2360. ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector2_color", Color(0.74, 0.57, 0.95), true);
  2361. ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector3_color", Color(0.84, 0.49, 0.93), true);
  2362. ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector4_color", Color(1.0, 0.125, 0.95), true);
  2363. ed_settings->set_initial_value("editors/visual_editors/connection_colors/boolean_color", Color(0.55, 0.65, 0.94), true);
  2364. ed_settings->set_initial_value("editors/visual_editors/connection_colors/transform_color", Color(0.96, 0.66, 0.43), true);
  2365. ed_settings->set_initial_value("editors/visual_editors/connection_colors/sampler_color", Color(1.0, 1.0, 0.0), true);
  2366. // Node category colors (used for the node headers)
  2367. Ref<StyleBoxFlat> gn_panel_style = p_theme->get_stylebox(SceneStringName(panel), "GraphNode");
  2368. Color gn_bg_color = gn_panel_style->get_bg_color();
  2369. ed_settings->set_initial_value("editors/visual_editors/category_colors/output_color", gn_bg_color, true);
  2370. ed_settings->set_initial_value("editors/visual_editors/category_colors/color_color", gn_bg_color, true);
  2371. ed_settings->set_initial_value("editors/visual_editors/category_colors/conditional_color", gn_bg_color, true);
  2372. ed_settings->set_initial_value("editors/visual_editors/category_colors/input_color", gn_bg_color, true);
  2373. ed_settings->set_initial_value("editors/visual_editors/category_colors/scalar_color", gn_bg_color, true);
  2374. ed_settings->set_initial_value("editors/visual_editors/category_colors/textures_color", gn_bg_color, true);
  2375. ed_settings->set_initial_value("editors/visual_editors/category_colors/transform_color", gn_bg_color, true);
  2376. ed_settings->set_initial_value("editors/visual_editors/category_colors/utility_color", gn_bg_color, true);
  2377. ed_settings->set_initial_value("editors/visual_editors/category_colors/vector_color", gn_bg_color, true);
  2378. ed_settings->set_initial_value("editors/visual_editors/category_colors/special_color", gn_bg_color, true);
  2379. ed_settings->set_initial_value("editors/visual_editors/category_colors/particle_color", gn_bg_color, true);
  2380. }
  2381. }
  2382. void EditorThemeManager::_reset_dirty_flag() {
  2383. outdated_cache_dirty = true;
  2384. }
  2385. // Public interface for theme generation.
  2386. Ref<EditorTheme> EditorThemeManager::generate_theme(const Ref<EditorTheme> &p_old_theme) {
  2387. OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Generate Theme");
  2388. Ref<EditorTheme> theme = _create_base_theme(p_old_theme);
  2389. OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Merge Custom Theme");
  2390. const String custom_theme_path = EDITOR_GET("interface/theme/custom_theme");
  2391. if (!custom_theme_path.is_empty()) {
  2392. Ref<Theme> custom_theme = ResourceLoader::load(custom_theme_path);
  2393. if (custom_theme.is_valid()) {
  2394. theme->merge_with(custom_theme);
  2395. }
  2396. }
  2397. OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Merge Custom Theme");
  2398. OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Generate Theme");
  2399. benchmark_run++;
  2400. return theme;
  2401. }
  2402. bool EditorThemeManager::is_generated_theme_outdated() {
  2403. // This list includes settings used by files in the editor/themes folder.
  2404. // Note that the editor scale is purposefully omitted because it cannot be changed
  2405. // without a restart, so there is no point regenerating the theme.
  2406. if (outdated_cache_dirty) {
  2407. // TODO: We can use this information more intelligently to do partial theme updates and speed things up.
  2408. outdated_cache = EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") ||
  2409. EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/font") ||
  2410. EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/main_font") ||
  2411. EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/code_font") ||
  2412. EditorSettings::get_singleton()->check_changed_settings_in_group("editors/visual_editors") ||
  2413. EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme") ||
  2414. EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/help/help") ||
  2415. EditorSettings::get_singleton()->check_changed_settings_in_group("docks/property_editor/subresource_hue_tint") ||
  2416. EditorSettings::get_singleton()->check_changed_settings_in_group("filesystem/file_dialog/thumbnail_size") ||
  2417. EditorSettings::get_singleton()->check_changed_settings_in_group("run/output/font_size");
  2418. // The outdated flag is relevant at the moment of changing editor settings.
  2419. callable_mp_static(&EditorThemeManager::_reset_dirty_flag).call_deferred();
  2420. outdated_cache_dirty = false;
  2421. }
  2422. return outdated_cache;
  2423. }
  2424. bool EditorThemeManager::is_dark_theme() {
  2425. // Light color mode for icons and fonts means it's a dark theme, and vice versa.
  2426. int icon_font_color_setting = EDITOR_GET("interface/theme/icon_and_font_color");
  2427. if (icon_font_color_setting == ColorMode::AUTO_COLOR) {
  2428. Color base_color = EDITOR_GET("interface/theme/base_color");
  2429. return base_color.get_luminance() < 0.5;
  2430. }
  2431. return icon_font_color_setting == ColorMode::LIGHT_COLOR;
  2432. }
  2433. void EditorThemeManager::initialize() {
  2434. EditorColorMap::create();
  2435. EditorTheme::initialize();
  2436. }
  2437. void EditorThemeManager::finalize() {
  2438. EditorColorMap::finish();
  2439. EditorTheme::finalize();
  2440. }