diff --git a/imgui/imgui.go b/imgui/imgui.go index 82b7e162..4f784984 100644 --- a/imgui/imgui.go +++ b/imgui/imgui.go @@ -1298,6 +1298,34 @@ func SetTabItemClosed(tabOrDockedWindowLabel string) { C.iggSetTabItemClosed(labelArg) } +// ScrollX returns the horizontal scrolling amount [0..GetScrollMaxX()]. +func ScrollX() float32 { + return float32(C.iggGetScrollX()) +} + +// ScrollY returns the vertical scrolling amount [0..GetScrollMaxY()]. +func ScrollY() float32 { + return float32(C.iggGetScrollY()) +} + +// ScrollMaxX returns the maximum horizontal scrolling amount: ContentSize.X - WindowSize.X . +func ScrollMaxX() float32 { + return float32(C.iggGetScrollMaxX()) +} + +// ScrollMaxY returns the maximum vertical scrolling amount: ContentSize.Y - WindowSize.Y . +func ScrollMaxY() float32 { + return float32(C.iggGetScrollMaxY()) +} + +// SetScrollHereX adjusts horizontal scrolling amount to make current cursor +// position visible. ratio=0.0: left, 0.5: center, 1.0: right. When using to +// make a "default/current item" visible, consider using SetItemDefaultFocus() +// instead. +func SetScrollHereX(ratio float32) { + C.iggSetScrollHereX(C.float(ratio)) +} + // SetScrollHereY adjusts scrolling amount to make current cursor position visible. // ratio=0.0: top, 0.5: center, 1.0: bottom. // When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. @@ -1305,6 +1333,16 @@ func SetScrollHereY(ratio float32) { C.iggSetScrollHereY(C.float(ratio)) } +// SetScrollX sets horizontal scrolling amount [0..GetScrollMaxX()]. +func SetScrollX(scrollX float32) { + C.iggSetScrollX(C.float(scrollX)) +} + +// SetScrollY sets vertical scrolling amount [0..GetScrollMaxY()]. +func SetScrollY(scrollY float32) { + C.iggSetScrollY(C.float(scrollY)) +} + // SetItemDefaultFocus makes the last item the default focused item of a window. func SetItemDefaultFocus() { C.iggSetItemDefaultFocus() diff --git a/imgui/imguiWrapper.cpp b/imgui/imguiWrapper.cpp index 949f2112..8e0779da 100644 --- a/imgui/imguiWrapper.cpp +++ b/imgui/imguiWrapper.cpp @@ -780,11 +780,46 @@ int iggGetColumnsCount() return ImGui::GetColumnsCount(); } +float iggGetScrollX() +{ + return ImGui::GetScrollX(); +} + +float iggGetScrollY() +{ + return ImGui::GetScrollY(); +} + +float iggGetScrollMaxX() +{ + return ImGui::GetScrollMaxX(); +} + +float iggGetScrollMaxY() +{ + return ImGui::GetScrollMaxY(); +} + +void iggSetScrollHereX(float centerXRatio) +{ + ImGui::SetScrollHereX(centerXRatio); +} + void iggSetScrollHereY(float centerYRatio) { ImGui::SetScrollHereY(centerYRatio); } +void iggSetScrollX(float scrollX) +{ + ImGui::SetScrollX(scrollX); +} + +void iggSetScrollY(float scrollY) +{ + ImGui::SetScrollY(scrollY); +} + void iggSetItemDefaultFocus() { ImGui::SetItemDefaultFocus(); diff --git a/imgui/imguiWrapper.h b/imgui/imguiWrapper.h index c45e7cb0..5649463b 100644 --- a/imgui/imguiWrapper.h +++ b/imgui/imguiWrapper.h @@ -220,7 +220,15 @@ extern void iggSetColumnWidth(int index, float width); extern float iggGetColumnOffset(int index); extern void iggSetColumnOffset(int index, float offsetX); extern int iggGetColumnsCount(); + +extern float iggGetScrollX(); +extern float iggGetScrollY(); +extern float iggGetScrollMaxX(); +extern float iggGetScrollMaxY(); +extern void iggSetScrollHereX(float centerXRatio); extern void iggSetScrollHereY(float centerYRatio); +extern void iggSetScrollX(float scrollX); +extern void iggSetScrollY(float scrollY); extern void iggSetItemDefaultFocus(); extern IggBool iggIsItemFocused();