UVtools icon indicating copy to clipboard operation
UVtools copied to clipboard

[FEATURE REQUEST] AvaloniaControls.AdvancedImageBox: Allow showing alternating grid background even when scroll bars are visible

Open Athari opened this issue 1 month ago • 8 comments

Is your feature request related to a problem?

In the AdvancedImageBox control for Avalonia, alternating grid colors are disabled based on scroll bar visibility. This is due to this condition:

https://github.com/sn4k3/UVtools/blob/beda0ac49d208973a3b7a1b75f484ff780689b7f/UVtools.AvaloniaControls/AdvancedImageBox.cs#L1545-L1565

I don't know what the reasoning is, but I find this behavior rather surprising as I don't expect background to change based on scroll bar visibility.

Describe the solution you'd like

Allow showing alternating grid background no matter the state of scroll bars.

If the app relies on this behavior, it can be achieved by binding ShowGrid or GridCellSize to !(IsHorizontalBarVisible && IsVerticalBarVisible) condition.

Files

No response

Athari avatar Nov 09 '25 02:11 Athari

This is your first time submitting an issue with UVtools 🥳Please review your issue and ensure that the submit template was followed, the information is complete, and not related to any other open issue. It will be reviewed shortly. Debugging is very important and make the program better. Thanks for contributing and making the software better! 🙌

github-actions[bot] avatar Nov 09 '25 02:11 github-actions[bot]

In theory grid is only visible if image is smaller than viewport, this is because render grid takes cycles and if there are zoom with bars visible means no need to render grid because it's hidden under image. However this is not always true if you use manual modes or hide scroll. What is your use case and where is missing the grid? Screenshot if possible.

Definitely a better method is to check if image is larger than viewport and render if the case

sn4k3 avatar Nov 09 '25 16:11 sn4k3

My use case is viewing an image with complex alpha. There's no reason for the grid to disappear because it's never fully obscured. Isn't the main use case for alternating grid is viewing images with alpha?

Image

When I hacked together a solution by overriding the Render method, I understood another interesting detail: it isn't as obvious as I thought at first that the alternating grid background should move with the image, like it does in Photoshop and many other apps. It's actually more useful for me to have it stuck with the viewport (which is the behavior you get if you just comment the scrollbar condition out) as it allows seeing how the half-transparent pixels interact with the background much more easily.

So I think an option to choose between panning the alternating grid with the image and it being fixed to the viewport could be useful (some sort of IsGridPanning / IsGridFixed boolean?).

Athari avatar Nov 10 '25 06:11 Athari

I forgot about alpha use case. As you are playing with render method can you see if removing the && (!IsHorizontalBarVisible || !IsVerticalBarVisible) condition solves your problem? The grid is fixed as it render with viewport coordinates

sn4k3 avatar Nov 10 '25 14:11 sn4k3

As you are playing with render method can you see if removing the && (!IsHorizontalBarVisible || !IsVerticalBarVisible) condition solves your problem?

It solves 80% of the problem. The behavior will be different from most graphics software, but it works for me personally. 😁

Athari avatar Nov 10 '25 15:11 Athari

While working on this I now renember one more reason why the "if" is there

Image

It bleeds to scroll bar with autohide

sn4k3 avatar Nov 12 '25 20:11 sn4k3

Right. Seems to me the image needs to be expanded to the whole control area too.

Athari avatar Nov 13 '25 09:11 Athari

For my use case that not good since I need all image able to edit, if you extend to scroll, the control will be in focus and you cant click in image pixels on that region. In my software I will change bars to AutoHide = false and that solve the visual problem.

sn4k3 avatar Nov 13 '25 13:11 sn4k3