-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another try at a viewport widget. #1248
Conversation
I see a few terminology things I'm not fond of and I can't do an in-depth review at this moment. However at first glance this seems to be a reasonable compromise! |
If you have better naming suggestions, I'd be happy to hear them! Like, I know that I'm also in no rush to merge. |
Just saying thanks for all the work on a big PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry I can't give a very thorough review at this moment but I wanted to give at least a bit of feedback. I don't have anything against the name of RectPort
, what I was referring to are the references to scrolling in Viewport
which doesn't line up with the potential usage cases.
druid/src/widget/viewport.rs
Outdated
|
||
/// Represents the size and position of a rectangular "viewport" into a larger area. | ||
#[derive(Clone, Copy, Default, Debug, PartialEq)] | ||
pub struct RectPort { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there must be a better name than this but I can't think of one right now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could call this Viewport
and call the widget ClipContainer
or something? just spitballing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Viewport is rapidly becoming a very overloaded term. In some cases it can be the size of the window, in other situations it refers to the paint rect of a widget, and now we are adding two new things which each reference related topics with similar terminology. I don't have much against RectPort
but I do like renaming the widget to ClipContainer
or something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ClipContainer
is missing half the story for me, since I see this widget as being about both clipping and panning. I'm going to try sticking with Viewport
for now and renaming RectPort
to ViewportPos
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify how the distinction between clipping and panning? I think of panning as just a particular subjective experience of something being clipped. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have a very strong opinion on this, but when I hear "clip" I just think of the graphical operation. Like, even without a transformation, a ClipContainer
might be able to clip a child so that it has rounded corners or something? That does admittedly sound pretty contrived...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, just curious. I think it's fairly common for UI toolkits to call this sort of thing a 'clip view'; at least, that's what it's called in AppKit.
@ForLoveOfCats Did I imagine it or did you leave some comments on some of the API docs? I could have sworn you did but I can't find it now, either here or in the old PR. |
Nope, I've barely skimmed the updated doc comments |
I've poked at this some more and while I feel good about this PR on the whole I do have a few concerns which I've voiced a bit earlier inline but I want to cover a bit more. However I don't want to block on these concerns alone. I'm worried about the term "viewport". At this point we have quite a few meanings for the word and this PR adds another new meaning to it. Ironically in several locations in the impl for the |
I agree that the names don't feel perfect. The only real suggestion I have is |
I am really interested in using this. Are there any blockers? |
No, I've just been busy on other things, sorry. I'll try changing the names to |
Implement a ClipBox widget as a building block for widgets that scroll.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel more comfortable with the data structure being called Viewport
over the widget. I do still have concerns as we generally refer to the paint rect as the "viewport" leading to code which touches two separate values with the name viewport but containing completely different data and different purposes mere lines apart. That said I do feel like clarifying our terminology in this area can be a separate conversation in the same vein as the discussions on resolution terminology.
Here's another stab at a viewport widget. This one differs from the previous one in that it doesn't make
ScrollComponent
depend on the viewport widget. It does make other changes toScrollComponent
, though. Specifically, it separates the "viewport state" (which I've calledRectPort
) from the scrollbar state. The scroll component no longer stores the viewport state; in methods that need to modify the viewport state, it gets a mutable reference. The reason for this was that I wanted to make these modifications explicit for the caller, because the caller will typically need to do something in response to the viewport changing.