mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Add scroll hints to ScrollContainer and Tree
This commit is contained in:
parent
9dd6c4dbac
commit
639e396d98
10 changed files with 282 additions and 16 deletions
|
|
@ -5127,6 +5127,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)) {
|
||||
|
|
@ -5995,6 +6010,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.
|
||||
|
|
@ -6656,6 +6697,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);
|
||||
|
||||
|
|
@ -6691,9 +6738,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"));
|
||||
|
|
@ -6719,6 +6769,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");
|
||||
|
||||
|
|
@ -6749,6 +6804,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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue