Skip to content

Commit

Permalink
Merge pull request godotengine#87085 from YuriSizov/editor-improved-t…
Browse files Browse the repository at this point in the history
…heme-flexibility

Refactor editor theme generation and add spacing presets
  • Loading branch information
akien-mga authored Jan 16, 2024
2 parents 6bb89c7 + dc3b07e commit 4b55c81
Show file tree
Hide file tree
Showing 173 changed files with 3,357 additions and 2,693 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ doc_classes/* @godotengine/documentation
# Editor

/editor/*debugger* @godotengine/debugger
/editor/gui/ @godotengine/usability @godotengine/gui-nodes
/editor/icons/ @godotengine/usability
/editor/import/ @godotengine/import
/editor/plugins/*2d_*.* @godotengine/2d-editor
/editor/plugins/*3d_*.* @godotengine/3d-editor
/editor/plugins/script_*.* @godotengine/script-editor
/editor/plugins/*shader*.* @godotengine/shaders
/editor/themes/ @godotengine/usability @godotengine/gui-nodes
/editor/code_editor.* @godotengine/script-editor
/editor/*dock*.* @godotengine/docks
/editor/*shader*.* @godotengine/shaders
Expand Down
11 changes: 9 additions & 2 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,16 @@
<member name="interface/theme/accent_color" type="Color" setter="" getter="">
The color to use for "highlighted" user interface elements in the editor (pressed and hovered items).
</member>
<member name="interface/theme/additional_spacing" type="float" setter="" getter="">
The spacing to add for buttons and list items in the editor (in pixels). Increasing this value is useful to improve usability on touch screens, at the cost of reducing the amount of usable screen real estate.
<member name="interface/theme/additional_spacing" type="int" setter="" getter="">
The extra spacing to add to various GUI elements in the editor (in pixels). Increasing this value is useful to improve usability on touch screens, at the cost of reducing the amount of usable screen real estate.
See also [member interface/theme/spacing_preset].
</member>
<member name="interface/theme/base_color" type="Color" setter="" getter="">
The base color to use for user interface elements in the editor. Secondary colors (such as darker/lighter variants) are derived from this color.
</member>
<member name="interface/theme/base_spacing" type="int" setter="" getter="">
The base spacing used by various GUI elements in the editor (in pixels). See also [member interface/theme/spacing_preset].
</member>
<member name="interface/theme/border_size" type="int" setter="" getter="">
The border size to use for interface elements (in pixels).
</member>
Expand Down Expand Up @@ -699,6 +703,9 @@
<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/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>
<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
14 changes: 1 addition & 13 deletions editor/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,6 @@ if env.editor_build:
env.Run(editor_builders.make_doc_translations_header, "Generating translations header."),
)

# Fonts
flist = glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.ttf")
flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.otf"))
flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff"))
flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff2"))
flist.sort()
env.Depends("#editor/builtin_fonts.gen.h", flist)
env.CommandNoCache(
"#editor/builtin_fonts.gen.h",
flist,
env.Run(editor_builders.make_fonts_header, "Generating builtin fonts header."),
)

env.add_source_files(env.editor_sources, "*.cpp")
env.add_source_files(env.editor_sources, "register_exporters.gen.cpp")

Expand All @@ -126,6 +113,7 @@ if env.editor_build:
SConscript("icons/SCsub")
SConscript("import/SCsub")
SConscript("plugins/SCsub")
SConscript("themes/SCsub")

lib = env.add_library("editor", env.editor_sources)
env.Prepend(LIBS=[lib])
2 changes: 1 addition & 1 deletion editor/action_map_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

#include "editor/action_map_editor.h"

#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/event_listener_line_edit.h"
#include "editor/input_event_configuration_dialog.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/check_button.h"
#include "scene/gui/separator.h"
#include "scene/gui/tree.h"
Expand Down
4 changes: 2 additions & 2 deletions editor/animation_bezier_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#include "animation_bezier_editor.h"

#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/view_panner.h"
#include "scene/resources/text_line.h"

Expand Down Expand Up @@ -334,7 +334,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
}
}

Color dc = get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor));
Color dc = get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor));

Ref<Texture2D> remove = get_editor_theme_icon(SNAME("Remove"));
float remove_hpos = limit - hsep - remove->get_width();
Expand Down
4 changes: 2 additions & 2 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
#include "core/input/input.h"
#include "editor/animation_bezier_editor.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_spin_slider.h"
#include "editor/gui/scene_tree_editor.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/themes/editor_scale.h"
#include "scene/animation/animation_player.h"
#include "scene/animation/tween.h"
#include "scene/gui/check_box.h"
Expand Down Expand Up @@ -1921,7 +1921,7 @@ void AnimationTrackEdit::_notification(int p_what) {
Color linecolor = color;
linecolor.a = 0.2;

Color dc = get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor));
Color dc = get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor));

// NAMES AND ICONS //

Expand Down
2 changes: 1 addition & 1 deletion editor/animation_track_editor_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

#include "editor/audio_stream_preview.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/themes/editor_scale.h"
#include "scene/2d/animated_sprite_2d.h"
#include "scene/2d/sprite_2d.h"
#include "scene/3d/sprite_3d.h"
Expand Down
2 changes: 1 addition & 1 deletion editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
#include "core/os/keyboard.h"
#include "core/string/string_builder.h"
#include "core/templates/pair.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor/themes/editor_scale.h"
#include "scene/resources/font.h"

void GotoLineDialog::popup_find_line(CodeEdit *p_edit) {
Expand Down
2 changes: 1 addition & 1 deletion editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
#include "editor/editor_help.h"
#include "editor/editor_inspector.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/scene_tree_editor.h"
#include "editor/node_dock.h"
#include "editor/scene_tree_dock.h"
#include "editor/themes/editor_scale.h"
#include "plugins/script_editor_plugin.h"
#include "scene/gui/button.h"
#include "scene/gui/check_box.h"
Expand Down
4 changes: 2 additions & 2 deletions editor/create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#include "editor/editor_feature_profile.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"

void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const String &p_current_type, const String &p_current_name) {
_fill_type_list();
Expand Down Expand Up @@ -306,7 +306,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String

r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type));
if (!instantiable) {
r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor)));
r_item->set_custom_color(0, search_options->get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor)));
}

HashMap<String, DocData::ClassDoc>::Iterator class_doc = EditorHelp::get_doc_data()->class_list.find(p_type);
Expand Down
2 changes: 1 addition & 1 deletion editor/debugger/editor_performance_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include "editor_performance_profiler.h"

#include "editor/editor_property_name_processor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"
#include "main/performance.h"

EditorPerformanceProfiler::Monitor::Monitor() {}
Expand Down
2 changes: 1 addition & 1 deletion editor/debugger/editor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include "editor_profiler.h"

#include "core/os/os.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"
#include "scene/resources/image_texture.h"

void EditorProfiler::_make_metric_ptrs(Metric &m) {
Expand Down
2 changes: 1 addition & 1 deletion editor/debugger/editor_visual_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include "editor_visual_profiler.h"

#include "core/os/os.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"
#include "scene/resources/image_texture.h"

void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
Expand Down
2 changes: 1 addition & 1 deletion editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
#include "editor/editor_log.h"
#include "editor/editor_node.h"
#include "editor/editor_property_name_processor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/editor_debugger_plugin.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/themes/editor_scale.h"
#include "main/performance.h"
#include "scene/3d/camera_3d.h"
#include "scene/debugger/scene_debugger.h"
Expand Down
2 changes: 1 addition & 1 deletion editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#include "core/io/resource_loader.h"
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/margin_container.h"

void DependencyEditor::_searched(const String &p_path) {
Expand Down
2 changes: 1 addition & 1 deletion editor/directory_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

#include "core/io/dir_access.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/gui/editor_validation_panel.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/box_container.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
Expand Down
1 change: 1 addition & 0 deletions editor/editor_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "core/license.gen.h"
#include "core/version.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"

// The metadata key used to store and retrieve the version text to copy to the clipboard.
const String EditorAbout::META_TEXT_TO_COPY = "text_to_copy";
Expand Down
2 changes: 0 additions & 2 deletions editor/editor_about.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/tree.h"

#include "editor/editor_scale.h"

/**
* NOTE: Do not assume the EditorNode singleton to be available in this class' methods.
* EditorAbout is also used from the project manager where EditorNode isn't initialized.
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_asset_installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
#include "core/io/zip_io.h"
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/gui/editor_toaster.h"
#include "editor/progress_dialog.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/check_box.h"
#include "scene/gui/label.h"
#include "scene/gui/link_button.h"
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_audio_buses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
#include "core/io/resource_saver.h"
#include "core/os/keyboard.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/filesystem_dock.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/separator.h"
#include "scene/resources/font.h"
#include "servers/audio_server.h"
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_autoload_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
#include "core/config/project_settings.h"
#include "core/core_constants.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/filesystem_dock.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/project_settings_editor.h"
#include "editor/themes/editor_scale.h"
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"

Expand Down
4 changes: 2 additions & 2 deletions editor/editor_build_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_property_name_processor.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/themes/editor_scale.h"

const char *EditorBuildProfile::build_option_identifiers[BUILD_OPTION_MAX] = {
// This maps to SCons build options.
Expand Down Expand Up @@ -601,7 +601,7 @@ void EditorBuildProfileManager::_fill_classes_from(TreeItem *p_parent, const Str

bool disabled = edited->is_class_disabled(p_class);
if (disabled) {
class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), EditorStringName(Editor)));
class_item->set_custom_color(0, class_list->get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor)));
}

class_item->set_text(0, text);
Expand Down
29 changes: 1 addition & 28 deletions editor/editor_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
"""

import os
import os.path
import shutil
Expand Down Expand Up @@ -49,34 +50,6 @@ def make_doc_header(target, source, env):
g.close()


def make_fonts_header(target, source, env):
dst = target[0]

g = open(dst, "w", encoding="utf-8")

g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_FONTS_H\n")
g.write("#define _EDITOR_FONTS_H\n")

# Saving uncompressed, since FreeType will reference from memory pointer.
for i in range(len(source)):
with open(source[i], "rb") as f:
buf = f.read()

name = os.path.splitext(os.path.basename(source[i]))[0]

g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n")
g.write("static const unsigned char _font_" + name + "[] = {\n")
for j in range(len(buf)):
g.write("\t" + str(buf[j]) + ",\n")

g.write("};\n")

g.write("#endif")

g.close()


def make_translations_header(target, source, env, category):
dst = target[0]

Expand Down
2 changes: 1 addition & 1 deletion editor/editor_command_palette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#include "editor/editor_command_palette.h"
#include "core/os/keyboard.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_toaster.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/control.h"
#include "scene/gui/tree.h"

Expand Down
Loading

0 comments on commit 4b55c81

Please sign in to comment.