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

Add support for ImGui mouse cursors in ImgWindow. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions ImgWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,22 @@ ImgWindow::HandleCursorFuncCB(
float outX, outY;
thisWindow->translateToImguiSpace(x, y, outX, outY);
io.MousePos = ImVec2(outX, outY);
//FIXME: Maybe we can support imgui's cursors a bit better?
return xplm_CursorDefault;

// Exclude resize regions handled by XPLM for self-styled windows:
if (thisWindow->IsInsideSim() && thisWindow->bHandleWndResize &&
(x < (thisWindow->mLeft + WND_RESIZE_LEFT_WIDTH) ||
x > (thisWindow->mRight - WND_RESIZE_RIGHT_WIDTH) ||
y > (thisWindow->mTop - WND_RESIZE_TOP_WIDTH) ||
y < (thisWindow->mBottom + WND_RESIZE_BOTTOM_WIDTH)))
{
// Defer to XPLM's hand cursor for managed resize grab regions:
io.MouseDrawCursor = false;
return xplm_CursorDefault;
}

// Have ImGui take over the mouse cursor for the rest:
io.MouseDrawCursor = true;
return xplm_CursorHidden;
}

int
Expand Down