Skip to content

ItemList guides should always be drawn behind selected style box #81142

Closed
@bluenote10

Description

Godot version

v4.1.1.stable.official [bd6af8e]

System information

Godot v4.1.1.stable - Ubuntu 22.04.3 LTS 22.04 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 980 (nvidia; 535.86.05) - Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz (4 Threads)

Issue description

The guides of a style box should always be drawn behind the style box used for selection. This seems to be the case by default, but when setting an explicit guide color, the guides seem to get priority over select style box, messing up the appearance of the selected style box:

image

Notice that the bottom border of the selected style box gets overdrawn by the guide. Since the guides are "low priority" visual elements compared to emphasized nature of "selected" style box, this should probably not be the case.

Also, if I comment out the explicitly set guide_color in the reproduction code, the behavior switches back to the expected behavior:

image

I.e., the fact of changing the guide color seems to change the priority, which I'd assume is not intended? This seems to prevent setting a custom guide_color (I just wanted to make it a bit more lighter).

Steps to reproduce

Self-bootstrapping example scene:

extends MarginContainer

func _ready():
    var item_list = ItemList.new()
    for i in 100:
        item_list.add_item("Item %d" % i)
    add_child(item_list)

    var custom_theme = Theme.new()
    custom_theme.set_constant("margin_left", "MarginContainer", 20)
    custom_theme.set_constant("margin_right", "MarginContainer", 20)
    custom_theme.set_constant("margin_bottom", "MarginContainer", 20)
    custom_theme.set_constant("margin_top", "MarginContainer", 20)
    
    # This line messes up the priority of the guides
    custom_theme.set_color("guide_color", "ItemList", Color(0.95, 0.95, 0.95))
    
    var style_box
    style_box = StyleBoxFlat.new()
    style_box.bg_color = Color(1, 1, 1)
    style_box.set_border_width_all(1)
    style_box.set_content_margin_all(20)
    custom_theme.set_stylebox("panel", "ItemList", style_box)

    style_box = StyleBoxFlat.new()
    style_box.bg_color = Color(0.9, 0.9, 1)
    style_box.border_color = Color(0.5, 0.5, 1)
    style_box.set_border_width_all(1)
    custom_theme.set_stylebox("selected", "ItemList", style_box)
    custom_theme.set_stylebox("selected_focus", "ItemList", style_box)

    custom_theme.set_stylebox("focus", "ItemList", StyleBoxEmpty.new())
    
    set_theme(custom_theme)

Minimal reproduction project

ItemListStyleBox.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions