diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml
index 057e6fef653e..988748b398a8 100644
--- a/doc/classes/ScrollContainer.xml
+++ b/doc/classes/ScrollContainer.xml
@@ -52,6 +52,10 @@
Deadzone for touch scrolling. Lower deadzone makes the scrolling more sensitive.
+
+ The way which scroll hints (indicators that show that the content can still be scrolled in a certain direction) will be shown.
+ [b]Note:[/b] Hints won't be shown if the content can be scrolled both vertically and horizontally.
+
The current horizontal scroll value.
[b]Note:[/b] If you are setting this value in the [method Node._ready] function or earlier, it needs to be wrapped with [method Object.set_deferred], since scroll bar's [member Range.max_value] is not initialized yet.
@@ -74,6 +78,9 @@
Overrides the [member ScrollBar.custom_step] used when clicking the internal scroll bar's vertical increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused.
+
+ If [code]true[/code], the scroll hint texture will be tiled instead of stretched. See [member scroll_hint_mode].
+
Controls whether vertical scrollbar can be used and when it should be visible.
@@ -108,6 +115,18 @@
Combines [constant SCROLL_MODE_AUTO] and [constant SCROLL_MODE_SHOW_ALWAYS]. The scrollbar is only visible if necessary, but the content size is adjusted as if it was always visible. It's useful for ensuring that content size stays the same regardless if the scrollbar is visible.
+
+ Scroll hints will never be shown.
+
+
+ Scroll hints will be shown at the top and bottom (if vertical), or left and right (if horizontal).
+
+
+ Scroll hints will be shown at the top (if vertical), or the left (if horizontal).
+
+
+ Scroll hints will be shown at the bottom (if horizontal), or the right (if horizontal).
+
@@ -116,6 +135,12 @@
The space between the ScrollContainer's horizontal scroll bar and its content, in pixels. No space will be added when the content's minimum size is larger than the ScrollContainer's size.
+
+ The indicator that will be shown when the content can still be scrolled horizontally. See [member scroll_hint_mode].
+
+
+ The indicator that will be shown when the content can still be scrolled vertically. See [member scroll_hint_mode].
+
The focus border [StyleBox] of the [ScrollContainer]. Only used if [member draw_focus_border] is [code]true[/code].
diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index 1d1ca87693a2..ac9c243c130a 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -383,6 +383,9 @@
If [code]true[/code], the tree's root is hidden.
+
+ The way which scroll hints (indicators that show that the content can still be scrolled in a certain direction) will be shown.
+
If [code]true[/code], enables horizontal scrolling.
@@ -392,6 +395,9 @@
Allows single or multiple selection. See the [enum SelectMode] constants.
+
+ If [code]true[/code], the scroll hint texture will be tiled instead of stretched. See [member scroll_hint_mode].
+
@@ -514,6 +520,18 @@
Enables "above item" and "below item" drop sections. The "above item" drop section covers the top half of the item, and the "below item" drop section covers the bottom half.
When combined with [constant DROP_MODE_ON_ITEM], these drop sections halves the height and stays on top / bottom accordingly.
+
+ Scroll hints will never be shown.
+
+
+ Scroll hints will be shown at the top and bottom.
+
+
+ Only the top scroll hint will be shown.
+
+
+ Only the bottom scroll hint will be shown.
+
@@ -667,6 +685,9 @@
The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is indeterminate and non-editable (see [method TreeItem.set_editable]).
+
+ The indicator that will be shown when the content can still be scrolled. See [member scroll_hint_mode].
+
The arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell.
diff --git a/editor/docks/inspector_dock.cpp b/editor/docks/inspector_dock.cpp
index c968562a6d45..64e52a449eb5 100644
--- a/editor/docks/inspector_dock.cpp
+++ b/editor/docks/inspector_dock.cpp
@@ -873,6 +873,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) {
inspector->set_property_name_style(property_name_style);
inspector->set_use_folding(!bool(EDITOR_GET("interface/inspector/disable_folding")));
inspector->register_text_enter(search);
+ inspector->set_scroll_hint_mode(ScrollContainer::SCROLL_HINT_MODE_TOP_AND_LEFT);
inspector->set_use_filter(true);
diff --git a/editor/themes/theme_classic.cpp b/editor/themes/theme_classic.cpp
index 0295e7d69daa..172662710bac 100644
--- a/editor/themes/theme_classic.cpp
+++ b/editor/themes/theme_classic.cpp
@@ -35,6 +35,7 @@
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme_manager.h"
#include "scene/gui/graph_edit.h"
+#include "scene/resources/compressed_texture.h"
#include "scene/resources/dpi_texture.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/style_box_flat.h"
@@ -1551,6 +1552,13 @@ void ThemeClassic::populate_editor_styles(const Ref &p_theme, Edito
Ref style_widget_scroll_container = p_config.button_style_focus->duplicate();
p_theme->set_stylebox("focus", "ScrollContainer", style_widget_scroll_container);
+ // Hide scroll hints.
+ Ref empty_texture;
+ empty_texture.instantiate();
+ p_theme->set_icon("scroll_hint_vertical", "ScrollContainer", empty_texture);
+ p_theme->set_icon("scroll_hint_horizontal", "ScrollContainer", empty_texture);
+ p_theme->set_icon("scroll_hint", "Tree", empty_texture);
+
// This stylebox is used in 3d and 2d viewports (no borders).
Ref style_content_panel_vp = p_config.content_panel_style->duplicate();
style_content_panel_vp->set_content_margin_individual(p_config.border_width * 2, p_config.base_margin * EDSCALE, p_config.border_width * 2, p_config.border_width * 2);
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 8edd27ba12f4..bb2366a94534 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -32,6 +32,7 @@
#include "core/config/project_settings.h"
#include "scene/gui/panel_container.h"
+#include "scene/gui/texture_rect.h"
#include "scene/main/window.h"
#include "scene/theme/theme_db.h"
@@ -343,6 +344,7 @@ void ScrollContainer::ensure_control_visible(Control *p_control) {
void ScrollContainer::_reposition_children() {
update_scrollbars();
+ update_scroll_hints();
Rect2 margins = _get_margins();
Size2 size = get_size();
@@ -362,10 +364,7 @@ void ScrollContainer::_reposition_children() {
for (int i = 0; i < get_child_count(); i++) {
Control *c = as_sortable_control(get_child(i));
- if (!c) {
- continue;
- }
- if (c == h_scroll || c == v_scroll || c == focus_panel) {
+ if (!c || c->is_internal()) {
continue;
}
Size2 minsize = c->get_combined_minimum_size();
@@ -445,7 +444,10 @@ void ScrollContainer::_notification(int p_what) {
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_SET_SCROLL_OFFSET, callable_mp(this, &ScrollContainer::_accessibility_action_scroll_set));
} break;
- case NOTIFICATION_THEME_CHANGED:
+ case NOTIFICATION_THEME_CHANGED: {
+ update_scroll_hints();
+ [[fallthrough]];
+ }
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_TRANSLATION_CHANGED: {
_updating_scrollbars = true;
@@ -602,6 +604,48 @@ void ScrollContainer::update_scrollbars() {
callable_mp(this, &ScrollContainer::_update_scrollbar_position).call_deferred();
}
+void ScrollContainer::update_scroll_hints() {
+ Size2 size = get_size();
+ Rect2 margins = _get_margins();
+ Size2 scroll_size = size - margins.position + margins.size;
+
+ float v_scroll_value = v_scroll->get_value();
+ bool v_scroll_below_max = v_scroll_value < (largest_child_min_size.height - scroll_size.height - 1);
+ bool show_vertical_hints = v_scroll_value > 1 || v_scroll_below_max;
+
+ float h_scroll_value = h_scroll->get_value();
+ bool h_scroll_below_max = h_scroll_value < (largest_child_min_size.width - scroll_size.width - 1);
+ bool show_horizontal_hints = h_scroll_value > 1 || h_scroll_below_max;
+
+ if (show_vertical_hints) {
+ scroll_hint_top_left->set_texture(theme_cache.scroll_hint_vertical);
+ scroll_hint_top_left->set_visible(!show_horizontal_hints && (scroll_hint_mode == SCROLL_HINT_MODE_ALL || scroll_hint_mode == SCROLL_HINT_MODE_TOP_AND_LEFT) && v_scroll_value > 1);
+ scroll_hint_top_left->set_offsets_preset(PRESET_TOP_WIDE, LayoutPresetMode::PRESET_MODE_MINSIZE);
+
+ scroll_hint_bottom_right->set_flip_h(false);
+ scroll_hint_bottom_right->set_flip_v(true);
+ scroll_hint_bottom_right->set_texture(theme_cache.scroll_hint_vertical);
+ scroll_hint_bottom_right->set_visible(!show_horizontal_hints && (scroll_hint_mode == SCROLL_HINT_MODE_ALL || scroll_hint_mode == SCROLL_HINT_MODE_BOTTOM_AND_RIGHT) && v_scroll_below_max);
+ scroll_hint_bottom_right->set_offsets_preset(PRESET_BOTTOM_WIDE, LayoutPresetMode::PRESET_MODE_MINSIZE);
+ } else {
+ bool rtl = is_layout_rtl();
+
+ scroll_hint_top_left->set_texture(theme_cache.scroll_hint_horizontal);
+ scroll_hint_top_left->set_visible(!show_vertical_hints && (scroll_hint_mode == SCROLL_HINT_MODE_ALL || (rtl ? scroll_hint_mode == SCROLL_HINT_MODE_BOTTOM_AND_RIGHT : scroll_hint_mode == SCROLL_HINT_MODE_TOP_AND_LEFT)) && h_scroll_value > 1);
+ scroll_hint_top_left->set_offsets_preset(rtl ? PRESET_RIGHT_WIDE : PRESET_LEFT_WIDE, LayoutPresetMode::PRESET_MODE_MINSIZE);
+ if (rtl) {
+ // TODO: Find out why this is even necessary.
+ scroll_hint_top_left->set_position(Point2(0, scroll_hint_top_left->get_position().y));
+ }
+
+ scroll_hint_bottom_right->set_flip_h(true);
+ scroll_hint_bottom_right->set_flip_v(false);
+ scroll_hint_bottom_right->set_texture(theme_cache.scroll_hint_horizontal);
+ scroll_hint_bottom_right->set_visible(!show_vertical_hints && (scroll_hint_mode == SCROLL_HINT_MODE_ALL || (rtl ? scroll_hint_mode == SCROLL_HINT_MODE_TOP_AND_LEFT : scroll_hint_mode == SCROLL_HINT_MODE_BOTTOM_AND_RIGHT)) && h_scroll_below_max);
+ scroll_hint_bottom_right->set_offsets_preset(rtl ? PRESET_LEFT_WIDE : PRESET_RIGHT_WIDE, LayoutPresetMode::PRESET_MODE_MINSIZE);
+ }
+}
+
void ScrollContainer::_scroll_moved(float) {
queue_sort();
}
@@ -676,6 +720,32 @@ void ScrollContainer::set_deadzone(int p_deadzone) {
deadzone = p_deadzone;
}
+void ScrollContainer::set_scroll_hint_mode(ScrollHintMode p_mode) {
+ if (scroll_hint_mode == p_mode) {
+ return;
+ }
+
+ scroll_hint_mode = p_mode;
+ update_scroll_hints();
+}
+
+ScrollContainer::ScrollHintMode ScrollContainer::get_scroll_hint_mode() const {
+ return scroll_hint_mode;
+}
+
+void ScrollContainer::set_tile_scroll_hint(bool p_enable) {
+ if (tile_scroll_hint != p_enable) {
+ return;
+ }
+
+ tile_scroll_hint = p_enable;
+ update_scroll_hints();
+}
+
+bool ScrollContainer::is_scroll_hint_tiled() {
+ return tile_scroll_hint;
+}
+
bool ScrollContainer::is_following_focus() const {
return follow_focus;
}
@@ -691,10 +761,7 @@ PackedStringArray ScrollContainer::get_configuration_warnings() const {
for (int i = 0; i < get_child_count(); i++) {
Control *c = as_sortable_control(get_child(i), SortableVisibilityMode::VISIBLE);
- if (!c) {
- continue;
- }
- if (c == h_scroll || c == v_scroll || c == focus_panel) {
+ if (!c || c->is_internal()) {
continue;
}
@@ -742,6 +809,12 @@ void ScrollContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_deadzone", "deadzone"), &ScrollContainer::set_deadzone);
ClassDB::bind_method(D_METHOD("get_deadzone"), &ScrollContainer::get_deadzone);
+ ClassDB::bind_method(D_METHOD("set_scroll_hint_mode", "scroll_hint_mode"), &ScrollContainer::set_scroll_hint_mode);
+ ClassDB::bind_method(D_METHOD("get_scroll_hint_mode"), &ScrollContainer::get_scroll_hint_mode);
+
+ ClassDB::bind_method(D_METHOD("set_tile_scroll_hint", "tile_scroll_hint"), &ScrollContainer::set_tile_scroll_hint);
+ ClassDB::bind_method(D_METHOD("is_scroll_hint_tiled"), &ScrollContainer::is_scroll_hint_tiled);
+
ClassDB::bind_method(D_METHOD("set_follow_focus", "enabled"), &ScrollContainer::set_follow_focus);
ClassDB::bind_method(D_METHOD("is_following_focus"), &ScrollContainer::is_following_focus);
@@ -758,7 +831,7 @@ void ScrollContainer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_focus"), "set_follow_focus", "is_following_focus");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_focus_border"), "set_draw_focus_border", "get_draw_focus_border");
- ADD_GROUP("Scroll", "scroll_");
+ ADD_GROUP("Scrollbar", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_horizontal", PROPERTY_HINT_NONE, "suffix:px"), "set_h_scroll", "get_h_scroll");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_vertical", PROPERTY_HINT_NONE, "suffix:px"), "set_v_scroll", "get_v_scroll");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scroll_horizontal_custom_step", PROPERTY_HINT_RANGE, "-1,4096,suffix:px"), "set_horizontal_custom_step", "get_horizontal_custom_step");
@@ -767,18 +840,30 @@ void ScrollContainer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "vertical_scroll_mode", PROPERTY_HINT_ENUM, "Disabled,Auto,Always Show,Never Show,Reserve"), "set_vertical_scroll_mode", "get_vertical_scroll_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_deadzone"), "set_deadzone", "get_deadzone");
+ ADD_GROUP("Scroll Hint", "");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_hint_mode", PROPERTY_HINT_ENUM, "Disabled,All,Top and Left,Bottom and Right"), "set_scroll_hint_mode", "get_scroll_hint_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tile_scroll_hint"), "set_tile_scroll_hint", "is_scroll_hint_tiled");
+
BIND_ENUM_CONSTANT(SCROLL_MODE_DISABLED);
BIND_ENUM_CONSTANT(SCROLL_MODE_AUTO);
BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_ALWAYS);
BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_NEVER);
BIND_ENUM_CONSTANT(SCROLL_MODE_RESERVE);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_ALL);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_TOP_AND_LEFT);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_BOTTOM_AND_RIGHT);
+
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ScrollContainer, scrollbar_h_separation);
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ScrollContainer, scrollbar_v_separation);
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, panel_style, "panel");
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, focus_style, "focus");
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ScrollContainer, scroll_hint_vertical);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ScrollContainer, scroll_hint_horizontal);
+
GLOBAL_DEF("gui/common/default_scroll_deadzone", 0);
}
@@ -802,6 +887,16 @@ bool ScrollContainer::child_has_focus() {
}
ScrollContainer::ScrollContainer() {
+ scroll_hint_top_left = memnew(TextureRect);
+ scroll_hint_top_left->set_mouse_filter(MOUSE_FILTER_IGNORE);
+ scroll_hint_top_left->hide();
+ add_child(scroll_hint_top_left, false, INTERNAL_MODE_BACK);
+
+ scroll_hint_bottom_right = memnew(TextureRect);
+ scroll_hint_bottom_right->set_mouse_filter(MOUSE_FILTER_IGNORE);
+ scroll_hint_bottom_right->hide();
+ add_child(scroll_hint_bottom_right, false, INTERNAL_MODE_BACK);
+
h_scroll = memnew(HScrollBar);
h_scroll->set_name("_h_scroll");
add_child(h_scroll, false, INTERNAL_MODE_BACK);
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 879969f0e9a1..208a59a1e753 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -35,6 +35,7 @@
#include "scroll_bar.h"
class PanelContainer;
+class TextureRect;
class ScrollContainer : public Container {
GDCLASS(ScrollContainer, Container);
@@ -48,6 +49,13 @@ class ScrollContainer : public Container {
SCROLL_MODE_RESERVE,
};
+ enum ScrollHintMode {
+ SCROLL_HINT_MODE_DISABLED,
+ SCROLL_HINT_MODE_ALL,
+ SCROLL_HINT_MODE_TOP_AND_LEFT,
+ SCROLL_HINT_MODE_BOTTOM_AND_RIGHT,
+ };
+
private:
HScrollBar *h_scroll = nullptr;
VScrollBar *v_scroll = nullptr;
@@ -67,18 +75,29 @@ class ScrollContainer : public Container {
bool beyond_deadzone = false;
bool scroll_on_drag_hover = false;
+ TextureRect *scroll_hint_top_left = nullptr;
+ TextureRect *scroll_hint_bottom_right = nullptr;
+
ScrollMode horizontal_scroll_mode = SCROLL_MODE_AUTO;
ScrollMode vertical_scroll_mode = SCROLL_MODE_AUTO;
+ void update_scroll_hints();
+
int deadzone = 0;
bool follow_focus = false;
int scroll_border = 20;
int scroll_speed = 12;
+ ScrollHintMode scroll_hint_mode = SCROLL_HINT_MODE_DISABLED;
+ bool tile_scroll_hint = false;
+
struct ThemeCache {
Ref panel_style;
Ref focus_style;
+ Ref scroll_hint_vertical;
+ Ref scroll_hint_horizontal;
+
int scrollbar_h_separation = 0;
int scrollbar_v_separation = 0;
} theme_cache;
@@ -134,8 +153,14 @@ class ScrollContainer : public Container {
void set_vertical_scroll_mode(ScrollMode p_mode);
ScrollMode get_vertical_scroll_mode() const;
- int get_deadzone() const;
void set_deadzone(int p_deadzone);
+ int get_deadzone() const;
+
+ void set_scroll_hint_mode(ScrollHintMode p_mode);
+ ScrollHintMode get_scroll_hint_mode() const;
+
+ void set_tile_scroll_hint(bool p_enable);
+ bool is_scroll_hint_tiled();
bool is_following_focus() const;
void set_follow_focus(bool p_follow);
@@ -155,3 +180,4 @@ class ScrollContainer : public Container {
};
VARIANT_ENUM_CAST(ScrollContainer::ScrollMode);
+VARIANT_ENUM_CAST(ScrollContainer::ScrollHintMode);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 84c6911f5f8b..a0b806e8efd6 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -5121,6 +5121,21 @@ void Tree::_notification(int p_what) {
}
}
+ if (scroll_hint_mode != SCROLL_HINT_MODE_DISABLED) {
+ Size2 size = get_size();
+ float v_scroll_value = v_scroll->get_value();
+ bool v_scroll_below_max = v_scroll_value < (get_internal_min_size().height - size.height - 1);
+ if (v_scroll_value > 1 || v_scroll_below_max) {
+ int hint_height = theme_cache.scroll_hint->get_height();
+ if ((scroll_hint_mode == SCROLL_HINT_MODE_BOTH || scroll_hint_mode == SCROLL_HINT_MODE_TOP) && v_scroll_value > 1) {
+ draw_texture_rect(theme_cache.scroll_hint, Rect2(Point2(), Size2(size.width, hint_height)), tile_scroll_hint);
+ }
+ if ((scroll_hint_mode == SCROLL_HINT_MODE_BOTH || scroll_hint_mode == SCROLL_HINT_MODE_BOTTOM) && v_scroll_below_max) {
+ draw_texture_rect(theme_cache.scroll_hint, Rect2(Point2(0, size.height - hint_height), Size2(size.width, -hint_height)), tile_scroll_hint);
+ }
+ }
+ }
+
// Draw the focus outline last, so that it is drawn in front of the section headings.
// Otherwise, section heading backgrounds can appear to be in front of the focus outline when scrolling.
if (has_focus(true)) {
@@ -5989,6 +6004,32 @@ bool Tree::is_v_scroll_enabled() const {
return v_scroll_enabled;
}
+void Tree::set_scroll_hint_mode(ScrollHintMode p_mode) {
+ if (scroll_hint_mode == p_mode) {
+ return;
+ }
+
+ scroll_hint_mode = p_mode;
+ queue_redraw();
+}
+
+Tree::ScrollHintMode Tree::get_scroll_hint_mode() const {
+ return scroll_hint_mode;
+}
+
+void Tree::set_tile_scroll_hint(bool p_enable) {
+ if (tile_scroll_hint == p_enable) {
+ return;
+ }
+
+ tile_scroll_hint = p_enable;
+ queue_redraw();
+}
+
+bool Tree::is_scroll_hint_tiled() {
+ return tile_scroll_hint;
+}
+
TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) {
TreeItem *from = p_at;
TreeItem *loop = nullptr; // Safe-guard against infinite loop.
@@ -6650,6 +6691,12 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_v_scroll_enabled", "h_scroll"), &Tree::set_v_scroll_enabled);
ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &Tree::is_v_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("set_scroll_hint_mode", "scroll_hint_mode"), &Tree::set_scroll_hint_mode);
+ ClassDB::bind_method(D_METHOD("get_scroll_hint_mode"), &Tree::get_scroll_hint_mode);
+
+ ClassDB::bind_method(D_METHOD("set_tile_scroll_hint", "tile_scroll_hint"), &Tree::set_tile_scroll_hint);
+ ClassDB::bind_method(D_METHOD("is_scroll_hint_tiled"), &Tree::is_scroll_hint_tiled);
+
ClassDB::bind_method(D_METHOD("set_hide_folding", "hide"), &Tree::set_hide_folding);
ClassDB::bind_method(D_METHOD("is_folding_hidden"), &Tree::is_folding_hidden);
@@ -6685,9 +6732,12 @@ void Tree::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_root"), "set_hide_root", "is_root_hidden");
ADD_PROPERTY(PropertyInfo(Variant::INT, "drop_mode_flags", PROPERTY_HINT_FLAGS, "On Item,In Between"), "set_drop_mode_flags", "get_drop_mode_flags");
ADD_PROPERTY(PropertyInfo(Variant::INT, "select_mode", PROPERTY_HINT_ENUM, "Single,Row,Multi"), "set_select_mode", "get_select_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_tooltip"), "set_auto_tooltip", "is_auto_tooltip_enabled");
+ ADD_GROUP("Scroll", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_horizontal_enabled"), "set_h_scroll_enabled", "is_h_scroll_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll_vertical_enabled"), "set_v_scroll_enabled", "is_v_scroll_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_tooltip"), "set_auto_tooltip", "is_auto_tooltip_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_hint_mode", PROPERTY_HINT_ENUM, "Disabled,Both,Top,Bottom"), "set_scroll_hint_mode", "get_scroll_hint_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tile_scroll_hint"), "set_tile_scroll_hint", "is_scroll_hint_tiled");
ADD_SIGNAL(MethodInfo("item_selected"));
ADD_SIGNAL(MethodInfo("cell_selected"));
@@ -6713,6 +6763,11 @@ void Tree::_bind_methods() {
BIND_ENUM_CONSTANT(DROP_MODE_ON_ITEM);
BIND_ENUM_CONSTANT(DROP_MODE_INBETWEEN);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_DISABLED);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_BOTH);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_TOP);
+ BIND_ENUM_CONSTANT(SCROLL_HINT_MODE_BOTTOM);
+
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, Tree, panel_style, "panel");
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, Tree, focus_style, "focus");
@@ -6743,6 +6798,7 @@ void Tree::_bind_methods() {
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, arrow_collapsed_mirrored);
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, select_arrow);
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, updown);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, Tree, scroll_hint);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, custom_button);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, custom_button_hover);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 2d085677236a..6c83ff1278f2 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -464,6 +464,13 @@ class Tree : public Control {
DROP_MODE_INBETWEEN = 2
};
+ enum ScrollHintMode {
+ SCROLL_HINT_MODE_DISABLED,
+ SCROLL_HINT_MODE_BOTH,
+ SCROLL_HINT_MODE_TOP,
+ SCROLL_HINT_MODE_BOTTOM,
+ };
+
private:
friend class TreeItem;
@@ -620,6 +627,7 @@ class Tree : public Control {
Ref arrow_collapsed_mirrored;
Ref select_arrow;
Ref updown;
+ Ref scroll_hint;
Color font_color;
Color font_hovered_color;
@@ -736,6 +744,9 @@ class Tree : public Control {
bool allow_rmb_select = false;
bool scrolling = false;
+ ScrollHintMode scroll_hint_mode = SCROLL_HINT_MODE_DISABLED;
+ bool tile_scroll_hint = false;
+
bool allow_reselect = false;
bool allow_search = true;
@@ -891,6 +902,12 @@ class Tree : public Control {
void set_v_scroll_enabled(bool p_enable);
bool is_v_scroll_enabled() const;
+ void set_scroll_hint_mode(ScrollHintMode p_mode);
+ ScrollHintMode get_scroll_hint_mode() const;
+
+ void set_tile_scroll_hint(bool p_enable);
+ bool is_scroll_hint_tiled();
+
void set_cursor_can_exit_tree(bool p_enable);
VScrollBar *get_vscroll_bar() { return v_scroll; }
@@ -930,3 +947,4 @@ class Tree : public Control {
VARIANT_ENUM_CAST(Tree::SelectMode);
VARIANT_ENUM_CAST(Tree::DropModeFlags);
+VARIANT_ENUM_CAST(Tree::ScrollHintMode);
diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp
index 8eb6428ce3f6..940f5317f666 100644
--- a/scene/theme/default_theme.cpp
+++ b/scene/theme/default_theme.cpp
@@ -660,6 +660,9 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const
focus_style->set_border_color(style_focus_color);
theme->set_stylebox("focus", "ScrollContainer", focus_style);
+ theme->set_icon("scroll_hint_vertical", "ScrollContainer", icons["scroll_hint_vertical"]);
+ theme->set_icon("scroll_hint_horizontal", "ScrollContainer", icons["scroll_hint_horizontal"]);
+
// Window
theme->set_stylebox("embedded_border", "Window", sb_expand(make_flat_stylebox(style_popup_color, 10, 28, 10, 8), 8, 32, 8, 6));
@@ -878,6 +881,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const
theme->set_icon("arrow", "Tree", icons["arrow_down"]);
theme->set_icon("arrow_collapsed", "Tree", icons["arrow_right"]);
theme->set_icon("arrow_collapsed_mirrored", "Tree", icons["arrow_left"]);
+ theme->set_icon("scroll_hint", "Tree", icons["scroll_hint_vertical"]);
theme->set_font("title_button_font", "Tree", Ref());
theme->set_font(SceneStringName(font), "Tree", Ref());
diff --git a/scene/theme/icons/scroll_hint_horizontal.svg b/scene/theme/icons/scroll_hint_horizontal.svg
new file mode 100644
index 000000000000..04e9c01fa0ee
--- /dev/null
+++ b/scene/theme/icons/scroll_hint_horizontal.svg
@@ -0,0 +1 @@
+
diff --git a/scene/theme/icons/scroll_hint_vertical.svg b/scene/theme/icons/scroll_hint_vertical.svg
new file mode 100644
index 000000000000..e504619b8d94
--- /dev/null
+++ b/scene/theme/icons/scroll_hint_vertical.svg
@@ -0,0 +1 @@
+