Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Border BoxShadow only works with BackgroundSizing=CenterBorder

Open amwx opened this issue 1 month ago • 4 comments

Describe the bug

Setting BackgroundSizing to anything other than CenterBorder causes the BoxShadow to not render:

image

To Reproduce

<StackPanel Orientation="Horizontal"
            Spacing="20"
            HorizontalAlignment="Center">

    <Border Background="Gray"
            Width="200" Height="200"
            BoxShadow="0 16 16 0 #35000000">
        <TextBlock Text="CenterBorder"
                   HorizontalAlignment="Center"/>
    </Border>

    <Border Background="Gray"
            Width="200" Height="200"
            BoxShadow="0 16 16 0 #35000000"
            BackgroundSizing="InnerBorderEdge">
        <TextBlock Text="InnerBorderEdge"
                   HorizontalAlignment="Center"/>
    </Border>

    <Border Background="Gray"
           Width="200" Height="200"
           BoxShadow="0 16 16 0 #35000000"
           BackgroundSizing="OuterBorderEdge">
        <TextBlock Text="OuterBorderEdge"
                   HorizontalAlignment="Center"/>
    </Border>
    
</StackPanel>

Expected behavior

No response

Avalonia version

11.1-beta1

OS

Windows

Additional context

No response

amwx avatar May 04 '24 14:05 amwx

Related: #13251 Now that we have BackgroundSizing which draws via geometry (if not wanting the Skia default), it might be time to allow shadows on things that aren't just Rectangles

amwx avatar May 04 '24 14:05 amwx

Hmm, I suspect there is a bit more going on here. I don't recall running across the box shadow code for the BackgroundSizing work. That said, I suspect the box shadow only ever worked with the simple rendering path.

robloo avatar May 04 '24 20:05 robloo

I suspect the box shadow only ever worked with the simple rendering path.

I am pretty sure that's the case.

Effects="drop-shadow(5 5 0 Green)" should still work with complex geometry. And we might be able to convert box shadow to drop shadow for complex borders.

maxkatz6 avatar May 04 '24 23:05 maxkatz6

Oh, I didn't know about the Effects API which is what along the lines of what I was thinking was needed. That works nicely.

amwx avatar May 05 '24 01:05 amwx