From 9bedcb530498ef2d94da52b1ed657c0b2fc97940 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 2 Jul 2015 14:46:49 -0600 Subject: [PATCH] Added GetCursorStartPos() necessary for using scroll target relative to beginning of window content (#150) --- imgui.cpp | 6 ++++++ imgui.h | 1 + 2 files changed, 7 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 63b74b07..06f00d44 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4797,6 +4797,12 @@ void ImGui::SetCursorPosY(float y) window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y); } +ImVec2 ImGui::GetCursorStartPos() +{ + ImGuiWindow* window = GetCurrentWindow(); + return window->DC.CursorStartPos - window->Pos; +} + ImVec2 ImGui::GetCursorScreenPos() { ImGuiWindow* window = GetCurrentWindow(); diff --git a/imgui.h b/imgui.h index fd1bc922..3b520df7 100644 --- a/imgui.h +++ b/imgui.h @@ -201,6 +201,7 @@ namespace ImGui IMGUI_API void SetCursorPos(const ImVec2& pos); // " IMGUI_API void SetCursorPosX(float x); // " IMGUI_API void SetCursorPosY(float y); // " + IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize] IMGUI_API void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets