Skip to content

Commit 6211f83

Browse files
committed
Add sticky tree item support
1 parent 81cecf0 commit 6211f83

9 files changed

Lines changed: 178 additions & 38 deletions

File tree

doc/classes/EditorSettings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,9 @@
983983
Expanding main editor window content to the title, if supported by [DisplayServer]. See [constant DisplayServer.WINDOW_FLAG_EXTEND_TO_TITLE].
984984
Specific to the macOS platform.
985985
</member>
986+
<member name="interface/editor/appearance/max_sticky_tree_items" type="int" setter="" getter="">
987+
The maximum number of tree items allowed to stick to the top while its children are in view. A value of [code]0[/code] disables sticking.
988+
</member>
986989
<member name="interface/editor/appearance/project_manager_screen" type="int" setter="" getter="">
987990
The preferred monitor to display the project manager.
988991
</member>

doc/classes/Tree.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@
650650
<theme_item name="scroll_border" data_type="constant" type="int" default="4">
651651
The maximum distance between the mouse cursor and the control's border to trigger border scrolling when dragging.
652652
</theme_item>
653+
<theme_item name="scroll_max_sticky_items" data_type="constant" type="int" default="0">
654+
The maximum number of tree items allowed to stick to the top while its children are in view. A value of [code]0[/code] disables sticking.
655+
</theme_item>
653656
<theme_item name="scroll_speed" data_type="constant" type="int" default="12">
654657
The speed of border scrolling.
655658
</theme_item>

editor/settings/editor_settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#include "scene/gui/file_dialog.h"
6060
#include "scene/main/node.h"
6161
#include "scene/main/scene_tree.h"
62-
#include "scene/main/window.h"
6362
#include "scene/resources/animation.h"
6463
#include "servers/display/display_server.h"
6564

@@ -506,6 +505,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
506505
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/appearance/use_embedded_menu", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_BASIC_SETTING)
507506
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/appearance/use_native_file_dialogs", false, "", PROPERTY_USAGE_DEFAULT)
508507
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/appearance/expand_to_title", true, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING)
508+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_RANGE, "interface/editor/appearance/max_sticky_tree_items", 6, "0,16")
509509

510510
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_RANGE, "interface/editor/fonts/main_font_size", 14, "8,48,1")
511511
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_RANGE, "interface/editor/fonts/code_font_size", 14, "8,48,1")

editor/themes/editor_theme_manager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(
268268
config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
269269
config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint");
270270
config.dragging_hover_wait_msec = (float)EDITOR_GET("interface/editor/timers/dragging_hover_wait_seconds") * 1000;
271+
config.max_sticky_tree_items = EDITOR_GET("interface/editor/appearance/max_sticky_tree_items");
271272

272273
// Handle theme style.
273274
if (config.preset != "Custom") {
@@ -718,6 +719,7 @@ bool EditorThemeManager::is_generated_theme_outdated() {
718719
// TODO: We can use this information more intelligently to do partial theme updates and speed things up.
719720
outdated_cache = EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") ||
720721
EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/fonts") ||
722+
EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/appearance/max_sticky_tree_items") ||
721723
EditorSettings::get_singleton()->check_changed_settings_in_group("interface/touchscreen/enable_touch_optimizations") ||
722724
EditorSettings::get_singleton()->check_changed_settings_in_group("editors/visual_editors") ||
723725
EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme") ||

editor/themes/editor_theme_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class EditorThemeManager {
8080
int inspector_property_height = 28;
8181
float subresource_hue_tint = 0.0;
8282
float dragging_hover_wait_msec = 0;
83+
int max_sticky_tree_items = 5;
8384

8485
// Make sure to keep those in sync with the definitions in the editor settings.
8586
const float default_icon_saturation = 2.0;

editor/themes/theme_classic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ void ThemeClassic::populate_standard_styles(const Ref<EditorTheme> &p_theme, Edi
624624
p_theme->set_constant("icon_h_separation", "Tree", (p_config.increased_margin + 2) * EDSCALE);
625625
p_theme->set_constant("button_margin", "Tree", p_config.base_margin * EDSCALE);
626626
p_theme->set_constant("dragging_unfold_wait_msec", "Tree", p_config.dragging_hover_wait_msec);
627+
p_theme->set_constant("scroll_max_sticky_items", "Tree", p_config.max_sticky_tree_items);
627628
p_theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
628629
p_theme->set_constant("scroll_speed", "Tree", 12);
629630
p_theme->set_constant("outline_size", "Tree", 0);

editor/themes/theme_modern.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ void ThemeModern::populate_standard_styles(const Ref<EditorTheme> &p_theme, Edit
650650
p_theme->set_constant("icon_h_separation", "Tree", p_config.base_margin * 1.5 * EDSCALE);
651651
p_theme->set_constant("button_margin", "Tree", p_config.base_margin * EDSCALE);
652652
p_theme->set_constant("dragging_unfold_wait_msec", "Tree", p_config.dragging_hover_wait_msec);
653+
p_theme->set_constant("scroll_max_sticky_items", "Tree", p_config.max_sticky_tree_items);
653654
p_theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
654655
p_theme->set_constant("scroll_speed", "Tree", 12);
655656
p_theme->set_constant("outline_size", "Tree", 0);

0 commit comments

Comments
 (0)