Skip to content

Commit

Permalink
Merge pull request #80 from zlianon/master
Browse files Browse the repository at this point in the history
Add ItemSpacing/FrameHeightWithSpacing
  • Loading branch information
AllenDang authored Nov 4, 2020
2 parents ec1448f + fe6bc13 commit e95a98d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Style.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ func GetWindowPadding() (float32, float32) {
return vec2.X, vec2.Y
}

func GetItemSpacing() (float32, float32) {
vec2 := imgui.CurrentStyle().ItemSpacing()
return vec2.X, vec2.Y
}

func GetItemInnerSpacing() (float32, float32) {
vec2 := imgui.CurrentStyle().ItemInnerSpacing()
return vec2.X, vec2.Y
Expand Down
9 changes: 9 additions & 0 deletions imgui/Style.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ func (style Style) handle() C.IggGuiStyle {
return C.IggGuiStyle(style)
}

// ItemSpacing is the horizontal and vertical spacing between widgets/lines.
func (style Style) ItemSpacing() Vec2 {
var value Vec2
valueArg, valueFin := value.wrapped()
C.iggStyleGetItemSpacing(style.handle(), valueArg)
valueFin()
return value
}

// ItemInnerSpacing is the horizontal and vertical spacing between elements of
// a composed widget (e.g. a slider and its label).
func (style Style) ItemInnerSpacing() Vec2 {
Expand Down
6 changes: 6 additions & 0 deletions imgui/StyleWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
#include "StyleWrapper.h"
#include "WrapperConverter.h"

void iggStyleGetItemSpacing(IggGuiStyle handle, IggVec2 *value)
{
ImGuiStyle *style = reinterpret_cast<ImGuiStyle *>(handle);
exportValue(*value, style->ItemSpacing);
}

void iggStyleGetItemInnerSpacing(IggGuiStyle handle, IggVec2 *value)
{
ImGuiStyle *style = reinterpret_cast<ImGuiStyle *>(handle);
Expand Down
2 changes: 2 additions & 0 deletions imgui/StyleWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extern "C"
{
#endif

extern void iggStyleGetItemSpacing(IggGuiStyle handle, IggVec2 *value);

extern void iggStyleGetItemInnerSpacing(IggGuiStyle handle, IggVec2 *value);

extern void iggStyleGetWindowPadding(IggGuiStyle handle, IggVec2 *value);
Expand Down
5 changes: 5 additions & 0 deletions imgui/imgui.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@ func TextLineHeightWithSpacing() float32 {
return float32(C.iggGetTextLineHeightWithSpacing())
}

// FrameHeightWithSpacing return ~ FontSize + style.FramePadding.y * 2.0f + style.ItemSpacing.y;
func FrameHeightWithSpacing() float32 {
return float32(C.iggFrameHeightWithSpacing())
}

// TreeNodeV returns true if the tree branch is to be rendered. Call TreePop() in this case.
func TreeNodeV(label string, flags int) bool {
labelArg, labelFin := wrapString(label)
Expand Down
5 changes: 5 additions & 0 deletions imgui/imguiWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,11 @@ float iggGetTextLineHeightWithSpacing(void)
return ImGui::GetTextLineHeightWithSpacing();
}

float iggFrameHeightWithSpacing(void)
{
return ImGui::GetFrameHeightWithSpacing();
}

IggBool iggTreeNode(char const *label, int flags)
{
return ImGui::TreeNodeEx(label, flags) ? 1 : 0;
Expand Down
1 change: 1 addition & 0 deletions imgui/imguiWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extern void iggMousePos(IggVec2 *pos);
extern void iggAlignTextToFramePadding();
extern float iggGetTextLineHeight(void);
extern float iggGetTextLineHeightWithSpacing(void);
extern float iggFrameHeightWithSpacing(void);

extern IggBool iggTreeNode(char const *label, int flags);
extern void iggTreePop(void);
Expand Down

0 comments on commit e95a98d

Please sign in to comment.