Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface/theme/{window_border_margin,top_bar_separation,default_margin_size} editor settings #86363

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,9 @@
<member name="interface/theme/custom_theme" type="String" setter="" getter="">
The custom theme resource to use for the editor. Must be a Godot theme resource in [code].tres[/code] or [code].res[/code] format.
</member>
<member name="interface/theme/default_margin_size" type="int" setter="" getter="">
Sets the default margin size for components used in the editor.
</member>
<member name="interface/theme/draw_extra_borders" type="bool" setter="" getter="">
If [code]true[/code], draws additional borders around interactive UI elements in the editor. This is automatically enabled when using the [b]Black (OLED)[/b] theme preset, as this theme preset uses a fully black background.
</member>
Expand All @@ -684,6 +687,12 @@
<member name="interface/theme/relationship_line_opacity" type="float" setter="" getter="">
The opacity to use when drawing relationship lines in the editor's [Tree]-based GUIs (such as the Scene tree dock).
</member>
<member name="interface/theme/top_bar_separation" type="int" setter="" getter="">
The margin between the top bar and the rest of the editor.
</member>
<member name="interface/theme/window_border_margin" type="int" setter="" getter="">
The margins between the window border and the content of an editor window.
</member>
<member name="interface/touchscreen/enable_long_press_as_right_click" type="bool" setter="" getter="">
If [code]true[/code], long press on touchscreen is treated as right click.
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
Expand Down
3 changes: 3 additions & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/border_size", 0, "0,2,1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/corner_radius", 3, "0,6,1")
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/theme/additional_spacing", 0.0, "0,5,0.1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/default_margin_size", 4, "0,16,1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/window_border_margin", 8, "0,100,1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/top_bar_separation", 8, "0,100,1")
EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/theme/custom_theme", "", "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)

// Touchscreen
Expand Down
8 changes: 5 additions & 3 deletions editor/editor_themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,15 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
}

const int thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");

theme->set_constant("scale", EditorStringName(Editor), EDSCALE);
theme->set_constant("thumb_size", EditorStringName(Editor), thumb_size);
theme->set_constant("class_icon_size", EditorStringName(Editor), 16 * EDSCALE);
theme->set_constant("dark_theme", EditorStringName(Editor), dark_theme);
theme->set_constant("color_picker_button_height", EditorStringName(Editor), 28 * EDSCALE);
theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), gizmo_handle_scale);
theme->set_constant("window_border_margin", EditorStringName(Editor), 8);
theme->set_constant("top_bar_separation", EditorStringName(Editor), 8 * EDSCALE);
theme->set_constant("window_border_margin", EditorStringName(Editor), (int)EDITOR_GET("interface/theme/window_border_margin"));
theme->set_constant("top_bar_separation", EditorStringName(Editor), (int)EDITOR_GET("interface/theme/top_bar_separation") * EDSCALE);

// Register editor icons.
// If the settings are comparable to the old theme, then just copy them over.
Expand Down Expand Up @@ -800,7 +801,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// Ensure borders are visible when using an editor scale below 100%.
const int border_width = CLAMP(border_size, 0, 2) * MAX(1, EDSCALE);
const int corner_width = CLAMP(corner_radius, 0, 6);
const int default_margin_size = 4;
int default_margin_size = EDITOR_GET("interface/theme/default_margin_size");

const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 2);

// Styleboxes
Expand Down
Loading