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

Add auto_shrink() function to egui::Window #4602

Closed
wants to merge 6 commits into from

Conversation

rustbasic
Copy link
Contributor

@rustbasic rustbasic commented Jun 1, 2024

Add auto_shrink() function to egui::Window

/// Show the [`ScrollArea::auto_shrink`]
#[inline]
pub fn auto_shrink(mut self, auto_shrink: impl Into<Vec2b>) -> Self {
self.scroll = self.scroll.auto_shrink(auto_shrink);
Copy link
Owner

Choose a reason for hiding this comment

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

From the docs of ScrollArea::auto_shrink:

  • If true, egui will add blank space outside the scroll area.
  • If false, egui will add blank space inside the scroll area.

For a window we never want blank space outside the scroll area, so we should just change the default of Window::scroll to always have .auto_shrink(false)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't fully understand what you meant.

This doesn't seem to be clearly explained in ScrollArea::auto_shrink.

If we want to change the default value of egui::Window,

  1. we can either change the default value of ScrollArea::auto_shrink to false,

OR

  1. add an auto_shrink variable to egui::Window.

I am unsure of which option is the best approach.

Copy link
Owner

Choose a reason for hiding this comment

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

In Window::new do scroll: ScrollArea::neither().auto_shrink(false)

@rustbasic rustbasic requested a review from emilk June 25, 2024 09:55
///
/// Show the [`ScrollArea::auto_shrink`]
#[inline]
pub fn auto_shrink(mut self, auto_shrink: impl Into<Vec2b>) -> Self {
Copy link
Owner

Choose a reason for hiding this comment

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

and now you can remove this

@rustbasic rustbasic requested a review from emilk June 28, 2024 12:53
Comment on lines +359 to +365
/// If there is [`ScrollArea`], For each axis, should the containing area shrink if the content is small?
#[inline]
pub fn auto_shrink(mut self, auto_shrink: impl Into<Vec2b>) -> Self {
self.scroll = self.scroll.auto_shrink(auto_shrink);
self
}

Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
/// If there is [`ScrollArea`], For each axis, should the containing area shrink if the content is small?
#[inline]
pub fn auto_shrink(mut self, auto_shrink: impl Into<Vec2b>) -> Self {
self.scroll = self.scroll.auto_shrink(auto_shrink);
self
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new code you suggested is the same as the original one. There seems to be no changes in the suggestion.

@rustbasic rustbasic requested a review from emilk June 28, 2024 14:52
emilk added a commit that referenced this pull request Jun 28, 2024
This ensures that the scroll bars are always the outermost

* Closes #4602
@emilk emilk closed this in #4733 Jun 28, 2024
@emilk emilk closed this in d4e8966 Jun 28, 2024
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.

None yet

2 participants