Skip to content
Merged
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
17 changes: 10 additions & 7 deletions imgui-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct WindowContext {
bool windowHasFocus;
bool mouseMoved;
bool mousePressed[3];
ImGuiMouseCursor lastCursor;

bool touchDown[3];
sf::Vector2i touchPos;
Expand Down Expand Up @@ -202,6 +203,7 @@ struct WindowContext {
mousePressed[i] = false;
touchDown[i] = false;
}
lastCursor = ImGuiMouseCursor_COUNT;

joystickId = getConnectedJoystickId();
for (int i = 0; i < ImGuiNavInput_COUNT; ++i) {
Expand Down Expand Up @@ -432,22 +434,23 @@ void Update(sf::RenderWindow& window, sf::Time dt) {

void Update(sf::Window& window, sf::RenderTarget& target, sf::Time dt) {
SetCurrentWindow(window);
assert(s_currWindowCtx);

// Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
updateMouseCursor(window);
ImGuiMouseCursor mouse_cursor =
ImGui::GetIO().MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
if (s_currWindowCtx->lastCursor != mouse_cursor) {
s_currWindowCtx->lastCursor = mouse_cursor;
updateMouseCursor(window);
}

assert(s_currWindowCtx);
if (!s_currWindowCtx->mouseMoved) {
if (sf::Touch::isDown(0)) s_currWindowCtx->touchPos = sf::Touch::getPosition(0, window);

Update(s_currWindowCtx->touchPos, static_cast<sf::Vector2f>(target.getSize()), dt);
} else {
Update(sf::Mouse::getPosition(window), static_cast<sf::Vector2f>(target.getSize()), dt);
}

if (ImGui::GetIO().MouseDrawCursor) {
// Hide OS mouse cursor if imgui is drawing it
window.setMouseCursorVisible(false);
}
}

void Update(const sf::Vector2i& mousePos, const sf::Vector2f& displaySize, sf::Time dt) {
Expand Down