Skip to content

Commit 5de7f69

Browse files
committed
(BREAKING) Commented out obsolete ImageButton(). (#5533, #4471, #2464, #1390)
1 parent 214977e commit 5de7f69

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

docs/CHANGELOG.txt

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ Breaking changes:
5757
(Because PlatformOpenInShellFn and PlatformSetImeDataFn were introduced very recently and
5858
often automatically set by core library and backends, we are exceptionally not maintaining
5959
a legacy redirection symbol for those two.)
60+
- Commented the old ImageButton() signature obsoleted in 1.89 (~August 2022). (#5533, #4471, #2464, #1390)
61+
- old ImageButton() used ImTextureId as item id (created issue with e.g. multiple buttons in same scope, transient texture id values, opaque computation of ID)
62+
- new ImageButton() requires an explicit 'const char* str_id'
63+
- old ImageButton() had frame_padding' override argument.
64+
- new ImageButton() always use style.FramePadding, which you can freely override with PushStyleVar()/PopStyleVar().
6065

6166
Other changes:
6267

docs/TODO.txt

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
190190
- tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height? format only %s/%c to be able to count height?)
191191

192192
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
193+
- settings: facilitate extension lazily calling AddSettingsHandler() while running and still getting their data call the ReadXXX handlers immediately.
193194
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)
194195
- settings/persistence: helpers to make TreeNodeBehavior persist (even during dev!) - may need to store some semantic and/or data type in ImGuiStoragePair
195196

imgui.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ CODE
438438
- io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint (#7389, #6719, #2278)
439439
- access those via GetPlatformIO() instead of GetIO().
440440
some were introduced very recently and often automatically setup by core library and backends, so for those we are exceptionally not maintaining a legacy redirection symbol.
441+
- commented the old ImageButton() signature obsoleted in 1.89 (~August 2022). As a reminder:
442+
- old ImageButton() before 1.89 used ImTextureId as item id (created issue with e.g. multiple buttons in same scope, transient texture id values, opaque computation of ID)
443+
- new ImageButton() since 1.89 requires an explicit 'const char* str_id'
444+
- old ImageButton() before 1.89 had frame_padding' override argument.
445+
- new ImageButton() since 1.89 always use style.FramePadding, which you can freely override with PushStyleVar()/PopStyleVar().
441446
- 2024/07/25 (1.91.0) - obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). (see #7838 on GitHub for more info)
442447
you should never need those functions. you can do everything with GetCursorScreenPos() and GetContentRegionAvail() in a more simple way.
443448
- instead of: GetWindowContentRegionMax().x - GetCursorPos().x

imgui.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3547,13 +3547,13 @@ namespace ImGui
35473547
// OBSOLETED in 1.89.4 (from March 2023)
35483548
static inline void PushAllowKeyboardFocus(bool tab_stop) { PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop); }
35493549
static inline void PopAllowKeyboardFocus() { PopItemFlag(); }
3550-
// OBSOLETED in 1.89 (from August 2022)
3551-
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1)); // Use new ImageButton() signature (explicit item id, regular FramePadding)
35523550
// OBSOLETED in 1.87 (from February 2022 but more formally obsoleted April 2024)
35533551
IMGUI_API ImGuiKey GetKeyIndex(ImGuiKey key); // Map ImGuiKey_* values into legacy native key index. == io.KeyMap[key]. When using a 1.87+ backend using io.AddKeyEvent(), calling GetKeyIndex() with ANY ImGuiKey_XXXX values will return the same value!
35543552
//static inline ImGuiKey GetKeyIndex(ImGuiKey key) { IM_ASSERT(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END); return key; }
35553553

35563554
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
3555+
//-- OBSOLETED in 1.89 (from August 2022)
3556+
//IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1)); // --> Use new ImageButton() signature (explicit item id, regular FramePadding). Refer to code in 1.91 if you want to grab a copy of this version.
35573557
//-- OBSOLETED in 1.88 (from May 2022)
35583558
//static inline void CaptureKeyboardFromApp(bool want_capture_keyboard = true) { SetNextFrameWantCaptureKeyboard(want_capture_keyboard); } // Renamed as name was misleading + removed default value.
35593559
//static inline void CaptureMouseFromApp(bool want_capture_mouse = true) { SetNextFrameWantCaptureMouse(want_capture_mouse); } // Renamed as name was misleading + removed default value.

imgui_widgets.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -1108,28 +1108,24 @@ bool ImGui::ImageButton(const char* str_id, ImTextureID user_texture_id, const I
11081108

11091109
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
11101110
// Legacy API obsoleted in 1.89. Two differences with new ImageButton()
1111-
// - new ImageButton() requires an explicit 'const char* str_id' Old ImageButton() used opaque imTextureId (created issue with: multiple buttons with same image, transient texture id values, opaque computation of ID)
1112-
// - new ImageButton() always use style.FramePadding Old ImageButton() had an override argument.
1113-
// If you need to change padding with new ImageButton() you can use PushStyleVar(ImGuiStyleVar_FramePadding, value), consistent with other Button functions.
1111+
// - old ImageButton() used ImTextureId as item id (created issue with multiple buttons with same image, transient texture id values, opaque computation of ID)
1112+
// - new ImageButton() requires an explicit 'const char* str_id'
1113+
// - old ImageButton() had frame_padding' override argument.
1114+
// - new ImageButton() always use style.FramePadding.
1115+
/*
11141116
bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col)
11151117
{
1116-
ImGuiContext& g = *GImGui;
1117-
ImGuiWindow* window = g.CurrentWindow;
1118-
if (window->SkipItems)
1119-
return false;
1120-
11211118
// Default to using texture ID as ID. User can still push string/integer prefixes.
11221119
PushID((void*)(intptr_t)user_texture_id);
1123-
const ImGuiID id = window->GetID("#image");
1124-
PopID();
1125-
11261120
if (frame_padding >= 0)
11271121
PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2((float)frame_padding, (float)frame_padding));
1128-
bool ret = ImageButtonEx(id, user_texture_id, size, uv0, uv1, bg_col, tint_col);
1122+
bool ret = ImageButton("", user_texture_id, size, uv0, uv1, bg_col, tint_col);
11291123
if (frame_padding >= 0)
11301124
PopStyleVar();
1125+
PopID();
11311126
return ret;
11321127
}
1128+
*/
11331129
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
11341130

11351131
bool ImGui::Checkbox(const char* label, bool* v)

0 commit comments

Comments
 (0)