slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Rectangle border-width should default to 1px #110

Closed ogoffart closed 7 months ago

ogoffart commented 3 years ago

Since the border-color defaults to transparent, setting only one of these property should be enough to make a visible border

ogoffart commented 3 years ago

The question is wether the behavior of a 1px transparent border is actually not something:

Rectangle {
   border-width: 100px;
   border-color: transparent;
   color: blue;
   width: 500px; height: 500px;
}

Is the rectangle size 500 or 300 px? if the transparent border adds some "margins", we cannot default to 1px. (Current behavior, the 300px, CSS behavior: 500px, QML: somehow like CSS, but broken) => We should do the same as CSS, so we could default to 1px

Implementation wise, we should make sure that adding a default property to the border don't make everything an BorderRectangle

ogoffart commented 1 year ago

The background should cover the full item width/height (including the border) the border size should default to 1px.

This is a breaking change so maybe only do that with the new syntax. (and the updater can add a border-width: 0px if a border-color is set

(or we just don't care and change the behevior before 1.0 )

tronical commented 1 year ago

The issue about whether the rectangle's size is 300 or 500, how the border affects clipping, is now in https://github.com/slint-ui/slint/issues/1988 .

ogoffart commented 1 year ago

I've had a few issue with this.

tronical commented 1 year ago

But changing the default of the border to 1px would have desastrous consequence on the clipping then, so we should only do that if we really say that the clip clips outside of the border.

In https://github.com/slint-ui/slint/issues/1988#issuecomment-1386646549, what did you mean with "But in a sense, i think it makes more sense to take the border into account." ? Do you mean that clip: true should be like CSS's border-box or like content-box?

ogoffart commented 1 year ago

Blocked on #1988

We need to have a way so that a 1px border wouldn't mean that the clip is shifted by 1px

ogoffart commented 7 months ago

Probably a bit too magical.