Addendum to 0ad1d97fb55fb8472daf4ca5dcfaed874f56758d
Note: previously the second parameter to ItemSize() was 0.0f was default, now -1.0f to signify "no text baseline offset request". If you have code using ItemSize() with an hardcoded zero you may need to change it.
diff --git a/imgui.cpp b/imgui.cpp
index a35b20b..130067d 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -2979,7 +2979,7 @@
// We increase the height in this function to accommodate for baseline offset.
// In theory we should be offsetting the starting position (window->DC.CursorPos), that will be the topic of a larger refactor,
// but since ItemSize() is not yet an API that moves the cursor (to handle e.g. wrapping) enlarging the height has the same effect.
- const float offset_to_match_baseline_y = ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y);
+ const float offset_to_match_baseline_y = (text_baseline_y >= 0) ? ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y) : 0.0f;
const float line_height = ImMax(window->DC.CurrLineSize.y, size.y + offset_to_match_baseline_y);
// Always align ourselves on pixel boundaries
@@ -7125,7 +7125,7 @@
}
window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
- ItemSize(group_bb.GetSize(), window->DC.CurrLineTextBaseOffset);
+ ItemSize(group_bb.GetSize());
ItemAdd(group_bb, 0);
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
diff --git a/imgui_internal.h b/imgui_internal.h
index df96fd8..f60bf58 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1542,8 +1542,8 @@
IMGUI_API void PushOverrideID(ImGuiID id);
// Basic Helpers for widget code
- IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = 0.0f);
- IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = 0.0f);
+ IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f);
+ IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = -1.0f);
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index c90a7e6..1550b04 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -213,7 +213,7 @@
text_size.y = (pos - text_pos).y;
ImRect bb(text_pos, text_pos + text_size);
- ItemSize(text_size);
+ ItemSize(text_size, 0.0f);
ItemAdd(bb, 0);
}
else
@@ -222,7 +222,7 @@
const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width);
ImRect bb(text_pos, text_pos + text_size);
- ItemSize(text_size);
+ ItemSize(text_size, 0.0f);
if (!ItemAdd(bb, 0))
return;
@@ -692,7 +692,7 @@
const ImGuiID id = window->GetID(str_id);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
const float default_size = GetFrameHeight();
- ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
+ ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f);
if (!ItemAdd(bb, id))
return false;
@@ -5497,7 +5497,7 @@
ImVec2 pos = window->DC.CursorPos;
pos.y += window->DC.CurrLineTextBaseOffset;
ImRect bb_inner(pos, pos + size);
- ItemSize(size);
+ ItemSize(size, 0.0f);
// Fill horizontal space.
ImVec2 window_padding = window->WindowPadding;
@@ -6428,7 +6428,7 @@
tab_bar->FramePadding = g.Style.FramePadding;
// Layout
- ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()));
+ ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
window->DC.CursorPos.x = tab_bar->BarRect.Min.x;
// Draw separator