Skip to content

Commit

Permalink
[imgui]: Update to 1.91.5 (#42244)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomconder authored Nov 22, 2024
1 parent 5b55679 commit ab65510
Show file tree
Hide file tree
Showing 24 changed files with 304 additions and 185 deletions.
1 change: 1 addition & 0 deletions ports/hello-imgui/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
fix-upw.patch
use-new-imguiimagebutton.patch # Upstream commit: https://github.com/pthom/hello_imgui/commit/3ba369ad5b9bc281f01a2b2ee78d64ecef7d632a
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down
28 changes: 28 additions & 0 deletions ports/hello-imgui/use-new-imguiimagebutton.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/src/hello_imgui/internal/image_from_asset.cpp b/src/hello_imgui/internal/image_from_asset.cpp
index 7416a69..b838d88 100644
--- a/src/hello_imgui/internal/image_from_asset.cpp
+++ b/src/hello_imgui/internal/image_from_asset.cpp
@@ -116,7 +116,7 @@ namespace HelloImGui
auto textureId = cachedImage->TextureID();
auto imageSize = ImVec2((float)cachedImage->Width, (float)cachedImage->Height);
ImVec2 displayedSize = ImageProportionalSize(size, imageSize);
- bool clicked = ImGui::ImageButton(textureId, displayedSize, uv0, uv1, frame_padding, bg_col, tint_col);
+ bool clicked = ImGui::ImageButton(assetPath, textureId, displayedSize, uv0, uv1, bg_col, tint_col);
return clicked;
}

diff --git a/src/hello_imgui/internal/image_gl_deprecated.cpp b/src/hello_imgui/internal/image_gl_deprecated.cpp
index 5c66c24..98d21d5 100644
--- a/src/hello_imgui/internal/image_gl_deprecated.cpp
+++ b/src/hello_imgui/internal/image_gl_deprecated.cpp
@@ -67,7 +67,9 @@ bool ImageGl::DrawButton(
const ImVec4& tint_col)
{
ImVec2 displayedSize = ImageProportionalSize(size, this->imageSize);
- return ImGui::ImageButton(this->imTextureId, displayedSize, uv0, uv1, frame_padding, bg_col, tint_col);
+ char str_id[64];
+ snprintf(str_id, 64, "ImageButton_%p", this->imTextureId);
+ return ImGui::ImageButton(str_id, this->imTextureId, displayedSize, uv0, uv1, bg_col, tint_col);
}

ImageGlPtr ImageGl::FactorImage(const char *assetPath)
1 change: 1 addition & 0 deletions ports/hello-imgui/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "hello-imgui",
"version": "1.5.2",
"port-version": 1,
"description": "Hello ImGui: unleash your creativity in app development and prototyping",
"homepage": "https://pthom.github.io/hello_imgui/",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions ports/imgui-node-editor/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
fix-vec2-math-operators.patch
remove-getkeyindex.patch # GetKeyIndex() is a no-op since 1.87; see https://github.com/ocornut/imgui/issues/5979#issuecomment-1345349492
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
Expand Down
72 changes: 72 additions & 0 deletions ports/imgui-node-editor/remove-getkeyindex.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
diff --git a/imgui_node_editor.cpp b/imgui_node_editor.cpp
index 1d2bb06..f70d099 100644
--- a/imgui_node_editor.cpp
+++ b/imgui_node_editor.cpp
@@ -60,6 +60,7 @@ namespace Detail {

DECLARE_KEY_TESTER(ImGuiKey_F);
DECLARE_KEY_TESTER(ImGuiKey_D);
+DECLARE_KEY_TESTER(ImGuiKey_Delete);

static inline int GetKeyIndexForF()
{
@@ -70,6 +71,11 @@ static inline int GetKeyIndexForD()
{
return KeyTester_ImGuiKey_D::Get<ImGuiKey_>(nullptr);
}
+
+static inline int GetKeyIndexForDelete()
+{
+ return KeyTester_ImGuiKey_Delete::Get<ImGuiKey_>(nullptr);
+}
# else
static inline ImGuiKey GetKeyIndexForF()
{
@@ -80,6 +86,11 @@ static inline ImGuiKey GetKeyIndexForD()
{
return ImGuiKey_D;
}
+
+static inline ImGuiKey GetKeyIndexForDelete()
+{
+ return ImGuiKey_Delete;
+}
# endif

} // namespace Detail
@@ -4391,6 +4402,7 @@ ed::EditorAction::AcceptResult ed::ShortcutAction::Accept(const Control& control
Action candidateAction = None;

auto& io = ImGui::GetIO();
+# if !defined(IMGUI_VERSION_NUM) || (IMGUI_VERSION_NUM < 18822)
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_X)))
candidateAction = Cut;
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)))
@@ -4401,6 +4413,18 @@ ed::EditorAction::AcceptResult ed::ShortcutAction::Accept(const Control& control
candidateAction = Duplicate;
if (!io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space)))
candidateAction = CreateNode;
+# else
+ if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_X))
+ candidateAction = Cut;
+ if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_C))
+ candidateAction = Copy;
+ if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_V))
+ candidateAction = Paste;
+ if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(GetKeyIndexForD()))
+ candidateAction = Duplicate;
+ if (!io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_Space))
+ candidateAction = CreateNode;
+# endif

