fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.57k stars 1.37k forks source link

Separators Rendering Issues #4475

Open zarkones opened 8 months ago

zarkones commented 8 months ago

Checklist

Describe the bug

Separators become invisible on occasion. Interacting with an element might bring them back. Resizing the window might make them show up or become invisible again. I am experiencing this issue on Linux, however on Discord channel I heard form a Windows user that they experience exactly the same issue.

I do not get any warning in the console, therefore I am unable to supply debug information.

How to reproduce

There are not specific steps, apart from resizing the window.

Screenshots

image VS. image

Tree element: image VS. image

Example code

container.NewVBox( widget.NewLabel("test"), widget.NewSeparator(), )

Fyne version

2.4.2

Go compiler version

1.20

Operating system and version

Linux

Additional Information

No response

andydotxyz commented 8 months ago

Isn't this the same as #3573 ?

zarkones commented 8 months ago

Isn't this the same as #3573 ?

I personally haven't experienced inconsistent stroke width. They're either the right size or not shown at all. Does this make the issue distinct enough?

andydotxyz commented 8 months ago

If you are on a low DPI device (i.e. not retina/4k) then it's probably the same. i.e. you're seeing the difference between 1 and 0 whereas the other post is HighDPI and seeing 2 vs 1 - that is my guess anyhow.

zarkones commented 8 months ago

If you are on a low DPI device (i.e. not retina/4k) then it's probably the same

I broke my 4k monitor couple of weeks ago, can't test. At the moment, I'm using 1920x1080 laptop's builtin monitor. Will update you once I get a new 4k.

Jacalz commented 8 months ago

Can you share a simpler code example for reproducing the issue? As per the issue template, the issue template needs to be runnable and not just a code snippet.

williambrode commented 5 months ago

I've had the same issue for some time. Just looked at the code and it seems pretty clear to me what the problem is:

In tree.go Layout():

    // Hide any separators that haven't been reused
    for ; separatorCount < len(r.separators); separatorCount++ {
        r.separators[separatorCount].Hide()
    }

Yet, when we reuse that separator again when we expand the tree, we don't call Show() on it:

            if addSeparator {
                var separator fyne.CanvasObject
                if separatorCount < len(r.separators) {
    >>>             separator = r.separators[separatorCount]
                    } else {
                    separator = NewSeparator()
                    r.separators = append(r.separators, separator)
                }

Tried adding the fix locally and I no longer get missing separators after expanding and contracting the tree.

                    separator = r.separators[separatorCount]
                    separator.Show()