8000 Experiment with a new `Group` container by emilk · Pull Request #4631 · emilk/egui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Experiment with a new Group container #4631

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Experiment with a new Group container #4631

wants to merge 1 commit into from

Conversation

emilk
Copy link
Owner
@emilk emilk commented Jun 6, 2024

Using the new sizing pass logic, we can now support centering of a group of widgets, something we couldn't support before.

This needs more work before it would be ready to use though.

image

@emilk emilk added the layout Related to widget layout label Jun 6, 2024
@emilk emilk mentioned this pull request Jun 6, 2024
@emilk emilk added this to the Next Major Release milestone Jun 7, 2024
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[must_use = "You should call .show()"]
pub struct Group {
Copy link
Contributor
8000

Choose a reason for hiding this comment

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

Is Ui::group going to be changed to use this? Or maybe renamed to avoid confusion?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't know yet. This is all very much related to #4634 in that I would like a simple way to create a new Ui which has opt-in support for the new "grouping" behavior of this PR, as well as a frame (like ui.group does).

@YgorSouza
Copy link
Contributor

I made the following change on this branch to see if it fixes emilk/egui_plot#15:

M crates/egui_plot/src/lib.rs
@@ -723,7 +723,9 @@ impl<'a> Plot<'a> {
         ui: &mut Ui,
         build_fn: impl FnOnce(&mut PlotUi) -> R + 'a,
     ) -> PlotResponse<R> {
-        self.show_dyn(ui, Box::new(build_fn))
+        Group::new(self.id_source.with("group"))
+            .show(ui, |ui| self.show_dyn(ui, Box::new(build_fn)))
+            .inner
     }

And it does, so that's nice.

@DasLixou
Copy link
DasLixou commented Jul 6, 2024

Would this also fix #4039 ?

@emilk
Copy link
Owner Author
emilk commented Jul 7, 2024

Would this also fix #4039 ?

yup, but with a frame of nothingness before the content show up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
layout Related to widget layout
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
0