Skip to content

Remove use of obsolete ImGui functions - v1.89 #303

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

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
-DIMGUI_SFML_BUILD_EXAMPLES=ON \
-DIMGUI_SFML_BUILD_TESTING=ON \
-DIMGUI_SFML_ENABLE_WARNINGS=ON \
-DIMGUI_SFML_DISABLE_OBSOLETE_FUNCTIONS=ON \
${{matrix.platform.flags}} \
${{matrix.config.flags}}

Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project(imgui_sfml VERSION 2.6 LANGUAGES CXX)
option(IMGUI_SFML_FIND_SFML "Use find_package to find SFML" ON)
option(IMGUI_SFML_IMGUI_DEMO "Build imgui_demo.cpp" ON)
option(IMGUI_SFML_ENABLE_WARNINGS "Enable compiler warnings" OFF)
option(IMGUI_SFML_DISABLE_OBSOLETE_FUNCTIONS "Disable obsolete ImGui functions" OFF)

# If you want to use your own user config when compiling ImGui, please set the following variables
# For example, if you have your config in /path/to/dir/with/config/myconfig.h, set the variables as follows:
Expand Down Expand Up @@ -84,6 +85,9 @@ if(BUILD_SHARED_LIBS)
set_target_properties(ImGui-SFML PROPERTIES DEFINE_SYMBOL "IMGUI_SFML_EXPORTS")
set_target_properties(ImGui-SFML PROPERTIES DEBUG_POSTFIX "_d")
endif()
if(IMGUI_SFML_DISABLE_OBSOLETE_FUNCTIONS)
target_compile_definitions(ImGui-SFML PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS)
endif()

# Add compiler warnings
if(IMGUI_SFML_ENABLE_WARNINGS)
Expand Down
16 changes: 8 additions & 8 deletions imgui-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ void ProcessEvent(const sf::Event& event) {
if (mod != ImGuiKey_None) {
io.AddKeyEvent(mod, down);
} else {
io.AddKeyEvent(ImGuiKey_ModCtrl, event.key.control);
io.AddKeyEvent(ImGuiKey_ModShift, event.key.shift);
io.AddKeyEvent(ImGuiKey_ModAlt, event.key.alt);
io.AddKeyEvent(ImGuiKey_ModSuper, event.key.system);
io.AddKeyEvent(ImGuiMod_Ctrl, event.key.control);
io.AddKeyEvent(ImGuiMod_Shift, event.key.shift);
io.AddKeyEvent(ImGuiMod_Alt, event.key.alt);
io.AddKeyEvent(ImGuiMod_Super, event.key.system);
}

const ImGuiKey key = keycodeToImGuiKey(event.key.code);
Expand Down Expand Up @@ -1341,16 +1341,16 @@ ImGuiKey keycodeToImGuiMod(sf::Keyboard::Key code) {
switch (code) {
case sf::Keyboard::LControl:
case sf::Keyboard::RControl:
return ImGuiKey_ModCtrl;
return ImGuiMod_Ctrl;
case sf::Keyboard::LShift:
case sf::Keyboard::RShift:
return ImGuiKey_ModShift;
return ImGuiMod_Shift;
case sf::Keyboard::LAlt:
case sf::Keyboard::RAlt:
return ImGuiKey_ModAlt;
return ImGuiMod_Alt;
case sf::Keyboard::LSystem:
case sf::Keyboard::RSystem:
return ImGuiKey_ModSuper;
return ImGuiMod_Super;
default:
break;
}
Expand Down