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

Child window position changes depending on the viewport coordinate sign #6144

Open
Vucee opened this issue Feb 3, 2023 · 4 comments
Open

Comments

@Vucee
Copy link

Vucee commented Feb 3, 2023

Version/Branch of Dear ImGui:
v1.89.3 docking

Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_dx11.cpp + imgui_impl_win32.cpp
Operating System: Windows 10

My Issue/Question:
The position of a child window is different on each monitor.
Depedning on which monitor I drag the UI, the result differs. Is there anything I'm doing wrong?

Main Monitor:
image

Top Monitor:
image

Left Monitor:
image

My code for drawing the UI:

ImGui::SetNextWindowBgAlpha(1.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, { 0.0f });
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4{ 0.161f, 0.157f, 0.173f, 1.0f });
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4{ 1,1,1, 1.0f });
//ImGui::GetStyle().Alpha = 1.0f;		
ImGui::SetNextWindowSize({1000,750});
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::Begin(lpWindowName, &bDraw, WindowFlags);
{	
	ImVec2 pos = ImGui::GetWindowPos();
	//ImDrawList* draw = ImGui::GetWindowDrawList();
	
	ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f );
	ImGui::PushStyleColor(ImGuiCol_Border, ImVec4{ 1.0f, 1.0f ,0.0f , 1.0f });
	ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4{ 0.0f, 0.0f, 0.0f, 1.0f });
	ImGui::SetNextWindowPos(pos);
	ImGui::BeginChild("main", {800, 550});
	{

	}
        ImGui::EndChild();
}
ImGui::End();
@ocornut
Copy link
Owner

ocornut commented Feb 3, 2023

What are the monitor coordinates?
You can see them in Tools->Metrics->Viewports

May be caused by rounding, this issue #2176

@Vucee Vucee closed this as completed Feb 3, 2023
@Vucee Vucee reopened this Feb 3, 2023
@Vucee
Copy link
Author

Vucee commented Feb 3, 2023

Main Monitor:
image

Top Monitor:
image

Left Monitor:
image

image

@ocornut
Copy link
Owner

ocornut commented Feb 3, 2023

Sorry I have linked #2176 but that goes talking about a different issue.
The actual issue with negative coordinates is #2884. There is a likely trivial fix which is to use ImFloorSigned() instead of ImFloor(), or completely replace the later with the earlier. Doing the 100% fix I worry would need too-careful measurement, but I presume we could do the half fix first which would be to use ImFloorSigned() in a few selected places pertaining to window position, and that would not have measurable impact.

@ocornut ocornut added the bug label Feb 3, 2023
@Vucee
Copy link
Author

Vucee commented Feb 3, 2023

thanks! ImFloorSigned() worked for me.

It isn't really a big deal anyway. I just wasn't sure if that is a bug or not.

@ocornut ocornut changed the title Child window position changes depending on the screen it's on Child window position changes depending on the viewport coordinate sign Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants