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

Add an option to disable the scrollbox containing the scrollbar #988

Closed jrmoulton closed 8 months ago

jrmoulton commented 2 years ago

Currently Slint has no way to disable the boxes around a scrollbar in a scrollview. It would be nice to have the option to be able to disable them.

with

Screen Shot 2022-02-25 at 5 49 19 PM

vs without

Screen Shot 2022-02-25 at 5 49 32 PM

I got this workign in Qt but it feels pretty hacky. On this line https://github.com/slint-ui/slint/blob/55fb9c13aaec5a011951b0aa8a9b1d814d2395bb/internal/backends/qt/qt_widgets/scrollview.rs#L356 I initialized QRect with (0,0,0, r.size().height())

What would be the best way to go about adding this feature? Do similar changes need to be made in all backends?

jrmoulton commented 2 years ago

The way I listed above isn't a great way to not draw the scrollbox. I haven't used Qt much but it looks like the option should be in the QStyleOptionSlider but I can't find a way to manipulate the drawing of the box. I've tried setting the painter to fill transparent and tried to set the painter pen to have no width but that didn't have any effect on the box.

How could I go about hiding the scrollbox?

ogoffart commented 2 years ago

What Style and what platform are you on? How does Qt application looks otherwise?

jrmoulton commented 2 years ago

Fluent Style on macOS with Qt 6. Do you know of an option inside of Qt to draw the slider without the box?

ogoffart commented 2 years ago

I'm a bit confused, because the Fluent style is not having a dark mode like on your screenshot. So i guess this is the native style using Qt, and there might be a bug drawing the scrollbar

jrmoulton commented 2 years ago

Oh your right I got confused. It is the native style. And I don't think this is a bug I'm just trying to add a style option to the native style because it is common on macOS to have a scrollslider but without the scrollbox. So I've found a way to color it differently using the QPainter but I haven't found a way to just hide it.

tronical commented 2 years ago

Hm, now that you mention it - I see the scroll box on macOS, for example in Safari and TextEdit. Where in macOS would it be absent?

Or do you mean transparent overlay scrollbars like on iOS/iPadOS?

Maybe @n-raine has an idea as well?

tronical commented 2 years ago

@lukas-jung kindly helped me "see" - when disconnecting my "real" mouse and just use the touchpad I get overlay scrollbars.

@jrmoulton are you looking for rendering overlay scrollbars basically?

tronical commented 2 years ago

Qt seems to be capable of overlay (transient) scrollbars. But I don't know (yet) how to use QStyle to draw them that way. And we also need to do the logic for showing/hiding ourselves, as well as run a timer for the animation.

jrmoulton commented 2 years ago

@tronical Yep. I didn't know the name of what I was looking for but after a google search it seems like overlay scrollbars are what I was looking for. Another example would be in the mattermost app on macOS it has a scrollslider but no scollbox around that slider.

Screen Shot 2022-03-03 at 4 35 03 PM

I'll keep looking and see if I can find how to do that with Qt.

ogoffart commented 1 year ago

Relates to https://github.com/slint-ui/slint/issues/824 ?

ogoffart commented 8 months ago

The cupertino style is now the recommended style on mac, and we don't really support the qt style on mac anymore.