Skip to content

Add event::window_resize event handler #187

Description

@mrparmesan01

To be able to ensure we can signal for viewport (or multiple) have been resized.

We can use the event::window_resize to provide an API that allows us to trigger this event to update all of the aspect ratio parameters that is used widely throughout the codebase.

Having the assurance the aspect ratio is correct when the viewport or any dockspace that renders as a render target are being resized properly.

This is what is causing the stretch that occurs when resizing the viewport in imgui.

Checkout issue #177 for more on this bug.

Example Prototype

// internally in the game engine to setup what should happen
// when this event occurs and how to handle it.
m_bus->subscribe<event::window_resize>(this, &scene::on_resize);

void scene::on_resize(event::window_resize& p_event) {
    m_aspect_ratio = static_cast<float>(p_event.width * p_event.height);
}

// editor-specific code that triggers the event when a window size occurs
// NOTE: Pseudo-code; replace with actual imgui API
if(ImGui::WindowChangeSize()) {
    event::window_resize window_resize_event = {
        .width = ImGui::AvailableRegion().x,
        .height = ImGui::AvailableRegion().y,
    };
    trigger(window_resize_event);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working💳 Tech DebtTasks that have some kind of user API tech debt

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions