Open codecat opened 3 years ago
As a workaround, I've included imgui_internal.h
and wrote my own function:
static void ScriptUI_DummyEx(const glm::vec2& size, float text_baseline_y)
{
//NOTE: Same as ImGui::Dummy, but with the added baseline parameter
ImGuiWindow* window = ImGui::GetCurrentWindow();
if (window->SkipItems) {
return;
}
const ImRect bb(window->DC.CursorPos, ImVec2(window->DC.CursorPos.x + size.x, window->DC.CursorPos.y + size.y));
ImGui::ItemSize(ImVec2(size.x, size.y), text_baseline_y);
ImGui::ItemAdd(bb, 0);
}
Hello,
For now I suggest you keep using your helper DummyEx()
. I'll like to keep this open as I'm been unhappy with the amount of issues caused by text baseline features and I'd like to consider a better overall solution (maybe have baseline as a style var).
Version/Branch of Dear ImGui:
Version: 1.84.1 Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp Operating System: Windows
My Issue/Question:
For custom controls, it would be useful to have access to the baseline offset from
ImGui::Dummy
which would be passed down toItemSize
.https://github.com/ocornut/imgui/blob/2d0a6a4969b4da5eae0704e740e1ae0e11b946d9/imgui_widgets.cpp#L1319-L1328
Screenshots/Video
My custom control is a simple tag, which is a colored background around around some text. In the below screenshots, note the
test
text is anImGui::Text
afterImGui::SameLine
.Without baseline offset:
With baseline offset:
Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261)