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

Experiment with a new Group container #4631

Draft
wants to merge 1 commit into
base: master
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

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