Skip to content

Commit 5b2d323

Browse files
committed
Add support for platform's customization of the editor theme
Adds a new theme for the Android and XR editor based off https://github.com/passivestar/godot-minimal-theme
1 parent 2582793 commit 5b2d323

File tree

9 files changed

+786
-19
lines changed

9 files changed

+786
-19
lines changed

core/os/os.h

+4
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ class OS {
359359
// This is invoked by the GDExtensionManager after loading GDExtensions specified by the project.
360360
virtual void load_platform_gdextensions() const {}
361361

362+
// Allows the platform to customize the editor theme.
363+
// Should return a path to a theme resource that will be merged with the current editor theme.
364+
virtual String get_editor_theme_override(const String &p_editor_theme_preset) { return String(); }
365+
362366
OS();
363367
virtual ~OS();
364368
};

doc/classes/EditorSettings.xml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1024,12 +1024,20 @@
10241024
The saturation to use for editor icons. Higher values result in more vibrant colors.
10251025
[b]Note:[/b] The default editor icon saturation was increased by 30% in Godot 4.0 and later. To get Godot 3.x's icon saturation back, set [member interface/theme/icon_saturation] to [code]0.77[/code].
10261026
</member>
1027+
<member name="interface/theme/increase_scrollbar_touch_area" type="bool" setter="" getter="">
1028+
If [code]true[/code], increases the scrollbar touch area to improve usability on touchscreen devices.
1029+
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
1030+
</member>
10271031
<member name="interface/theme/preset" type="String" setter="" getter="">
10281032
The editor theme preset to use.
10291033
</member>
10301034
<member name="interface/theme/relationship_line_opacity" type="float" setter="" getter="">
10311035
The opacity to use when drawing relationship lines in the editor's [Tree]-based GUIs (such as the Scene tree dock).
10321036
</member>
1037+
<member name="interface/theme/scale_gizmo_handles" type="float" setter="" getter="">
1038+
Specify the multiplier to apply to the scale for the editor gizmo handles to improve usability on touchscreen devices.
1039+
[b]Note:[/b] Defaults to [code]1[/code] on non-touchscreen devices.
1040+
</member>
10331041
<member name="interface/theme/spacing_preset" type="String" setter="" getter="">
10341042
The editor theme spacing preset to use. See also [member interface/theme/base_spacing] and [member interface/theme/additional_spacing].
10351043
</member>
@@ -1045,14 +1053,6 @@
10451053
If [code]true[/code], enable two finger pan and scale gestures on touchscreen devices.
10461054
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
10471055
</member>
1048-
<member name="interface/touchscreen/increase_scrollbar_touch_area" type="bool" setter="" getter="">
1049-
If [code]true[/code], increases the scrollbar touch area to improve usability on touchscreen devices.
1050-
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
1051-
</member>
1052-
<member name="interface/touchscreen/scale_gizmo_handles" type="float" setter="" getter="">
1053-
Specify the multiplier to apply to the scale for the editor gizmo handles to improve usability on touchscreen devices.
1054-
[b]Note:[/b] Defaults to [code]1[/code] on non-touchscreen devices.
1055-
</member>
10561056
<member name="network/connection/engine_version_update_mode" type="int" setter="" getter="">
10571057
Specifies how the engine should check for updates.
10581058
- [b]Disable Update Checks[/b] will block the engine from checking updates (see also [member network/connection/network_mode]).

editor/editor_settings.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,16 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
537537
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "interface/inspector/default_color_picker_shape", (int32_t)ColorPicker::SHAPE_OKHSL_CIRCLE, "HSV Rectangle,HSV Rectangle Wheel,VHS Circle,OKHSL Circle")
538538

539539
// Theme
540+
bool has_touchscreen_ui = DisplayServer::get_singleton()->is_touchscreen_available();
541+
bool is_native_touchscreen = has_touchscreen_ui && !OS::get_singleton()->has_feature("xr_editor");
542+
540543
EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_ENUM, "interface/theme/follow_system_theme", false, "")
541-
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/preset", "Default", "Default,Breeze Dark,Godot 2,Gray,Light,Solarized (Dark),Solarized (Light),Black (OLED),Custom")
544+
545+
String default_theme_preset = "Default";
546+
#ifdef ANDROID_ENABLED
547+
default_theme_preset = "Android";
548+
#endif
549+
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/preset", default_theme_preset, "Default,Breeze Dark,Godot 2,Gray,Light,Solarized (Dark),Solarized (Light),Black (OLED),Custom,Android")
542550
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/spacing_preset", "Default", "Compact,Default,Spacious,Custom")
543551
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/theme/icon_and_font_color", 0, "Auto,Dark,Light")
544552
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "interface/theme/base_color", Color(0.2, 0.23, 0.31), "")
@@ -552,21 +560,19 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
552560
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/corner_radius", 3, "0,6,1")
553561
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/base_spacing", 4, "0,8,1")
554562
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/additional_spacing", 0, "0,8,1")
563+
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/theme/increase_scrollbar_touch_area", is_native_touchscreen, "")
564+
set_restart_if_changed("interface/theme/increase_scrollbar_touch_area", true);
565+
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/theme/scale_gizmo_handles", has_touchscreen_ui ? 3 : 1, "1,5,1")
566+
set_restart_if_changed("interface/theme/scale_gizmo_handles", true);
555567
EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/theme/custom_theme", "", "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)
556568

557569
// Touchscreen
558-
bool has_touchscreen_ui = DisplayServer::get_singleton()->is_touchscreen_available();
559570
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_pan_and_scale_gestures", has_touchscreen_ui, "")
560571
set_restart_if_changed("interface/touchscreen/enable_pan_and_scale_gestures", true);
561-
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/touchscreen/scale_gizmo_handles", has_touchscreen_ui ? 3 : 1, "1,5,1")
562-
set_restart_if_changed("interface/touchscreen/scale_gizmo_handles", true);
563572

564573
// Disable some touchscreen settings by default for the XR Editor.
565-
bool is_native_touchscreen = has_touchscreen_ui && !OS::get_singleton()->has_feature("xr_editor");
566574
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_long_press_as_right_click", is_native_touchscreen, "")
567575
set_restart_if_changed("interface/touchscreen/enable_long_press_as_right_click", true);
568-
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/increase_scrollbar_touch_area", is_native_touchscreen, "")
569-
set_restart_if_changed("interface/touchscreen/increase_scrollbar_touch_area", true);
570576

571577
// Scene tabs
572578
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/scene_tabs/display_close_button", 1, "Never,If Tab Active,Always"); // TabBar::CloseButtonDisplayPolicy

editor/plugins/curve_editor_plugin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void CurveEdit::_notification(int p_what) {
121121
}
122122
} break;
123123
case NOTIFICATION_THEME_CHANGED: {
124-
float gizmo_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
124+
float gizmo_scale = EDITOR_GET("interface/theme/scale_gizmo_handles");
125125
point_radius = Math::round(BASE_POINT_RADIUS * get_theme_default_base_scale() * gizmo_scale);
126126
hover_radius = Math::round(BASE_HOVER_RADIUS * get_theme_default_base_scale() * gizmo_scale);
127127
tangent_radius = Math::round(BASE_TANGENT_RADIUS * get_theme_default_base_scale() * gizmo_scale);

editor/themes/editor_theme_manager.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
245245
config.relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
246246
config.thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
247247
config.class_icon_size = 16 * EDSCALE;
248-
config.increase_scrollbar_touch_area = EDITOR_GET("interface/touchscreen/increase_scrollbar_touch_area");
249-
config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
248+
config.increase_scrollbar_touch_area = EDITOR_GET("interface/theme/increase_scrollbar_touch_area");
249+
config.gizmo_handle_scale = EDITOR_GET("interface/theme/scale_gizmo_handles");
250250
config.color_picker_button_height = 28 * EDSCALE;
251251
config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint");
252252

@@ -282,9 +282,15 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
282282
Color preset_base_color;
283283
float preset_contrast = 0;
284284
bool preset_draw_extra_borders = false;
285+
float preset_icon_saturation = config.icon_saturation;
285286

286287
// Please use alphabetical order if you're adding a new theme here.
287-
if (config.preset == "Breeze Dark") {
288+
if (config.preset == "Android") {
289+
preset_accent_color = Color(0.34, 0.62, 1.00);
290+
preset_base_color = Color(0.15, 0.15, 0.15);
291+
preset_contrast = 0.3;
292+
preset_icon_saturation = 2;
293+
} else if (config.preset == "Breeze Dark") {
288294
preset_accent_color = Color(0.26, 0.76, 1.00);
289295
preset_base_color = Color(0.24, 0.26, 0.28);
290296
preset_contrast = config.default_contrast;
@@ -326,11 +332,13 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
326332
config.base_color = preset_base_color;
327333
config.contrast = preset_contrast;
328334
config.draw_extra_borders = preset_draw_extra_borders;
335+
config.icon_saturation = preset_icon_saturation;
329336

330337
EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", config.accent_color);
331338
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", config.base_color);
332339
EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", config.contrast);
333340
EditorSettings::get_singleton()->set_initial_value("interface/theme/draw_extra_borders", config.draw_extra_borders);
341+
EditorSettings::get_singleton()->set_initial_value("interface/theme/icon_saturation", config.icon_saturation);
334342
}
335343

336344
if (follow_system_theme && system_base_color != Color(0, 0, 0, 0)) {
@@ -349,6 +357,7 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
349357
EditorSettings::get_singleton()->set_manually("interface/theme/base_color", config.base_color);
350358
EditorSettings::get_singleton()->set_manually("interface/theme/contrast", config.contrast);
351359
EditorSettings::get_singleton()->set_manually("interface/theme/draw_extra_borders", config.draw_extra_borders);
360+
EditorSettings::get_singleton()->set_manually("interface/theme/icon_saturation", config.icon_saturation);
352361
}
353362

354363
// Handle theme spacing preset.
@@ -2770,6 +2779,14 @@ Ref<EditorTheme> EditorThemeManager::generate_theme(const Ref<EditorTheme> &p_ol
27702779

27712780
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Merge Custom Theme");
27722781

2782+
const String platform_theme_override_path = OS::get_singleton()->get_editor_theme_override(EDITOR_GET("interface/theme/preset"));
2783+
if (!platform_theme_override_path.is_empty()) {
2784+
Ref<Theme> platform_theme_override = ResourceLoader::load(platform_theme_override_path);
2785+
if (platform_theme_override.is_valid()) {
2786+
theme->merge_with(platform_theme_override);
2787+
}
2788+
}
2789+
27732790
const String custom_theme_path = EDITOR_GET("interface/theme/custom_theme");
27742791
if (!custom_theme_path.is_empty()) {
27752792
Ref<Theme> custom_theme = ResourceLoader::load(custom_theme_path);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Godot Minimal Theme
2+
- Source: https://github.com/passivestar/godot-minimal-theme
3+
- Version: https://github.com/passivestar/godot-minimal-theme/releases/tag/2.0.1

0 commit comments

Comments
 (0)