Skip to content
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

Merged
merged 1 commit into from
Oct 20, 2020
Merged

Another try at a viewport widget. #1248

merged 1 commit into from
Oct 20, 2020

Conversation

jneem
Copy link
Collaborator

@jneem jneem commented Sep 20, 2020

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 to ScrollComponent, though. Specifically, it separates the "viewport state" (which I've called RectPort) 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.

@ForLoveOfCats
Copy link
Collaborator

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!

@jneem
Copy link
Collaborator Author

jneem commented Sep 21, 2020

If you have better naming suggestions, I'd be happy to hear them! Like, I know that RectPort is a bad name, but Viewport was already taken...

I'm also in no rush to merge.

@derekdreery
Copy link
Collaborator

Just saying thanks for all the work on a big PR.

Copy link
Collaborator

@ForLoveOfCats ForLoveOfCats left a 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 Show resolved Hide resolved
druid/src/widget/viewport.rs Outdated Show resolved Hide resolved
druid/src/widget/viewport.rs Outdated Show resolved Hide resolved
druid/src/widget/viewport.rs Outdated Show resolved Hide resolved
druid/src/widget/viewport.rs Outdated Show resolved Hide resolved
druid/src/widget/scroll.rs Outdated Show resolved Hide resolved
druid/src/scroll_component.rs Show resolved Hide resolved

/// Represents the size and position of a rectangular "viewport" into a larger area.
#[derive(Clone, Copy, Default, Debug, PartialEq)]
pub struct RectPort {
Copy link
Collaborator

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...

Copy link
Member

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...

Copy link
Collaborator

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.

Copy link
Collaborator Author

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...

Copy link
Member

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. 🤔

Copy link
Collaborator Author

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...

Copy link
Member

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.

@jneem
Copy link
Collaborator Author

jneem commented Sep 26, 2020

@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.

@ForLoveOfCats
Copy link
Collaborator

Nope, I've barely skimmed the updated doc comments

druid/src/widget/viewport.rs Outdated Show resolved Hide resolved
@ForLoveOfCats
Copy link
Collaborator

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 Viewport widget it constructs a local rect variable called viewport. Furthermore the ViewportPos feels non-descriptive as it does not directly contain a position value (the closest is ViewportPos::rect.origin()) which leads to Viewport having the .pos(&self) method which does not return an actual position. Again I don't want to explicitly block on any of this. Naming things is hard and I don't really have any ready suggestions at this exact moment. My worry is the increased mental load of keeping track of these things and the non-specificity which the term viewport is heading towards.

@cmyr
Copy link
Member

cmyr commented Oct 6, 2020

I agree that the names don't feel perfect. The only real suggestion I have is ClipBox for the widget, which gives us Viewport or the thing describing the visible region. 🤷

@ruffson
Copy link

ruffson commented Oct 15, 2020

I am really interested in using this. Are there any blockers?

@jneem
Copy link
Collaborator Author

jneem commented Oct 15, 2020

No, I've just been busy on other things, sorry. I'll try changing the names to ClipBox/Viewport and see if that flies.

Implement a ClipBox widget as a building block for widgets that scroll.
Copy link
Collaborator

@ForLoveOfCats ForLoveOfCats left a 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.

@jneem jneem merged commit bed8894 into linebender:master Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants