editor_theme_manager.cpp 177 KB

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