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

Setting window position with a pivot is incorrect with collapsed window #3433

Closed
hiddenhare opened this issue Aug 26, 2020 · 1 comment
Closed
Labels

Comments

@hiddenhare
Copy link

Version/Branch of Dear ImGui:

Version: 1.75
Branch: imgui-rs (Rust binding), version 0.4
Back-end: Custom

My Issue/Question:

I'm attempting to position a stack of windows in the bottom-left corner of the screen. I position the first window with a pivot of [0.0, 1.0] and a condition of Always. I measure that window's height, and then position my second window just above it, with the same pivot and condition.

Expected behaviour: When collapsed, the first window should reposition itself so that the bottom-left corner of its titlebar lines up with the bottom-left corner of the screen.

Observed behaviour: When collapsed, the first window retains its current position, causing it to overlap with the second window.

Example:

const PADDING: f32 = 30.0;

let window1 = Window::new(&ImString::new("Window 1"))
    .position([PADDING, screen_height - PADDING], Condition::Always)
    .position_pivot([0.0, 1.0])
    .movable(false)
    .resizable(false)
    .begin(&ui);

let mut window1_size = [0.0, 0.0];
if let Some(window1) = window1 {
    ui.text("Window 1 Contents");
    window1_size = ui.window_size();
    window1.end(&ui);
}

let window2 = Window::new(&ImString::new("Window 2"))
    .position([PADDING, screen_height - window1_size[1] - PADDING * 2.0], Condition::Always)
    .position_pivot([0.0, 1.0])
    .movable(false)
    .resizable(false)
    .begin(&ui);

if let Some(window2) = window2 {
    ui.text("Window 2 Contents");
    window2.end(&ui);
}
ocornut added a commit that referenced this issue Aug 26, 2020
@ocornut
Copy link
Owner

ocornut commented Aug 26, 2020

Thank you @hiddenhare for your report.
Here's the C++ repro:

float padding = 32.0f;
ImGui::SetNextWindowPos(ImVec2(padding, ImGui::GetIO().DisplaySize.y - padding), ImGuiCond_Always, ImVec2(0.0f, 1.0f));
ImGui::Begin("Window 1", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
ImGui::Text("Window 1 contents");
ImVec2 window1_size = ImGui::GetWindowSize();
ImGui::End();

ImGui::SetNextWindowPos(ImVec2(padding, ImGui::GetIO().DisplaySize.y - window1_size.y - padding * 2.0f), ImGuiCond_Always, ImVec2(0.0f, 1.0f));
ImGui::Begin("Window 2", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
ImGui::Text("Window 2 contents");
ImGui::End();

And the bug has been fixed and pushed by 45499b8.
Will add this to our list of regression tests.

@ocornut ocornut closed this as completed Aug 26, 2020
@ocornut ocornut changed the title Collapsed windows ignore pivot Setting window position with a pivot is incorrect with collapsed window Aug 28, 2020
@ocornut ocornut added the bug label Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants