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 a new theme for the Android and XR editor #99246

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions core/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ class OS {
// This is invoked by the GDExtensionManager after loading GDExtensions specified by the project.
virtual void load_platform_gdextensions() const {}

// Allows the platform to customize the editor theme.
// Should return a path to a theme resource that will be merged with the current editor theme.
virtual String get_editor_theme_override(const String &p_editor_theme_preset) { return String(); }

OS();
virtual ~OS();
};
Expand Down
16 changes: 8 additions & 8 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1024,12 +1024,20 @@
The saturation to use for editor icons. Higher values result in more vibrant colors.
[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].
</member>
<member name="interface/theme/increase_scrollbar_touch_area" type="bool" setter="" getter="">
If [code]true[/code], increases the scrollbar touch area to improve usability on touchscreen devices.
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
</member>
<member name="interface/theme/preset" type="String" setter="" getter="">
The editor theme preset to use.
</member>
<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/scale_gizmo_handles" type="float" setter="" getter="">
Specify the multiplier to apply to the scale for the editor gizmo handles to improve usability on touchscreen devices.
[b]Note:[/b] Defaults to [code]1[/code] on non-touchscreen devices.
</member>
<member name="interface/theme/spacing_preset" type="String" setter="" getter="">
The editor theme spacing preset to use. See also [member interface/theme/base_spacing] and [member interface/theme/additional_spacing].
</member>
Expand All @@ -1045,14 +1053,6 @@
If [code]true[/code], enable two finger pan and scale gestures on touchscreen devices.
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
</member>
<member name="interface/touchscreen/increase_scrollbar_touch_area" type="bool" setter="" getter="">
If [code]true[/code], increases the scrollbar touch area to improve usability on touchscreen devices.
[b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices.
</member>
<member name="interface/touchscreen/scale_gizmo_handles" type="float" setter="" getter="">
Specify the multiplier to apply to the scale for the editor gizmo handles to improve usability on touchscreen devices.
[b]Note:[/b] Defaults to [code]1[/code] on non-touchscreen devices.
</member>
<member name="network/connection/engine_version_update_mode" type="int" setter="" getter="">
Specifies how the engine should check for updates.
- [b]Disable Update Checks[/b] will block the engine from checking updates (see also [member network/connection/network_mode]).
Expand Down
20 changes: 13 additions & 7 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,16 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
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")

// Theme
bool has_touchscreen_ui = DisplayServer::get_singleton()->is_touchscreen_available();
bool is_native_touchscreen = has_touchscreen_ui && !OS::get_singleton()->has_feature("xr_editor");

EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_ENUM, "interface/theme/follow_system_theme", false, "")
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")

String default_theme_preset = "Default";
#ifdef ANDROID_ENABLED
default_theme_preset = "Android";
#endif
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")
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/spacing_preset", "Default", "Compact,Default,Spacious,Custom")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/theme/icon_and_font_color", 0, "Auto,Dark,Light")
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "interface/theme/base_color", Color(0.2, 0.23, 0.31), "")
Expand All @@ -552,21 +560,19 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/corner_radius", 3, "0,6,1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/base_spacing", 4, "0,8,1")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/additional_spacing", 0, "0,8,1")
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/theme/increase_scrollbar_touch_area", is_native_touchscreen, "")
set_restart_if_changed("interface/theme/increase_scrollbar_touch_area", true);
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/theme/scale_gizmo_handles", has_touchscreen_ui ? 3 : 1, "1,5,1")
set_restart_if_changed("interface/theme/scale_gizmo_handles", true);
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
bool has_touchscreen_ui = DisplayServer::get_singleton()->is_touchscreen_available();
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_pan_and_scale_gestures", has_touchscreen_ui, "")
set_restart_if_changed("interface/touchscreen/enable_pan_and_scale_gestures", true);
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/touchscreen/scale_gizmo_handles", has_touchscreen_ui ? 3 : 1, "1,5,1")
set_restart_if_changed("interface/touchscreen/scale_gizmo_handles", true);

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

// Scene tabs
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/scene_tabs/display_close_button", 1, "Never,If Tab Active,Always"); // TabBar::CloseButtonDisplayPolicy
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/curve_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void CurveEdit::_notification(int p_what) {
}
} break;
case NOTIFICATION_THEME_CHANGED: {
float gizmo_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
float gizmo_scale = EDITOR_GET("interface/theme/scale_gizmo_handles");
point_radius = Math::round(BASE_POINT_RADIUS * get_theme_default_base_scale() * gizmo_scale);
hover_radius = Math::round(BASE_HOVER_RADIUS * get_theme_default_base_scale() * gizmo_scale);
tangent_radius = Math::round(BASE_TANGENT_RADIUS * get_theme_default_base_scale() * gizmo_scale);
Expand Down
23 changes: 20 additions & 3 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
config.relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
config.thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
config.class_icon_size = 16 * EDSCALE;
config.increase_scrollbar_touch_area = EDITOR_GET("interface/touchscreen/increase_scrollbar_touch_area");
config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
config.increase_scrollbar_touch_area = EDITOR_GET("interface/theme/increase_scrollbar_touch_area");
config.gizmo_handle_scale = EDITOR_GET("interface/theme/scale_gizmo_handles");
config.color_picker_button_height = 28 * EDSCALE;
config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint");

Expand Down Expand Up @@ -282,9 +282,15 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
Color preset_base_color;
float preset_contrast = 0;
bool preset_draw_extra_borders = false;
float preset_icon_saturation = config.icon_saturation;

// Please use alphabetical order if you're adding a new theme here.
if (config.preset == "Breeze Dark") {
if (config.preset == "Android") {
preset_accent_color = Color(0.34, 0.62, 1.00);
preset_base_color = Color(0.15, 0.15, 0.15);
preset_contrast = 0.3;
preset_icon_saturation = 2;
} else if (config.preset == "Breeze Dark") {
preset_accent_color = Color(0.26, 0.76, 1.00);
preset_base_color = Color(0.24, 0.26, 0.28);
preset_contrast = config.default_contrast;
Expand Down Expand Up @@ -326,11 +332,13 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
config.base_color = preset_base_color;
config.contrast = preset_contrast;
config.draw_extra_borders = preset_draw_extra_borders;
config.icon_saturation = preset_icon_saturation;

EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", config.accent_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", config.base_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", config.contrast);
EditorSettings::get_singleton()->set_initial_value("interface/theme/draw_extra_borders", config.draw_extra_borders);
EditorSettings::get_singleton()->set_initial_value("interface/theme/icon_saturation", config.icon_saturation);
}

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

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

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

const String platform_theme_override_path = OS::get_singleton()->get_editor_theme_override(EDITOR_GET("interface/theme/preset"));
if (!platform_theme_override_path.is_empty()) {
Ref<Theme> platform_theme_override = ResourceLoader::load(platform_theme_override_path);
if (platform_theme_override.is_valid()) {
theme->merge_with(platform_theme_override);
}
}

const String custom_theme_path = EDITOR_GET("interface/theme/custom_theme");
if (!custom_theme_path.is_empty()) {
Ref<Theme> custom_theme = ResourceLoader::load(custom_theme_path);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Godot Minimal Theme
- Source: https://github.com/passivestar/godot-minimal-theme
- Version: https://github.com/passivestar/godot-minimal-theme/releases/tag/2.0.1
Loading