Skip to content

How to change the useful space that bevy_egui uses? #444

@nuzzles

Description

@nuzzles

I have a custom macOS titlebar, and I want egui to not use any of the space in my virtual titlebar, e.g. the top 28 pixels of space.

How do I tell egui that the screen rect is actually 28pixels smaller?

Image

I tried something like this, it did not work:

        #[cfg(target_os = "macos")]
        app.add_systems(
            EguiPrimaryContextPass,
            macos_titlebar.run_if(woot_app::fullscreen::is_windowed),
        );

...

#[cfg(target_os = "macos")]
fn modify_screen_rect(mut contexts: EguiContexts) -> Result {
    let ctx = contexts.ctx_mut()?;

    // Modify the raw input to shrink the screen rect
    ctx.input_mut(|i| {
        let old_rect = i.screen_rect;
        i.screen_rect = egui::Rect {
            min: egui::Pos2 {
                x: old_rect.min.x,
                y: old_rect.min.y + MACOS_TITLEBAR_HEIGHT,
            },
            max: old_rect.max,
        };
    });

    Ok(())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions