-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
304 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.