Merge pull request #114751 from YeldhamDev/scrolled_hinted_tinted

Add color theme for scroll hints
This commit is contained in:
Thaddeus Crews
2026-01-08 12:46:30 -06:00
12 changed files with 36 additions and 6 deletions

View File

@@ -525,6 +525,9 @@
<theme_item name="guide_color" data_type="color" type="Color" default="Color(0.7, 0.7, 0.7, 0.25)">
[Color] of the guideline. The guideline is a line drawn between each row of items.
</theme_item>
<theme_item name="scroll_hint_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
[Color] used to modulate the [theme_item scroll_hint] texture.
</theme_item>
<theme_item name="h_separation" data_type="constant" type="int" default="4">
The horizontal spacing between items.
</theme_item>

View File

@@ -129,6 +129,12 @@
</constant>
</constants>
<theme_items>
<theme_item name="scroll_hint_horizontal_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
[Color] used to modulate the [theme_item scroll_hint_horizontal] texture.
</theme_item>
<theme_item name="scroll_hint_vertical_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
[Color] used to modulate the [theme_item scroll_hint_vertical] texture.
</theme_item>
<theme_item name="scrollbar_h_separation" data_type="constant" type="int" default="0">
The space between the ScrollContainer's vertical 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.
</theme_item>

View File

@@ -573,6 +573,9 @@
<theme_item name="relationship_line_color" data_type="color" type="Color" default="Color(0.27, 0.27, 0.27, 1)">
The default [Color] of the relationship lines.
</theme_item>
<theme_item name="scroll_hint_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
[Color] used to modulate the [theme_item scroll_hint] texture.
</theme_item>
<theme_item name="title_button_color" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 1)">
Default text [Color] of the title button.
</theme_item>

View File

@@ -1711,10 +1711,10 @@ void ItemList::_notification(int p_what) {
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(control_size.width, hint_height)), tile_scroll_hint);
draw_texture_rect(theme_cache.scroll_hint, Rect2(Point2(), Size2(control_size.width, hint_height)), tile_scroll_hint, theme_cache.scroll_hint_color);
}
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, control_size.height - hint_height), Size2(control_size.width, -hint_height)), tile_scroll_hint);
draw_texture_rect(theme_cache.scroll_hint, Rect2(Point2(0, control_size.height - hint_height), Size2(control_size.width, -hint_height)), tile_scroll_hint, theme_cache.scroll_hint_color);
}
}
}
@@ -2442,6 +2442,7 @@ void ItemList::_bind_methods() {
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_CONSTANT, ItemList, font_outline_size, "outline_size");
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, ItemList, font_outline_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ItemList, scroll_hint);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, ItemList, scroll_hint_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ItemList, line_separation);
BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, ItemList, icon_margin);

View File

@@ -188,6 +188,7 @@ protected:
Color guide_color;
Ref<Texture2D> scroll_hint;
Color scroll_hint_color;
} theme_cache;
void _notification(int p_what);

View File

@@ -619,6 +619,7 @@ void ScrollContainer::_update_scroll_hints() {
bool rtl = is_layout_rtl();
if (show_vertical_hints) {
scroll_hint_top_left->set_texture(theme_cache.scroll_hint_vertical);
scroll_hint_top_left->set_modulate(theme_cache.scroll_hint_vertical_color);
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_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, rtl ? -size.x : 0);
scroll_hint_top_left->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, rtl ? 0 : size.x);
@@ -628,6 +629,7 @@ void ScrollContainer::_update_scroll_hints() {
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_modulate(theme_cache.scroll_hint_vertical_color);
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_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, rtl ? -size.x : 0);
scroll_hint_bottom_right->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, rtl ? 0 : size.x);
@@ -635,6 +637,7 @@ void ScrollContainer::_update_scroll_hints() {
scroll_hint_bottom_right->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0);
} else {
scroll_hint_top_left->set_texture(theme_cache.scroll_hint_horizontal);
scroll_hint_top_left->set_modulate(theme_cache.scroll_hint_horizontal_color);
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_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, rtl ? (size.x - theme_cache.scroll_hint_horizontal->get_width()) : 0);
scroll_hint_top_left->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_BEGIN, rtl ? size.x : theme_cache.scroll_hint_horizontal->get_width());
@@ -644,6 +647,7 @@ void ScrollContainer::_update_scroll_hints() {
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_modulate(theme_cache.scroll_hint_horizontal_color);
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_anchor_and_offset(SIDE_LEFT, ANCHOR_END, rtl ? -size.x : -theme_cache.scroll_hint_horizontal->get_width());
scroll_hint_bottom_right->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, rtl ? (-size.x + theme_cache.scroll_hint_horizontal->get_width()) : 0);
@@ -872,6 +876,9 @@ void ScrollContainer::_bind_methods() {
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ScrollContainer, scroll_hint_vertical);
BIND_THEME_ITEM(Theme::DATA_TYPE_ICON, ScrollContainer, scroll_hint_horizontal);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, ScrollContainer, scroll_hint_vertical_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, ScrollContainer, scroll_hint_horizontal_color);
GLOBAL_DEF("gui/common/default_scroll_deadzone", 0);
}

