From a54827e133233e454ee63b3087348bf396edeb29 Mon Sep 17 00:00:00 2001 From: WhalesState Date: Sun, 26 Jan 2025 22:18:25 +0200 Subject: [PATCH] Add Blazium default theme --- .pre-commit-config.yaml | 2 + SConstruct | 4 + doc/classes/Button.xml | 24 +- doc/classes/CodeEdit.xml | 4 +- doc/classes/ColorPicker.xml | 2 +- doc/classes/FileDialog.xml | 6 +- doc/classes/FoldableContainer.xml | 18 +- doc/classes/GraphEdit.xml | 6 +- doc/classes/GraphFrame.xml | 2 +- doc/classes/GraphNode.xml | 2 +- doc/classes/ItemList.xml | 8 +- doc/classes/Label.xml | 4 +- doc/classes/LineEdit.xml | 14 +- doc/classes/LinkButton.xml | 12 +- doc/classes/MarginContainer.xml | 8 +- doc/classes/MenuBar.xml | 12 +- doc/classes/OptionButton.xml | 2 +- doc/classes/PopupMenu.xml | 12 +- doc/classes/ProgressBar.xml | 2 +- doc/classes/ProjectSettings.xml | 61 + doc/classes/RichTextLabel.xml | 14 +- doc/classes/SpinBox.xml | 18 +- doc/classes/SplitContainer.xml | 6 +- doc/classes/TabBar.xml | 10 +- doc/classes/TabContainer.xml | 14 +- doc/classes/TextEdit.xml | 20 +- doc/classes/ThemeDB.xml | 5 + doc/classes/Tree.xml | 32 +- doc/classes/Window.xml | 2 +- editor/editor_node.cpp | 2 +- scene/resources/theme.cpp | 17 +- scene/resources/theme.h | 5 + scene/theme/SCsub | 12 +- scene/theme/blazium_default_theme.cpp | 1631 +++++++++++++++++ scene/theme/blazium_default_theme.h | 64 + scene/theme/default_theme.cpp | 23 +- scene/theme/icons/add.svg | 2 +- scene/theme/icons/arrow_down.svg | 2 +- scene/theme/icons/arrow_left.svg | 2 +- scene/theme/icons/arrow_right.svg | 2 +- scene/theme/icons/arrow_up.svg | 2 +- scene/theme/icons/bookmark.svg | 2 +- scene/theme/icons/breakpoint.svg | 2 +- scene/theme/icons/checked.svg | 2 +- scene/theme/icons/checked_disabled.svg | 2 +- scene/theme/icons/close.svg | 2 +- scene/theme/icons/close_hl.svg | 2 +- scene/theme/icons/color_picker_bar_arrow.svg | 2 +- scene/theme/icons/color_picker_overbright.svg | 2 +- scene/theme/icons/color_picker_pipette.svg | 2 +- scene/theme/icons/error_icon.svg | 2 +- scene/theme/icons/expanded_arrow.svg | 1 + scene/theme/icons/expanded_arrow_mirrored.svg | 1 + scene/theme/icons/file.svg | 2 +- scene/theme/icons/folded_arrow.svg | 1 + scene/theme/icons/folded_arrow_mirrored.svg | 1 + scene/theme/icons/folder.svg | 2 +- scene/theme/icons/folder_create.svg | 2 +- scene/theme/icons/folder_up.svg | 2 +- scene/theme/icons/graph_port.svg | 2 +- scene/theme/icons/grid_layout.svg | 2 +- scene/theme/icons/grid_minimap.svg | 2 +- scene/theme/icons/grid_snap.svg | 2 +- scene/theme/icons/grid_toggle.svg | 2 +- scene/theme/icons/hslider_tick.svg | 2 +- scene/theme/icons/indeterminate.svg | 2 +- scene/theme/icons/indeterminate_disabled.svg | 2 +- scene/theme/icons/line_edit_clear.svg | 2 +- scene/theme/icons/mini_checkerboard.svg | 2 +- scene/theme/icons/option_button_arrow.svg | 2 +- scene/theme/icons/picker_shape_circle.svg | 2 +- scene/theme/icons/picker_shape_rectangle.svg | 2 +- .../icons/picker_shape_rectangle_wheel.svg | 2 +- scene/theme/icons/popup_menu_arrow_left.svg | 2 +- scene/theme/icons/popup_menu_arrow_right.svg | 2 +- scene/theme/icons/radio_checked.svg | 2 +- scene/theme/icons/radio_checked_disabled.svg | 2 +- scene/theme/icons/radio_unchecked.svg | 2 +- .../theme/icons/radio_unchecked_disabled.svg | 2 +- scene/theme/icons/region_folded.svg | 2 +- scene/theme/icons/region_unfolded.svg | 2 +- scene/theme/icons/reload.svg | 2 +- scene/theme/icons/resizer_nw.svg | 2 +- scene/theme/icons/resizer_se.svg | 2 +- scene/theme/icons/scroll_button_left.svg | 2 +- scene/theme/icons/scroll_button_left_hl.svg | 2 +- scene/theme/icons/scroll_button_right.svg | 2 +- scene/theme/icons/scroll_button_right_hl.svg | 2 +- scene/theme/icons/slider_grabber.svg | 2 +- scene/theme/icons/slider_grabber_disabled.svg | 2 +- scene/theme/icons/slider_grabber_hl.svg | 2 +- scene/theme/icons/tabs_drop_mark.svg | 2 +- scene/theme/icons/tabs_menu.svg | 2 +- scene/theme/icons/tabs_menu_hl.svg | 2 +- scene/theme/icons/text_edit_ellipsis.svg | 2 +- scene/theme/icons/text_edit_space.svg | 2 +- scene/theme/icons/text_edit_tab.svg | 2 +- scene/theme/icons/toggle_off.svg | 2 +- scene/theme/icons/toggle_off_disabled.svg | 2 +- .../icons/toggle_off_disabled_mirrored.svg | 2 +- scene/theme/icons/toggle_off_mirrored.svg | 2 +- scene/theme/icons/toggle_on.svg | 2 +- scene/theme/icons/toggle_on_disabled.svg | 2 +- .../icons/toggle_on_disabled_mirrored.svg | 2 +- scene/theme/icons/toggle_on_mirrored.svg | 2 +- scene/theme/icons/unchecked.svg | 2 +- scene/theme/icons/unchecked_disabled.svg | 2 +- scene/theme/icons/updown.svg | 2 +- scene/theme/icons/updown_disabled.svg | 1 + scene/theme/icons/value_down.svg | 2 +- scene/theme/icons/value_up.svg | 2 +- scene/theme/icons/visibility_visible.svg | 2 +- scene/theme/icons/vslider_tick.svg | 2 +- scene/theme/icons/zoom_less.svg | 2 +- scene/theme/icons/zoom_more.svg | 2 +- scene/theme/icons/zoom_reset.svg | 2 +- scene/theme/theme_db.cpp | 338 +++- scene/theme/theme_db.h | 45 + tests/scene/test_code_edit.h | 3 + tests/scene/test_text_edit.h | 19 + 120 files changed, 2409 insertions(+), 231 deletions(-) create mode 100644 scene/theme/blazium_default_theme.cpp create mode 100644 scene/theme/blazium_default_theme.h create mode 100644 scene/theme/icons/expanded_arrow.svg create mode 100644 scene/theme/icons/expanded_arrow_mirrored.svg create mode 100644 scene/theme/icons/folded_arrow.svg create mode 100644 scene/theme/icons/folded_arrow_mirrored.svg create mode 100644 scene/theme/icons/updown_disabled.svg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4969c0df5450..aa38479fdda0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -145,6 +145,8 @@ repos: platform/android/java/editor/src/main/java/com/android/.*| platform/android/java/lib/src/com/.*| modules/blazium_sdk/.*| + scene/theme/blazium_default_theme.cpp| + scene/theme/blazium_default_theme.h| platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView\.java$| platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper\.java$| platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix\.java$ diff --git a/SConstruct b/SConstruct index f260030b4d27..71bca6da7e84 100644 --- a/SConstruct +++ b/SConstruct @@ -227,6 +227,7 @@ opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loade opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True)) opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "") opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True)) +opts.Add(BoolVariable("legacy_theme", "Allow using the legacy default theme.", False)) # Advanced options opts.Add(BoolVariable("dev_mode", "Alias for dev options: verbose=yes warnings=extra werror=yes tests=yes", False)) @@ -526,6 +527,9 @@ if not env["deprecated"]: if env["precision"] == "double": env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"]) +if env["legacy_theme"]: + env.Append(CPPDEFINES=["USE_LEGACY_THEME"]) + tmppath = "./platform/" + env["platform"] sys.path.insert(0, tmppath) import detect diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml index 68fb918904f3..5320364e9ba2 100644 --- a/doc/classes/Button.xml +++ b/doc/classes/Button.xml @@ -79,43 +79,43 @@ - + Default text [Color] of the [Button]. - + Text [Color] used when the [Button] is disabled. - + Text [Color] used when the [Button] is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color. - + Text [Color] used when the [Button] is being hovered. - + Text [Color] used when the [Button] is being hovered and pressed. The tint of text outline of the [Button]. - + Text [Color] used when the [Button] is being pressed. - + Icon modulate [Color] used when the [Button] is disabled. - + Icon modulate [Color] used when the [Button] is focused. Only replaces the normal modulate color of the button. Disabled, hovered, and pressed states take precedence over this color. - + Icon modulate [Color] used when the [Button] is being hovered. - + Icon modulate [Color] used when the [Button] is being hovered and pressed. - + Default icon modulate [Color] of the [Button]. - + Icon modulate [Color] used when the [Button] is being pressed. diff --git a/doc/classes/CodeEdit.xml b/doc/classes/CodeEdit.xml index d455799c2981..4d3417928da2 100644 --- a/doc/classes/CodeEdit.xml +++ b/doc/classes/CodeEdit.xml @@ -679,10 +679,10 @@ Background highlight [Color] for matching text in code completion options. - + [Color] of the scrollbar in the code completion popup. - + [Color] of the scrollbar in the code completion popup when hovered. diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index 04b0732eed33..8cd46f49ff81 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -173,7 +173,7 @@ The minimum width of the color labels next to sliders. - + The margin around the [ColorPicker]. diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 3eabb71a59c7..2f3d093b756e 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -206,13 +206,13 @@ - + The color tint for disabled files (when the [FileDialog] is used in open folder mode). - + The color modulation applied to the file icon. - + The color modulation applied to the folder icon. diff --git a/doc/classes/FoldableContainer.xml b/doc/classes/FoldableContainer.xml index 95896cb3126c..63701ef5c8a2 100644 --- a/doc/classes/FoldableContainer.xml +++ b/doc/classes/FoldableContainer.xml @@ -287,31 +287,31 @@ - + The title's icon color when disabled. - + The title's icon color when hovered. - + The title's icon color when normal. - + The title's icon color when pressed. - + The title's font color when collapsed. - + The title's font color when expanded. - + The title's font outline color. - + The title's font hover color. - + The horizontal separation between the title's icon and text. diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 670df10a89cc..5d077579c21d 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -491,7 +491,7 @@ Color which is blended with the connection line when the mouse is hovering over it. - + Color of the rim around each connection line used for making intersecting lines more distinguishable. @@ -503,10 +503,10 @@ Color of minor grid lines/dots. - + The fill color of the selection rectangle. - + The outline color of the selection rectangle. diff --git a/doc/classes/GraphFrame.xml b/doc/classes/GraphFrame.xml index 52bb451d9570..541d9f4ad3c7 100644 --- a/doc/classes/GraphFrame.xml +++ b/doc/classes/GraphFrame.xml @@ -47,7 +47,7 @@ - + The color modulation applied to the resizer icon. diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index cc3acad6d663..bafa681889a1 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -284,7 +284,7 @@ - + The color modulation applied to the resizer icon. diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index a1e5d9cbd9c2..ac0a34489060 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -455,19 +455,19 @@ - + Default text [Color] of the item. - + Text [Color] used when the item is hovered and not selected yet. The tint of text outline of the item. - + Text [Color] used when the item is selected. - + [Color] of the guideline. The guideline is a line drawn between each row of items. diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index 5ec65640a02a..6559390ed764 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -112,7 +112,7 @@ - + Default text [Color] of the [Label]. @@ -121,7 +121,7 @@ [Color] of the text's shadow effect. - + Vertical space between lines in multiline [Label]. diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index 0cd642fb4a49..cfc27b7047ca 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -495,16 +495,16 @@ - + Color of the [LineEdit]'s caret (text cursor). This can be set to a fully transparent color to hide the caret entirely. - + Color used as default tint for the clear button. - + Color used for the clear button when it's pressed. - + Default font color. @@ -513,13 +513,13 @@ Font color for [member placeholder_text]. - + Font color for selected text (inside the selection rectangle). - + Font color when editing is disabled. - + Color of the selection rectangle. diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml index bcdffcd1eeaf..4b01ddb76738 100644 --- a/doc/classes/LinkButton.xml +++ b/doc/classes/LinkButton.xml @@ -59,25 +59,25 @@ - + Default text [Color] of the [LinkButton]. - + Text [Color] used when the [LinkButton] is disabled. - + Text [Color] used when the [LinkButton] is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color. - + Text [Color] used when the [LinkButton] is being hovered. - + Text [Color] used when the [LinkButton] is being hovered and pressed. The tint of text outline of the [LinkButton]. - + Text [Color] used when the [LinkButton] is being pressed. diff --git a/doc/classes/MarginContainer.xml b/doc/classes/MarginContainer.xml index e3dd64648f70..170cac1f7802 100644 --- a/doc/classes/MarginContainer.xml +++ b/doc/classes/MarginContainer.xml @@ -29,16 +29,16 @@ $DOCS_URL/tutorials/ui/gui_containers.html - + Offsets towards the inside direct children of the container by this amount of pixels from the bottom. - + Offsets towards the inside direct children of the container by this amount of pixels from the left. - + Offsets towards the inside direct children of the container by this amount of pixels from the right. - + Offsets towards the inside direct children of the container by this amount of pixels from the top. diff --git a/doc/classes/MenuBar.xml b/doc/classes/MenuBar.xml index 9e4287331c61..8359fbad01d7 100644 --- a/doc/classes/MenuBar.xml +++ b/doc/classes/MenuBar.xml @@ -117,25 +117,25 @@ - + Default text [Color] of the menu item. - + Text [Color] used when the menu item is disabled. - + Text [Color] used when the menu item is focused. Only replaces the normal text color of the menu item. Disabled, hovered, and pressed states take precedence over this color. - + Text [Color] used when the menu item is being hovered. - + Text [Color] used when the menu item is being hovered and pressed. The tint of text outline of the menu item. - + Text [Color] used when the menu item is being pressed. diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index f04b0d942f70..be2cfa2ef715 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -243,7 +243,7 @@ - + The horizontal space between the arrow icon and the right edge of the button. diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 004bbe2286bb..a95af83064c3 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -678,13 +678,13 @@ - + The text [Color] used for shortcuts and accelerators that show next to the menu item name when defined. See [method get_item_accelerator] for more info on accelerators. - + The default text [Color] for menu items' names. - + [Color] used for disabled menu items' text. @@ -693,7 +693,7 @@ The tint of text outline of the menu item. - + [Color] used for labeled separators' text. See [method add_separator]. @@ -708,10 +708,10 @@ Width of the single indentation level. - + Horizontal padding to the right of the items (or left, in RTL layout). - + Horizontal padding to the left of the items (or right, in RTL layout). diff --git a/doc/classes/ProgressBar.xml b/doc/classes/ProgressBar.xml index e562d39bb71d..25c5ee949db0 100644 --- a/doc/classes/ProgressBar.xml +++ b/doc/classes/ProgressBar.xml @@ -37,7 +37,7 @@ - + The color of the text. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 8bd31a5307d5..e8e2c8add4eb 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1046,12 +1046,33 @@ + + The theme accent color. + + + The theme base color. + + + The contrast of the background style color. + + + The border width for some theme styles. + + + Changes the contrast of the theme styles. + + + The corner radius for theme styles. + Path to a custom [Theme] resource file to use for the project ([code].theme[/code] or generic [code].tres[/code]/[code].res[/code] extension). Path to a custom [Font] resource to use as default for all GUI elements of the project. + + Changes the font color if [member gui/theme/font_color_override] is set to Custom. + Font anti-aliasing mode for the default project font. See [member FontFile.antialiasing]. [b]Note:[/b] This setting does not affect custom [Font]s used within the project. Use the [b]Import[/b] dock for that instead (see [member ResourceImporterDynamicFont.antialiasing]). @@ -1078,9 +1099,49 @@ The default scale factor for [Control]s, when not overridden by a [Theme]. [b]Note:[/b] This property is only read when the project starts. To change the default scale at runtime, set [member ThemeDB.fallback_base_scale] instead. + + Can be Auto, Dark, Light and Custom, if Custom is selected, it will use [member gui/theme/custom_font_color] for font color and icons. + + + If is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness. + [b]Note:[/b] Emboldened fonts might have self-intersecting outlines, which will prevent MSDF fonts and [TextMesh] from working correctly. + + + + + + + + + Extra spacing at the bottom of the line in pixels. + + + Extra spacing between graphical glyphs. + + + Extra width of the space glyphs. + + + Extra spacing at the top of the line in pixels. + + + The contrast of the hover style color. + LCD subpixel layout used for font anti-aliasing. See [enum TextServer.FontLCDSubpixelLayout]. + + The margin used to separate items, ie. separation. + + + The contrast of the normal style color. + + + The padding of the theme items, ie. content margins. + + + The contrast of the pressed style color. + When [member BaseButton.shortcut_feedback] is enabled, this is the time the [BaseButton] will remain highlighted after a shortcut. diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 7e0c39ac7c85..1b867b8e5e0f 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -770,19 +770,19 @@ - + The default text color. The default tint of text outline. - + The color of selected text, used when [member selection_enabled] is [code]true[/code]. If equal to [code]Color(0, 0, 0, 0)[/code], it will be ignored. The color of the font's shadow. - + The color of the selection box. @@ -810,16 +810,16 @@ The size of the shadow outline. - + The horizontal separation of elements in a table. - + The vertical separation of elements in a table. - + The horizontal padding around boxes drawn by the [code][fgcolor][/code] and [code][bgcolor][/code] tags. This does not affect the appearance of text selection. - + The vertical padding around boxes drawn by the [code][fgcolor][/code] and [code][bgcolor][/code] tags. This does not affect the appearance of text selection. diff --git a/doc/classes/SpinBox.xml b/doc/classes/SpinBox.xml index c3b06784e8fa..1390e643a1a0 100644 --- a/doc/classes/SpinBox.xml +++ b/doc/classes/SpinBox.xml @@ -71,28 +71,28 @@ - + Down button icon modulation color, when the button is disabled. - + Down button icon modulation color, when the button is hovered. - + Down button icon modulation color. - + Down button icon modulation color, when the button is being pressed. - + Up button icon modulation color, when the button is disabled. - + Up button icon modulation color, when the button is hovered. - + Up button icon modulation color. - + Up button icon modulation color, when the button is being pressed. @@ -104,7 +104,7 @@ Width of the horizontal separation between the text input field ([LineEdit]) and the buttons. - + If not [code]0[/code], the minimum button width corresponds to the widest of all icons set on those buttons, even if [theme_item buttons_width] is smaller. diff --git a/doc/classes/SplitContainer.xml b/doc/classes/SplitContainer.xml index 9952d09524c3..618b8958df05 100644 --- a/doc/classes/SplitContainer.xml +++ b/doc/classes/SplitContainer.xml @@ -99,10 +99,10 @@ - + The grabber icon normal color. - + The grabber icon pressed color. @@ -120,7 +120,7 @@ The minimum thickness of the area users can click on to grab the splitting line. If [theme_item separation] or [theme_item h_grabber] / [theme_item v_grabber]'s thickness are too small, this ensure that the splitting line can still be dragged. - + The space between sides of the container. diff --git a/doc/classes/TabBar.xml b/doc/classes/TabBar.xml index d080294c1a40..c9c2c3a4f276 100644 --- a/doc/classes/TabBar.xml +++ b/doc/classes/TabBar.xml @@ -367,22 +367,22 @@ - + Modulation color for the [theme_item drop_mark] icon. - + Font color of disabled tabs. - + Font color of the currently hovered tab. Does not apply to the selected tab. The tint of text outline of the tab name. - + Font color of the currently selected tab. - + Font color of the other, unselected tabs. diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 090afa022078..f7800f8eb14a 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -298,35 +298,35 @@ - + Modulation color for the [theme_item drop_mark] icon. - + Font color of disabled tabs. - + Font color of the currently hovered tab. The tint of text outline of the tab name. - + Font color of the currently selected tab. - + Font color of the other, unselected tabs. The maximum allowed width of the tab's icon. This limit is applied on top of the default size of the icon, but before the value set with [method TabBar.set_tab_icon_max_width]. The height is adjusted according to the icon's ratio. - + Space between tab's name and its icon. The size of the tab text outline. [b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended. - + The space at the left or right edges of the tab bar, accordingly with the current [member tab_alignment]. The margin is ignored with [constant TabBar.ALIGNMENT_RIGHT] if the tabs are clipped (see [member clip_tabs]) or a popup has been set (see [method set_popup]). The margin is always ignored with [constant TabBar.ALIGNMENT_CENTER]. diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index f71601f9ae10..91b63e91672c 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -1577,16 +1577,16 @@ Sets the background [Color] of this [TextEdit]. - + [Color] of the text behind the caret when using a block caret. - + [Color] of the caret. This can be set to a fully transparent color to hide the caret entirely. - + Background [Color] of the line containing the caret. - + Sets the font [Color]. @@ -1595,22 +1595,22 @@ Font color for [member placeholder_text]. - + Sets the font [Color] when [member editable] is disabled. - + Sets the [Color] of the selected text. If equal to [code]Color(0, 0, 0, 0)[/code], it will be ignored. - + [Color] of the border around text that matches the search query. - + [Color] behind the text that matches the search query. - + Sets the highlight [Color] of text selections. - + Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled. diff --git a/doc/classes/ThemeDB.xml b/doc/classes/ThemeDB.xml index 106d011c434f..f6da3555e5a1 100644 --- a/doc/classes/ThemeDB.xml +++ b/doc/classes/ThemeDB.xml @@ -50,5 +50,10 @@ Emitted when one of the fallback values had been changed. Use it to refresh the look of controls that may rely on the fallback theme items. + + + Emits when the theme icons scale or colors changes. + + diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index b0cb25fafd8a..9892f9314b59 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -494,37 +494,37 @@ - + The [Color] of the relationship lines between the selected [TreeItem] and its children. - + Text [Color] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered. - + [Color] used to draw possible drop locations. See [enum DropModeFlags] constants for further description of drop locations. - + Default text [Color] of the item. - + Text [Color] for a [constant TreeItem.CELL_MODE_CHECK] mode cell when it's non-editable (see [method TreeItem.set_editable]). The tint of text outline of the item. - + Text [Color] used when the item is selected. - + [Color] of the guideline. - + The [Color] of the relationship lines between the selected [TreeItem] and its parents. - + The default [Color] of the relationship lines. - + Default text [Color] of the title button. @@ -533,10 +533,10 @@ The width of the relationship lines between the selected [TreeItem] and its children. - + Draws the guidelines if not zero, this acts as a boolean. The guideline is a horizontal line drawn at the bottom of each item. - + Draws the relationship lines if not zero, this acts as a boolean. Relationship lines are drawn at the start of child items to show hierarchy. @@ -548,16 +548,16 @@ The inner bottom margin of a cell. - + The inner left margin of a cell. - + The inner right margin of a cell. The inner top margin of a cell. - + The horizontal margin at the start of an item. This is used when folding is enabled for the item. @@ -567,7 +567,7 @@ The space between the parent relationship lines for the selected [TreeItem] and the relationship lines to its siblings that are not selected. - + The width of the relationship lines between the selected [TreeItem] and its parents. diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index ca155881c8ed..c8b3d2d30b64 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -907,7 +907,7 @@ - + The color of the title's text. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 35f5b0d7cd72..e99e3e1f25a3 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -522,7 +522,7 @@ void EditorNode::_update_theme(bool p_skip_creation) { Vector> editor_themes; editor_themes.push_back(theme); - editor_themes.push_back(ThemeDB::get_singleton()->get_default_theme()); + editor_themes.push_back(ThemeDB::get_singleton()->get_default_theme()->duplicate(true)); ThemeContext *node_tc = ThemeDB::get_singleton()->get_theme_context(this); if (node_tc) { diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 1ac90b89803f..eb85d4c562f6 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -1539,9 +1539,22 @@ void Theme::_freeze_change_propagation() { } void Theme::_unfreeze_and_propagate_changes() { - no_change_propagation = false; - _emit_theme_changed(true); + if (no_change_propagation) { + no_change_propagation = false; + _emit_theme_changed(true); + } +} + +#ifndef USE_LEGACY_THEME +// These methods are used to avoid conflicts when merging changes from different branches. +void Theme::freeze_change_propagation() { + _freeze_change_propagation(); +} + +void Theme::unfreeze_and_propagate_changes() { + _unfreeze_and_propagate_changes(); } +#endif // !USE_LEGACY_THEME void Theme::merge_with(const Ref &p_other) { if (p_other.is_null()) { diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 14ad4ae0fd6a..b7821ed63da6 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -218,6 +218,11 @@ class Theme : public Resource { void get_type_list(List *p_list) const; void get_type_dependencies(const StringName &p_base_type, const StringName &p_type_variant, Vector &r_result); +#ifndef USE_LEGACY_THEME + void freeze_change_propagation(); + void unfreeze_and_propagate_changes(); +#endif // !USE_LEGACY_THEME + void merge_with(const Ref &p_other); void clear(); diff --git a/scene/theme/SCsub b/scene/theme/SCsub index 2372d1820a50..8ac65a998581 100644 --- a/scene/theme/SCsub +++ b/scene/theme/SCsub @@ -4,7 +4,17 @@ Import("env") import default_theme_builders -env.add_source_files(env.scene_sources, "*.cpp") +sources = [ + "theme_db.cpp", + "theme_owner.cpp" +] + +if env["legacy_theme"]: + sources += ["default_theme.cpp"] +else: + sources += ["blazium_default_theme.cpp"] + +env.add_source_files(env.scene_sources, sources) SConscript("icons/SCsub") diff --git a/scene/theme/blazium_default_theme.cpp b/scene/theme/blazium_default_theme.cpp new file mode 100644 index 000000000000..bb52c5b756c0 --- /dev/null +++ b/scene/theme/blazium_default_theme.cpp @@ -0,0 +1,1631 @@ +/**************************************************************************/ +/* blazium_default_theme.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* BLAZIUM ENGINE */ +/* https://blazium.app */ +/**************************************************************************/ +/* Copyright (c) 2024-present Blazium Engine contributors. */ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "blazium_default_theme.h" + +#include "default_font.gen.h" +#include "default_theme_icons.gen.h" +#include "scene/resources/font.h" +#include "scene/resources/gradient_texture.h" +#include "scene/resources/image_texture.h" +#include "scene/resources/style_box_flat.h" +#include "scene/resources/style_box_line.h" +#include "scene/resources/theme.h" +#include "scene/scene_string_names.h" +#include "scene/theme/theme_db.h" +#include "servers/text_server.h" + +#include "modules/modules_enabled.gen.h" // For svg. + +static Dictionary icons; + +static Ref button_normal_style; +static Ref button_pressed_style; +static Ref button_hover_style; +static Ref button_disabled_style; +static Ref button_focus_style; +static Ref button_empty_style; + +static Ref color_button_normal_style; +static Ref color_button_hover_style; +static Ref color_button_pressed_style; +static Ref color_button_disabled_style; +static Ref color_button_focus_style; + +static Ref popup_hover_style; +static Ref popup_panel_style; + +static Ref panel_style; +static Ref flat_panel_style; + +static Ref foldable_panel_style; +static Ref flat_foldable_panel_style; +static Ref foldable_title_style; +static Ref foldable_title_collapsed_style; +static Ref foldable_title_hover_style; +static Ref foldable_title_collapsed_hover_style; + +static Ref tab_selected_style; +static Ref flat_tab_selected_style; +static Ref tab_unselected_style; +static Ref tab_hover_style; +static Ref tab_focus_style; +static Ref tab_empty_style; +static Ref tab_panel_style; +static Ref flat_tab_panel_style; + +static Ref slider_style; +static Ref grabber_style; +static Ref grabber_highlight_style; + +static Ref embedded_style; +static Ref embedded_unfocused_style; + +static Ref progress_background_style; +static Ref progress_fill_style; + +static Ref graph_title_style; +static Ref graph_frame_title_style; +static Ref graph_frame_title_selected_style; +static Ref graph_title_selected_style; +static Ref graph_panel_style; +static Ref graph_panel_selected_style; + +static Ref h_split_bar_background; +static Ref v_split_bar_background; + +static Ref code_edit_completion_style; + +static Ref h_scroll_style; +static Ref v_scroll_style; + +static Ref h_separator_style; +static Ref v_separator_style; + +static Ref fallback_font; +static Ref custom_font; +static Ref bold_font; +static Ref bold_italics_font; +static Ref italics_font; + +static bool using_custom_font_variation = false; +static bool is_dark_theme = false; + +static Ref generate_icon(int p_index, float p_scale, Color p_font_color, Color p_accent_color) { + Ref img = memnew(Image); + +#ifdef MODULE_SVG_ENABLED + String svg = default_theme_icons_sources[p_index]; + svg = svg.replace("\"red\"", vformat("\"#%s\"", p_font_color.to_html(false))); + svg = svg.replace("\"#0f0\"", vformat("\"#%s\"", p_accent_color.to_html(false))); + + Error err = img->load_svg_from_string(svg, p_scale); + if (err == OK) { + img->fix_alpha_edges(); + } + ERR_FAIL_COND_V_MSG(err != OK, Ref(), "Failed generating icon, unsupported or invalid SVG data in default theme."); +#else + // If the SVG module is disabled, we can't really display the UI well, but at least we won't crash. + // 16 pixels is used as it's the most common base size for Godot icons. + img = Image::create_empty(Math::round(16 * p_scale), Math::round(16 * p_scale), false, Image::FORMAT_RGBA8); +#endif + + return img; +} + +void update_theme_icons(Ref &p_theme, Color p_font_color, Color p_accent_color) { + if (icons.is_empty()) { + Ref empty_icon = memnew(ImageTexture); + p_theme->set_icon("increment", "HScrollBar", empty_icon); + p_theme->set_icon("increment_highlight", "HScrollBar", empty_icon); + p_theme->set_icon("increment_pressed", "HScrollBar", empty_icon); + p_theme->set_icon("decrement", "HScrollBar", empty_icon); + p_theme->set_icon("decrement_highlight", "HScrollBar", empty_icon); + p_theme->set_icon("decrement_pressed", "HScrollBar", empty_icon); + p_theme->set_icon("increment", "VScrollBar", empty_icon); + p_theme->set_icon("increment_highlight", "VScrollBar", empty_icon); + p_theme->set_icon("increment_pressed", "VScrollBar", empty_icon); + p_theme->set_icon("decrement", "VScrollBar", empty_icon); + p_theme->set_icon("decrement_highlight", "VScrollBar", empty_icon); + p_theme->set_icon("decrement_pressed", "VScrollBar", empty_icon); + p_theme->set_icon("updown", "SpinBox", empty_icon); + { + const int precision = 7; + + Ref hue_gradient; + hue_gradient.instantiate(); + PackedFloat32Array offsets; + offsets.resize(precision); + PackedColorArray colors; + colors.resize(precision); + + for (int i = 0; i < precision; i++) { + float h = i / float(precision - 1); + offsets.write[i] = h; + colors.write[i] = Color::from_hsv(h, 1, 1); + } + hue_gradient->set_offsets(offsets); + hue_gradient->set_colors(colors); + + Ref hue_texture; + hue_texture.instantiate(); + hue_texture->set_width(512); + hue_texture->set_height(1); + hue_texture->set_gradient(hue_gradient); + p_theme->set_icon("color_hue", "ColorPicker", hue_texture); + } + + { + const int precision = 7; + + Ref hue_gradient; + hue_gradient.instantiate(); + PackedFloat32Array offsets; + offsets.resize(precision); + PackedColorArray colors; + colors.resize(precision); + + for (int i = 0; i < precision; i++) { + float h = i / float(precision - 1); + offsets.write[i] = h; + colors.write[i] = Color::from_ok_hsl(h, 1, 0.5); + } + hue_gradient->set_offsets(offsets); + hue_gradient->set_colors(colors); + + Ref hue_texture; + hue_texture.instantiate(); + hue_texture->set_width(512); + hue_texture->set_height(1); + hue_texture->set_gradient(hue_gradient); + + p_theme->set_icon("color_okhsl_hue", "ColorPicker", hue_texture); + } + } + + const float scale = p_theme->get_default_base_scale(); + const Color font_color = p_font_color.clamp(); + const Color accent_color = p_accent_color.clamp(); + + for (int i = 0; i < default_theme_icons_count; i++) { + Ref img = generate_icon(i, scale, font_color, accent_color); + if (icons.has(default_theme_icons_names[i]) && ((Ref)icons[default_theme_icons_names[i]])->get_size() == (Vector2)img->get_size()) { + ((Ref)icons[default_theme_icons_names[i]])->update(img); + } else { + icons[default_theme_icons_names[i]] = ImageTexture::create_from_image(img); + } + } + + p_theme->set_icon("checked", "CheckBox", icons["checked"]); + p_theme->set_icon("checked_disabled", "CheckBox", icons["checked_disabled"]); + p_theme->set_icon("unchecked", "CheckBox", icons["unchecked"]); + p_theme->set_icon("unchecked_disabled", "CheckBox", icons["unchecked_disabled"]); + p_theme->set_icon("radio_checked", "CheckBox", icons["radio_checked"]); + p_theme->set_icon("radio_checked_disabled", "CheckBox", icons["radio_checked_disabled"]); + p_theme->set_icon("radio_unchecked", "CheckBox", icons["radio_unchecked"]); + p_theme->set_icon("radio_unchecked_disabled", "CheckBox", icons["radio_unchecked_disabled"]); + + p_theme->set_icon("checked", "CheckButton", icons["toggle_on"]); + p_theme->set_icon("checked_disabled", "CheckButton", icons["toggle_on_disabled"]); + p_theme->set_icon("unchecked", "CheckButton", icons["toggle_off"]); + p_theme->set_icon("unchecked_disabled", "CheckButton", icons["toggle_off_disabled"]); + p_theme->set_icon("checked_mirrored", "CheckButton", icons["toggle_on_mirrored"]); + p_theme->set_icon("checked_disabled_mirrored", "CheckButton", icons["toggle_on_disabled_mirrored"]); + p_theme->set_icon("unchecked_mirrored", "CheckButton", icons["toggle_off_mirrored"]); + p_theme->set_icon("unchecked_disabled_mirrored", "CheckButton", icons["toggle_off_disabled_mirrored"]); + + p_theme->set_icon("up", "SpinBox", icons["value_up"]); + p_theme->set_icon("up_hover", "SpinBox", icons["value_up"]); + p_theme->set_icon("up_pressed", "SpinBox", icons["value_up"]); + p_theme->set_icon("up_disabled", "SpinBox", icons["value_up"]); + p_theme->set_icon("down", "SpinBox", icons["value_down"]); + p_theme->set_icon("down_hover", "SpinBox", icons["value_down"]); + p_theme->set_icon("down_pressed", "SpinBox", icons["value_down"]); + p_theme->set_icon("down_disabled", "SpinBox", icons["value_down"]); + + p_theme->set_icon("arrow", "OptionButton", icons["option_button_arrow"]); + + p_theme->set_icon("clear", "LineEdit", icons["line_edit_clear"]); + + p_theme->set_icon("tab", "TextEdit", icons["text_edit_tab"]); + p_theme->set_icon("space", "TextEdit", icons["text_edit_space"]); + + p_theme->set_icon("tab", "CodeEdit", icons["text_edit_tab"]); + p_theme->set_icon("space", "CodeEdit", icons["text_edit_space"]); + p_theme->set_icon("breakpoint", "CodeEdit", icons["breakpoint"]); + p_theme->set_icon("bookmark", "CodeEdit", icons["bookmark"]); + p_theme->set_icon("executing_line", "CodeEdit", icons["arrow_right"]); + p_theme->set_icon("can_fold", "CodeEdit", icons["arrow_down"]); + p_theme->set_icon("folded", "CodeEdit", icons["arrow_right"]); + p_theme->set_icon("can_fold_code_region", "CodeEdit", icons["region_unfolded"]); + p_theme->set_icon("folded_code_region", "CodeEdit", icons["region_folded"]); + p_theme->set_icon("folded_eol_icon", "CodeEdit", icons["text_edit_ellipsis"]); + p_theme->set_icon("completion_color_bg", "CodeEdit", icons["mini_checkerboard"]); + + p_theme->set_icon("grabber", "HSlider", icons["slider_grabber"]); + p_theme->set_icon("grabber_highlight", "HSlider", icons["slider_grabber_hl"]); + p_theme->set_icon("grabber_disabled", "HSlider", icons["slider_grabber_disabled"]); + p_theme->set_icon("tick", "HSlider", icons["hslider_tick"]); + + p_theme->set_icon("grabber", "VSlider", icons["slider_grabber"]); + p_theme->set_icon("grabber_highlight", "VSlider", icons["slider_grabber_hl"]); + p_theme->set_icon("grabber_disabled", "VSlider", icons["slider_grabber_disabled"]); + p_theme->set_icon("tick", "VSlider", icons["vslider_tick"]); + + p_theme->set_icon("checked", "Tree", icons["checked"]); + p_theme->set_icon("checked_disabled", "Tree", icons["checked_disabled"]); + p_theme->set_icon("unchecked", "Tree", icons["unchecked"]); + p_theme->set_icon("unchecked_disabled", "Tree", icons["unchecked_disabled"]); + p_theme->set_icon("indeterminate", "Tree", icons["indeterminate"]); + p_theme->set_icon("indeterminate_disabled", "Tree", icons["indeterminate_disabled"]); + p_theme->set_icon("updown", "Tree", icons["updown"]); + p_theme->set_icon("select_arrow", "Tree", icons["option_button_arrow"]); + p_theme->set_icon("arrow", "Tree", icons["arrow_down"]); + p_theme->set_icon("arrow_collapsed", "Tree", icons["arrow_right"]); + p_theme->set_icon("arrow_collapsed_mirrored", "Tree", icons["arrow_left"]); + + p_theme->set_icon("h_grabber", "SplitContainer", icons["hsplitter"]); + p_theme->set_icon("v_grabber", "SplitContainer", icons["vsplitter"]); + p_theme->set_icon("grabber", "VSplitContainer", icons["vsplitter"]); + p_theme->set_icon("grabber", "HSplitContainer", icons["hsplitter"]); + + p_theme->set_icon("increment", "TabContainer", icons["scroll_button_right"]); + p_theme->set_icon("increment_highlight", "TabContainer", icons["scroll_button_right_hl"]); + p_theme->set_icon("decrement", "TabContainer", icons["scroll_button_left"]); + p_theme->set_icon("decrement_highlight", "TabContainer", icons["scroll_button_left_hl"]); + p_theme->set_icon("menu", "TabContainer", icons["tabs_menu"]); + p_theme->set_icon("menu_highlight", "TabContainer", icons["tabs_menu_hl"]); + p_theme->set_icon("drop_mark", "TabContainer", icons["tabs_drop_mark"]); + + p_theme->set_icon("increment", "TabBar", icons["scroll_button_right"]); + p_theme->set_icon("increment_highlight", "TabBar", icons["scroll_button_right_hl"]); + p_theme->set_icon("decrement", "TabBar", icons["scroll_button_left"]); + p_theme->set_icon("decrement_highlight", "TabBar", icons["scroll_button_left_hl"]); + p_theme->set_icon("close", "TabBar", icons["close"]); + p_theme->set_icon("drop_mark", "TabBar", icons["tabs_drop_mark"]); + + p_theme->set_icon("folded_arrow", "ColorPicker", icons["arrow_right"]); + p_theme->set_icon("folded_arrow_mirrored", "ColorPicker", icons["arrow_left"]); + p_theme->set_icon("expanded_arrow", "ColorPicker", icons["arrow_down"]); + p_theme->set_icon("screen_picker", "ColorPicker", icons["color_picker_pipette"]); + p_theme->set_icon("shape_circle", "ColorPicker", icons["picker_shape_circle"]); + p_theme->set_icon("shape_rect", "ColorPicker", icons["picker_shape_rectangle"]); + p_theme->set_icon("shape_rect_wheel", "ColorPicker", icons["picker_shape_rectangle_wheel"]); + p_theme->set_icon("add_preset", "ColorPicker", icons["add"]); + p_theme->set_icon("sample_bg", "ColorPicker", icons["mini_checkerboard"]); + p_theme->set_icon("sample_revert", "ColorPicker", icons["reload"]); + p_theme->set_icon("overbright_indicator", "ColorPicker", icons["color_picker_overbright"]); + p_theme->set_icon("bar_arrow", "ColorPicker", icons["color_picker_bar_arrow"]); + p_theme->set_icon("picker_cursor", "ColorPicker", icons["color_picker_cursor"]); + p_theme->set_icon("picker_cursor_bg", "ColorPicker", icons["color_picker_cursor_bg"]); + p_theme->set_icon("hex_icon", "ColorPicker", icons["color_picker_hex"]); + p_theme->set_icon("hex_code_icon", "ColorPicker", icons["color_picker_hex_code"]); + + p_theme->set_icon("bg", "ColorButton", icons["mini_checkerboard"]); + p_theme->set_icon("overbright_indicator", "ColorButton", icons["color_picker_overbright"]); + + p_theme->set_icon("expanded_arrow", "FoldableContainer", icons["expanded_arrow"]); + p_theme->set_icon("expanded_arrow_mirrored", "FoldableContainer", icons["expanded_arrow_mirrored"]); + p_theme->set_icon("folded_arrow", "FoldableContainer", icons["folded_arrow"]); + p_theme->set_icon("folded_arrow_mirrored", "FoldableContainer", icons["folded_arrow_mirrored"]); + + p_theme->set_icon("port", "GraphNode", icons["graph_port"]); + p_theme->set_icon("resizer", "GraphNode", icons["resizer_se"]); + p_theme->set_icon("resizer", "GraphFrame", icons["resizer_se"]); + p_theme->set_icon("zoom_out", "GraphEdit", icons["zoom_less"]); + p_theme->set_icon("zoom_in", "GraphEdit", icons["zoom_more"]); + p_theme->set_icon("zoom_reset", "GraphEdit", icons["zoom_reset"]); + p_theme->set_icon("grid_toggle", "GraphEdit", icons["grid_toggle"]); + p_theme->set_icon("minimap_toggle", "GraphEdit", icons["grid_minimap"]); + p_theme->set_icon("snapping_toggle", "GraphEdit", icons["grid_snap"]); + p_theme->set_icon("layout", "GraphEdit", icons["grid_layout"]); + p_theme->set_icon("resizer", "GraphEditMinimap", icons["resizer_nw"]); + + p_theme->set_icon("parent_folder", "FileDialog", icons["folder_up"]); + p_theme->set_icon("back_folder", "FileDialog", icons["arrow_left"]); + p_theme->set_icon("forward_folder", "FileDialog", icons["arrow_right"]); + p_theme->set_icon("reload", "FileDialog", icons["reload"]); + p_theme->set_icon("toggle_hidden", "FileDialog", icons["visibility_visible"]); + p_theme->set_icon("folder", "FileDialog", icons["folder"]); + p_theme->set_icon("file", "FileDialog", icons["file"]); + p_theme->set_icon("create_folder", "FileDialog", icons["folder_create"]); + + p_theme->set_icon("checked", "PopupMenu", icons["checked"]); + p_theme->set_icon("checked_disabled", "PopupMenu", icons["checked_disabled"]); + p_theme->set_icon("unchecked", "PopupMenu", icons["unchecked"]); + p_theme->set_icon("unchecked_disabled", "PopupMenu", icons["unchecked_disabled"]); + p_theme->set_icon("radio_checked", "PopupMenu", icons["radio_checked"]); + p_theme->set_icon("radio_checked_disabled", "PopupMenu", icons["radio_checked_disabled"]); + p_theme->set_icon("radio_unchecked", "PopupMenu", icons["radio_unchecked"]); + p_theme->set_icon("radio_unchecked_disabled", "PopupMenu", icons["radio_unchecked_disabled"]); + p_theme->set_icon("submenu", "PopupMenu", icons["popup_menu_arrow_right"]); + p_theme->set_icon("submenu_mirrored", "PopupMenu", icons["popup_menu_arrow_left"]); + + p_theme->set_icon("close", "Window", icons["close"]); + p_theme->set_icon("close_pressed", "Window", icons["close_hl"]); + + p_theme->set_icon("zoom_less", "ZoomWidget", icons["zoom_less"]); + p_theme->set_icon("zoom_more", "ZoomWidget", icons["zoom_more"]); + + p_theme->set_icon("close", "Icons", icons["close"]); + p_theme->set_icon("error_icon", "Icons", icons["error_icon"]); + + ThemeDB::get_singleton()->set_fallback_icon(icons["error_icon"]); +} + +Color contrast_color(Color p_color, float p_contrast) { + if (Math::is_zero_approx(p_contrast)) { + return p_color; + } + + Color contrast_color = is_dark_theme ? Color(1, 1, 1) : Color(0, 0, 0); + if (p_contrast < 0.f) { + contrast_color.invert(); + p_contrast *= -1; + } + + return p_color.lerp(contrast_color, p_contrast).clamp(); +} + +// `Panel` and `PanelContainer` uses the `base_color` by default, another variation `FlatPanel` and `FlatPanelContainer` uses `bg_color`. +// `TabContainer` and `FoldableContainer` panels uses the `bg_color` by default, another variation `FlatTabContainer` and `FlatFoldableContainer` uses `base_color`. +// Other panels that doesn't allow having children like `Tree` and `ItemList` uses `style_normal_color` by default. +void update_theme_colors(Ref &p_theme, Color p_base_color, Color p_accent_color, float p_contrast, float p_normal_contrast, float p_hover_contrast, float p_pressed_contrast, float p_bg_contrast) { + const Color base_color = p_base_color.clamp(); + const Color accent_color = p_accent_color.clamp(); + + const Color contrasted_color = contrast_color(base_color, p_contrast); + const Color bg_color = base_color.lerp(contrasted_color, p_bg_contrast).clamp(); + const Color style_normal_color = base_color.lerp(contrasted_color, p_normal_contrast).clamp(); + const Color style_pressed_color = base_color.lerp(contrasted_color, p_pressed_contrast).clamp(); + const Color style_hover_color = base_color.lerp(contrasted_color, p_hover_contrast).clamp(); + const Color style_disabled_color = Color(style_normal_color.r, style_normal_color.g, style_normal_color.b, 0.4); + const Color bg_color2 = Color(bg_color.r, bg_color.g, bg_color.b, 0.6); + const Color accent_color2 = Color(accent_color.r, accent_color.g, accent_color.b, 0.6); + + panel_style->set_bg_color(base_color); + graph_panel_style->set_bg_color(base_color); + popup_panel_style->set_bg_color(base_color); + flat_tab_panel_style->set_bg_color(base_color); + flat_tab_selected_style->set_bg_color(base_color); + flat_foldable_panel_style->set_bg_color(base_color); + + foldable_panel_style->set_bg_color(bg_color); + tab_selected_style->set_bg_color(bg_color); + tab_panel_style->set_bg_color(bg_color); + flat_panel_style->set_bg_color(bg_color); + p_theme->set_color("current_line_color", "TextEdit", bg_color); + p_theme->set_color("current_line_color", "CodeEdit", bg_color); + + h_scroll_style->set_bg_color(bg_color2); + v_scroll_style->set_bg_color(bg_color2); + slider_style->set_bg_color(bg_color2); + + button_focus_style->set_bg_color(accent_color); + color_button_focus_style->set_bg_color(accent_color); + h_split_bar_background->set_bg_color(accent_color); + v_split_bar_background->set_bg_color(accent_color); + tab_focus_style->set_border_color(accent_color); + graph_panel_selected_style->set_border_color(accent_color); + graph_frame_title_selected_style->set_border_color(accent_color); + graph_title_selected_style->set_border_color(accent_color); + button_focus_style->set_border_color(accent_color); + color_button_focus_style->set_border_color(accent_color); + tab_selected_style->set_border_color(accent_color); + flat_tab_selected_style->set_border_color(accent_color); + p_theme->set_color("icon_pressed_color", "Button", accent_color); + p_theme->set_color("icon_hover_pressed_color", "Button", accent_color); + p_theme->set_color("font_pressed_color", "Button", accent_color); + p_theme->set_color("font_hover_pressed_color", "Button", accent_color); + p_theme->set_color("drop_mark_color", "TabContainer", accent_color); + p_theme->set_color("drop_mark_color", "TabBar", accent_color); + p_theme->set_color("font_pressed_color", "LinkButton", accent_color); + p_theme->set_color("font_hover_pressed_color", "LinkButton", accent_color); + p_theme->set_color("grabber_icon_pressed", "SplitContainer", accent_color); + p_theme->set_color("grabber_icon_pressed", "HSplitContainer", accent_color); + p_theme->set_color("grabber_icon_pressed", "VSplitContainer", accent_color); + p_theme->set_color("clear_button_color_pressed", "LineEdit", accent_color); + p_theme->set_color("font_pressed_color", "MenuBar", accent_color); + p_theme->set_color("font_pressed_color", "OptionButton", accent_color); + p_theme->set_color("font_pressed_color", "MenuButton", accent_color); + p_theme->set_color("font_pressed_color", "CheckBox", accent_color); + p_theme->set_color("font_hover_pressed_color", "CheckBox", accent_color); + p_theme->set_color("font_pressed_color", "CheckButton", accent_color); + p_theme->set_color("font_hover_pressed_color", "CheckButton", accent_color); + p_theme->set_color("down_pressed_icon_modulate", "SpinBox", accent_color); + p_theme->set_color("up_pressed_icon_modulate", "SpinBox", accent_color); + p_theme->set_color("selection_stroke", "GraphEdit", accent_color); + p_theme->set_color("button_icon_pressed", "FoldableContainer", accent_color); + + p_theme->set_color("search_result_color", "TextEdit", accent_color2); + p_theme->set_color("search_result_color", "CodeEdit", accent_color2); + grabber_highlight_style->set_bg_color(accent_color2); + progress_fill_style->set_bg_color(accent_color2); + + embedded_unfocused_style->set_bg_color(style_normal_color); + tab_unselected_style->set_bg_color(style_normal_color); + button_normal_style->set_bg_color(style_normal_color); + color_button_normal_style->set_bg_color(style_normal_color); + foldable_title_style->set_bg_color(style_normal_color); + foldable_title_collapsed_style->set_bg_color(style_normal_color); + graph_title_style->set_bg_color(style_normal_color); + graph_frame_title_style->set_bg_color(style_normal_color); + embedded_style->set_bg_color(style_normal_color); + progress_background_style->set_bg_color(style_normal_color); + code_edit_completion_style->set_bg_color(style_normal_color); + + button_hover_style->set_bg_color(style_hover_color); + tab_hover_style->set_bg_color(style_hover_color); + color_button_hover_style->set_bg_color(style_hover_color); + foldable_title_hover_style->set_bg_color(style_hover_color); + foldable_title_collapsed_hover_style->set_bg_color(style_hover_color); + popup_hover_style->set_bg_color(style_hover_color); + p_theme->set_color("word_highlighted_color", "TextEdit", style_hover_color); + p_theme->set_color("word_highlighted_color", "CodeEdit", style_hover_color); + + color_button_pressed_style->set_bg_color(style_pressed_color); + button_pressed_style->set_bg_color(style_pressed_color); + graph_frame_title_selected_style->set_bg_color(style_pressed_color); + graph_title_selected_style->set_bg_color(style_pressed_color); + graph_panel_selected_style->set_bg_color(style_pressed_color); + p_theme->set_color("selection_color", "LineEdit", style_pressed_color); + p_theme->set_color("selection_color", "TextEdit", style_pressed_color); + p_theme->set_color("selection_color", "CodeEdit", style_pressed_color); + p_theme->set_color("selection_color", "RichTextLabel", style_pressed_color); + + button_disabled_style->set_bg_color(style_disabled_color); + color_button_disabled_style->set_bg_color(style_disabled_color); + h_separator_style->set_color(style_disabled_color); + v_separator_style->set_color(style_disabled_color); + + float v = is_dark_theme ? 1.f : 0.f; + p_theme->set_color("grid_minor", "GraphEdit", Color(v, v, v, 0.05)); + p_theme->set_color("grid_major", "GraphEdit", Color(v, v, v, 0.2)); + p_theme->set_color("activity", "GraphEdit", Color(v, v, v)); + p_theme->set_color("connection_hover_tint_color", "GraphEdit", Color(1.f - v, 1.f - v, 1.f - v, 0.3)); + p_theme->set_color("connection_valid_target_tint_color", "GraphEdit", Color(v, v, v, 0.4)); +} + +void update_font_color(Ref &p_theme, Color p_color) { + Color font_color = p_color.clamp(); + is_dark_theme = font_color.get_luminance() > 0.5; + + popup_panel_style->set_border_color(font_color); + graph_title_style->set_border_color(font_color); + graph_frame_title_style->set_border_color(font_color); + graph_panel_style->set_border_color(font_color); + color_button_pressed_style->set_border_color(font_color); + p_theme->set_color("font_hover_color", "Button", font_color); + p_theme->set_color("icon_hover_color", "Button", font_color); + p_theme->set_color("font_hovered_color", "TabContainer", font_color); + p_theme->set_color("font_hovered_color", "TabBar", font_color); + p_theme->set_color("font_hover_color", "PopupMenu", font_color); + p_theme->set_color("font_selected_color", "LineEdit", font_color); + p_theme->set_color("font_selected_color", "TextEdit", font_color); + p_theme->set_color("font_selected_color", "RichTextLabel", font_color); + p_theme->set_color("font_selected_color", "CodeEdit", font_color); + p_theme->set_color("font_selected_color", "ItemList", font_color); + p_theme->set_color("font_selected_color", "TabContainer", font_color); + p_theme->set_color("font_selected_color", "TabBar", font_color); + p_theme->set_color("font_selected_color", "Tree", font_color); + p_theme->set_color("font_hovered_color", "Tree", font_color); + p_theme->set_color("caret_background_color", "TextEdit", font_color); + p_theme->set_color("caret_background_color", "CodeEdit", font_color); + p_theme->set_color("font_color", "ProgressBar", font_color); + p_theme->set_color("font_hover_color", "LinkButton", font_color); + p_theme->set_color("font_hover_color", "MenuBar", font_color); + p_theme->set_color("font_hover_color", "LinkButton", font_color); + p_theme->set_color("font_hover_pressed_color", "MenuBar", font_color); + p_theme->set_color("font_hover_color", "OptionButton", font_color); + p_theme->set_color("font_hover_pressed_color", "OptionButton", font_color); + p_theme->set_color("font_hover_color", "MenuButton", font_color); + p_theme->set_color("font_hover_color", "CheckBox", font_color); + p_theme->set_color("font_hover_color", "CheckButton", font_color); + p_theme->set_color("drop_position_color", "Tree", font_color); + p_theme->set_color("up_hover_icon_modulate", "SpinBox", font_color); + p_theme->set_color("down_hover_icon_modulate", "SpinBox", font_color); + p_theme->set_color("font_hovered_color", "ItemList", font_color); + p_theme->set_color("connection_rim_color", "GraphEdit", font_color); + p_theme->set_color("hover_font_color", "FoldableContainer", font_color); + p_theme->set_color("button_icon_hovered", "FoldableContainer", font_color); + font_color.a = 0.9; + p_theme->set_color("icon_focus_color", "Button", font_color); + p_theme->set_color("font_focus_color", "Button", font_color); + p_theme->set_color("parent_hl_line_color", "Tree", font_color); + p_theme->set_color("font_focus_color", "LinkButton", font_color); + p_theme->set_color("font_focus_color", "MenuBar", font_color); + p_theme->set_color("title_color", "Window", font_color); + p_theme->set_color("font_focus_color", "OptionButton", font_color); + p_theme->set_color("font_focus_color", "MenuButton", font_color); + p_theme->set_color("font_focus_color", "CheckBox", font_color); + p_theme->set_color("font_focus_color", "CheckButton", font_color); + p_theme->set_color("custom_button_font_highlight", "Tree", font_color); + p_theme->set_color("resizer_color", "GraphEditMinimap", font_color); + p_theme->set_color("resizer_color", "GraphNode", font_color); + p_theme->set_color("resizer_color", "GraphFrame", font_color); + font_color.a = 0.8; + p_theme->set_color(SceneStringName(font_color), "Button", font_color); + p_theme->set_color(SceneStringName(font_color), "Tree", font_color); + p_theme->set_color(SceneStringName(font_color), "LinkButton", font_color); + p_theme->set_color(SceneStringName(font_color), "Label", font_color); + p_theme->set_color(SceneStringName(font_color), "LineEdit", font_color); + p_theme->set_color(SceneStringName(font_color), "TextEdit", font_color); + p_theme->set_color(SceneStringName(font_color), "CodeEdit", font_color); + p_theme->set_color(SceneStringName(font_color), "PopupMenu", font_color); + p_theme->set_color(SceneStringName(font_color), "FoldableContainer", font_color); + p_theme->set_color(SceneStringName(font_color), "MenuBar", font_color); + p_theme->set_color(SceneStringName(font_color), "OptionButton", font_color); + p_theme->set_color(SceneStringName(font_color), "MenuButton", font_color); + p_theme->set_color(SceneStringName(font_color), "CheckBox", font_color); + p_theme->set_color(SceneStringName(font_color), "CheckButton", font_color); + p_theme->set_color(SceneStringName(font_color), "GraphNodeTitleLabel", font_color); + p_theme->set_color(SceneStringName(font_color), "TooltipLabel", font_color); + p_theme->set_color(SceneStringName(font_color), "GraphFrameTitleLabel", font_color); + p_theme->set_color(SceneStringName(font_color), "ItemList", font_color); + p_theme->set_color("icon_normal_color", "Button", font_color); + p_theme->set_color("caret_color", "LineEdit", font_color); + p_theme->set_color("caret_color", "TextEdit", font_color); + p_theme->set_color("caret_color", "CodeEdit", font_color); + p_theme->set_color("clear_button_color", "LineEdit", font_color); + p_theme->set_color("font_unselected_color", "TabContainer", font_color); + p_theme->set_color("font_unselected_color", "TabBar", font_color); + p_theme->set_color("folder_icon_color", "FileDialog", font_color); + p_theme->set_color("file_icon_color", "FileDialog", font_color); + p_theme->set_color("title_button_color", "Tree", font_color); + p_theme->set_color("children_hl_line_color", "Tree", font_color); + p_theme->set_color("default_color", "RichTextLabel", font_color); + p_theme->set_color("up_icon_modulate", "SpinBox", font_color); + p_theme->set_color("down_icon_modulate", "SpinBox", font_color); + p_theme->set_color("collapsed_font_color", "FoldableContainer", font_color); + p_theme->set_color("button_icon_normal", "FoldableContainer", font_color); + font_color.a = 0.6; + grabber_style->set_bg_color(font_color); + p_theme->set_color("font_separator_color", "PopupMenu", font_color); + p_theme->set_color("font_accelerator_color", "PopupMenu", font_color); + p_theme->set_color("font_disabled_color", "PopupMenu", font_color); + p_theme->set_color("grabber_icon_normal", "SplitContainer", font_color); + p_theme->set_color("grabber_icon_normal", "HSplitContainer", font_color); + p_theme->set_color("grabber_icon_normal", "VSplitContainer", font_color); + p_theme->set_color("font_uneditable_color", "LineEdit", font_color); + p_theme->set_color("font_readonly_color", "TextEdit", font_color); + p_theme->set_color("font_readonly_color", "CodeEdit", font_color); + p_theme->set_color("font_placeholder_color", "LineEdit", font_color); + p_theme->set_color("font_placeholder_color", "TextEdit", font_color); + p_theme->set_color("font_placeholder_color", "CodeEdit", font_color); + p_theme->set_color("relationship_line_color", "Tree", font_color); + p_theme->set_color("font_hovered_dimmed_color", "Tree", font_color); + font_color.a = 0.4; + p_theme->set_color("icon_disabled_color", "Button", font_color); + p_theme->set_color("font_disabled_color", "Button", font_color); + p_theme->set_color("search_result_border_color", "TextEdit", font_color); + p_theme->set_color("search_result_border_color", "CodeEdit", font_color); + p_theme->set_color("guide_color", "Tree", font_color); + p_theme->set_color("guide_color", "ItemList", font_color); + p_theme->set_color("file_disabled_color", "FileDialog", font_color); + p_theme->set_color("font_disabled_color", "TabContainer", font_color); + p_theme->set_color("font_disabled_color", "TabBar", font_color); + p_theme->set_color("font_disabled_color", "Tree", font_color); + p_theme->set_color("icon_disabled_color", "LinkButton", font_color); + p_theme->set_color("font_disabled_color", "MenuBar", font_color); + p_theme->set_color("font_disabled_color", "LinkButton", font_color); + p_theme->set_color("font_disabled_color", "OptionButton", font_color); + p_theme->set_color("font_disabled_color", "MenuButton", font_color); + p_theme->set_color("font_disabled_color", "CheckBox", font_color); + p_theme->set_color("font_disabled_color", "CheckButton", font_color); + p_theme->set_color("up_disabled_icon_modulate", "SpinBox", font_color); + p_theme->set_color("down_disabled_icon_modulate", "SpinBox", font_color); + p_theme->set_color("selection_fill", "GraphEdit", font_color); + p_theme->set_color("completion_scroll_hovered_color", "CodeEdit", font_color); + p_theme->set_color("completion_scroll_color", "CodeEdit", font_color); + p_theme->set_color("button_icon_disabled", "FoldableContainer", font_color); +} + +void update_font_outline_color(Ref &p_theme, Color p_color) { + Color outline_color = p_color.clamp(); + p_theme->set_color("font_outline_color", "Button", outline_color); + p_theme->set_color("font_outline_color", "RichTextLabel", outline_color); + p_theme->set_color("font_outline_color", "FoldableContainer", outline_color); + p_theme->set_color("font_outline_color", "TooltipLabel", outline_color); + p_theme->set_color("font_outline_color", "TabBar", outline_color); + p_theme->set_color("font_outline_color", "TabContainer", outline_color); + p_theme->set_color("font_outline_color", "ItemList", outline_color); + p_theme->set_color("font_outline_color", "Tree", outline_color); + p_theme->set_color("font_outline_color", "GraphFrameTitleLabel", outline_color); + p_theme->set_color("font_outline_color", "GraphNodeTitleLabel", outline_color); + p_theme->set_color("font_outline_color", "PopupMenu", outline_color); + p_theme->set_color("font_outline_color", "CodeEdit", outline_color); + p_theme->set_color("font_outline_color", "TextEdit", outline_color); + p_theme->set_color("font_outline_color", "ProgressBar", outline_color); + p_theme->set_color("font_outline_color", "LineEdit", outline_color); + p_theme->set_color("font_outline_color", "Label", outline_color); + p_theme->set_color("font_outline_color", "CheckButton", outline_color); + p_theme->set_color("font_outline_color", "CheckBox", outline_color); + p_theme->set_color("font_outline_color", "MenuButton", outline_color); + p_theme->set_color("font_outline_color", "OptionButton", outline_color); + p_theme->set_color("font_outline_color", "LinkButton", outline_color); + p_theme->set_color("font_outline_color", "MenuBar", outline_color); + p_theme->set_color("font_separator_outline_color", "PopupMenu", outline_color); + p_theme->set_color("title_outline_modulate", "Window", outline_color); +} + +void update_font_outline_size(Ref &p_theme, int p_outline_size) { + int outline_size = p_outline_size * MAX(p_theme->get_default_base_scale(), 0.5); + + p_theme->set_constant("outline_size", "Button", outline_size); + p_theme->set_constant("separator_outline_size", "PopupMenu", outline_size); + p_theme->set_constant("outline_size", "RichTextLabel", outline_size); + p_theme->set_constant("outline_size", "FoldableContainer", outline_size); + p_theme->set_constant("outline_size", "TooltipLabel", outline_size); + p_theme->set_constant("outline_size", "TabBar", outline_size); + p_theme->set_constant("outline_size", "TabContainer", outline_size); + p_theme->set_constant("outline_size", "ItemList", outline_size); + p_theme->set_constant("outline_size", "Tree", outline_size); + p_theme->set_constant("outline_size", "GraphFrameTitleLabel", outline_size); + p_theme->set_constant("outline_size", "GraphNodeTitleLabel", outline_size); + p_theme->set_constant("outline_size", "PopupMenu", outline_size); + p_theme->set_constant("title_outline_size", "Window", outline_size); + p_theme->set_constant("outline_size", "CodeEdit", outline_size); + p_theme->set_constant("outline_size", "TextEdit", outline_size); + p_theme->set_constant("outline_size", "ProgressBar", outline_size); + p_theme->set_constant("outline_size", "LineEdit", outline_size); + p_theme->set_constant("outline_size", "Label", outline_size); + p_theme->set_constant("outline_size", "CheckButton", outline_size); + p_theme->set_constant("outline_size", "CheckBox", outline_size); + p_theme->set_constant("outline_size", "MenuButton", outline_size); + p_theme->set_constant("outline_size", "OptionButton", outline_size); + p_theme->set_constant("outline_size", "LinkButton", outline_size); + p_theme->set_constant("outline_size", "MenuBar", outline_size); +} + +void update_font_size(Ref &p_theme, int p_font_size) { + p_theme->set_default_font_size(p_font_size); + + p_theme->set_font_size(SceneStringName(font_size), "HeaderSmall", p_font_size + 4); + p_theme->set_font_size(SceneStringName(font_size), "HeaderMedium", p_font_size + 8); + p_theme->set_font_size(SceneStringName(font_size), "GraphFrameTitleLabel", p_font_size + 8); + p_theme->set_font_size(SceneStringName(font_size), "HeaderLarge", p_font_size + 12); +} + +void update_font_embolden(float p_embolden) { + if (custom_font.is_valid() && !using_custom_font_variation) { + custom_font->set_variation_embolden(p_embolden); + } + fallback_font->set_variation_embolden(p_embolden); + bold_font->set_variation_embolden(p_embolden + 0.2); + bold_italics_font->set_variation_embolden(p_embolden + 0.2); + italics_font->set_variation_embolden(p_embolden); +} + +void update_font_spacing_glyph(int p_spacing) { + if (custom_font.is_valid() && !using_custom_font_variation) { + custom_font->set_spacing(TextServer::SPACING_GLYPH, p_spacing); + } + fallback_font->set_spacing(TextServer::SPACING_GLYPH, p_spacing); + bold_font->set_spacing(TextServer::SPACING_GLYPH, p_spacing); + bold_italics_font->set_spacing(TextServer::SPACING_GLYPH, p_spacing); + italics_font->set_spacing(TextServer::SPACING_GLYPH, p_spacing); +} + +void update_font_spacing_space(int p_spacing) { + if (custom_font.is_valid() && !using_custom_font_variation) { + custom_font->set_spacing(TextServer::SPACING_SPACE, p_spacing); + } + fallback_font->set_spacing(TextServer::SPACING_SPACE, p_spacing); + bold_font->set_spacing(TextServer::SPACING_SPACE, p_spacing); + bold_italics_font->set_spacing(TextServer::SPACING_SPACE, p_spacing); + italics_font->set_spacing(TextServer::SPACING_SPACE, p_spacing); +} + +void update_font_spacing_top(int p_spacing) { + if (custom_font.is_valid() && !using_custom_font_variation) { + custom_font->set_spacing(TextServer::SPACING_TOP, p_spacing); + } + fallback_font->set_spacing(TextServer::SPACING_TOP, p_spacing); + bold_italics_font->set_spacing(TextServer::SPACING_TOP, p_spacing); + bold_font->set_spacing(TextServer::SPACING_TOP, p_spacing); + italics_font->set_spacing(TextServer::SPACING_TOP, p_spacing); +} + +void update_font_spacing_bottom(int p_spacing) { + if (custom_font.is_valid() && !using_custom_font_variation) { + custom_font->set_spacing(TextServer::SPACING_BOTTOM, p_spacing); + } + fallback_font->set_spacing(TextServer::SPACING_BOTTOM, p_spacing); + bold_font->set_spacing(TextServer::SPACING_BOTTOM, p_spacing); + bold_italics_font->set_spacing(TextServer::SPACING_BOTTOM, p_spacing); + italics_font->set_spacing(TextServer::SPACING_BOTTOM, p_spacing); +} + +void update_theme_font(Ref &p_theme, Ref p_font) { + if (p_font.is_valid()) { + if (p_font->is_class("FontVariation")) { + custom_font = p_font; + using_custom_font_variation = true; + + Ref base_font = custom_font->get_base_font(); + bold_font->set_base_font(base_font); + bold_italics_font->set_base_font(base_font); + italics_font->set_base_font(base_font); + } else { + custom_font = ThemeDB::get_singleton()->get_fallback_font()->duplicate(); + custom_font->set_base_font(p_font); + using_custom_font_variation = false; + + bold_font->set_base_font(p_font); + bold_italics_font->set_base_font(p_font); + italics_font->set_base_font(p_font); + } + p_theme->set_default_font(custom_font); + + } else { + if (custom_font.is_valid()) { + custom_font = Ref(); + using_custom_font_variation = false; + + Ref base_font = fallback_font->get_base_font(); + bold_font->set_base_font(base_font); + bold_italics_font->set_base_font(base_font); + italics_font->set_base_font(base_font); + } + p_theme->set_default_font(Ref()); + } +} + +void update_font_subpixel_positioning(TextServer::SubpixelPositioning p_font_subpixel_positioning) { + Ref base_font = fallback_font->get_base_font(); + base_font->set_subpixel_positioning(p_font_subpixel_positioning); +} + +void update_font_antialiasing(TextServer::FontAntialiasing p_font_antialiasing) { + Ref base_font = fallback_font->get_base_font(); + base_font->set_antialiasing(p_font_antialiasing); +} + +void update_font_lcd_subpixel_layout(TextServer::FontLCDSubpixelLayout p_font_lcd_subpixel_layout) { + Ref base_font = fallback_font->get_base_font(); + base_font->set_lcd_subpixel_layout(p_font_lcd_subpixel_layout); +} + +void update_font_hinting(TextServer::Hinting p_font_hinting) { + Ref base_font = fallback_font->get_base_font(); + base_font->set_hinting(p_font_hinting); +} + +void update_font_msdf(bool p_font_msdf) { + Ref base_font = fallback_font->get_base_font(); + base_font->set_multichannel_signed_distance_field(p_font_msdf); +} + +void update_font_generate_mipmaps(bool p_font_generate_mipmaps) { + Ref base_font = fallback_font->get_base_font(); + base_font->set_generate_mipmaps(p_font_generate_mipmaps); +} + +void update_theme_margins(Ref &p_theme, int p_margin) { + int margin = p_margin * MAX(p_theme->get_default_base_scale(), 0.5); + + p_theme->set_constant("h_separation", "Button", margin); + p_theme->set_constant("separation", "BoxContainer", margin); + p_theme->set_constant("separation", "HBoxContainer", margin); + p_theme->set_constant("separation", "VBoxContainer", margin); + p_theme->set_constant("h_separation", "FoldableContainer", margin); + p_theme->set_constant("h_separation", "Tree", margin); + p_theme->set_constant("h_separation", "ScrollContainer", margin); + p_theme->set_constant("h_separation", "TabBar", margin); + p_theme->set_constant("h_separation", "OptionButton", margin); + p_theme->set_constant("h_separation", "MenuButton", margin); + p_theme->set_constant("h_separation", "CheckBox", margin); + p_theme->set_constant("h_separation", "CheckButton", margin); + p_theme->set_constant("h_separation", "FlowContainer", margin); + p_theme->set_constant("v_separation", "FlowContainer", margin); + p_theme->set_constant("h_separation", "HFlowContainer", margin); + p_theme->set_constant("v_separation", "HFlowContainer", margin); + p_theme->set_constant("h_separation", "VFlowContainer", margin); + p_theme->set_constant("v_separation", "VFlowContainer", margin); + p_theme->set_constant("v_separation", "ScrollContainer", margin); + p_theme->set_constant("button_margin", "Tree", margin); + p_theme->set_constant("inner_margin_left", "Tree", margin); + p_theme->set_constant("inner_margin_right", "Tree", margin); + p_theme->set_constant("separation", "HSeparator", margin); + p_theme->set_constant("separation", "VSeparator", margin); + p_theme->set_constant("scrollbar_h_separation", "Tree", margin); + p_theme->set_constant("scrollbar_v_separation", "Tree", margin); + p_theme->set_constant("h_separation", "ItemList", margin); + p_theme->set_constant("v_separation", "ItemList", margin); + p_theme->set_constant("icon_margin", "ItemList", margin); + p_theme->set_constant("h_separation", "GridContainer", margin); + p_theme->set_constant("v_separation", "GridContainer", margin); +} + +void update_theme_padding(Ref &p_theme, int p_padding) { + float base_scale = MAX(p_theme->get_default_base_scale(), 0.5); + int padding = p_padding * base_scale; + + panel_style->set_content_margin_all(padding); + flat_panel_style->set_content_margin_all(padding); + tab_panel_style->set_content_margin_all(padding); + flat_tab_panel_style->set_content_margin_all(padding); + progress_background_style->set_content_margin_all(padding); + graph_frame_title_style->set_content_margin_all(padding); + graph_frame_title_selected_style->set_content_margin_all(padding); + foldable_panel_style->set_content_margin(SIDE_TOP, padding); + flat_foldable_panel_style->set_content_margin(SIDE_TOP, padding); + graph_title_style->set_content_margin_individual(12 * base_scale, padding, padding, padding); + graph_title_selected_style->set_content_margin_individual(12 * base_scale, padding, padding, padding); + p_theme->set_constant("margin_left", "MarginContainer", padding); + p_theme->set_constant("margin_top", "MarginContainer", padding); + p_theme->set_constant("margin_right", "MarginContainer", padding); + p_theme->set_constant("margin_bottom", "MarginContainer", padding); + p_theme->set_constant("item_start_padding", "PopupMenu", padding); + p_theme->set_constant("item_end_padding", "PopupMenu", padding); +} + +void update_theme_corner_radius(Ref &p_theme, int p_corner_radius) { + float base_scale = MAX(p_theme->get_default_base_scale(), 0.5); + int corners = p_corner_radius * base_scale; + + panel_style->set_corner_radius_all(corners); + flat_panel_style->set_corner_radius_all(corners); + button_hover_style->set_corner_radius_all(corners); + button_normal_style->set_corner_radius_all(corners); + button_pressed_style->set_corner_radius_all(corners); + button_disabled_style->set_corner_radius_all(corners); + color_button_normal_style->set_corner_radius_all(corners); + color_button_hover_style->set_corner_radius_all(corners); + color_button_pressed_style->set_corner_radius_all(corners); + color_button_disabled_style->set_corner_radius_all(corners); + grabber_style->set_corner_radius_all(corners); + grabber_highlight_style->set_corner_radius_all(corners); + slider_style->set_corner_radius_all(corners); + h_scroll_style->set_corner_radius_all(corners); + v_scroll_style->set_corner_radius_all(corners); + foldable_title_collapsed_style->set_corner_radius_all(corners); + foldable_title_collapsed_hover_style->set_corner_radius_all(corners); + foldable_panel_style->set_corner_radius_individual(0, 0, corners, corners); + flat_foldable_panel_style->set_corner_radius_individual(0, 0, corners, corners); + foldable_title_style->set_corner_radius_individual(corners, corners, 0, 0); + foldable_title_hover_style->set_corner_radius_individual(corners, corners, 0, 0); + graph_panel_style->set_corner_radius_individual(0, 0, corners, corners); + graph_panel_selected_style->set_corner_radius_individual(0, 0, corners, corners); + graph_title_style->set_corner_radius_individual(corners, corners, 0, 0); + graph_frame_title_style->set_corner_radius_individual(corners, corners, 0, 0); + graph_title_selected_style->set_corner_radius_individual(corners, corners, 0, 0); + graph_frame_title_selected_style->set_corner_radius_individual(corners, corners, 0, 0); + + int focus_border = MAX(p_corner_radius - 2, 0) * base_scale; + button_focus_style->set_corner_radius_all(focus_border); + color_button_focus_style->set_corner_radius_all(focus_border); +} + +void update_theme_border_width(Ref &p_theme, int p_border_width) { + int border_width = p_border_width * MAX(p_theme->get_default_base_scale(), 0.5); + + popup_panel_style->set_content_margin_all(MAX(border_width, 1)); + button_focus_style->set_border_width_all(MAX(border_width, 1)); +} + +void update_theme_border_padding(Ref &p_theme, int p_border_padding) { + int border_padding = p_border_padding * MAX(p_theme->get_default_base_scale(), 0.5); + + button_normal_style->set_content_margin_all(border_padding); + button_empty_style->set_content_margin_all(border_padding); + button_pressed_style->set_content_margin_all(border_padding); + button_hover_style->set_content_margin_all(border_padding); + button_disabled_style->set_content_margin_all(border_padding); + p_theme->set_constant("inner_item_margin_left", "Tree", border_padding); + p_theme->set_constant("inner_item_margin_right", "Tree", border_padding); + p_theme->set_constant("arrow_margin", "OptionButton", border_padding); + foldable_title_style->set_content_margin_all(border_padding); + foldable_title_hover_style->set_content_margin_all(border_padding); + foldable_title_collapsed_style->set_content_margin_all(border_padding); + foldable_title_collapsed_hover_style->set_content_margin_all(border_padding); + foldable_panel_style->set_content_margin(SIDE_LEFT, border_padding); + foldable_panel_style->set_content_margin(SIDE_RIGHT, border_padding); + foldable_panel_style->set_content_margin(SIDE_BOTTOM, border_padding); + flat_foldable_panel_style->set_content_margin(SIDE_LEFT, border_padding); + flat_foldable_panel_style->set_content_margin(SIDE_RIGHT, border_padding); + flat_foldable_panel_style->set_content_margin(SIDE_BOTTOM, border_padding); +} + +void update_theme_scale(Ref &p_theme) { + float base_scale = MAX(p_theme->get_default_base_scale(), 0.5); + int int_scale = MAX(Math::floor(base_scale), 1); + int x2_scale = 2 * base_scale; + int x4_scale = 4 * base_scale; + int x6_scale = 6 * base_scale; + + popup_panel_style->set_border_width_all(int_scale); + p_theme->set_constant("children_hl_line_width", "Tree", int_scale); + p_theme->set_constant("shadow_offset_x", "Label", int_scale); + p_theme->set_constant("shadow_offset_y", "Label", int_scale); + p_theme->set_constant("shadow_outline_size", "Label", int_scale); + p_theme->set_constant("shadow_offset_x", "GraphNodeTitleLabel", int_scale); + p_theme->set_constant("shadow_offset_y", "GraphNodeTitleLabel", int_scale); + p_theme->set_constant("shadow_outline_size", "GraphNodeTitleLabel", int_scale); + p_theme->set_constant("shadow_offset_x", "GraphFrameTitleLabel", int_scale); + p_theme->set_constant("shadow_offset_y", "GraphFrameTitleLabel", int_scale); + p_theme->set_constant("shadow_outline_size", "GraphFrameTitleLabel", int_scale); + p_theme->set_constant("shadow_offset_x", "TooltipLabel", int_scale); + p_theme->set_constant("shadow_offset_y", "TooltipLabel", int_scale); + p_theme->set_constant("shadow_offset_x", "RichTextLabel", int_scale); + p_theme->set_constant("shadow_offset_y", "RichTextLabel", int_scale); + p_theme->set_constant("shadow_outline_size", "RichTextLabel", int_scale); + p_theme->set_constant("caret_width", "LineEdit", int_scale); + p_theme->set_constant("caret_width", "TextEdit", int_scale); + p_theme->set_constant("relationship_line_width", "Tree", int_scale); + p_theme->set_constant("parent_hl_line_width", "Tree", 2 * int_scale); + p_theme->set_constant("indent", "PopupMenu", 10 * base_scale); + p_theme->set_constant("buttons_separation", "AcceptDialog", 10 * base_scale); + p_theme->set_constant("scroll_speed", "Tree", 12 * base_scale); + p_theme->set_constant("item_margin", "Tree", 12 * base_scale); + p_theme->set_constant("buttons_width", "SpinBox", 16 * base_scale); + p_theme->set_constant("close_h_offset", "Window", 18 * base_scale); + p_theme->set_constant("port_hotzone_inner_extent", "GraphEdit", 22 * base_scale); + p_theme->set_constant("close_v_offset", "Window", 24 * base_scale); + p_theme->set_constant("port_hotzone_outer_extent", "GraphEdit", 26 * base_scale); + p_theme->set_constant("title_height", "Window", 36 * base_scale); + p_theme->set_constant("completion_max_width", "CodeEdit", 50 * base_scale); + p_theme->set_constant("h_width", "ColorPicker", 30 * base_scale); + p_theme->set_constant("sample_height", "ColorPicker", 30 * base_scale); + p_theme->set_constant("preset_size", "ColorPicker", 30 * base_scale); + p_theme->set_constant("sv_width", "ColorPicker", 256 * base_scale); + p_theme->set_constant("sv_height", "ColorPicker", 256 * base_scale); + + color_button_focus_style->set_border_width_all(x2_scale); + tab_focus_style->set_border_width_all(x2_scale); + h_separator_style->set_thickness(x2_scale); + v_separator_style->set_thickness(x2_scale); + slider_style->set_content_margin_all(x2_scale); + p_theme->set_constant("line_spacing", "Label", x2_scale); + p_theme->set_constant("line_spacing", "GraphNodeTitleLabel", x2_scale); + p_theme->set_constant("line_spacing", "GraphFrameTitleLabel", x2_scale); + p_theme->set_constant("underline_spacing", "LinkButton", x2_scale); + p_theme->set_constant("field_and_buttons_separation", "SpinBox", x2_scale); + p_theme->set_constant("icon_separation", "TabContainer", x2_scale); + p_theme->set_constant("text_highlight_h_padding", "RichTextLabel", x2_scale); + p_theme->set_constant("text_highlight_v_padding", "RichTextLabel", x2_scale); + p_theme->set_constant("separation", "GraphNode", x2_scale); + p_theme->set_constant(SceneStringName(line_separation), "ItemList", x2_scale); + p_theme->set_constant("table_h_separation", "RichTextLabel", x2_scale); + p_theme->set_constant("table_v_separation", "RichTextLabel", x2_scale); + graph_panel_style->set_border_width(SIDE_LEFT, x2_scale); + graph_panel_style->set_border_width(SIDE_RIGHT, x2_scale); + graph_panel_style->set_border_width(SIDE_BOTTOM, x2_scale); + graph_panel_selected_style->set_border_width(SIDE_LEFT, x2_scale); + graph_panel_selected_style->set_border_width(SIDE_RIGHT, x2_scale); + graph_panel_selected_style->set_border_width(SIDE_BOTTOM, x2_scale); + graph_title_style->set_border_width(SIDE_LEFT, x2_scale); + graph_title_style->set_border_width(SIDE_RIGHT, x2_scale); + graph_title_style->set_border_width(SIDE_TOP, x2_scale); + graph_frame_title_style->set_border_width(SIDE_LEFT, x2_scale); + graph_frame_title_style->set_border_width(SIDE_RIGHT, x2_scale); + graph_frame_title_style->set_border_width(SIDE_TOP, x2_scale); + graph_title_selected_style->set_border_width(SIDE_LEFT, x2_scale); + graph_title_selected_style->set_border_width(SIDE_RIGHT, x2_scale); + graph_title_selected_style->set_border_width(SIDE_TOP, x2_scale); + graph_frame_title_selected_style->set_border_width(SIDE_LEFT, x2_scale); + graph_frame_title_selected_style->set_border_width(SIDE_RIGHT, x2_scale); + graph_frame_title_selected_style->set_border_width(SIDE_TOP, x2_scale); + tab_selected_style->set_border_width(SIDE_TOP, x2_scale); + flat_tab_selected_style->set_border_width(SIDE_TOP, x2_scale); + h_split_bar_background->set_expand_margin_individual(x2_scale, 0, x2_scale, 0); + v_split_bar_background->set_expand_margin_individual(0, x2_scale, 0, x2_scale); + + grabber_style->set_content_margin_all(x4_scale); + h_scroll_style->set_content_margin_individual(0, x4_scale, 0, x4_scale); + v_scroll_style->set_content_margin_individual(x4_scale, 0, x4_scale, 0); + color_button_pressed_style->set_border_width_all(x4_scale); + p_theme->set_constant("line_spacing", "TextEdit", x4_scale); + p_theme->set_constant("line_spacing", "CodeEdit", x4_scale); + p_theme->set_constant("h_separation", "PopupMenu", x4_scale); + p_theme->set_constant("v_separation", "PopupMenu", x4_scale); + p_theme->set_constant("v_separation", "Tree", x4_scale); + p_theme->set_constant("h_separation", "MenuBar", x4_scale); + p_theme->set_constant("scroll_border", "Tree", x4_scale); + p_theme->set_constant("resize_margin", "Window", x4_scale); + p_theme->set_constant("drop_mark_width", "TabContainer", x4_scale); + p_theme->set_constant("drop_mark_width", "TabBar", x4_scale); + + color_button_normal_style->set_content_margin_all(x6_scale); + color_button_hover_style->set_content_margin_all(x6_scale); + color_button_pressed_style->set_content_margin_all(x6_scale); + color_button_disabled_style->set_content_margin_all(x6_scale); + p_theme->set_constant("separation", "SplitContainer", x6_scale); + p_theme->set_constant("separation", "HSplitContainer", x6_scale); + p_theme->set_constant("separation", "VSplitContainer", x6_scale); + p_theme->set_constant("minimum_grab_thickness", "SplitContainer", x6_scale); + p_theme->set_constant("minimum_grab_thickness", "HSplitContainer", x6_scale); + p_theme->set_constant("minimum_grab_thickness", "VSplitContainer", x6_scale); + p_theme->set_constant("separation", "ColorPicker", x6_scale); + p_theme->set_constant("margin", "ColorPicker", x6_scale); + + tab_unselected_style->set_content_margin_individual(x6_scale, x4_scale, x6_scale, x2_scale); + tab_hover_style->set_content_margin_individual(x6_scale, x4_scale, x6_scale, x2_scale); + tab_empty_style->set_content_margin_individual(x6_scale, x4_scale, x6_scale, x2_scale); + tab_selected_style->set_content_margin_individual(x6_scale, x4_scale, x6_scale, x2_scale); + flat_tab_selected_style->set_content_margin_individual(x6_scale, x4_scale, x6_scale, x2_scale); +} + +void make_default_theme(Ref p_font, float p_scale, TextServer::SubpixelPositioning p_font_subpixel, TextServer::Hinting p_font_hinting, TextServer::FontAntialiasing p_font_antialiasing, TextServer::FontLCDSubpixelLayout p_font_lcd_subpixel_layout, bool p_font_msdf, bool p_font_generate_mipmaps, Color p_base_color, Color p_accent_color, Color p_font_color, Color p_font_outline_color, float p_contrast, float p_normal_contrast, float p_hover_contrast, float p_pressed_contrast, float p_bg_contrast, int p_margin, int p_padding, int p_border_width, int p_corner_radius, int p_font_size, int p_font_outline, float p_font_embolden, int p_font_spacing_glyph, int p_font_spacing_space, int p_font_spacing_top, int p_font_spacing_bottom) { + float scale = CLAMP(p_scale, 0.5, 8.0); + + Ref t; + t.instantiate(); + + Ref base_font; + base_font.instantiate(); + base_font->set_data_ptr(_font_OpenSans_SemiBold, _font_OpenSans_SemiBold_size); + + fallback_font.instantiate(); + fallback_font->set_base_font(base_font); + + ThemeDB::get_singleton()->set_fallback_font(fallback_font); + + bold_font.instantiate(); + bold_italics_font.instantiate(); + italics_font.instantiate(); + + bold_italics_font->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0)); + italics_font->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0)); + + t->set_default_base_scale(scale); + + t->set_type_variation("FlatButton", "Button"); + t->set_type_variation("FlatMenuButton", "MenuButton"); + t->set_type_variation("TooltipPanel", "PopupPanel"); + t->set_type_variation("FlatPanelContainer", "PanelContainer"); + t->set_type_variation("FlatPanel", "Panel"); + t->set_type_variation("ButtonsTabBar", "TabBar"); + t->set_type_variation("FlatTabContainer", "TabContainer"); + t->set_type_variation("FlatFoldableContainer", "TabContainer"); + t->set_type_variation("GraphNodeTitleLabel", "Label"); + t->set_type_variation("GraphFrameTitleLabel", "Label"); + t->set_type_variation("TooltipLabel", "Label"); + t->set_type_variation("HeaderSmall", "Label"); + t->set_type_variation("HeaderMedium", "Label"); + t->set_type_variation("HeaderLarge", "Label"); + t->set_type_variation("FlatSplitContainer", "SplitContainer"); + t->set_type_variation("FlatHSplitContainer", "HSplitContainer"); + t->set_type_variation("FlatVSplitContainer", "VSplitContainer"); + + Ref empty_style(memnew(StyleBoxEmpty)); + + panel_style.instantiate(); + flat_panel_style.instantiate(); + popup_panel_style.instantiate(); + tab_selected_style.instantiate(); + flat_tab_selected_style.instantiate(); + tab_unselected_style.instantiate(); + tab_hover_style.instantiate(); + tab_focus_style.instantiate(); + tab_empty_style.instantiate(); + tab_panel_style.instantiate(); + flat_tab_panel_style.instantiate(); + button_hover_style.instantiate(); + button_normal_style.instantiate(); + button_pressed_style.instantiate(); + button_disabled_style.instantiate(); + button_focus_style.instantiate(); + color_button_normal_style.instantiate(); + color_button_hover_style.instantiate(); + color_button_pressed_style.instantiate(); + color_button_disabled_style.instantiate(); + color_button_focus_style.instantiate(); + popup_hover_style.instantiate(); + progress_background_style.instantiate(); + progress_fill_style.instantiate(); + grabber_style.instantiate(); + grabber_highlight_style.instantiate(); + slider_style.instantiate(); + h_scroll_style.instantiate(); + v_scroll_style.instantiate(); + foldable_panel_style.instantiate(); + flat_foldable_panel_style.instantiate(); + foldable_title_style.instantiate(); + foldable_title_collapsed_style.instantiate(); + foldable_title_hover_style.instantiate(); + foldable_title_collapsed_hover_style.instantiate(); + h_separator_style.instantiate(); + v_separator_style.instantiate(); + button_empty_style.instantiate(); + embedded_style.instantiate(); + embedded_unfocused_style.instantiate(); + graph_title_style.instantiate(); + graph_frame_title_style.instantiate(); + graph_frame_title_selected_style.instantiate(); + graph_title_selected_style.instantiate(); + graph_panel_style.instantiate(); + graph_panel_selected_style.instantiate(); + code_edit_completion_style.instantiate(); + h_split_bar_background.instantiate(); + v_split_bar_background.instantiate(); + + update_theme_font(t, p_font); + update_theme_margins(t, p_margin); + update_theme_padding(t, p_padding); + update_theme_corner_radius(t, p_corner_radius); + update_theme_border_width(t, p_border_width); + update_theme_border_padding(t, p_border_width + p_padding); + update_theme_scale(t); + update_font_color(t, p_font_color); // Update font color before icons and theme colors. + update_theme_icons(t, p_font_color, p_accent_color); + update_theme_colors(t, p_base_color, p_accent_color, p_contrast, p_normal_contrast, p_hover_contrast, p_pressed_contrast, p_bg_contrast); + update_font_outline_color(t, p_font_outline_color); + update_font_outline_size(t, p_font_outline); + update_font_size(t, p_font_size); + update_font_embolden(p_font_embolden); + update_font_spacing_glyph(p_font_spacing_glyph); + update_font_spacing_space(p_font_spacing_space); + update_font_spacing_top(p_font_spacing_top); + update_font_spacing_bottom(p_font_spacing_bottom); + update_font_subpixel_positioning(p_font_subpixel); + update_font_lcd_subpixel_layout(p_font_lcd_subpixel_layout); + update_font_antialiasing(p_font_antialiasing); + update_font_hinting(p_font_hinting); + update_font_msdf(p_font_msdf); + update_font_generate_mipmaps(p_font_generate_mipmaps); + + t->set_stylebox(CoreStringName(normal), "Button", button_normal_style); + t->set_stylebox(SceneStringName(pressed), "Button", button_pressed_style); + t->set_stylebox("hover", "Button", button_hover_style); + t->set_stylebox("disabled", "Button", button_disabled_style); + t->set_stylebox("focus", "Button", button_focus_style); + + t->set_stylebox(CoreStringName(normal), "ColorButton", color_button_normal_style); + t->set_stylebox(SceneStringName(pressed), "ColorButton", color_button_pressed_style); + t->set_stylebox("hover", "ColorButton", color_button_hover_style); + t->set_stylebox("disabled", "ColorButton", color_button_disabled_style); + t->set_stylebox("focus", "ColorButton", color_button_focus_style); + + t->set_stylebox(CoreStringName(normal), "MenuButton", button_normal_style); + t->set_stylebox(SceneStringName(pressed), "MenuButton", button_pressed_style); + t->set_stylebox("hover", "MenuButton", button_hover_style); + t->set_stylebox("disabled", "MenuButton", button_disabled_style); + t->set_stylebox("focus", "MenuButton", button_focus_style); + + t->set_stylebox(CoreStringName(normal), "OptionButton", button_normal_style); + t->set_stylebox(SceneStringName(pressed), "OptionButton", button_pressed_style); + t->set_stylebox("hover", "OptionButton", button_hover_style); + t->set_stylebox("disabled", "OptionButton", button_disabled_style); + t->set_stylebox("focus", "OptionButton", button_focus_style); + t->set_stylebox("normal_mirrored", "OptionButton", button_normal_style); + t->set_stylebox("pressed_mirrored", "OptionButton", button_pressed_style); + t->set_stylebox("hover_mirrored", "OptionButton", button_hover_style); + t->set_stylebox("disabled_mirrored", "OptionButton", button_disabled_style); + + t->set_stylebox(CoreStringName(normal), "CheckBox", button_empty_style); + t->set_stylebox(SceneStringName(pressed), "CheckBox", button_empty_style); + t->set_stylebox("hover", "CheckBox", button_empty_style); + t->set_stylebox("hover_pressed", "CheckBox", button_empty_style); + t->set_stylebox("disabled", "CheckBox", button_empty_style); + t->set_stylebox("focus", "CheckBox", button_focus_style); + + t->set_stylebox(CoreStringName(normal), "CheckButton", button_empty_style); + t->set_stylebox(SceneStringName(pressed), "CheckButton", button_empty_style); + t->set_stylebox("hover", "CheckButton", button_empty_style); + t->set_stylebox("hover_pressed", "CheckButton", button_empty_style); + t->set_stylebox("disabled", "CheckButton", button_empty_style); + t->set_stylebox("focus", "CheckButton", button_focus_style); + + t->set_stylebox(CoreStringName(normal), "FlatButton", button_empty_style); + t->set_stylebox(SceneStringName(pressed), "FlatButton", button_pressed_style); + t->set_stylebox("hover", "FlatButton", button_hover_style); + t->set_stylebox("disabled", "FlatButton", button_empty_style); + + t->set_stylebox(CoreStringName(normal), "FlatMenuButton", button_empty_style); + t->set_stylebox(SceneStringName(pressed), "FlatMenuButton", button_pressed_style); + t->set_stylebox("hover", "FlatMenuButton", button_empty_style); + t->set_stylebox("disabled", "FlatMenuButton", button_empty_style); + + t->set_stylebox("focus", "LinkButton", button_empty_style); + + t->set_stylebox("tab_selected", "TabBar", tab_selected_style); + t->set_stylebox("tab_unselected", "TabBar", tab_unselected_style); + t->set_stylebox("tab_hovered", "TabBar", tab_hover_style); + t->set_stylebox("tab_disabled", "TabBar", tab_empty_style); + t->set_stylebox("tab_focus", "TabBar", tab_focus_style); + t->set_stylebox("button_pressed", "TabBar", button_pressed_style); + t->set_stylebox("button_highlight", "TabBar", button_hover_style); + + t->set_stylebox("tab_selected", "ButtonsTabBar", button_pressed_style); + t->set_stylebox("tab_unselected", "ButtonsTabBar", button_empty_style); + t->set_stylebox("tab_hovered", "ButtonsTabBar", button_hover_style); + t->set_stylebox("tab_disabled", "ButtonsTabBar", button_empty_style); + t->set_stylebox("tab_focus", "ButtonsTabBar", button_focus_style); + + t->set_stylebox(SceneStringName(panel), "TabContainer", tab_panel_style); + t->set_stylebox("tab_selected", "TabContainer", tab_selected_style); + t->set_stylebox("tab_unselected", "TabContainer", tab_unselected_style); + t->set_stylebox("tab_hovered", "TabContainer", tab_hover_style); + t->set_stylebox("tab_disabled", "TabContainer", tab_empty_style); + t->set_stylebox("tab_focus", "TabContainer", tab_focus_style); + t->set_stylebox("tabbar_background", "TabContainer", empty_style); + + t->set_stylebox(SceneStringName(panel), "FlatTabContainer", flat_tab_panel_style); + t->set_stylebox("tab_selected", "FlatTabContainer", flat_tab_selected_style); + + t->set_stylebox("focus", "FoldableContainer", button_focus_style); + t->set_stylebox("title_panel", "FoldableContainer", foldable_title_style); + t->set_stylebox("title_collapsed_panel", "FoldableContainer", foldable_title_collapsed_style); + t->set_stylebox("title_hover_panel", "FoldableContainer", foldable_title_hover_style); + t->set_stylebox("title_collapsed_hover_panel", "FoldableContainer", foldable_title_collapsed_hover_style); + t->set_stylebox(SceneStringName(panel), "FoldableContainer", foldable_panel_style); + t->set_stylebox("button_normal_style", "FoldableContainer", button_empty_style); + t->set_stylebox("button_hovered_style", "FoldableContainer", button_normal_style); + t->set_stylebox("button_pressed_style", "FoldableContainer", button_pressed_style); + t->set_stylebox("button_disabled_style", "FoldableContainer", button_disabled_style); + + t->set_stylebox(SceneStringName(panel), "FlatFoldableContainer", flat_foldable_panel_style); + + t->set_stylebox("up_background_hovered", "SpinBox", button_hover_style); + t->set_stylebox("down_background_hovered", "SpinBox", button_hover_style); + t->set_stylebox("up_background_pressed", "SpinBox", button_pressed_style); + t->set_stylebox("down_background_pressed", "SpinBox", button_pressed_style); + t->set_stylebox("field_and_buttons_separator", "SpinBox", empty_style); + t->set_stylebox("up_down_buttons_separator", "SpinBox", empty_style); + t->set_stylebox("up_background", "SpinBox", button_empty_style); + t->set_stylebox("down_background", "SpinBox", button_empty_style); + t->set_stylebox("up_background_disabled", "SpinBox", button_empty_style); + t->set_stylebox("down_background_disabled", "SpinBox", button_empty_style); + + t->set_stylebox("custom_button", "Tree", button_empty_style); + t->set_stylebox("custom_button_hover", "Tree", button_hover_style); + t->set_stylebox("custom_button_pressed", "Tree", button_pressed_style); + t->set_stylebox("focus", "Tree", button_focus_style); + t->set_stylebox("selected", "Tree", popup_hover_style); + t->set_stylebox("selected_focus", "Tree", popup_hover_style); + t->set_stylebox("title_button_hover", "Tree", button_hover_style); + t->set_stylebox("title_button_normal", "Tree", button_empty_style); + t->set_stylebox("title_button_pressed", "Tree", button_pressed_style); + t->set_stylebox("cursor", "Tree", button_focus_style); + t->set_stylebox("cursor_unfocused", "Tree", button_focus_style); + t->set_stylebox("button_pressed", "Tree", button_pressed_style); + t->set_stylebox(SceneStringName(panel), "Tree", button_normal_style); + + t->set_stylebox("hover", "PopupMenu", popup_hover_style); + t->set_stylebox("labeled_separator_left", "PopupMenu", h_separator_style); + t->set_stylebox("labeled_separator_right", "PopupMenu", h_separator_style); + t->set_stylebox("separator", "PopupMenu", h_separator_style); + t->set_stylebox(SceneStringName(panel), "PopupMenu", popup_panel_style); + + t->set_stylebox(CoreStringName(normal), "LineEdit", button_normal_style); + t->set_stylebox("read_only", "LineEdit", button_disabled_style); + t->set_stylebox("focus", "LineEdit", button_focus_style); + + t->set_stylebox(CoreStringName(normal), "TextEdit", button_normal_style); + t->set_stylebox("read_only", "TextEdit", button_disabled_style); + t->set_stylebox("focus", "TextEdit", button_focus_style); + + t->set_stylebox(CoreStringName(normal), "CodeEdit", button_normal_style); + t->set_stylebox("focus", "CodeEdit", button_focus_style); + t->set_stylebox("read_only", "CodeEdit", button_disabled_style); + t->set_stylebox("completion", "CodeEdit", code_edit_completion_style); + + t->set_stylebox("grabber_area", "HSlider", grabber_style); + t->set_stylebox("slider", "HSlider", slider_style); + t->set_stylebox("grabber_area_highlight", "HSlider", grabber_highlight_style); + + t->set_stylebox("grabber_area", "VSlider", grabber_style); + t->set_stylebox("grabber_area_highlight", "VSlider", grabber_highlight_style); + t->set_stylebox("slider", "VSlider", slider_style); + + t->set_stylebox("grabber", "HScrollBar", grabber_style); + t->set_stylebox("grabber_highlight", "HScrollBar", grabber_highlight_style); + t->set_stylebox("grabber_pressed", "HScrollBar", grabber_highlight_style); + t->set_stylebox("scroll", "HScrollBar", h_scroll_style); + t->set_stylebox("scroll_focus", "HScrollBar", empty_style); + + t->set_stylebox("grabber", "VScrollBar", grabber_style); + t->set_stylebox("grabber_highlight", "VScrollBar", grabber_highlight_style); + t->set_stylebox("grabber_pressed", "VScrollBar", grabber_highlight_style); + t->set_stylebox("scroll", "VScrollBar", v_scroll_style); + t->set_stylebox("scroll_focus", "VScrollBar", empty_style); + + t->set_stylebox("focus", "ItemList", button_focus_style); + t->set_stylebox("cursor", "ItemList", button_focus_style); + t->set_stylebox("cursor_unfocused", "ItemList", button_focus_style); + t->set_stylebox("hovered", "ItemList", button_hover_style); + t->set_stylebox("selected", "ItemList", button_pressed_style); + t->set_stylebox("selected_focus", "ItemList", button_pressed_style); + t->set_stylebox(SceneStringName(panel), "ItemList", panel_style); + + t->set_stylebox(CoreStringName(normal), "MenuBar", button_empty_style); + t->set_stylebox("hover", "MenuBar", button_hover_style); + t->set_stylebox(SceneStringName(pressed), "MenuBar", button_pressed_style); + t->set_stylebox("disabled", "MenuBar", button_disabled_style); + + t->set_stylebox("menu_panel", "GraphEdit", button_disabled_style); + t->set_stylebox(SceneStringName(panel), "GraphEdit", tab_panel_style); + + t->set_stylebox("camera", "GraphEditMinimap", button_focus_style); + t->set_stylebox("node", "GraphEditMinimap", empty_style); + t->set_stylebox(SceneStringName(panel), "GraphEditMinimap", empty_style); + + t->set_stylebox("titlebar", "GraphFrame", graph_frame_title_style); + t->set_stylebox("titlebar_selected", "GraphFrame", graph_frame_title_selected_style); + t->set_stylebox("panel_selected", "GraphFrame", graph_panel_selected_style); + t->set_stylebox(SceneStringName(panel), "GraphFrame", graph_panel_style); + + t->set_stylebox("panel_selected", "GraphNode", graph_panel_selected_style); + t->set_stylebox("titlebar", "GraphNode", graph_title_style); + t->set_stylebox("titlebar_selected", "GraphNode", graph_title_selected_style); + t->set_stylebox("slot", "GraphNode", empty_style); + t->set_stylebox(SceneStringName(panel), "GraphNode", graph_panel_style); + + t->set_stylebox(CoreStringName(normal), "GraphFrameTitleLabel", empty_style); + t->set_stylebox(CoreStringName(normal), "GraphNodeTitleLabel", empty_style); + + t->set_stylebox(SceneStringName(panel), "Panel", panel_style); + t->set_stylebox(SceneStringName(panel), "PanelContainer", panel_style); + t->set_stylebox(SceneStringName(panel), "FlatPanel", flat_panel_style); + t->set_stylebox(SceneStringName(panel), "FlatPanelContainer", flat_panel_style); + t->set_stylebox(SceneStringName(panel), "PopupPanel", popup_panel_style); + t->set_stylebox(SceneStringName(panel), "AcceptDialog", popup_panel_style); + t->set_stylebox(SceneStringName(panel), "TooltipPanel", popup_panel_style); + t->set_stylebox(SceneStringName(panel), "PopupDialog", popup_panel_style); + t->set_stylebox(SceneStringName(panel), "ScrollContainer", empty_style); + + t->set_stylebox("background", "ProgressBar", progress_background_style); + t->set_stylebox("fill", "ProgressBar", progress_fill_style); + + t->set_stylebox("separator", "HSeparator", h_separator_style); + t->set_stylebox("separator", "VSeparator", v_separator_style); + + t->set_stylebox(CoreStringName(normal), "Label", empty_style); + + t->set_stylebox("focus", "RichTextLabel", button_focus_style); + t->set_stylebox(CoreStringName(normal), "RichTextLabel", button_empty_style); + + t->set_stylebox("embedded_border", "Window", embedded_style); + t->set_stylebox("embedded_unfocused_border", "Window", embedded_unfocused_style); + + t->set_stylebox("h_split_bar_background", "SplitContainer", empty_style); + t->set_stylebox("v_split_bar_background", "SplitContainer", empty_style); + t->set_stylebox("split_bar_background", "HSplitContainer", empty_style); + t->set_stylebox("split_bar_background", "VSplitContainer", empty_style); + + t->set_stylebox("h_split_bar_background", "FlatSplitContainer", h_split_bar_background); + t->set_stylebox("v_split_bar_background", "FlatSplitContainer", v_split_bar_background); + t->set_stylebox("split_bar_background", "FlatHSplitContainer", h_split_bar_background); + t->set_stylebox("split_bar_background", "FlatVSplitContainer", v_split_bar_background); + + v_separator_style->set_vertical(true); + tab_focus_style->set_draw_center(false); + button_focus_style->set_draw_center(false); + color_button_focus_style->set_draw_center(false); + + t->set_font_size(SceneStringName(font_size), "Button", -1); + t->set_font_size(SceneStringName(font_size), "MenuBar", -1); + t->set_font_size(SceneStringName(font_size), "LinkButton", -1); + t->set_font_size(SceneStringName(font_size), "OptionButton", -1); + t->set_font_size(SceneStringName(font_size), "MenuButton", -1); + t->set_font_size(SceneStringName(font_size), "CheckBox", -1); + t->set_font_size(SceneStringName(font_size), "CheckButton", -1); + t->set_font_size(SceneStringName(font_size), "Label", -1); + t->set_font_size(SceneStringName(font_size), "LineEdit", -1); + t->set_font_size(SceneStringName(font_size), "ProgressBar", -1); + t->set_font_size(SceneStringName(font_size), "TextEdit", -1); + t->set_font_size(SceneStringName(font_size), "CodeEdit", -1); + t->set_font_size(SceneStringName(font_size), "PopupMenu", -1); + t->set_font_size(SceneStringName(font_size), "GraphNodeTitleLabel", -1); + t->set_font_size(SceneStringName(font_size), "Tree", -1); + t->set_font_size(SceneStringName(font_size), "ItemList", -1); + t->set_font_size(SceneStringName(font_size), "TabContainer", -1); + t->set_font_size(SceneStringName(font_size), "TabBar", -1); + t->set_font_size(SceneStringName(font_size), "TooltipLabel", -1); + t->set_font_size(SceneStringName(font_size), "FoldableContainer", -1); + t->set_font_size("title_font_size", "Window", -1); + t->set_font_size("font_separator_size", "PopupMenu", -1); + t->set_font_size("title_button_font_size", "Tree", -1); + t->set_font_size("normal_font_size", "RichTextLabel", -1); + t->set_font_size("bold_font_size", "RichTextLabel", -1); + t->set_font_size("italics_font_size", "RichTextLabel", -1); + t->set_font_size("bold_italics_font_size", "RichTextLabel", -1); + t->set_font_size("mono_font_size", "RichTextLabel", -1); + t->set_constant("scrollbar_margin_left", "Tree", -1); + t->set_constant("scrollbar_margin_top", "Tree", -1); + t->set_constant("scrollbar_margin_right", "Tree", -1); + t->set_constant("scrollbar_margin_bottom", "Tree", -1); + + t->set_constant("icon_max_width", "Button", 0); + t->set_constant("align_to_largest_stylebox", "Button", 0); + t->set_constant("icon_max_width", "Tree", 0); + t->set_constant("check_v_offset", "CheckBox", 0); + t->set_constant("check_v_offset", "CheckButton", 0); + t->set_constant("center_grabber", "HSlider", 0); + t->set_constant("grabber_offset", "HSlider", 0); + t->set_constant("center_grabber", "VSlider", 0); + t->set_constant("grabber_offset", "VSlider", 0); + t->set_constant("inner_item_margin_bottom", "Tree", 0); + t->set_constant("inner_item_margin_top", "Tree", 0); + t->set_constant("buttons_vertical_separation", "SpinBox", 0); + t->set_constant("icon_max_width", "PopupMenu", 0); + t->set_constant("parent_hl_line_margin", "Tree", 0); + t->set_constant("icon_max_width", "TabContainer", 0); + t->set_constant("icon_max_width", "TabBar", 0); + t->set_constant("draw_guides", "Tree", 0); + t->set_constant("side_margin", "TabContainer", 0); + t->set_constant("modulate_arrow", "OptionButton", 0); + t->set_constant("port_h_offset", "GraphNode", 0); + t->set_constant(SceneStringName(line_separation), "RichTextLabel", 0); + t->set_constant("separation", "FlatSplitContainer", 0); + t->set_constant("separation", "FlatHSplitContainer", 0); + t->set_constant("separation", "FlatVSplitContainer", 0); + t->set_constant("draw_grabber_icon", "FlatSplitContainer", 0); + t->set_constant("draw_grabber_icon", "FlatHSplitContainer", 0); + t->set_constant("draw_grabber_icon", "FlatVSplitContainer", 0); + + t->set_constant("draw_split_bar", "FlatSplitContainer", 1); + t->set_constant("draw_split_bar", "FlatHSplitContainer", 1); + t->set_constant("draw_split_bar", "FlatVSplitContainer", 1); + t->set_constant("autohide", "SplitContainer", 1); + t->set_constant("autohide", "HSplitContainer", 1); + t->set_constant("autohide", "VSplitContainer", 1); + t->set_constant("autohide_split_bar", "SplitContainer", 1); + t->set_constant("autohide_split_bar", "HSplitContainer", 1); + t->set_constant("autohide_split_bar", "VSplitContainer", 1); + t->set_constant("draw_grabber_icon", "SplitContainer", 1); + t->set_constant("draw_grabber_icon", "HSplitContainer", 1); + t->set_constant("draw_grabber_icon", "VSplitContainer", 1); + t->set_constant("draw_relationship_lines", "Tree", 1); + t->set_constant("center_slider_grabbers", "ColorPicker", 1); + t->set_constant("colorize_sliders", "ColorPicker", 1); + + t->set_constant("minimum_character_width", "LineEdit", 4); + t->set_constant("completion_scroll_width", "CodeEdit", 6); + t->set_constant("completion_lines", "CodeEdit", 7); + t->set_constant("label_width", "ColorPicker", 10); + + t->set_color("font_shadow_color", "Label", Color(0, 0, 0, 0)); + t->set_color("font_shadow_color", "GraphNodeTitleLabel", Color(0, 0, 0, 0)); + t->set_color("font_shadow_color", "GraphFrameTitleLabel", Color(0, 0, 0, 0)); + t->set_color("font_shadow_color", "TooltipLabel", Color(0, 0, 0, 0)); + t->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0)); + t->set_color("background_color", "TextEdit", Color(0, 0, 0, 0)); + t->set_color("background_color", "CodeEdit", Color(0, 0, 0, 0)); + t->set_color("table_odd_row_bg", "RichTextLabel", Color(0, 0, 0, 0)); + t->set_color("table_even_row_bg", "RichTextLabel", Color(0, 0, 0, 0)); + t->set_color("table_border", "RichTextLabel", Color(0, 0, 0, 0)); + + t->set_color("completion_background_color", "CodeEdit", Color(0.17, 0.16, 0.2)); + t->set_color("completion_selected_color", "CodeEdit", Color(0.26, 0.26, 0.27)); + t->set_color("completion_existing_color", "CodeEdit", Color(0.87, 0.87, 0.87, 0.13)); + t->set_color("bookmark_color", "CodeEdit", Color(0.5, 0.64, 1, 0.8)); + t->set_color("breakpoint_color", "CodeEdit", Color(0.9, 0.29, 0.3)); + t->set_color("executing_line_color", "CodeEdit", Color(0.98, 0.89, 0.27)); + t->set_color("code_folding_color", "CodeEdit", Color(0.8, 0.8, 0.8, 0.8)); + t->set_color("folded_code_region_color", "CodeEdit", Color(0.68, 0.46, 0.77, 0.2)); + t->set_color("brace_mismatch_color", "CodeEdit", Color(1, 0.2, 0.2)); + t->set_color("line_number_color", "CodeEdit", Color(0.67, 0.67, 0.67, 0.4)); + t->set_color("line_length_guideline_color", "CodeEdit", Color(0.3, 0.5, 0.8, 0.1)); + + embedded_style->set_content_margin_individual(10, 28, 10, 8); + embedded_unfocused_style->set_content_margin_individual(10, 28, 10, 8); + embedded_style->set_expand_margin_individual(8, 32, 8, 6); + embedded_unfocused_style->set_expand_margin_individual(8, 32, 8, 6); + + t->set_font("bold_font", "RichTextLabel", bold_font); + t->set_font("italics_font", "RichTextLabel", italics_font); + t->set_font("bold_italics_font", "RichTextLabel", bold_italics_font); + t->set_font(SceneStringName(font), "Button", Ref()); + t->set_font(SceneStringName(font), "TabBar", Ref()); + t->set_font(SceneStringName(font), "ItemList", Ref()); + t->set_font(SceneStringName(font), "Tree", Ref()); + t->set_font(SceneStringName(font), "GraphNodeTitleLabel", Ref()); + t->set_font(SceneStringName(font), "PopupMenu", Ref()); + t->set_font(SceneStringName(font), "CodeEdit", Ref()); + t->set_font(SceneStringName(font), "TextEdit", Ref()); + t->set_font(SceneStringName(font), "ProgressBar", Ref()); + t->set_font(SceneStringName(font), "LineEdit", Ref()); + t->set_font(SceneStringName(font), "Label", Ref()); + t->set_font(SceneStringName(font), "CheckBox", Ref()); + t->set_font(SceneStringName(font), "CheckButton", Ref()); + t->set_font(SceneStringName(font), "FoldableContainer", Ref()); + t->set_font(SceneStringName(font), "LinkButton", Ref()); + t->set_font(SceneStringName(font), "MenuBar", Ref()); + t->set_font(SceneStringName(font), "MenuButton", Ref()); + t->set_font(SceneStringName(font), "OptionButton", Ref()); + t->set_font(SceneStringName(font), "TabContainer", Ref()); + t->set_font(SceneStringName(font), "TooltipLabel", Ref()); + t->set_font("font_separator", "PopupMenu", Ref()); + t->set_font("title_button_font", "Tree", Ref()); + t->set_font("title_font", "Window", Ref()); + t->set_font("normal_font", "RichTextLabel", Ref()); + t->set_font("mono_font", "RichTextLabel", Ref()); + + ThemeDB::get_singleton()->set_default_theme(t); + ThemeDB::get_singleton()->set_fallback_base_scale(scale); + ThemeDB::get_singleton()->set_fallback_stylebox(empty_style); + ThemeDB::get_singleton()->set_fallback_font_size(p_font_size * scale); +} + +void finalize_default_theme() { + icons.clear(); + + panel_style.unref(); + flat_panel_style.unref(); + popup_panel_style.unref(); + tab_selected_style.unref(); + flat_tab_selected_style.unref(); + tab_unselected_style.unref(); + tab_hover_style.unref(); + tab_focus_style.unref(); + tab_empty_style.unref(); + tab_panel_style.unref(); + flat_tab_panel_style.unref(); + button_normal_style.unref(); + button_empty_style.unref(); + button_pressed_style.unref(); + button_hover_style.unref(); + button_disabled_style.unref(); + button_focus_style.unref(); + color_button_normal_style.unref(); + color_button_hover_style.unref(); + color_button_pressed_style.unref(); + color_button_disabled_style.unref(); + color_button_focus_style.unref(); + popup_hover_style.unref(); + progress_background_style.unref(); + progress_fill_style.unref(); + grabber_style.unref(); + grabber_highlight_style.unref(); + slider_style.unref(); + h_scroll_style.unref(); + v_scroll_style.unref(); + foldable_panel_style.unref(); + flat_foldable_panel_style.unref(); + foldable_title_style.unref(); + foldable_title_collapsed_style.unref(); + foldable_title_hover_style.unref(); + foldable_title_collapsed_hover_style.unref(); + h_separator_style.unref(); + v_separator_style.unref(); + embedded_style.unref(); + embedded_unfocused_style.unref(); + graph_title_style.unref(); + graph_frame_title_style.unref(); + graph_frame_title_selected_style.unref(); + graph_title_selected_style.unref(); + graph_panel_style.unref(); + graph_panel_selected_style.unref(); + code_edit_completion_style.unref(); + h_split_bar_background.unref(); + v_split_bar_background.unref(); + + if (custom_font.is_valid()) { + custom_font.unref(); + } + + fallback_font.unref(); + bold_font.unref(); + bold_italics_font.unref(); + italics_font.unref(); +} diff --git a/scene/theme/blazium_default_theme.h b/scene/theme/blazium_default_theme.h new file mode 100644 index 000000000000..183c036b29ad --- /dev/null +++ b/scene/theme/blazium_default_theme.h @@ -0,0 +1,64 @@ +/**************************************************************************/ +/* blazium_default_theme.h */ +/**************************************************************************/ +/* This file is part of: */ +/* BLAZIUM ENGINE */ +/* https://blazium.app */ +/**************************************************************************/ +/* Copyright (c) 2024-present Blazium Engine contributors. */ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef BLAZIUM_DEFAULT_THEME_H +#define BLAZIUM_DEFAULT_THEME_H + +#include "scene/resources/theme.h" + +void finalize_default_theme(); +void update_theme_icons(Ref &p_theme, Color p_font_color, Color p_accent_color); +void update_font_color(Ref &p_theme, Color p_color); +void update_font_outline_color(Ref &p_theme, Color p_color); +void update_theme_margins(Ref &p_theme, int p_margin); +void update_theme_padding(Ref &p_theme, int p_padding); +void update_theme_corner_radius(Ref &p_theme, int p_corner_radius); +void update_theme_border_width(Ref &p_theme, int p_border_width); +void update_font_outline_size(Ref &p_theme, int p_outline_size); +void update_font_size(Ref &p_theme, int p_font_size); +void update_theme_border_padding(Ref &p_theme, int p_border_padding); +void update_theme_scale(Ref &p_theme); +void update_theme_colors(Ref &p_theme, Color p_base_color, Color p_accent_color, float p_contrast, float p_normal_contrast, float p_hover_contrast, float p_pressed_contrast, float p_bg_contrast); +void update_font_embolden(float p_embolden); +void update_font_spacing_glyph(int p_spacing); +void update_font_spacing_space(int p_spacing); +void update_font_spacing_top(int p_spacing); +void update_font_spacing_bottom(int p_spacing); +void update_theme_font(Ref &p_theme, Ref p_font); +void update_font_subpixel_positioning(TextServer::SubpixelPositioning p_font_subpixel_positioning); +void update_font_antialiasing(TextServer::FontAntialiasing p_font_antialiasing); +void update_font_lcd_subpixel_layout(TextServer::FontLCDSubpixelLayout p_font_lcd_subpixel_layout); +void update_font_hinting(TextServer::Hinting p_font_hinting); +void update_font_msdf(bool p_font_msdf); +void update_font_generate_mipmaps(bool p_font_generate_mipmaps); +void make_default_theme(Ref p_font, float p_scale = 1.f, TextServer::SubpixelPositioning p_font_subpixel = TextServer::SUBPIXEL_POSITIONING_AUTO, TextServer::Hinting p_font_hinting = TextServer::HINTING_LIGHT, TextServer::FontAntialiasing p_font_antialiased = TextServer::FONT_ANTIALIASING_GRAY, TextServer::FontLCDSubpixelLayout p_font_lcd_subpixel_layout = TextServer::FontLCDSubpixelLayout::FONT_LCD_SUBPIXEL_LAYOUT_HRGB, bool p_font_msdf = false, bool p_font_generate_mipmaps = false, Color p_base_color = Color(0.188, 0.188, 0.188), Color p_accent_color = Color(0.226, 0.478, 0.921), Color p_font_color = Color(0.875, 0.875, 0.875), Color p_font_outline_color = Color(0, 0, 0, 1), float p_contrast = -0.6f, float p_normal_contrast = 0.4f, float p_hover_contrast = -0.2f, float p_pressed_contrast = 0.6f, float p_bg_contrast = 0.2f, int p_margin = 4, int p_padding = 4, int p_border_width = 2, int p_corner_radius = 6, int p_font_size = 16, int p_font_outline_size = 0, float p_font_embolden = 0.f, int p_font_spacing_glyph = 0, int p_font_spacing_space = 0, int p_font_spacing_top = 0, int p_font_spacing_bottom = 0); + +#endif // BLAZIUM_DEFAULT_THEME_H diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp index 8784c1afdefe..51238dd9f206 100644 --- a/scene/theme/default_theme.cpp +++ b/scene/theme/default_theme.cpp @@ -44,9 +44,6 @@ #include "servers/text_server.h" #include "modules/modules_enabled.gen.h" // For svg. -#ifdef MODULE_SVG_ENABLED -#include "modules/svg/image_loader_svg.h" -#endif static const int default_font_size = 16; @@ -84,12 +81,14 @@ static Ref generate_icon(int p_index) { Ref img = memnew(Image); #ifdef MODULE_SVG_ENABLED - // Upsample icon generation only if the scale isn't an integer multiplier. - // Generating upsampled icons is slower, and the benefit is hardly visible - // with integer scales. - const bool upsample = !Math::is_equal_approx(Math::round(scale), scale); + String svg = default_theme_icons_sources[p_index]; + svg = svg.replace("\"red\"", vformat("\"#%s\"", Color(1, 1, 1).to_html(false))); + svg = svg.replace("\"#0f0\"", vformat("\"#%s\"", Color(1, 1, 1).to_html(false))); - Error err = ImageLoaderSVG::create_image_from_string(img, default_theme_icons_sources[p_index], scale, upsample, HashMap()); + Error err = img->load_svg_from_string(svg, scale); + if (err == OK) { + img->fix_alpha_edges(); + } ERR_FAIL_COND_V_MSG(err != OK, Ref(), "Failed generating icon, unsupported or invalid SVG data in default theme."); #else // If the SVG module is disabled, we can't really display the UI well, but at least we won't crash. @@ -1265,10 +1264,10 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_color("button_icon_pressed", "FoldableContainer", control_font_pressed_color); theme->set_color("button_icon_disabled", "FoldableContainer", control_font_disabled_color); - theme->set_icon("expanded_arrow", "FoldableContainer", icons["arrow_down"]); - theme->set_icon("expanded_arrow_mirrored", "FoldableContainer", icons["arrow_up"]); - theme->set_icon("folded_arrow", "FoldableContainer", icons["arrow_right"]); - theme->set_icon("folded_arrow_mirrored", "FoldableContainer", icons["arrow_left"]); + theme->set_icon("expanded_arrow", "FoldableContainer", icons["expanded_arrow"]); + theme->set_icon("expanded_arrow_mirrored", "FoldableContainer", icons["expanded_arrow_mirrored"]); + theme->set_icon("folded_arrow", "FoldableContainer", icons["folded_arrow"]); + theme->set_icon("folded_arrow_mirrored", "FoldableContainer", icons["folded_arrow_mirrored"]); theme->set_constant("outline_size", "FoldableContainer", 0); theme->set_constant("h_separation", "FoldableContainer", Math::round(2 * scale)); diff --git a/scene/theme/icons/add.svg b/scene/theme/icons/add.svg index 2dead5ea71a9..ebfb31fc2111 100644 --- a/scene/theme/icons/add.svg +++ b/scene/theme/icons/add.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/arrow_down.svg b/scene/theme/icons/arrow_down.svg index a3e9464748ae..40c47b27a6de 100644 --- a/scene/theme/icons/arrow_down.svg +++ b/scene/theme/icons/arrow_down.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/arrow_left.svg b/scene/theme/icons/arrow_left.svg index 96a3f605be8a..aa40acec770e 100644 --- a/scene/theme/icons/arrow_left.svg +++ b/scene/theme/icons/arrow_left.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/arrow_right.svg b/scene/theme/icons/arrow_right.svg index 6fc0656522dc..1ee616472ba8 100644 --- a/scene/theme/icons/arrow_right.svg +++ b/scene/theme/icons/arrow_right.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/arrow_up.svg b/scene/theme/icons/arrow_up.svg index dfd94b32bc09..0bdeb8eb09e8 100644 --- a/scene/theme/icons/arrow_up.svg +++ b/scene/theme/icons/arrow_up.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/bookmark.svg b/scene/theme/icons/bookmark.svg index c3919d38f850..8ae8192de19f 100644 --- a/scene/theme/icons/bookmark.svg +++ b/scene/theme/icons/bookmark.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/breakpoint.svg b/scene/theme/icons/breakpoint.svg index 075166f6a402..3dde6993a77d 100644 --- a/scene/theme/icons/breakpoint.svg +++ b/scene/theme/icons/breakpoint.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/checked.svg b/scene/theme/icons/checked.svg index 1ab415e7a14d..f62806e5cf60 100644 --- a/scene/theme/icons/checked.svg +++ b/scene/theme/icons/checked.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/checked_disabled.svg b/scene/theme/icons/checked_disabled.svg index 8319e808fa89..f991cd154802 100644 --- a/scene/theme/icons/checked_disabled.svg +++ b/scene/theme/icons/checked_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/close.svg b/scene/theme/icons/close.svg index 01236742310a..99949f0de7e8 100644 --- a/scene/theme/icons/close.svg +++ b/scene/theme/icons/close.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/close_hl.svg b/scene/theme/icons/close_hl.svg index 6654df80e810..11a00bc93f08 100644 --- a/scene/theme/icons/close_hl.svg +++ b/scene/theme/icons/close_hl.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/color_picker_bar_arrow.svg b/scene/theme/icons/color_picker_bar_arrow.svg index 5612ecaadccd..1fc62252f919 100644 --- a/scene/theme/icons/color_picker_bar_arrow.svg +++ b/scene/theme/icons/color_picker_bar_arrow.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/color_picker_overbright.svg b/scene/theme/icons/color_picker_overbright.svg index 7acdca1c471d..91a547ef6938 100644 --- a/scene/theme/icons/color_picker_overbright.svg +++ b/scene/theme/icons/color_picker_overbright.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/color_picker_pipette.svg b/scene/theme/icons/color_picker_pipette.svg index 3dae08eac07a..e738f60732a7 100644 --- a/scene/theme/icons/color_picker_pipette.svg +++ b/scene/theme/icons/color_picker_pipette.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/error_icon.svg b/scene/theme/icons/error_icon.svg index fef3d5f86efe..829b0745513e 100644 --- a/scene/theme/icons/error_icon.svg +++ b/scene/theme/icons/error_icon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/expanded_arrow.svg b/scene/theme/icons/expanded_arrow.svg new file mode 100644 index 000000000000..aee4404487fe --- /dev/null +++ b/scene/theme/icons/expanded_arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scene/theme/icons/expanded_arrow_mirrored.svg b/scene/theme/icons/expanded_arrow_mirrored.svg new file mode 100644 index 000000000000..b0c39716fece --- /dev/null +++ b/scene/theme/icons/expanded_arrow_mirrored.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scene/theme/icons/file.svg b/scene/theme/icons/file.svg index e8890f3968fd..39757b182f27 100644 --- a/scene/theme/icons/file.svg +++ b/scene/theme/icons/file.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/folded_arrow.svg b/scene/theme/icons/folded_arrow.svg new file mode 100644 index 000000000000..810f3cd2c77e --- /dev/null +++ b/scene/theme/icons/folded_arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scene/theme/icons/folded_arrow_mirrored.svg b/scene/theme/icons/folded_arrow_mirrored.svg new file mode 100644 index 000000000000..073b74c70f13 --- /dev/null +++ b/scene/theme/icons/folded_arrow_mirrored.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scene/theme/icons/folder.svg b/scene/theme/icons/folder.svg index 64dc9ab98b4a..9fec372865e8 100644 --- a/scene/theme/icons/folder.svg +++ b/scene/theme/icons/folder.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/folder_create.svg b/scene/theme/icons/folder_create.svg index 6c770d446b08..44244c1457ab 100644 --- a/scene/theme/icons/folder_create.svg +++ b/scene/theme/icons/folder_create.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/folder_up.svg b/scene/theme/icons/folder_up.svg index 7db5de871d2f..2cfad14a487e 100644 --- a/scene/theme/icons/folder_up.svg +++ b/scene/theme/icons/folder_up.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/graph_port.svg b/scene/theme/icons/graph_port.svg index 9d81bf1c5ba0..b08eb133c18f 100644 --- a/scene/theme/icons/graph_port.svg +++ b/scene/theme/icons/graph_port.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/grid_layout.svg b/scene/theme/icons/grid_layout.svg index 6015cd90687b..7b49d5376ffe 100644 --- a/scene/theme/icons/grid_layout.svg +++ b/scene/theme/icons/grid_layout.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/grid_minimap.svg b/scene/theme/icons/grid_minimap.svg index a2d7c9c9bbb6..6f764e49e2e2 100644 --- a/scene/theme/icons/grid_minimap.svg +++ b/scene/theme/icons/grid_minimap.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/grid_snap.svg b/scene/theme/icons/grid_snap.svg index beb4ee7b2a89..be69d6da6a4a 100644 --- a/scene/theme/icons/grid_snap.svg +++ b/scene/theme/icons/grid_snap.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/grid_toggle.svg b/scene/theme/icons/grid_toggle.svg index c4683aade1ee..ca673925988a 100644 --- a/scene/theme/icons/grid_toggle.svg +++ b/scene/theme/icons/grid_toggle.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/hslider_tick.svg b/scene/theme/icons/hslider_tick.svg index 6697632ae2a2..ef4d39b98219 100644 --- a/scene/theme/icons/hslider_tick.svg +++ b/scene/theme/icons/hslider_tick.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/indeterminate.svg b/scene/theme/icons/indeterminate.svg index f8edca3e526e..4c2614d835a8 100644 --- a/scene/theme/icons/indeterminate.svg +++ b/scene/theme/icons/indeterminate.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/indeterminate_disabled.svg b/scene/theme/icons/indeterminate_disabled.svg index 7276625eadb7..56882f6dd601 100644 --- a/scene/theme/icons/indeterminate_disabled.svg +++ b/scene/theme/icons/indeterminate_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/line_edit_clear.svg b/scene/theme/icons/line_edit_clear.svg index 01236742310a..212949690e3e 100644 --- a/scene/theme/icons/line_edit_clear.svg +++ b/scene/theme/icons/line_edit_clear.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/mini_checkerboard.svg b/scene/theme/icons/mini_checkerboard.svg index 2dd71a6addb7..4c129116a0ac 100644 --- a/scene/theme/icons/mini_checkerboard.svg +++ b/scene/theme/icons/mini_checkerboard.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/option_button_arrow.svg b/scene/theme/icons/option_button_arrow.svg index bdb27e0528d5..fa951a88ef1a 100644 --- a/scene/theme/icons/option_button_arrow.svg +++ b/scene/theme/icons/option_button_arrow.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/picker_shape_circle.svg b/scene/theme/icons/picker_shape_circle.svg index de104121c897..7785ae805bc4 100644 --- a/scene/theme/icons/picker_shape_circle.svg +++ b/scene/theme/icons/picker_shape_circle.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/picker_shape_rectangle.svg b/scene/theme/icons/picker_shape_rectangle.svg index 642b9f789dcb..f8acdf05d5be 100644 --- a/scene/theme/icons/picker_shape_rectangle.svg +++ b/scene/theme/icons/picker_shape_rectangle.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/picker_shape_rectangle_wheel.svg b/scene/theme/icons/picker_shape_rectangle_wheel.svg index e46cc4140290..32e3fe75bb17 100644 --- a/scene/theme/icons/picker_shape_rectangle_wheel.svg +++ b/scene/theme/icons/picker_shape_rectangle_wheel.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/popup_menu_arrow_left.svg b/scene/theme/icons/popup_menu_arrow_left.svg index c5c1b32da8ba..b098d8436014 100644 --- a/scene/theme/icons/popup_menu_arrow_left.svg +++ b/scene/theme/icons/popup_menu_arrow_left.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/popup_menu_arrow_right.svg b/scene/theme/icons/popup_menu_arrow_right.svg index 8741f3a3871e..064fa7ec76cd 100644 --- a/scene/theme/icons/popup_menu_arrow_right.svg +++ b/scene/theme/icons/popup_menu_arrow_right.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/radio_checked.svg b/scene/theme/icons/radio_checked.svg index 85a3d0c456f2..73fa4905d2aa 100644 --- a/scene/theme/icons/radio_checked.svg +++ b/scene/theme/icons/radio_checked.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/radio_checked_disabled.svg b/scene/theme/icons/radio_checked_disabled.svg index 30627c07cc43..93a24c5ef5b7 100644 --- a/scene/theme/icons/radio_checked_disabled.svg +++ b/scene/theme/icons/radio_checked_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/radio_unchecked.svg b/scene/theme/icons/radio_unchecked.svg index f78b678c5133..9f0a30c37d65 100644 --- a/scene/theme/icons/radio_unchecked.svg +++ b/scene/theme/icons/radio_unchecked.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/radio_unchecked_disabled.svg b/scene/theme/icons/radio_unchecked_disabled.svg index 706aa68b84a4..864e57fde6c7 100644 --- a/scene/theme/icons/radio_unchecked_disabled.svg +++ b/scene/theme/icons/radio_unchecked_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/region_folded.svg b/scene/theme/icons/region_folded.svg index 99e20678c9b2..7ede9df17601 100644 --- a/scene/theme/icons/region_folded.svg +++ b/scene/theme/icons/region_folded.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/region_unfolded.svg b/scene/theme/icons/region_unfolded.svg index 5186dd8afb4d..159804368e06 100644 --- a/scene/theme/icons/region_unfolded.svg +++ b/scene/theme/icons/region_unfolded.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/reload.svg b/scene/theme/icons/reload.svg index 7f4cef5d97c5..d278d1231701 100644 --- a/scene/theme/icons/reload.svg +++ b/scene/theme/icons/reload.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/resizer_nw.svg b/scene/theme/icons/resizer_nw.svg index a8457b14265f..393c74559965 100644 --- a/scene/theme/icons/resizer_nw.svg +++ b/scene/theme/icons/resizer_nw.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/resizer_se.svg b/scene/theme/icons/resizer_se.svg index c3b8746314e8..db7c228f6d66 100644 --- a/scene/theme/icons/resizer_se.svg +++ b/scene/theme/icons/resizer_se.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/scroll_button_left.svg b/scene/theme/icons/scroll_button_left.svg index 2a3c0e3a4a37..a6b2cff7462d 100644 --- a/scene/theme/icons/scroll_button_left.svg +++ b/scene/theme/icons/scroll_button_left.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/scroll_button_left_hl.svg b/scene/theme/icons/scroll_button_left_hl.svg index 659bf6b4c400..ab4d5b5730bf 100644 --- a/scene/theme/icons/scroll_button_left_hl.svg +++ b/scene/theme/icons/scroll_button_left_hl.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/scroll_button_right.svg b/scene/theme/icons/scroll_button_right.svg index 7736e1ef271b..225329ccaf49 100644 --- a/scene/theme/icons/scroll_button_right.svg +++ b/scene/theme/icons/scroll_button_right.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/scroll_button_right_hl.svg b/scene/theme/icons/scroll_button_right_hl.svg index b29e918253db..aca1e5450565 100644 --- a/scene/theme/icons/scroll_button_right_hl.svg +++ b/scene/theme/icons/scroll_button_right_hl.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/slider_grabber.svg b/scene/theme/icons/slider_grabber.svg index ef0a1fea8cd8..05bbab45e3a7 100644 --- a/scene/theme/icons/slider_grabber.svg +++ b/scene/theme/icons/slider_grabber.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/slider_grabber_disabled.svg b/scene/theme/icons/slider_grabber_disabled.svg index 48326fea9fed..ab10de8e1b71 100644 --- a/scene/theme/icons/slider_grabber_disabled.svg +++ b/scene/theme/icons/slider_grabber_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/slider_grabber_hl.svg b/scene/theme/icons/slider_grabber_hl.svg index 046878c9b129..a73a01e54c72 100644 --- a/scene/theme/icons/slider_grabber_hl.svg +++ b/scene/theme/icons/slider_grabber_hl.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/tabs_drop_mark.svg b/scene/theme/icons/tabs_drop_mark.svg index 104c65b8cb0f..2c69bbb77b0b 100644 --- a/scene/theme/icons/tabs_drop_mark.svg +++ b/scene/theme/icons/tabs_drop_mark.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/tabs_menu.svg b/scene/theme/icons/tabs_menu.svg index 9a70151d3924..03f414c04b0f 100644 --- a/scene/theme/icons/tabs_menu.svg +++ b/scene/theme/icons/tabs_menu.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/tabs_menu_hl.svg b/scene/theme/icons/tabs_menu_hl.svg index e55c1ad99eaf..4c14050391e1 100644 --- a/scene/theme/icons/tabs_menu_hl.svg +++ b/scene/theme/icons/tabs_menu_hl.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/text_edit_ellipsis.svg b/scene/theme/icons/text_edit_ellipsis.svg index a8e0a4e61539..61f45c0b89b2 100644 --- a/scene/theme/icons/text_edit_ellipsis.svg +++ b/scene/theme/icons/text_edit_ellipsis.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/text_edit_space.svg b/scene/theme/icons/text_edit_space.svg index 9f6a04ac50ba..e15dce104c08 100644 --- a/scene/theme/icons/text_edit_space.svg +++ b/scene/theme/icons/text_edit_space.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/text_edit_tab.svg b/scene/theme/icons/text_edit_tab.svg index e4bdf9058199..e026be46d73f 100644 --- a/scene/theme/icons/text_edit_tab.svg +++ b/scene/theme/icons/text_edit_tab.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_off.svg b/scene/theme/icons/toggle_off.svg index d58b6cdfe13b..40ef5731320a 100644 --- a/scene/theme/icons/toggle_off.svg +++ b/scene/theme/icons/toggle_off.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_off_disabled.svg b/scene/theme/icons/toggle_off_disabled.svg index 85b6aad0ea75..fb71e345d298 100644 --- a/scene/theme/icons/toggle_off_disabled.svg +++ b/scene/theme/icons/toggle_off_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_off_disabled_mirrored.svg b/scene/theme/icons/toggle_off_disabled_mirrored.svg index f65cbe60ae77..36408475c7ea 100644 --- a/scene/theme/icons/toggle_off_disabled_mirrored.svg +++ b/scene/theme/icons/toggle_off_disabled_mirrored.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_off_mirrored.svg b/scene/theme/icons/toggle_off_mirrored.svg index e24f24621c41..6f1454d72360 100644 --- a/scene/theme/icons/toggle_off_mirrored.svg +++ b/scene/theme/icons/toggle_off_mirrored.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_on.svg b/scene/theme/icons/toggle_on.svg index 4db88f2dbb95..25677592a61c 100644 --- a/scene/theme/icons/toggle_on.svg +++ b/scene/theme/icons/toggle_on.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_on_disabled.svg b/scene/theme/icons/toggle_on_disabled.svg index 622906bb2819..eaa092c4f52c 100644 --- a/scene/theme/icons/toggle_on_disabled.svg +++ b/scene/theme/icons/toggle_on_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_on_disabled_mirrored.svg b/scene/theme/icons/toggle_on_disabled_mirrored.svg index 0d444de6c4ee..27ce8ce5fc01 100644 --- a/scene/theme/icons/toggle_on_disabled_mirrored.svg +++ b/scene/theme/icons/toggle_on_disabled_mirrored.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/toggle_on_mirrored.svg b/scene/theme/icons/toggle_on_mirrored.svg index bfed6dd2063f..fe89b69bae74 100644 --- a/scene/theme/icons/toggle_on_mirrored.svg +++ b/scene/theme/icons/toggle_on_mirrored.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/unchecked.svg b/scene/theme/icons/unchecked.svg index 354df8e8c98d..42647dcf47b4 100644 --- a/scene/theme/icons/unchecked.svg +++ b/scene/theme/icons/unchecked.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/unchecked_disabled.svg b/scene/theme/icons/unchecked_disabled.svg index 4d352d744ee5..803d72b1808c 100644 --- a/scene/theme/icons/unchecked_disabled.svg +++ b/scene/theme/icons/unchecked_disabled.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/updown.svg b/scene/theme/icons/updown.svg index 4a48eb39a50a..f43087fd5edc 100644 --- a/scene/theme/icons/updown.svg +++ b/scene/theme/icons/updown.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/updown_disabled.svg b/scene/theme/icons/updown_disabled.svg new file mode 100644 index 000000000000..962790e69225 --- /dev/null +++ b/scene/theme/icons/updown_disabled.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/scene/theme/icons/value_down.svg b/scene/theme/icons/value_down.svg index 57837d03fdb1..b772ad0f4f8a 100644 --- a/scene/theme/icons/value_down.svg +++ b/scene/theme/icons/value_down.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/value_up.svg b/scene/theme/icons/value_up.svg index 53fb102fe2df..4241a5a8638a 100644 --- a/scene/theme/icons/value_up.svg +++ b/scene/theme/icons/value_up.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/visibility_visible.svg b/scene/theme/icons/visibility_visible.svg index cd826705361c..f4acd625968d 100644 --- a/scene/theme/icons/visibility_visible.svg +++ b/scene/theme/icons/visibility_visible.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/vslider_tick.svg b/scene/theme/icons/vslider_tick.svg index d1c5aa4dd695..b88ed3acb47d 100644 --- a/scene/theme/icons/vslider_tick.svg +++ b/scene/theme/icons/vslider_tick.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/zoom_less.svg b/scene/theme/icons/zoom_less.svg index eea325db42bd..1b2495233271 100644 --- a/scene/theme/icons/zoom_less.svg +++ b/scene/theme/icons/zoom_less.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/zoom_more.svg b/scene/theme/icons/zoom_more.svg index 441620e6e94a..67c91c568fe5 100644 --- a/scene/theme/icons/zoom_more.svg +++ b/scene/theme/icons/zoom_more.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/icons/zoom_reset.svg b/scene/theme/icons/zoom_reset.svg index fd35fe3c74fc..8159a89db964 100644 --- a/scene/theme/icons/zoom_reset.svg +++ b/scene/theme/icons/zoom_reset.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/scene/theme/theme_db.cpp b/scene/theme/theme_db.cpp index 3d0b2e4c384d..4f3fdd27d8d5 100644 --- a/scene/theme/theme_db.cpp +++ b/scene/theme/theme_db.cpp @@ -38,19 +38,36 @@ #include "scene/resources/font.h" #include "scene/resources/style_box.h" #include "scene/resources/texture.h" -#include "scene/theme/default_theme.h" #include "servers/text_server.h" +#ifdef USE_LEGACY_THEME +#include "scene/theme/default_theme.h" +#else +#include "scene/theme/blazium_default_theme.h" + // Default engine theme creation and configuration. +Color ThemeDB::_get_font_color() const { + Color fcolor = Color(0.875, 0.875, 0.875); + FontColorOverride fcolor_override = (FontColorOverride)(int)GLOBAL_GET("gui/theme/font_color_override"); + bool is_dark_theme = ((Color)GLOBAL_GET("gui/theme/base_color")).get_luminance() <= 0.5; + if (fcolor_override == FONT_COLOR_OVERRIDE_DARK || (fcolor_override == FONT_COLOR_OVERRIDE_AUTO && !is_dark_theme)) { + fcolor = Color(0.05, 0.05, 0.05); + } else if (fcolor_override == FONT_COLOR_OVERRIDE_CUSTOM) { + fcolor = GLOBAL_GET("gui/theme/custom_font_color"); + } + return fcolor; +} +#endif // USE_LEGACY_THEME + void ThemeDB::initialize_theme() { // Default theme-related project settings. +#ifdef USE_LEGACY_THEME // Allow creating the default theme at a different scale to suit higher/lower base resolutions. float default_theme_scale = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "gui/theme/default_theme_scale", PROPERTY_HINT_RANGE, "0.5,8,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), 1.0); - String project_theme_path = GLOBAL_DEF_RST_BASIC(PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); - String project_font_path = GLOBAL_DEF_RST_BASIC(PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.otf,*.ttf,*.woff,*.woff2,*.fnt,*.font,*.pfb,*.pfm", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); + String project_font_path = GLOBAL_DEF_RST_BASIC(PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.otf,*.ttc,*.ttf,*.woff,*.woff2,*.fnt,*.font,*.pfb,*.pfm", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); TextServer::FontAntialiasing font_antialiasing = (TextServer::FontAntialiasing)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), 1); TextServer::Hinting font_hinting = (TextServer::Hinting)(int)GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "gui/theme/default_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), TextServer::HINTING_LIGHT); @@ -59,6 +76,9 @@ void ThemeDB::initialize_theme() { const bool font_msdf = GLOBAL_DEF_RST("gui/theme/default_font_multichannel_signed_distance_field", false); const bool font_generate_mipmaps = GLOBAL_DEF_RST("gui/theme/default_font_generate_mipmaps", false); +#endif // USE_LEGACY_THEME + + String project_theme_path = GLOBAL_DEF_RST_BASIC(PropertyInfo(Variant::STRING, "gui/theme/custom", PROPERTY_HINT_FILE, "*.tres,*.res,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED), ""); // Attempt to load custom project theme and font. @@ -71,20 +91,31 @@ void ThemeDB::initialize_theme() { } } - Ref project_font; - if (!project_font_path.is_empty()) { - project_font = ResourceLoader::load(project_font_path); - if (project_font.is_valid()) { - set_fallback_font(project_font); - } else { - ERR_PRINT("Error loading custom project font '" + project_font_path + "'"); - } - } - // Always generate the default theme to serve as a fallback for all required theme definitions. +#ifdef USE_LEGACY_THEME + String custom_font = project_font_path; +#endif // USE_LEGACY_THEME + if (RenderingServer::get_singleton()) { + Ref project_font; + if (!custom_font.is_empty() && FileAccess::exists(custom_font)) { + project_font = ResourceLoader::load(custom_font); + if (project_font.is_null()) { + ERR_PRINT("Error loading custom project font '" + custom_font + "'"); + } +#ifdef USE_LEGACY_THEME + else { + set_fallback_font(project_font); + } +#endif // USE_LEGACY_THEME + } + +#ifdef USE_LEGACY_THEME make_default_theme(default_theme_scale, project_font, font_subpixel_positioning, font_hinting, font_antialiasing, lcd_subpixel_layout, font_msdf, font_generate_mipmaps); +#else + make_default_theme(project_font, scale, font_subpixel_positioning, font_hinting, font_antialiasing, font_lcd_subpixel_layout, font_msdf, font_generate_mipmaps, base_color, accent_color, _get_font_color(), font_outline_color, contrast, normal_contrast, hover_contrast, pressed_contrast, bg_contrast, margin, padding, border_width, corner_radius, font_size, font_outline_size, font_embolden, font_spacing_glyph, font_spacing_space, font_spacing_top, font_spacing_bottom); +#endif // USE_LEGACY_THEME } _init_default_theme_context(); @@ -92,7 +123,11 @@ void ThemeDB::initialize_theme() { void ThemeDB::initialize_theme_noproject() { if (RenderingServer::get_singleton()) { +#ifdef USE_LEGACY_THEME make_default_theme(1.0, Ref()); +#else + make_default_theme(Ref()); +#endif // USE_LEGACY_THEME } _init_default_theme_context(); @@ -104,6 +139,9 @@ void ThemeDB::finalize_theme() { } _finalize_theme_contexts(); +#ifndef USE_LEGACY_THEME + finalize_default_theme(); +#endif // USE_LEGACY_THEME default_theme.unref(); fallback_font.unref(); @@ -410,6 +448,239 @@ void ThemeDB::_sort_theme_items() { } } +#ifndef USE_LEGACY_THEME +void ThemeDB::_update_default_theme() { + bool update_icons = false; + bool scale_changed = false; + bool border_padding_changed = false; + bool update_colors = false; + + float _scale = GLOBAL_GET("gui/theme/default_theme_scale"); + if (default_theme->get_default_base_scale() != _scale) { + default_theme->set_default_base_scale(_scale); + scale_changed = true; + } + + Color _font_color = _get_font_color(); + if (font_color != _font_color) { + if ((font_color.get_luminance() > 0.5) != (_font_color.get_luminance() > 0.5)) { + update_colors = true; + } + font_color = _font_color; + default_theme->freeze_change_propagation(); + update_font_color(default_theme, font_color); + update_icons = true; + } + + Color _accent_color = GLOBAL_GET("gui/theme/accent_color"); + if (accent_color != _accent_color) { + accent_color = _accent_color; + update_icons = true; + update_colors = true; + } + + if (update_icons || scale_changed) { + default_theme->freeze_change_propagation(); + update_theme_icons(default_theme, font_color, accent_color); + emit_signal(SNAME("icons_changed")); + } + + Color _font_outline_color = GLOBAL_GET("gui/theme/font_outline_color"); + if (font_outline_color != _font_outline_color) { + font_outline_color = _font_outline_color; + default_theme->freeze_change_propagation(); + update_font_outline_color(default_theme, font_outline_color); + } + + int _margin = GLOBAL_GET("gui/theme/margin"); + if (margin != _margin || scale_changed) { + margin = _margin; + default_theme->freeze_change_propagation(); + update_theme_margins(default_theme, margin); + } + + int _padding = GLOBAL_GET("gui/theme/padding"); + if (padding != _padding || scale_changed) { + padding = _padding; + default_theme->freeze_change_propagation(); + update_theme_padding(default_theme, padding); + border_padding_changed = true; + } + + int _corner_radius = GLOBAL_GET("gui/theme/corner_radius"); + if (corner_radius != _corner_radius || scale_changed) { + corner_radius = _corner_radius; + default_theme->freeze_change_propagation(); + update_theme_corner_radius(default_theme, corner_radius); + } + + int _border_width = GLOBAL_GET("gui/theme/border_width"); + if (border_width != _border_width || scale_changed) { + border_width = _border_width; + default_theme->freeze_change_propagation(); + update_theme_border_width(default_theme, border_width); + border_padding_changed = true; + } + + int _font_outline_size = GLOBAL_GET("gui/theme/font_outline_size"); + if (font_outline_size != _font_outline_size || scale_changed) { + font_outline_size = _font_outline_size; + default_theme->freeze_change_propagation(); + update_font_outline_size(default_theme, font_outline_size); + } + + int _font_size = GLOBAL_GET("gui/theme/font_size"); + if (font_size != _font_size) { + font_size = _font_size; + default_theme->freeze_change_propagation(); + update_font_size(default_theme, font_size); + } + + if (border_padding_changed || scale_changed) { + default_theme->freeze_change_propagation(); + update_theme_border_padding(default_theme, border_width + padding); + } + + Color _base_color = GLOBAL_GET("gui/theme/base_color"); + if (base_color != _base_color) { + base_color = _base_color; + update_colors = true; + } + + float _contrast = GLOBAL_GET("gui/theme/contrast"); + if (contrast != _contrast) { + contrast = _contrast; + update_colors = true; + } + + float _normal_contrast = GLOBAL_GET("gui/theme/normal_contrast"); + if (normal_contrast != _normal_contrast) { + normal_contrast = _normal_contrast; + update_colors = true; + } + + float _hover_contrast = GLOBAL_GET("gui/theme/hover_contrast"); + if (hover_contrast != _hover_contrast) { + hover_contrast = _hover_contrast; + update_colors = true; + } + + float _pressed_contrast = GLOBAL_GET("gui/theme/pressed_contrast"); + if (pressed_contrast != _pressed_contrast) { + pressed_contrast = _pressed_contrast; + update_colors = true; + } + + float _bg_contrast = GLOBAL_GET("gui/theme/bg_contrast"); + if (bg_contrast != _bg_contrast) { + bg_contrast = _bg_contrast; + update_colors = true; + } + + if (update_colors) { + default_theme->freeze_change_propagation(); + update_theme_colors(default_theme, base_color, accent_color, contrast, normal_contrast, hover_contrast, pressed_contrast, bg_contrast); + } + + float _font_embolden = GLOBAL_GET("gui/theme/font_embolden"); + if (font_embolden != _font_embolden) { + font_embolden = _font_embolden; + default_theme->freeze_change_propagation(); + update_font_embolden(font_embolden); + } + + int _font_spacing_glyph = GLOBAL_GET("gui/theme/font_spacing_glyph"); + if (font_spacing_glyph != _font_spacing_glyph || scale_changed) { + font_spacing_glyph = _font_spacing_glyph; + default_theme->freeze_change_propagation(); + update_font_spacing_glyph(Math::round(font_spacing_glyph * _scale)); + } + + int _font_spacing_space = GLOBAL_GET("gui/theme/font_spacing_space"); + if (font_spacing_space != _font_spacing_space || scale_changed) { + font_spacing_space = _font_spacing_space; + default_theme->freeze_change_propagation(); + update_font_spacing_space(Math::round(font_spacing_space * _scale)); + } + + int _font_spacing_top = GLOBAL_GET("gui/theme/font_spacing_top"); + if (font_spacing_top != _font_spacing_top || scale_changed) { + font_spacing_top = _font_spacing_top; + default_theme->freeze_change_propagation(); + update_font_spacing_top(Math::round(font_spacing_top * _scale)); + } + + int _font_spacing_bottom = GLOBAL_GET("gui/theme/font_spacing_bottom"); + if (font_spacing_bottom != _font_spacing_bottom || scale_changed) { + font_spacing_bottom = _font_spacing_bottom; + default_theme->freeze_change_propagation(); + update_font_spacing_bottom(Math::round(font_spacing_bottom * _scale)); + } + + String _custom_font = GLOBAL_GET("gui/theme/custom_font"); + if (custom_font != _custom_font) { + custom_font = _custom_font; + Ref project_font; + if (!custom_font.is_empty() && FileAccess::exists(custom_font)) { + project_font = ResourceLoader::load(custom_font); + } else { + project_font = Ref(); + } + default_theme->freeze_change_propagation(); + update_theme_font(default_theme, project_font); + } + + TextServer::SubpixelPositioning _font_subpixel_positioning = (TextServer::SubpixelPositioning)(int)GLOBAL_GET("gui/theme/default_font_subpixel_positioning"); + if (font_subpixel_positioning != _font_subpixel_positioning) { + font_subpixel_positioning = _font_subpixel_positioning; + default_theme->freeze_change_propagation(); + update_font_subpixel_positioning(font_subpixel_positioning); + } + + TextServer::FontAntialiasing _font_antialiasing = (TextServer::FontAntialiasing)(int)GLOBAL_GET("gui/theme/default_font_antialiasing"); + if (font_antialiasing != _font_antialiasing) { + font_antialiasing = _font_antialiasing; + default_theme->freeze_change_propagation(); + update_font_antialiasing(font_antialiasing); + } + + TextServer::FontLCDSubpixelLayout _font_lcd_subpixel_layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_GET("gui/theme/lcd_subpixel_layout"); + if (font_lcd_subpixel_layout != _font_lcd_subpixel_layout) { + font_lcd_subpixel_layout = _font_lcd_subpixel_layout; + default_theme->freeze_change_propagation(); + update_font_lcd_subpixel_layout(font_lcd_subpixel_layout); + } + + TextServer::Hinting _font_hinting = (TextServer::Hinting)(int)GLOBAL_GET("gui/theme/default_font_hinting"); + if (font_hinting != _font_hinting) { + font_hinting = _font_hinting; + default_theme->freeze_change_propagation(); + update_font_hinting(font_hinting); + } + + bool _font_msdf = GLOBAL_GET("gui/theme/default_font_multichannel_signed_distance_field"); + if (font_msdf != _font_msdf) { + font_msdf = _font_msdf; + default_theme->freeze_change_propagation(); + update_font_msdf(font_msdf); + } + + bool _font_generate_mipmaps = GLOBAL_GET("gui/theme/default_font_generate_mipmaps"); + if (font_generate_mipmaps != _font_generate_mipmaps) { + font_generate_mipmaps = _font_generate_mipmaps; + default_theme->freeze_change_propagation(); + update_font_generate_mipmaps(font_generate_mipmaps); + } + + if (scale_changed) { + default_theme->freeze_change_propagation(); + update_theme_scale(default_theme); + } + + default_theme->unfreeze_and_propagate_changes(); +} +#endif // !USE_LEGACY_THEME + // Object methods. void ThemeDB::_bind_methods() { @@ -435,6 +706,9 @@ void ThemeDB::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback_stylebox", PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", PROPERTY_USAGE_NONE), "set_fallback_stylebox", "get_fallback_stylebox"); ADD_SIGNAL(MethodInfo("fallback_changed")); +#ifndef USE_LEGACY_THEME + ADD_SIGNAL(MethodInfo("icons_changed")); +#endif // !USE_LEGACY_THEME } // Memory management, reference, and initialization. @@ -447,8 +721,43 @@ ThemeDB *ThemeDB::get_singleton() { ThemeDB::ThemeDB() { singleton = this; +#ifndef USE_LEGACY_THEME + base_color = GLOBAL_DEF_BASIC(PropertyInfo(Variant::COLOR, "gui/theme/base_color", PROPERTY_HINT_COLOR_NO_ALPHA), Color(0.188, 0.188, 0.188)); + accent_color = GLOBAL_DEF_BASIC(PropertyInfo(Variant::COLOR, "gui/theme/accent_color", PROPERTY_HINT_COLOR_NO_ALPHA), Color(0.226, 0.478, 0.921)); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/font_color_override", PROPERTY_HINT_ENUM, "Auto,Light,Dark,Custom"), 0); + GLOBAL_DEF_BASIC(PropertyInfo(Variant::COLOR, "gui/theme/custom_font_color", PROPERTY_HINT_COLOR_NO_ALPHA), Color(0.875, 0.875, 0.875)); + font_color = _get_font_color(); + font_outline_color = GLOBAL_DEF_BASIC(PropertyInfo(Variant::COLOR, "gui/theme/font_outline_color"), Color(0, 0, 0, 1)); + contrast = GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "gui/theme/contrast", PROPERTY_HINT_RANGE, "-1.0, 1.0, 0.01"), -0.6); + normal_contrast = GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "gui/theme/normal_contrast", PROPERTY_HINT_RANGE, "-1.0, 1.0, 0.01"), 0.4); + hover_contrast = GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "gui/theme/hover_contrast", PROPERTY_HINT_RANGE, "-1.0, 1.0, 0.01"), -0.2); + pressed_contrast = GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "gui/theme/pressed_contrast", PROPERTY_HINT_RANGE, "-1.0, 1.0, 0.01"), 0.6); + bg_contrast = GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "gui/theme/bg_contrast", PROPERTY_HINT_RANGE, "-1.0, 1.0, 0.01"), 0.2); + margin = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/margin", PROPERTY_HINT_RANGE, "0, 32, 1"), 4); + padding = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/padding", PROPERTY_HINT_RANGE, "0, 32, 1"), 4); + border_width = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/border_width", PROPERTY_HINT_RANGE, "0, 32, 1"), 2); + corner_radius = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/corner_radius", PROPERTY_HINT_RANGE, "0, 32, 1"), 6); + font_size = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/font_size", PROPERTY_HINT_RANGE, "0, 64, 1"), 16); + font_outline_size = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/font_outline_size", PROPERTY_HINT_RANGE, "0, 64, 1"), 0); + font_embolden = GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "gui/theme/font_embolden", PROPERTY_HINT_RANGE, "-2.0, 2.0, 0.01"), 0.0); + font_spacing_glyph = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/font_spacing_glyph", PROPERTY_HINT_RANGE, "-64, 64, 1"), 0); + font_spacing_space = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/font_spacing_space", PROPERTY_HINT_RANGE, "-64, 64, 1"), 0); + font_spacing_top = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/font_spacing_top", PROPERTY_HINT_RANGE, "-64, 64, 1"), 0); + font_spacing_bottom = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/font_spacing_bottom", PROPERTY_HINT_RANGE, "-64, 64, 1"), 0); + scale = GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "gui/theme/default_theme_scale", PROPERTY_HINT_RANGE, "0.5,8,0.01"), 1.0); + custom_font = GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.otf,*.ttf,*.ttc,*.woff,*.woff2,*.fnt,*.font,*.pfb,*.pfm"), ""); + font_subpixel_positioning = (TextServer::SubpixelPositioning)(int)GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/default_font_subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One Half of a Pixel,One Quarter of a Pixel"), TextServer::SUBPIXEL_POSITIONING_AUTO); + font_antialiasing = (TextServer::FontAntialiasing)(int)GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/default_font_antialiasing", PROPERTY_HINT_ENUM, "None,Grayscale,LCD Subpixel"), 1); + font_lcd_subpixel_layout = (TextServer::FontLCDSubpixelLayout)(int)GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/lcd_subpixel_layout", PROPERTY_HINT_ENUM, "Disabled,Horizontal RGB,Horizontal BGR,Vertical RGB,Vertical BGR"), 1); + font_hinting = (TextServer::Hinting)(int)GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "gui/theme/default_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), TextServer::HINTING_LIGHT); + font_msdf = GLOBAL_DEF_BASIC("gui/theme/default_font_multichannel_signed_distance_field", false); + font_generate_mipmaps = GLOBAL_DEF_BASIC("gui/theme/default_font_generate_mipmaps", false); +#endif // !USE_LEGACY_THEME if (MessageQueue::get_singleton()) { // May not exist in tests etc. callable_mp(this, &ThemeDB::_sort_theme_items).call_deferred(); +#ifndef USE_LEGACY_THEME + ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ThemeDB::_update_default_theme)); +#endif // !USE_LEGACY_THEME } } @@ -458,6 +767,9 @@ ThemeDB::~ThemeDB() { // frees any objects that can be recreated by initialize_theme*(). _finalize_theme_contexts(); +#ifndef USE_LEGACY_THEME + finalize_default_theme(); +#endif // !USE_LEGACY_THEME default_theme.unref(); project_theme.unref(); diff --git a/scene/theme/theme_db.h b/scene/theme/theme_db.h index 353894f41e47..2328a3d8bfac 100644 --- a/scene/theme/theme_db.h +++ b/scene/theme/theme_db.h @@ -80,6 +80,47 @@ class ThemeDB : public Object { Ref default_theme; Ref project_theme; +#ifndef USE_LEGACY_THEME + // Global Theme resources used by the default theme context. + enum FontColorOverride { + FONT_COLOR_OVERRIDE_AUTO, + FONT_COLOR_OVERRIDE_LIGHT, + FONT_COLOR_OVERRIDE_DARK, + FONT_COLOR_OVERRIDE_CUSTOM + }; + + Color _get_font_color() const; + + Color base_color; + Color accent_color; + Color font_color; + Color font_outline_color; + float contrast; + float normal_contrast; + float hover_contrast; + float pressed_contrast; + float bg_contrast; + int margin; + int padding; + int border_width; + int corner_radius; + int font_size; + int font_outline_size; + float font_embolden; + int font_spacing_glyph; + int font_spacing_space; + int font_spacing_top; + int font_spacing_bottom; + float scale; + String custom_font; + TextServer::SubpixelPositioning font_subpixel_positioning; + TextServer::FontLCDSubpixelLayout font_lcd_subpixel_layout; + TextServer::FontAntialiasing font_antialiasing; + TextServer::Hinting font_hinting; + bool font_msdf; + bool font_generate_mipmaps; +#endif // !USE_LEGACY_THEME + // Universal default values, final fallback for every theme. float fallback_base_scale = 1.0; @@ -124,6 +165,10 @@ class ThemeDB : public Object { void _sort_theme_items(); +#ifndef USE_LEGACY_THEME + void _update_default_theme(); +#endif // !USE_LEGACY_THEME + protected: static void _bind_methods(); diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index 9ec1b812dfc4..07fa5c673258 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -4492,6 +4492,9 @@ TEST_CASE("[SceneTree][CodeEdit] symbol lookup") { Point2 caret_pos = code_edit->get_caret_draw_pos(); caret_pos.x += 60; +#ifndef USE_LEGACY_THEME + caret_pos.x += 2; +#endif // !USE_LEGACY_THEME SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::NONE, 0, Key::NONE); CHECK(code_edit->get_text_for_symbol_lookup() == "this is s" + String::chr(0xFFFF) + "ome text"); diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h index bf20eee3cf82..ebe296ade500 100644 --- a/tests/scene/test_text_edit.h +++ b/tests/scene/test_text_edit.h @@ -6443,7 +6443,11 @@ TEST_CASE("[SceneTree][TextEdit] mouse") { TextEdit *text_edit = memnew(TextEdit); SceneTree::get_singleton()->get_root()->add_child(text_edit); +#ifdef USE_LEGACY_THEME text_edit->set_size(Size2(800, 200)); +#else + text_edit->set_size(Size2(804, 200)); +#endif //USE_LEGACY_THEME CHECK(text_edit->get_rect_at_line_column(0, 0).get_position() == Point2i(0, 0)); @@ -6474,7 +6478,11 @@ TEST_CASE("[SceneTree][TextEdit] mouse") { // Add method to get drawn column count? Point2i start_pos = text_edit->get_pos_at_line_column(0, 0); +#ifdef USE_LEGACY_THEME + Point2i end_pos = text_edit->get_pos_at_line_column(0, 104); +#else Point2i end_pos = text_edit->get_pos_at_line_column(0, 105); +#endif // USE_LEGACY_THEME CHECK(text_edit->get_line_column_at_pos(Point2i(start_pos.x, start_pos.y)) == Point2i(0, 0)); CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y)) == Point2i(104, 0)); @@ -7167,7 +7175,13 @@ TEST_CASE("[SceneTree][TextEdit] multicaret") { CHECK(text_edit->get_caret_column(1) == 0); text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); + +#ifdef USE_LEGACY_THEME text_edit->set_size(Size2(50, 100)); +#else + text_edit->set_size(Size2(54, 104)); +#endif //USE_LEGACY_THEME + // Line wraps: `\t,this, is\nso,me\n\t,test, ,text`. CHECK(text_edit->is_line_wrapped(0)); MessageQueue::get_singleton()->flush(); @@ -7330,7 +7344,12 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { SceneTree::get_singleton()->get_root()->add_child(text_edit); // No subcases here for performance. +#ifdef USE_LEGACY_THEME text_edit->set_size(Size2(800, 600)); +#else + text_edit->set_size(Size2(804, 604)); +#endif // USE_LEGACY_THEME + for (int i = 0; i < 50; i++) { text_edit->insert_line_at(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); }