Skip to content

Commit

Permalink
Merge pull request #130 from saucesaft/master
Browse files Browse the repository at this point in the history
Add imgui scroll functions
  • Loading branch information
AllenDang authored Jan 24, 2021
2 parents 809022c + ba657c0 commit 712f0f1
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
38 changes: 38 additions & 0 deletions imgui/imgui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1298,13 +1298,51 @@ 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.
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()
Expand Down
35 changes: 35 additions & 0 deletions imgui/imguiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions imgui/imguiWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 712f0f1

Please sign in to comment.