Skip to content

Make add_container public again #50

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

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

Conversation

vladbat00
Copy link

@vladbat00 vladbat00 commented Jan 6, 2025

I was using add_container as follows:

let continue_response =
    flex.add_container(egui_flex::item().grow(1.0), Box::new(|ui, container| {
        ui.add_enabled_ui(is_enabled, |ui| {
            container.content_widget(ui, egui::Button::new("[C] Restart"))
        })
        .inner
    }));

as a work-around for item growth not applying recursively to inner UI elements.

If I try to use the following code:

let continue_response = flex.add_ui(egui_flex::item().grow(1.0), |ui| {
    let is_enabled = time.elapsed() - *last_requested_respawn_at
        > Duration::from_secs_f32(RESPAWN_REQUEST_COOLDOWN_SECS);
    ui.add_enabled(is_enabled, egui::Button::new("[C] Restart"))
});

my UI looks like this (note the Restart button not occupying all the available width):
ui

Probably there's a better solution for this particular problem, I'd appreciate it as well, but at this point maybe we could just make add_container public again.

@lucasmerlin
Copy link
Owner

Hmm, I'd really like to keep it private, since it is an implementaion detail at this point and I might want to remove it in a future version.
The reason you need this is that you'd like to disable the button you add, right?
How about adding a .disabled() or a .enabled(bool) function to the FlexItem?

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.

2 participants