Skip to content

Updated Scroll_to_View#2141

Merged
xarvic merged 9 commits intolinebender:masterfrom
xarvic:scroll_to_view_update
Mar 2, 2022
Merged

Updated Scroll_to_View#2141
xarvic merged 9 commits intolinebender:masterfrom
xarvic:scroll_to_view_update

Conversation

@xarvic
Copy link
Collaborator

@xarvic xarvic commented Feb 7, 2022

This PR adds that ClipBox and Tabs can handle scroll_to_view.

  • ClipBox discards scroll_to_view_requests for hidden areas unless managed() was called.
  • Tabs discards all scroll_to_view requests which originate from hidden widgets.
  • Notification now has a known_target flag. When set to false there will be no warning even if the notification reaches the root widget.

@xarvic xarvic force-pushed the scroll_to_view_update branch 4 times, most recently from 49dfa15 to c33f82a Compare February 7, 2022 17:38
Copy link
Member

@jneem jneem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the motivation for having a ClipBox that isn't managed? My initial reaction is that if you're clipping your children and ignoring SCROLL_TO_VIEW then that's a bug, and we don't need to be working around it in ClipBox.

@xarvic
Copy link
Collaborator Author

xarvic commented Feb 9, 2022

Could you explain the motivation for having a ClipBox that isn't managed? My initial reaction is that if you're clipping your children and ignoring SCROLL_TO_VIEW then that's a bug, and we don't need to be working around it in ClipBox.

I can't think of a specific usecase. But you can use ClipBox without creating a custom widget and in this case it could result in pretty strange behavior.
Maybe we should print a warning when a SCROLL_TO_VIEW notification was stopped?

@jneem
Copy link
Member

jneem commented Feb 18, 2022

Sorry for the slow reply. I've been thinking a bit more about this, and I think what worries me is that both the mananged and unmanaged scenarios have the potential for silently causing unexpected behavior. I agree that if you use ClipBox without handling SCROLL_TO_VIEW (for example, because you just use it directly in your widget tree without a custom widget or a controller) then you might see surprising behavior without warning. But on the other hand if you are handling SCROLL_TO_VIEW but you forget to make the ClipBox managed then you'll also see surprising behavior without warning.

I don't see a great way out of this situation, but I'm still of the opinion that if you have a ClipBox you should handle SCROLL_TO_VIEW. So maybe it makes sense to have managed be the default, and the alternative could be called by a very explicit name like clip_scroll_notifications?

@xarvic
Copy link
Collaborator Author

xarvic commented Feb 18, 2022

I don't see a great way out of this situation, but I'm still of the opinion that if you have a ClipBox you should handle SCROLL_TO_VIEW. So maybe it makes sense to have managed be the default, and the alternative could be called by a very explicit name like clip_scroll_notifications?

Sounds good.

I think what worries me is that both the mananged and unmanaged scenarios have the potential for silently causing unexpected behavior.

In this case maybe we should not have a default value, but force the user to make an explicit decision which option would fit? Either by introducing ClipBox::managed and ClipBox::unmanaged instead of ClipBox::new or adding a flag to the current constructor?
Although this would be a breaking change.

@xarvic
Copy link
Collaborator Author

xarvic commented Feb 24, 2022

@jneem what do you think about this. I am in favor of the breaking change. But your suggestion would also be fine for me.

@jneem
Copy link
Member

jneem commented Feb 24, 2022

Oh, sorry, for some reason in my mind I had already replied. I don't have a strong preference between having a default or not having a default. I agree that defaulting to managed has the advantage of not being breaking, but I don't think that's a dealbreaker. I do prefer having named methods over having flags (because the resulting code is easier to read).

@xarvic
Copy link
Collaborator Author

xarvic commented Feb 24, 2022

Have I understood this correctly, you are in favor of the ClipBox::managed and ClipBox::unmanaged approach?

@jneem
Copy link
Member

jneem commented Feb 24, 2022

I'm ok with two approaches

  • ClipBox::new defaulting to managed, together with a ClipBox::unmanaged(self) -> Self builder method. (Or maybe a more explicit name like ClipBox::clip_notifications?); or
  • ClipBox::managed and ClipBox::unmanaged.

I don't have a strong preference between these two.

Copy link
Member

@jneem jneem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes! Just a couple documentation clarifications, and I think you also need to fix the doc link for CI to be satisfied.

/// internally.
///
/// `ClipBox` will forward [`SCROLL_TO_VIEW`] notifications to its parent unchanged.
/// In this case the parent has to handle said notification itself. By default the ClipBox will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no more "by default", right? The choice is now explicit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@xarvic
Copy link
Collaborator Author

xarvic commented Feb 27, 2022

Thanks for your time :)

Christoph added 7 commits March 2, 2022 18:05
@xarvic xarvic force-pushed the scroll_to_view_update branch from 47c7dff to 14c90b7 Compare March 2, 2022 17:07
@xarvic xarvic merged commit 94b6ce5 into linebender:master Mar 2, 2022
info!("{}: {:?}", i, n);
}
info!(
"if this was intended use EventCtx::submit_notification_unknown_target instead"
Copy link
Contributor

@Fenex Fenex Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect function name in note, fix #2210

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.

3 participants