Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #132 from inkyblackness/update/v1.79
Browse files Browse the repository at this point in the history
Update to v1.79, set Go module to v3
  • Loading branch information
dertseha authored Dec 28, 2020
2 parents 4e10d9b + fc3660c commit 0065f3b
Show file tree
Hide file tree
Showing 34 changed files with 5,626 additions and 3,029 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.12, 1.13, 1.14]
go-version: [1.12, 1.13, 1.14, 1.15]
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Set up Go
Expand Down
3 changes: 2 additions & 1 deletion AllocatedGlyphRanges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"testing"
"unsafe"

"github.com/inkyblackness/imgui-go/v2"
"github.com/inkyblackness/imgui-go/v3"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ The "verbose" variant should require all the parameters of the underlying functi

### Code Style

Please make sure code is formatted according to `go fmt`, and use the following linter: [golangci-lint](https://github.com/golangci/golangci-lint).
Please make sure Go code is formatted according to `go fmt`, and use the following linter: [golangci-lint](https://github.com/golangci/golangci-lint).

> If there are linter errors that you didn't introduce, you don't have to clean them up - I might have missed them and will be handling them separately.
For the C++ code under `/wrapper`, run `clang-format` (version 11 or newer) to adhere to the common formatting as specified by `/wrapper/.clang-format` file.

### Upgrade to newer Dear ImGui version

To update the **Dear ImGui** sources, overwrite the files in the `imgui` subfolders. Please avoid any files not needed by the wrapper.
Expand Down
2 changes: 2 additions & 0 deletions Condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package imgui
type Condition int

const (
// ConditionNone sets no condition (always set the variable), same as ConditionAlways.
ConditionNone = 0
// ConditionAlways sets the variable.
ConditionAlways Condition = 1 << 0
// ConditionOnce sets the variable once per runtime session (only the first call with succeed).
Expand Down
2 changes: 1 addition & 1 deletion DrawData_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package imgui_test
import (
"testing"

"github.com/inkyblackness/imgui-go/v2"
"github.com/inkyblackness/imgui-go/v3"

"github.com/stretchr/testify/assert"
)
Expand Down
8 changes: 4 additions & 4 deletions DrawList.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func (list DrawList) AddRectFilledV(min Vec2, max Vec2, col PackedColor, roundin
C.iggAddRectFilled(list.handle(), minArg, maxArg, C.IggPackedColor(col), C.float(rounding), C.int(drawCornerFlags))
}

// AddCircleFilled calls AddCircleFilledV(center, radius, col, 12).
// AddCircleFilled calls AddCircleFilledV(center, radius, col, 0).
func (list DrawList) AddCircleFilled(center Vec2, radius float32, col PackedColor) {
list.AddCircleFilledV(center, radius, col, 12)
list.AddCircleFilledV(center, radius, col, 0)
}

// AddCircleFilledV adds a filled circle to the draw list. min is the
Expand All @@ -159,9 +159,9 @@ func (list DrawList) AddCircleFilledV(center Vec2, radius float32, col PackedCol
C.iggAddCircleFilled(list.handle(), centerArg, C.float(radius), C.IggPackedColor(col), C.int(numSegments))
}

// AddCircle calls AddCircleV(center, radius, col, 12, 1.0).
// AddCircle calls AddCircleV(center, radius, col, 0, 1.0).
func (list DrawList) AddCircle(center Vec2, radius float32, col PackedColor) {
list.AddCircleV(center, radius, col, 12, 1.0)
list.AddCircleV(center, radius, col, 0, 1.0)
}

// AddCircleV adds a unfilled circle to the draw list. min is the upper-left
Expand Down
4 changes: 2 additions & 2 deletions Main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package imgui_test
import (
"testing"

"github.com/inkyblackness/imgui-go/v2"
"github.com/inkyblackness/imgui-go/v3"

"github.com/stretchr/testify/assert"
)

func TestVersion(t *testing.T) {
version := imgui.Version()
assert.Equal(t, "1.76", version)
assert.Equal(t, "1.79", version)
}
133 changes: 110 additions & 23 deletions Popup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,40 @@ package imgui
// #include "wrapper/Popup.h"
import "C"

// OpenPopup marks popup as open (don't call every frame!).
// Popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
// By default, Selectable()/MenuItem() are calling CloseCurrentPopup().
// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
func OpenPopup(id string) {
idArg, idFin := wrapString(id)
defer idFin()
C.iggOpenPopup(idArg)
}
// PopupFlags Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions.
// - To be backward compatible with older API which took an 'int mouse_button = 1' argument, we need to treat
// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
// IMPORTANT: because the default parameter is 1 (==ImGuiPopupFlags_MouseButtonRight), if you rely on the default parameter
// and want to another another flag, you need to pass in the ImGuiPopupFlags_MouseButtonRight flag.
// - Multiple buttons currently cannot be combined/or-ed in those functions (we could allow it later).
type PopupFlags int

const (
// PopupFlagsNone no popup flags apply.
PopupFlagsNone = 0
// PopupFlagsMouseButtonLeft For BeginPopupContext*(): open on Left Mouse release. Guaranteed to always be == 0 (same as ImGuiMouseButton_Left)
PopupFlagsMouseButtonLeft = 0
// PopupFlagsMouseButtonRight For BeginPopupContext*(): open on Right Mouse release. Guaranteed to always be == 1 (same as ImGuiMouseButton_Right)
PopupFlagsMouseButtonRight = 1
// PopupFlagsMouseButtonMiddle For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle)
PopupFlagsMouseButtonMiddle = 2
// PopupFlagsNoOpenOverExistingPopup For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
PopupFlagsNoOpenOverExistingPopup = 1 << 5
// PopupFlagsNoOpenOverItems For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space
PopupFlagsNoOpenOverItems = 1 << 6
// PopupFlagsAnyPopupID For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup.
PopupFlagsAnyPopupID = 1 << 7
// PopupFlagsAnyPopupLevel For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level)
PopupFlagsAnyPopupLevel = 1 << 8
// PopupFlagsAnyPopup for any usage.
PopupFlagsAnyPopup = PopupFlagsAnyPopupID | PopupFlagsAnyPopupLevel
)

// BeginPopupV returns true if the popup is open, and you can start outputting to it.
// Only call EndPopup() if BeginPopup() returns true.
func BeginPopupV(name string, flags int) bool {
func BeginPopupV(name string, flags PopupFlags) bool {
nameArg, nameFin := wrapString(name)
defer nameFin()
return C.iggBeginPopup(nameArg, C.int(flags)) != 0
Expand All @@ -28,7 +49,7 @@ func BeginPopup(name string) bool {

// BeginPopupModalV creates modal dialog (regular window with title bar, block interactions behind the modal window,
// can't close the modal window by clicking outside).
func BeginPopupModalV(name string, open *bool, flags int) bool {
func BeginPopupModalV(name string, open *bool, flags PopupFlags) bool {
nameArg, nameFin := wrapString(name)
defer nameFin()
openArg, openFin := wrapBool(open)
Expand All @@ -41,26 +62,92 @@ func BeginPopupModal(name string) bool {
return BeginPopupModalV(name, nil, 0)
}

// BeginPopupContextItemV returns true if the identified mouse button was pressed
// while hovering over the last item.
func BeginPopupContextItemV(label string, mouseButton int) bool {
labelArg, labelFin := wrapString(label)
defer labelFin()
return C.iggBeginPopupContextItem(labelArg, C.int(mouseButton)) != 0
// EndPopup finishes a popup. Only call EndPopup() if BeginPopupXXX() returns true!
func EndPopup() {
C.iggEndPopup()
}

// BeginPopupContextItem calls BeginPopupContextItemV("", 1).
func BeginPopupContextItem() bool {
return BeginPopupContextItemV("", 1)
// OpenPopupV marks popup as open (don't call every frame!).
// Popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
// By default, Selectable()/MenuItem() are calling CloseCurrentPopup().
// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
func OpenPopupV(id string, flags PopupFlags) {
idArg, idFin := wrapString(id)
defer idFin()
C.iggOpenPopup(idArg, C.int(flags))
}

// EndPopup finshes a popup. Only call EndPopup() if BeginPopupXXX() returns true!
func EndPopup() {
C.iggEndPopup()
// OpenPopup calls OpenPopupV(id, 0).
func OpenPopup(id string) {
OpenPopupV(id, 0)
}

// OpenPopupOnItemClickV helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors).
func OpenPopupOnItemClickV(id string, flags PopupFlags) {
idArg, idFin := wrapString(id)
defer idFin()
C.iggOpenPopupOnItemClick(idArg, C.int(flags))
}

// OpenPopupOnItemClick calls OpenPopupOnItemClickV("", PopupFlagsMouseButtonRight).
func OpenPopupOnItemClick() {
OpenPopupOnItemClickV("", PopupFlagsMouseButtonRight)
}

// CloseCurrentPopup closes the popup we have begin-ed into.
// Clicking on a MenuItem or Selectable automatically close the current popup.
func CloseCurrentPopup() {
C.iggCloseCurrentPopup()
}

// BeginPopupContextItemV returns true if the identified mouse button was pressed
// while hovering over the last item.
func BeginPopupContextItemV(id string, flags PopupFlags) bool {
idArg, idFin := wrapString(id)
defer idFin()
return C.iggBeginPopupContextItem(idArg, C.int(flags)) != 0
}

// BeginPopupContextItem calls BeginPopupContextItemV("", PopupFlagsMouseButtonRight).
func BeginPopupContextItem() bool {
return BeginPopupContextItemV("", PopupFlagsMouseButtonRight)
}

// BeginPopupContextWindowV open+begin popup when clicked on current window.
func BeginPopupContextWindowV(id string, flags PopupFlags) bool {
idArg, idFin := wrapString(id)
defer idFin()
return C.iggBeginPopupContextWindow(idArg, C.int(flags)) != 0
}

// BeginPopupContextWindow calls BeginPopupContextWindowV("", PopupFlagsMouseButtonRight).
func BeginPopupContextWindow() bool {
return BeginPopupContextWindowV("", PopupFlagsMouseButtonRight)
}

// BeginPopupContextVoidV open+begin popup when clicked in void (where there are no windows).
func BeginPopupContextVoidV(id string, flags PopupFlags) bool {
idArg, idFin := wrapString(id)
defer idFin()
return C.iggBeginPopupContextVoid(idArg, C.int(flags)) != 0
}

// BeginPopupContextVoid calls BeginPopupContextVoidV("", PopupFlagsMouseButtonRight).
func BeginPopupContextVoid() bool {
return BeginPopupContextVoidV("", PopupFlagsMouseButtonRight)
}

// IsPopupOpenV return true if the popup is open.
// IsPopupOpenV(id, PopupFlagsNone): return true if the popup is open at the current BeginPopup() level of the popup stack.
// IsPopupOpenV(id, PopupFlagsAnyPopupID: return true if any popup is open at the current BeginPopup() level of the popup stack.
// IsPopupOpenV(id, PopupFlagsAnyPopup): return true if any popup is open.
func IsPopupOpenV(id string, flags PopupFlags) bool {
idArg, idFin := wrapString(id)
defer idFin()
return C.iggIsPopupOpen(idArg, C.int(flags)) != 0
}

// IsPopupOpen calls IsPopupOpenV(id, PopupFlagsNone).
func IsPopupOpen(id string) bool {
return IsPopupOpenV(id, PopupFlagsNone)
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This library does not mirror the versions of the wrapped **Dear ImGui**. The sem
* Minor changes: Extensions in API. Typically done through small version increments of **Dear ImGui** and/or exposing further features in a compatible way.
* Patch changes: Bug fixes - either in the wrapper or the wrapped **Dear ImGui**, given that the API & behaviour remains the same.

At the moment, this library uses version [1.76](https://github.com/ocornut/imgui/releases/tag/v1.76) of **Dear ImGui**.
At the moment, this library uses version [1.79](https://github.com/ocornut/imgui/releases/tag/v1.79) of **Dear ImGui**.

## Examples
A separate repository was created to host ported examples and reference implementations.
Expand Down
24 changes: 0 additions & 24 deletions Scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,21 @@ package imgui
// #include "wrapper/Scroll.h"
import "C"

// GetScrollX is deprecated and will be removed in v3.0.0 .
// Deprecated: Use ScrollX() instead.
func GetScrollX() float32 {
return ScrollX()
}

// ScrollX returns the horizontal scrolling amount [0..GetScrollMaxX()].
func ScrollX() float32 {
return float32(C.iggGetScrollX())
}

// GetScrollY is deprecated and will be removed in v3.0.0 .
// Deprecated: Use ScrollY() instead.
func GetScrollY() float32 {
return ScrollY()
}

// ScrollY returns the vertical scrolling amount [0..GetScrollMaxY()].
func ScrollY() float32 {
return float32(C.iggGetScrollY())
}

// GetScrollMaxX is deprecated and will be removed in v3.0.0 .
// Deprecated: Use ScrollMaxX() instead.
func GetScrollMaxX() float32 {
return ScrollMaxX()
}

// ScrollMaxX returns the maximum horizontal scrolling amount: ContentSize.X - WindowSize.X .
func ScrollMaxX() float32 {
return float32(C.iggGetScrollMaxX())
}

// GetScrollMaxY is deprecated and will be removed in v3.0.0 .
// Deprecated: Use ScrollMaxY() instead.
func GetScrollMaxY() float32 {
return ScrollMaxY()
}

// ScrollMaxY returns the maximum vertical scrolling amount: ContentSize.Y - WindowSize.Y .
func ScrollMaxY() float32 {
return float32(C.iggGetScrollMaxY())
Expand Down
2 changes: 1 addition & 1 deletion Vectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/inkyblackness/imgui-go/v2"
"github.com/inkyblackness/imgui-go/v3"
)

func TestVec2Addition(t *testing.T) {
Expand Down
Loading

0 comments on commit 0065f3b

Please sign in to comment.