if (candidateAction != None)
{
@@ -4953,7 +4977,7 @@ ed::EditorAction::AcceptResult ed::DeleteItemsAction::Accept(const Control& cont
return False;

auto& io = ImGui::GetIO();
- if (Editor->CanAcceptUserInput() && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete)) && Editor->AreShortcutsEnabled())
+ if (Editor->CanAcceptUserInput() && ImGui::IsKeyPressed(GetKeyIndexForDelete()) && Editor->AreShortcutsEnabled())
{
auto& selection = Editor->GetSelectedObjects();
if (!selection.empty())
2 changes: 1 addition & 1 deletion ports/imgui-node-editor/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "imgui-node-editor",
"version": "0.9.3",
"port-version": 1,
"port-version": 2,
"description": "Node Editor built using Dear ImGui",
"homepage": "https://github.com/thedmd/imgui-node-editor",
"license": "MIT",
Expand Down
58 changes: 58 additions & 0 deletions ports/imgui-sfml/0002-clean-deprecated-api.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/imgui-SFML.cpp b/imgui-SFML.cpp
index d9c4f52..6ae99c1 100644
--- a/imgui-SFML.cpp
+++ b/imgui-SFML.cpp
@@ -867,36 +867,9 @@ void SetJoystickRTriggerThreshold(float threshold) {

void SetJoystickMapping(int key, unsigned int joystickButton) {
assert(s_currWindowCtx);
- // This function now expects ImGuiKey_* values.
- // For partial backwards compatibility, also expect some ImGuiNavInput_* values.
- ImGuiKey finalKey;
- switch (key) {
- case ImGuiNavInput_Activate:
- finalKey = ImGuiKey_GamepadFaceDown;
- break;
- case ImGuiNavInput_Cancel:
- finalKey = ImGuiKey_GamepadFaceRight;
- break;
- case ImGuiNavInput_Input:
- finalKey = ImGuiKey_GamepadFaceUp;
- break;
- case ImGuiNavInput_Menu:
- finalKey = ImGuiKey_GamepadFaceLeft;
- break;
- case ImGuiNavInput_FocusPrev:
- case ImGuiNavInput_TweakSlow:
- finalKey = ImGuiKey_GamepadL1;
- break;
- case ImGuiNavInput_FocusNext:
- case ImGuiNavInput_TweakFast:
- finalKey = ImGuiKey_GamepadR1;
- break;
- default:
- assert(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END);
- finalKey = static_cast<ImGuiKey>(key);
- }
+ assert(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END);
assert(joystickButton < sf::Joystick::ButtonCount);
- s_currWindowCtx->joystickMapping[joystickButton] = finalKey;
+ s_currWindowCtx->joystickMapping[joystickButton] = static_cast<ImGuiKey>(key);
}

void SetDPadXAxis(sf::Joystick::Axis dPadXAxis, bool inverted) {
@@ -1228,11 +1201,11 @@ void RenderDrawLists(ImDrawData* draw_data) {
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert),
- (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)));
+ (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, pos)));
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert),
- (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)));
+ (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, uv)));
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert),
- (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)));
+ (const GLvoid*)((const char*)vtx_buffer + offsetof(ImDrawVert, col)));