View File

@@ -98,6 +98,9 @@ private:
Ref<Texture2D> scroll_hint_vertical;
Ref<Texture2D> scroll_hint_horizontal;
Color scroll_hint_vertical_color;
Color scroll_hint_horizontal_color;
int scrollbar_h_separation = 0;
int scrollbar_v_separation = 0;
} theme_cache;

View File

@@ -5140,10 +5140,10 @@ void Tree::_notification(int p_what) {
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);
draw_texture_rect(theme_cache.scroll_hint, Rect2(Point2(), Size2(size.width, hint_height)), tile_scroll_hint, theme_cache.scroll_hint_color);
}
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_texture_rect(theme_cache.scroll_hint, Rect2(Point2(0, size.height - hint_height), Size2(size.width, -hint_height)), tile_scroll_hint, theme_cache.scroll_hint_color);
}
}
}
@@ -6815,6 +6815,7 @@ void Tree::_bind_methods() {
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_COLOR, Tree, scroll_hint_color);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, custom_button);
BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, Tree, custom_button_hover);

View File

@@ -644,6 +644,7 @@ private:
Color children_hl_line_color;
Color custom_button_font_highlight;
Color font_outline_color;
Color scroll_hint_color;
float base_scale = 1.0;
int font_outline_size = 0;

View File

@@ -666,6 +666,8 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_icon("scroll_hint_vertical", "ScrollContainer", icons["scroll_hint_vertical"]);
theme->set_icon("scroll_hint_horizontal", "ScrollContainer", icons["scroll_hint_horizontal"]);
theme->set_color("scroll_hint_vertical_color", "ScrollContainer", Color(0, 0, 0));
theme->set_color("scroll_hint_horizontal_color", "ScrollContainer", Color(0, 0, 0));
// Window
@@ -907,6 +909,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("parent_hl_line_color", "Tree", Color(0.27, 0.27, 0.27));
theme->set_color("children_hl_line_color", "Tree", Color(0.27, 0.27, 0.27));
theme->set_color("custom_button_font_highlight", "Tree", control_font_hover_color);
theme->set_color("scroll_hint_color", "Tree", Color(0, 0, 0));
theme->set_constant("h_separation", "Tree", Math::round(4 * scale));
theme->set_constant("v_separation", "Tree", Math::round(4 * scale));
@@ -952,6 +955,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("font_selected_color", "ItemList", control_font_pressed_color);
theme->set_color("font_outline_color", "ItemList", Color(0, 0, 0));
theme->set_color("guide_color", "ItemList", Color(0.7, 0.7, 0.7, 0.25));
theme->set_color("scroll_hint_color", "ItemList", Color(0, 0, 0));
theme->set_stylebox("hovered", "ItemList", make_flat_stylebox(Color(1, 1, 1, 0.07)));
theme->set_stylebox("hovered_selected", "ItemList", make_flat_stylebox(style_hover_selected_color));
theme->set_stylebox("hovered_selected_focus", "ItemList", make_flat_stylebox(style_hover_selected_color));

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="32" viewBox="0 0 6.35 8.467"><defs><linearGradient id="a"><stop offset="0" stop-opacity=".3"/><stop offset="1" stop-opacity="0"/></linearGradient><linearGradient xlink:href="#a" id="b" x1="4.233" x2="4.233" y1="0" y2="6.35" gradientTransform="translate(-8.467)" gradientUnits="userSpaceOnUse"/></defs><path fill="url(#b)" d="M-8.467 0H0V6.35H-8.467z" paint-order="fill markers stroke" transform="rotate(-90)"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="32" viewBox="0 0 6.35 8.467"><defs><linearGradient id="a"><stop offset="0" stop-color="#fff" stop-opacity=".3"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient><linearGradient xlink:href="#a" id="b" x1="4.233" x2="4.233" y1="0" y2="6.35" gradientTransform="translate(-8.467)" gradientUnits="userSpaceOnUse"/></defs><path fill="url(#b)" d="M-8.467 0H0V6.35H-8.467z" paint-order="fill markers stroke" transform="rotate(-90)"/></svg>

Before

Width:  |  Height:  |  Size: 519 B

After

Width:  |  Height:  |  Size: 555 B

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="24" viewBox="0 0 8.467 6.35"><defs><linearGradient id="a"><stop offset="0" stop-opacity=".3"/><stop offset="1" stop-opacity="0"/></linearGradient><linearGradient xlink:href="#a" id="b" x1="4.233" x2="4.233" y1="0" y2="6.35" gradientUnits="userSpaceOnUse"/></defs><path fill="url(#b)" d="M0 0H8.467V6.35H0z" paint-order="fill markers stroke"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="24" viewBox="0 0 8.467 6.35"><defs><linearGradient id="a"><stop offset="0" stop-color="#fff" stop-opacity=".3"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient><linearGradient xlink:href="#a" id="b" x1="4.233" x2="4.233" y1="0" y2="6.35" gradientUnits="userSpaceOnUse"/></defs><path fill="url(#b)" d="M0 0H8.467V6.35H0z" paint-order="fill markers stroke"/></svg>

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 487 B