slint icon indicating copy to clipboard operation
slint copied to clipboard

`visible` property on a `Rectangle` is not applied to drop-shadow

Open tronical opened this issue 3 years ago • 2 comments

The following test-case produces a visible shadow that should not be visible:

export App := Window {
    preferred-width: 300px;
    preferred-height: 300px;

    Rectangle { 
        x: 10px;
        y: 10px;
        width: 100px;
        height: 100px;

        visible: false;

        drop-shadow-offset-x: 5px;
        drop-shadow-offset-y: 5px;
        drop-shadow-blur: 4px;
        drop-shadow-color: green;
    }   
}

This is because in the compiler the handling of the synthetic visible property comes after injecting the drop shadow/opacity elements, so the synthetic clip is only a parent of the final rectangle, not the Opacity and DropShadow items.

tronical avatar Aug 05 '22 14:08 tronical

A workaround is to move the "remainder" into a child rectangle:


export App := Window {
    preferred-width: 300px;
    preferred-height: 300px;

    Rectangle { 
        x: 10px;
        y: 10px;
        width: 100px;
        height: 100px;

        visible: false;

        Rectangle {
            drop-shadow-offset-x: 5px;
            drop-shadow-offset-y: 5px;
            drop-shadow-blur: 4px;
            drop-shadow-color: green;
        }
    }   
}

tronical avatar Aug 05 '22 14:08 tronical

I'm not sure how to best fix this in the compiler since the visible part is deliberately at the end because of 0b5648c2f857d06c97370d96436bdc23d9583470 . Perhaps we somehow need record a kind of "anchor" per rectangle that the visible should finally apply to. But since this is a pass where each time we start afresh iterating through rectangles, this doesn't seem trivial. (Friday afternoon disclaimer ;)

tronical avatar Aug 05 '22 14:08 tronical