for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) {
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
111 changes: 111 additions & 0 deletions ports/imgui-sfml/0003-use-explicit-id.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
diff --git a/imgui-SFML.cpp b/imgui-SFML.cpp
index 6ae99c1..069fdeb 100644
--- a/imgui-SFML.cpp
+++ b/imgui-SFML.cpp
@@ -984,49 +984,30 @@ void Image(const sf::Sprite& sprite, const sf::Vector2f& size, const sf::Color&

/////////////// Image Button Overloads for sf::Texture

-bool ImageButton(const sf::Texture& texture, const int framePadding, const sf::Color& bgColor,
- const sf::Color& tintColor) {
- return ImageButton(texture, static_cast<sf::Vector2f>(texture.getSize()), framePadding, bgColor,
- tintColor);
-}
-
-bool ImageButton(const sf::Texture& texture, const sf::Vector2f& size, const int framePadding,
+bool ImageButton(const char* id, const sf::Texture& texture, const sf::Vector2f& size,
const sf::Color& bgColor, const sf::Color& tintColor) {
ImTextureID textureID = convertGLTextureHandleToImTextureID(texture.getNativeHandle());

- return ImGui::ImageButton(textureID, ImVec2(size.x, size.y), ImVec2(0, 0), ImVec2(1, 1),
- framePadding, toImColor(bgColor), toImColor(tintColor));
+ return ImGui::ImageButton(id, textureID, ImVec2(size.x, size.y), ImVec2(0, 0), ImVec2(1, 1),
+ toImColor(bgColor), toImColor(tintColor));
}

/////////////// Image Button Overloads for sf::RenderTexture

-bool ImageButton(const sf::RenderTexture& texture, const int framePadding, const sf::Color& bgColor,
- const sf::Color& tintColor) {
- return ImageButton(texture, static_cast<sf::Vector2f>(texture.getSize()), framePadding, bgColor,
- tintColor);
-}
-
-bool ImageButton(const sf::RenderTexture& texture, const sf::Vector2f& size, const int framePadding,
+bool ImageButton(const char* id, const sf::RenderTexture& texture, const sf::Vector2f& size,
const sf::Color& bgColor, const sf::Color& tintColor) {
ImTextureID textureID =
convertGLTextureHandleToImTextureID(texture.getTexture().getNativeHandle());

- return ImGui::ImageButton(textureID, ImVec2(size.x, size.y), ImVec2(0, 1),
+ return ImGui::ImageButton(id, textureID, ImVec2(size.x, size.y), ImVec2(0, 1),
ImVec2(1, 0), // flipped vertically, because textures in
// sf::RenderTexture are stored this way
- framePadding, toImColor(bgColor), toImColor(tintColor));
+ toImColor(bgColor), toImColor(tintColor));
}

/////////////// Image Button Overloads for sf::Sprite

-bool ImageButton(const sf::Sprite& sprite, const int framePadding, const sf::Color& bgColor,
- const sf::Color& tintColor) {
- sf::FloatRect spriteSize = sprite.getGlobalBounds();
- return ImageButton(sprite, sf::Vector2f(spriteSize.width, spriteSize.height), framePadding,
- bgColor, tintColor);
-}
-
-bool ImageButton(const sf::Sprite& sprite, const sf::Vector2f& size, const int framePadding,
+bool ImageButton(const char* id, const sf::Sprite& sprite, const sf::Vector2f& size,
const sf::Color& bgColor, const sf::Color& tintColor) {
#if SFML_VERSION_MAJOR >= 3
const sf::Texture& texture = sprite.getTexture();
@@ -1045,8 +1026,8 @@ bool ImageButton(const sf::Sprite& sprite, const sf::Vector2f& size, const int f
(textureRect.top + textureRect.height) / textureSize.y);

ImTextureID textureID = convertGLTextureHandleToImTextureID(texture.getNativeHandle());
- return ImGui::ImageButton(textureID, ImVec2(size.x, size.y), uv0, uv1, framePadding,
- toImColor(bgColor), toImColor(tintColor));
+ return ImGui::ImageButton(id, textureID, ImVec2(size.x, size.y), uv0, uv1, toImColor(bgColor),
+ toImColor(tintColor));
}

/////////////// Draw_list Overloads
diff --git a/imgui-SFML.h b/imgui-SFML.h
index e431e99..8cce4d6 100644
--- a/imgui-SFML.h
+++ b/imgui-SFML.h
@@ -99,29 +99,19 @@ IMGUI_SFML_API void Image(const sf::Sprite& sprite, const sf::Vector2f& size,
const sf::Color& borderColor = sf::Color::Transparent);

// ImageButton overloads for sf::Texture
-IMGUI_SFML_API bool ImageButton(const sf::Texture& texture, const int framePadding = -1,
- const sf::Color& bgColor = sf::Color::Transparent,
- const sf::Color& tintColor = sf::Color::White);
-IMGUI_SFML_API bool ImageButton(const sf::Texture& texture, const sf::Vector2f& size,
- const int framePadding = -1,
+IMGUI_SFML_API bool ImageButton(const char* id, const sf::Texture& texture,
+ const sf::Vector2f& size,
const sf::Color& bgColor = sf::Color::Transparent,
const sf::Color& tintColor = sf::Color::White);

// ImageButton overloads for sf::RenderTexture
-IMGUI_SFML_API bool ImageButton(const sf::RenderTexture& texture, const int framePadding = -1,
- const sf::Color& bgColor = sf::Color::Transparent,
- const sf::Color& tintColor = sf::Color::White);
-IMGUI_SFML_API bool ImageButton(const sf::RenderTexture& texture, const sf::Vector2f& size,
- const int framePadding = -1,
+IMGUI_SFML_API bool ImageButton(const char* id, const sf::RenderTexture& texture,
+ const sf::Vector2f& size,
const sf::Color& bgColor = sf::Color::Transparent,
const sf::Color& tintColor = sf::Color::White);

// ImageButton overloads for sf::Sprite
-IMGUI_SFML_API bool ImageButton(const sf::Sprite& sprite, const int framePadding = -1,
- const sf::Color& bgColor = sf::Color::Transparent,
- const sf::Color& tintColor = sf::Color::White);
-IMGUI_SFML_API bool ImageButton(const sf::Sprite& sprite, const sf::Vector2f& size,
- const int framePadding = -1,
+IMGUI_SFML_API bool ImageButton(const char* id, const sf::Sprite& sprite, const sf::Vector2f& size,
const sf::Color& bgColor = sf::Color::Transparent,
const sf::Color& tintColor = sf::Color::White);

2 changes: 2 additions & 0 deletions ports/imgui-sfml/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
0001-fix_find_package.patch
0002-clean-deprecated-api.patch # see https://github.com/SFML/imgui-sfml/pull/305
0003-use-explicit-id.patch # see https://github.com/SFML/imgui-sfml/pull/266
)

vcpkg_cmake_configure(
Expand Down
1 change: 1 addition & 0 deletions ports/imgui-sfml/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "imgui-sfml",
"version": "2.6",
"port-version": 1,
"description": "ImGui binding for use with SFML",
"homepage": "https://github.com/eliasdaler/imgui-sfml",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions ports/imgui/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ if ("docking-experimental" IN_LIST FEATURES)
OUT_SOURCE_PATH SOURCE_PATH
REPO ocornut/imgui
REF "v${VERSION}-docking"
SHA512 07492ef56d0518b1a941d8da6ccb1cfe9a8253db3057f2875a033b144047065f43240e0cb8f4ef5d3cad76ccd84fd26fc673c673f4a484d10d2c8545ec286bdb
SHA512 2864672d3b08caf3396f69affe1b83d7977d2300f571864378ebe5b4a1a1b5634e6e171c8870444b7f8947fdc681aeaf07f59b25a290c94059d36226fc7e1aad
HEAD_REF docking
)
else()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ocornut/imgui
REF "v${VERSION}"
SHA512 dbf0ce45dc6fb100c02bb4fda3d95e0bed615ae9d91b269ad6f42b11fb5aa6a22ec7649ac8c96eb260bed454db56e975de33cd6ab55fa8b7e249f9c87b07a90e
SHA512 85ced14d0c4c3506caf0cff5897dc2c49521fe6de5bcadbc1107e2b63d6bd9a19f967960ba31206187fc2c830246f635e8f2b29b0b1ff522be209dd2a5349529
HEAD_REF master
)
endif()
Expand Down Expand Up @@ -63,7 +63,7 @@ if ("test-engine" IN_LIST FEATURES)
OUT_SOURCE_PATH TEST_ENGINE_SOURCE_PATH
REPO ocornut/imgui_test_engine
REF "v${VERSION}"
SHA512 4c4d7fd32504c1a56a5f1816f5032e4390ea9eb5d56c1ee2293950c808e23c1b94df9edf524fcc4122d27fa86d749454862ddb0d1a83633c014fe33f900836b5
SHA512 b18d64732629f01eb4153c7f7dbc2184d7ad1d63d0dc1b4f42120209c673f20ebc202bf7bc6ab27ae1a23a9437d40cc9f77c3e100e0e6de3ed6eb0087c41b7a4
HEAD_REF master
)

Expand Down
2 changes: 1 addition & 1 deletion ports/imgui/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imgui",
"version": "1.91.0",
"version": "1.91.5",
"description": "Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies.",
"homepage": "https://github.com/ocornut/imgui",
"license": "MIT",
Expand Down
Loading

0 comments on commit ab65510

Please sign in to comment.