Skip to content

Commit

Permalink
Upgrade to new SFML 3 sf::Cursor API
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed May 28, 2024
1 parent 7758bfd commit 8d141e7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions imgui-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ struct WindowContext {
TriggerInfo lTriggerInfo;
TriggerInfo rTriggerInfo;

sf::Cursor mouseCursors[ImGuiMouseCursor_COUNT];
bool mouseCursorLoaded[ImGuiMouseCursor_COUNT] = {ImGuiKey_None};
std::optional<sf::Cursor> mouseCursors[ImGuiMouseCursor_COUNT];

#ifdef ANDROID
#ifdef USE_JNI
Expand Down Expand Up @@ -1065,8 +1064,7 @@ const char* getClipboardText(void* /*userData*/) {
}

void loadMouseCursor(ImGuiMouseCursor imguiCursorType, sf::Cursor::Type sfmlCursorType) {
s_currWindowCtx->mouseCursorLoaded[imguiCursorType] =
s_currWindowCtx->mouseCursors[imguiCursorType].loadFromSystem(sfmlCursorType);
s_currWindowCtx->mouseCursors[imguiCursorType] = sf::Cursor::loadFromSystem(sfmlCursorType);
}

void updateMouseCursor(sf::Window& window) {
Expand All @@ -1078,9 +1076,9 @@ void updateMouseCursor(sf::Window& window) {
} else {
window.setMouseCursorVisible(true);

const sf::Cursor& c = s_currWindowCtx->mouseCursorLoaded[cursor] ?
s_currWindowCtx->mouseCursors[cursor] :
s_currWindowCtx->mouseCursors[ImGuiMouseCursor_Arrow];
const sf::Cursor& c = s_currWindowCtx->mouseCursors[cursor] ?
*s_currWindowCtx->mouseCursors[cursor] :
*s_currWindowCtx->mouseCursors[ImGuiMouseCursor_Arrow];
window.setMouseCursor(c);
}
}
Expand Down

0 comments on commit 8d141e7

Please sign in to comment.