From c4770c0b6913a53be3a06c7d48570234c7e846d0 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 19 Aug 2022 16:23:16 -0700 Subject: [PATCH 01/13] Add support for FontGlyph --- Font.go | 72 +++++++++++++++++++++++++++++++++++++++ FontAtlas.go | 4 +++ wrapper/Font.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++ wrapper/Font.h | 13 ++++++++ wrapper/FontAtlas.cpp | 6 ++++ wrapper/FontAtlas.h | 1 + wrapper/Types.h | 1 + 7 files changed, 175 insertions(+) diff --git a/Font.go b/Font.go index 4eac79fc..9108fc45 100644 --- a/Font.go +++ b/Font.go @@ -7,6 +7,9 @@ import "C" // Font describes one loaded font in an atlas. type Font uintptr +// FontGlyph represents a single font glyph from a font atlas. +type FontGlyph uintptr + // DefaultFont can be used to refer to the default font of the current font atlas without // having the actual font reference. const DefaultFont Font = 0 @@ -43,3 +46,72 @@ func CalcTextSize(text string, hideTextAfterDoubleHash bool, wrapWidth float32) func (font Font) handle() C.IggFont { return C.IggFont(font) } + +// FindGlyph returns the FontGlyph corresponding to the given rune. +func (font Font) FindGlyph(ch rune) FontGlyph { + return FontGlyph(C.iggFindGlyph(font.handle(), C.int(ch))) +} + +func (glyph FontGlyph) handle() C.IggFontGlyph { + return C.IggFontGlyph(glyph) +} + +// Colored returns whether the glyph is colored. +func (glyph FontGlyph) Colored() bool { + return C.iggFontGlyphColored(glyph.handle()) != 0 +} + +// Visible indicates whether the glyph is visible; it will be false for a space character, for example. +func (glyph FontGlyph) Visible() bool { + return C.iggFontGlyphVisible(glyph.handle()) != 0 +} + +// Codepoint returns the codepoint associated with the glyph. +func (glyph FontGlyph) Codepoint() int { + return int(C.iggFontGlyphCodepoint(glyph.handle())) +} + +// AdvanceX returns the horizontal difference to the next character after the glyph is drawn. +func (glyph FontGlyph) AdvanceX() float32 { + return float32(C.iggFontGlyphAdvanceX(glyph.handle())) +} + +// X0 returns the lower x coordinate of the glyph. +func (glyph FontGlyph) X0() float32 { + return float32(C.iggFontGlyphX0(glyph.handle())) +} + +// Y0 returns the lower y coordinate of the glyph. +func (glyph FontGlyph) Y0() float32 { + return float32(C.iggFontGlyphY0(glyph.handle())) +} + +// X1 returns the upper x coordinate of the glyph. +func (glyph FontGlyph) X1() float32 { + return float32(C.iggFontGlyphX1(glyph.handle())) +} + +// Y1 returns the upper y coordinate of the glyph. +func (glyph FontGlyph) Y1() float32 { + return float32(C.iggFontGlyphY1(glyph.handle())) +} + +// U0 returns the u texture coordinate associated with the X0() vertex of the glyph. +func (glyph FontGlyph) U0() float32 { + return float32(C.iggFontGlyphU0(glyph.handle())) +} + +// V0 returns the v texture coordinate associated with the Y0() vertex of the glyph. +func (glyph FontGlyph) V0() float32 { + return float32(C.iggFontGlyphV0(glyph.handle())) +} + +// U1 returns the u texture coordinate associated with the X1() vertex of the glyph. +func (glyph FontGlyph) U1() float32 { + return float32(C.iggFontGlyphU1(glyph.handle())) +} + +// V1 returns the v texture coordinate associated with the Y1() vertex of the glyph. +func (glyph FontGlyph) V1() float32 { + return float32(C.iggFontGlyphV1(glyph.handle())) +} diff --git a/FontAtlas.go b/FontAtlas.go index fcec7890..500c5ce1 100644 --- a/FontAtlas.go +++ b/FontAtlas.go @@ -163,6 +163,10 @@ func (atlas FontAtlas) SetTextureID(id TextureID) { C.iggFontAtlasSetTextureID(atlas.handle(), id.handle()) } +func (atlas FontAtlas) GetTextureID() TextureID { + return TextureID(C.iggFontAtlasGetTextureID(atlas.handle())) +} + // Build pixels data. This is called automatically for you by the TextureData*** functions. func (atlas FontAtlas) Build() bool { return C.iggFontAtlasBuild(atlas.handle()) != 0 diff --git a/wrapper/Font.cpp b/wrapper/Font.cpp index df66e3d7..34d0c46e 100644 --- a/wrapper/Font.cpp +++ b/wrapper/Font.cpp @@ -22,3 +22,81 @@ void iggCalcTextSize(const char *text, int length, IggBool hide_text_after_doubl { exportValue(*value, ImGui::CalcTextSize(text, text + length, hide_text_after_double_hash, wrap_width)); } + +IggFontGlyph iggFindGlyph(IggFont handle, int ch) +{ + ImFont *font = reinterpret_cast(handle); + return (IggFontGlyph)font->FindGlyph(ch); +} + +int iggFontGlyphColored(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Colored; +} + +int iggFontGlyphVisible(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Visible; +} + +int iggFontGlyphCodepoint(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Codepoint; +} + +float iggFontGlyphAdvanceX(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->AdvanceX; +} + +float iggFontGlyphX0(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->X0; +} + +float iggFontGlyphY0(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Y0; +} + +float iggFontGlyphX1(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->X1; +} + +float iggFontGlyphY1(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Y1; +} + +float iggFontGlyphU0(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->U0; +} + +float iggFontGlyphV0(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->V0; +} + +float iggFontGlyphU1(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->U1; +} + +float iggFontGlyphV1(IggFontGlyph handle) +{ + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->V1; +} diff --git a/wrapper/Font.h b/wrapper/Font.h index 6611d4cf..45be03ef 100644 --- a/wrapper/Font.h +++ b/wrapper/Font.h @@ -10,6 +10,19 @@ extern void iggPushFont(IggFont handle); extern void iggPopFont(void); extern void iggCalcTextSize(const char *text, int length, IggBool hide_text_after_double_hash, float wrap_width, IggVec2 *value); extern float iggGetFontSize(); +extern IggFontGlyph iggFindGlyph(IggFont font, int ch); +extern int iggFontGlyphColored(IggFontGlyph glyph); +extern int iggFontGlyphVisible(IggFontGlyph glyph); +extern int iggFontGlyphCodepoint(IggFontGlyph glyph); +extern float iggFontGlyphAdvanceX(IggFontGlyph glyph); +extern float iggFontGlyphX0(IggFontGlyph glyph); +extern float iggFontGlyphY0(IggFontGlyph glyph); +extern float iggFontGlyphX1(IggFontGlyph glyph); +extern float iggFontGlyphY1(IggFontGlyph glyph); +extern float iggFontGlyphU0(IggFontGlyph glyph); +extern float iggFontGlyphV0(IggFontGlyph glyph); +extern float iggFontGlyphU1(IggFontGlyph glyph); +extern float iggFontGlyphV1(IggFontGlyph glyph); #ifdef __cplusplus } diff --git a/wrapper/FontAtlas.cpp b/wrapper/FontAtlas.cpp index 7f17381a..dd378881 100644 --- a/wrapper/FontAtlas.cpp +++ b/wrapper/FontAtlas.cpp @@ -106,6 +106,12 @@ void iggFontAtlasSetTextureID(IggFontAtlas handle, IggTextureID id) fontAtlas->SetTexID(reinterpret_cast(id)); } +IggTextureID iggFontAtlasGetTextureID(IggFontAtlas handle) +{ + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return IggTextureID(fontAtlas->TexID); +} + IggBool iggFontAtlasBuild(IggFontAtlas handle) { ImFontAtlas *fontAtlas = reinterpret_cast(handle); diff --git a/wrapper/FontAtlas.h b/wrapper/FontAtlas.h index 5eec373f..90e3f8b2 100644 --- a/wrapper/FontAtlas.h +++ b/wrapper/FontAtlas.h @@ -28,6 +28,7 @@ extern void iggFontAtlasGetTexDataAsAlpha8(IggFontAtlas handle, unsigned char ** extern void iggFontAtlasGetTexDataAsRGBA32(IggFontAtlas handle, unsigned char **pixels, int *width, int *height, int *bytesPerPixel); extern void iggFontAtlasSetTextureID(IggFontAtlas handle, IggTextureID id); +extern IggTextureID iggFontAtlasGetTextureID(IggFontAtlas handle); extern IggBool iggFontAtlasBuild(IggFontAtlas handle); extern unsigned int iggFontAtlasGetFontBuilderFlags(IggFontAtlas handle); diff --git a/wrapper/Types.h b/wrapper/Types.h index 3e02e5db..83af7767 100644 --- a/wrapper/Types.h +++ b/wrapper/Types.h @@ -17,6 +17,7 @@ typedef void *IggDrawList; typedef void *IggFontAtlas; typedef void *IggFontConfig; typedef void *IggFont; +typedef void *IggFontGlyph; typedef void *IggGlyphRanges; typedef void *IggGuiStyle; typedef void *IggInputTextCallbackData; From 0c2a8c60f7680ecc279252ba4f8f54b5ea71958d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 19 Aug 2022 16:27:37 -0700 Subject: [PATCH 02/13] run clang-format --- wrapper/Font.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/wrapper/Font.cpp b/wrapper/Font.cpp index 34d0c46e..2d39069f 100644 --- a/wrapper/Font.cpp +++ b/wrapper/Font.cpp @@ -31,72 +31,72 @@ IggFontGlyph iggFindGlyph(IggFont handle, int ch) int iggFontGlyphColored(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->Colored; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Colored; } int iggFontGlyphVisible(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->Visible; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Visible; } int iggFontGlyphCodepoint(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->Codepoint; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Codepoint; } float iggFontGlyphAdvanceX(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->AdvanceX; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->AdvanceX; } float iggFontGlyphX0(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->X0; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->X0; } float iggFontGlyphY0(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->Y0; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Y0; } float iggFontGlyphX1(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->X1; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->X1; } float iggFontGlyphY1(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->Y1; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->Y1; } float iggFontGlyphU0(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->U0; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->U0; } float iggFontGlyphV0(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->V0; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->V0; } float iggFontGlyphU1(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->U1; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->U1; } float iggFontGlyphV1(IggFontGlyph handle) { - ImFontGlyph *glyph = reinterpret_cast(handle); - return glyph->V1; + ImFontGlyph *glyph = reinterpret_cast(handle); + return glyph->V1; } From 0a57f07d03ab6477c29262f44da9d350dd32dd1c Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 20 Aug 2022 06:52:50 -0700 Subject: [PATCH 03/13] Add Font::FontSize() as well --- Font.go | 5 +++++ wrapper/Font.cpp | 6 ++++++ wrapper/Font.h | 1 + 3 files changed, 12 insertions(+) diff --git a/Font.go b/Font.go index 9108fc45..577a357a 100644 --- a/Font.go +++ b/Font.go @@ -47,6 +47,11 @@ func (font Font) handle() C.IggFont { return C.IggFont(font) } +// FontSize returns the height of the given font. +func (font Font) FontSize() float32 { + return float32(C.iggFontFontSize(font.handle())) +} + // FindGlyph returns the FontGlyph corresponding to the given rune. func (font Font) FindGlyph(ch rune) FontGlyph { return FontGlyph(C.iggFindGlyph(font.handle(), C.int(ch))) diff --git a/wrapper/Font.cpp b/wrapper/Font.cpp index 2d39069f..e40f5465 100644 --- a/wrapper/Font.cpp +++ b/wrapper/Font.cpp @@ -23,6 +23,12 @@ void iggCalcTextSize(const char *text, int length, IggBool hide_text_after_doubl exportValue(*value, ImGui::CalcTextSize(text, text + length, hide_text_after_double_hash, wrap_width)); } +float iggFontFontSize(IggFont handle) +{ + ImFont *font = reinterpret_cast(handle); + return font->FontSize; +} + IggFontGlyph iggFindGlyph(IggFont handle, int ch) { ImFont *font = reinterpret_cast(handle); diff --git a/wrapper/Font.h b/wrapper/Font.h index 45be03ef..d165e3dc 100644 --- a/wrapper/Font.h +++ b/wrapper/Font.h @@ -10,6 +10,7 @@ extern void iggPushFont(IggFont handle); extern void iggPopFont(void); extern void iggCalcTextSize(const char *text, int length, IggBool hide_text_after_double_hash, float wrap_width, IggVec2 *value); extern float iggGetFontSize(); +extern float iggFontFontSize(IggFont handle); extern IggFontGlyph iggFindGlyph(IggFont font, int ch); extern int iggFontGlyphColored(IggFontGlyph glyph); extern int iggFontGlyphVisible(IggFontGlyph glyph); From 3e70bdc09af386c2cd4204b3a8118e43e56030c2 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 25 Aug 2022 14:46:06 -0700 Subject: [PATCH 04/13] Add GetKeyIndex() --- State.go | 5 +++++ wrapper/State.cpp | 5 +++++ wrapper/State.h | 1 + 3 files changed, 11 insertions(+) diff --git a/State.go b/State.go index eaa449e1..aee1791d 100644 --- a/State.go +++ b/State.go @@ -169,6 +169,11 @@ func IsWindowHovered() bool { return IsWindowHoveredV(HoveredFlagsNone) } +// Returns the key index corresponding to an imgui key. +func GetKeyIndex(key int) int { + return int(C.iggGetKeyIndex(C.int(key))) +} + // IsKeyDown returns true if the corresponding key is currently being held down. func IsKeyDown(key int) bool { return C.iggIsKeyDown(C.int(key)) != 0 diff --git a/wrapper/State.cpp b/wrapper/State.cpp index cdc5e146..edd3b332 100644 --- a/wrapper/State.cpp +++ b/wrapper/State.cpp @@ -83,6 +83,11 @@ IggBool iggIsWindowHovered(int flags) return ImGui::IsWindowHovered(flags) ? 1 : 0; } +int iggGetKeyIndex(int key) +{ + return ImGui::GetKeyIndex(key); +} + IggBool iggIsKeyDown(int key) { return ImGui::IsKeyDown(key); diff --git a/wrapper/State.h b/wrapper/State.h index e41c71bf..d3d79bac 100644 --- a/wrapper/State.h +++ b/wrapper/State.h @@ -27,6 +27,7 @@ extern IggBool iggIsWindowCollapsed(); extern IggBool iggIsWindowFocused(int flags); extern IggBool iggIsWindowHovered(int flags); +extern int iggGetKeyIndex(int key); extern IggBool iggIsKeyDown(int key); extern IggBool iggIsKeyPressed(int key, IggBool repeat); extern IggBool iggIsKeyReleased(int key); From 949270a579e02ae0599a66b1bb07d90ed0e9ca02 Mon Sep 17 00:00:00 2001 From: VityaSchel Date: Sun, 31 Jul 2022 20:56:29 +0400 Subject: [PATCH 05/13] AddImageQuad --- DrawList.go | 12 ++++++++++++ wrapper/DrawList.cpp | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/DrawList.go b/DrawList.go index ca422f8a..f9a5ec39 100644 --- a/DrawList.go +++ b/DrawList.go @@ -291,6 +291,18 @@ func (list DrawList) AddImageV(textureID TextureID, posMin Vec2, posMax Vec2, uv C.iggAddImage(list.handle(), C.IggTextureID(textureID), posMinArg, posMaxArg, uvMinArg, uvMaxArg, C.IggPackedColor(tintCol)) } +func (list DrawList) AddImageQuad(textureID TextureID, p1 Vec2, p2 Vec2, p3 Vec2, p4 Vec2, uv1 Vec2, uv2 Vec2, uv3 Vec2, uv4 Vec2, tintCol PackedColor) { + p1Arg, _ := p1.wrapped() + p2Arg, _ := p2.wrapped() + p3Arg, _ := p3.wrapped() + p4Arg, _ := p4.wrapped() + uv1Arg, _ := uv1.wrapped() + uv2Arg, _ := uv2.wrapped() + uv3Arg, _ := uv3.wrapped() + uv4Arg, _ := uv4.wrapped() + C.iggAddImageQuad(list.handle(), C.IggTextureID(textureID), p1Arg, p2Arg, p3Arg, p4Arg, uv1Arg, uv2Arg, uv3Arg, uv4Arg, C.IggPackedColor(tintCol)) +} + // PushClipRect performs render-level scissoring. // It calls PushClipRectV(min, max, false). func (list DrawList) PushClipRect(min, max Vec2) { diff --git a/wrapper/DrawList.cpp b/wrapper/DrawList.cpp index abb5765e..80edc4b6 100644 --- a/wrapper/DrawList.cpp +++ b/wrapper/DrawList.cpp @@ -131,6 +131,20 @@ void iggAddImage(IggDrawList handle, IggTextureID textureID, IggVec2* pMin, IggV list->AddImage(reinterpret_cast(textureID), *pMinArg, *pMaxArg, *uvMinArg, *uvMaxArg, col); } +void iggAddImageQuad(IggDrawList handle, IggTextureID textureID, IggVec2* p1, IggVec2* p2, IggVec2* p3, IggVec2* p4, IggVec2* uv1, IggVec2* uv2, IggVec2* uv3, IggVec2* uv4, IggPackedColor col) { + Vec2Wrapper p1Arg(p1); + Vec2Wrapper p2Arg(p2); + Vec2Wrapper p3Arg(p3); + Vec2Wrapper p4Arg(p4); + Vec2Wrapper uv1Arg(uv1); + Vec2Wrapper uv2Arg(uv2); + Vec2Wrapper uv3Arg(uv3); + Vec2Wrapper uv4Arg(uv4); + + ImDrawList* list = reinterpret_cast(handle); + list->AddImageQuad(reinterpret_cast(textureID), p1Arg*, p2Arg*, p3Arg*, p4Arg*, uv1Arg*, uv2Arg*, uv3Arg*, uv4Arg*, col); +} + void iggPushClipRect(IggDrawList handle, IggVec2 const *min, IggVec2 const *max, IggBool intersectWithCurrentClipRect) { ImDrawList *list = reinterpret_cast(handle); From 34cd41c2dcd83f1e469aa469248eb4cadfd8aeef Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 22 Sep 2022 18:41:03 +0200 Subject: [PATCH 06/13] Add AddImageQuadV, add documentation --- DrawList.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/DrawList.go b/DrawList.go index f9a5ec39..e2821c5d 100644 --- a/DrawList.go +++ b/DrawList.go @@ -291,7 +291,17 @@ func (list DrawList) AddImageV(textureID TextureID, posMin Vec2, posMax Vec2, uv C.iggAddImage(list.handle(), C.IggTextureID(textureID), posMinArg, posMaxArg, uvMinArg, uvMaxArg, C.IggPackedColor(tintCol)) } -func (list DrawList) AddImageQuad(textureID TextureID, p1 Vec2, p2 Vec2, p3 Vec2, p4 Vec2, uv1 Vec2, uv2 Vec2, uv3 Vec2, uv4 Vec2, tintCol PackedColor) { +// AddImageQuad calls AddImageQuadV(textureID, p1, p2, p3, p4, +// Vec2{X: 0, Y: 0}, Vec2{X: 1, Y: 0}, Vec2{X: 1, Y: 1}, Vec2{X: 0, Y: 1}, +// Packed(color.White)). +func (list DrawList) AddImageQuad(textureID TextureID, p1 Vec2, p2 Vec2, p3 Vec2, p4 Vec2) { + list.AddImageQuadV(textureID, p1, p2, p3, p4, + Vec2{X: 0, Y: 0}, Vec2{X: 1, Y: 0}, Vec2{X: 1, Y: 1}, Vec2{X: 0, Y: 1}, + Packed(color.White)) +} + +// AddImageQuadV adds an image based on given texture ID, with four UV coordinates. +func (list DrawList) AddImageQuadV(textureID TextureID, p1 Vec2, p2 Vec2, p3 Vec2, p4 Vec2, uv1 Vec2, uv2 Vec2, uv3 Vec2, uv4 Vec2, tintCol PackedColor) { p1Arg, _ := p1.wrapped() p2Arg, _ := p2.wrapped() p3Arg, _ := p3.wrapped() From f68b9a8112af23ed4ee36686a6ec6a70093cc596 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 22 Sep 2022 18:51:27 +0200 Subject: [PATCH 07/13] Attempt to fix size_t type issue --- wrapper/Types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wrapper/Types.h b/wrapper/Types.h index 83af7767..1e6f8228 100644 --- a/wrapper/Types.h +++ b/wrapper/Types.h @@ -1,5 +1,6 @@ #pragma once +#include #include #ifdef __cplusplus From 246cbae367569fe36075cef7b508b7e41b63ec79 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 22 Sep 2022 18:54:37 +0200 Subject: [PATCH 08/13] Add missing forward declaration --- wrapper/DrawList.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wrapper/DrawList.h b/wrapper/DrawList.h index 37b37a22..8e5c0cf5 100644 --- a/wrapper/DrawList.h +++ b/wrapper/DrawList.h @@ -24,6 +24,7 @@ extern void iggAddTriangle(IggDrawList handle, IggVec2 *p1, IggVec2 *p2, IggVec2 extern void iggAddTriangleFilled(IggDrawList handle, IggVec2 *p1, IggVec2 *p2, IggVec2 *p3, IggPackedColor col); extern void iggAddText(IggDrawList handle, IggVec2 const *pos, IggPackedColor col, const char *text, int length); extern void iggAddImage(IggDrawList handle, IggTextureID textureID, IggVec2* pMin, IggVec2* pMax, IggVec2* uvMin, IggVec2* uvMax, IggPackedColor col); +extern void iggAddImageQuad(IggDrawList handle, IggTextureID textureID, IggVec2* p1, IggVec2* p2, IggVec2* p3, IggVec2* p4, IggVec2* uv1, IggVec2* uv2, IggVec2* uv3, IggVec2* uv4, IggPackedColor col); extern void iggPushClipRect(IggDrawList handle, IggVec2 const *min, IggVec2 const *max, IggBool intersectWithCurrentClipRect); extern void iggPopClipRect(IggDrawList handle); From 00962492f68ed2ed0b357a9902825b1b1f6954d2 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 22 Sep 2022 18:57:10 +0200 Subject: [PATCH 09/13] Fix function call --- wrapper/DrawList.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrapper/DrawList.cpp b/wrapper/DrawList.cpp index 80edc4b6..f1538283 100644 --- a/wrapper/DrawList.cpp +++ b/wrapper/DrawList.cpp @@ -141,8 +141,8 @@ void iggAddImageQuad(IggDrawList handle, IggTextureID textureID, IggVec2* p1, Ig Vec2Wrapper uv3Arg(uv3); Vec2Wrapper uv4Arg(uv4); - ImDrawList* list = reinterpret_cast(handle); - list->AddImageQuad(reinterpret_cast(textureID), p1Arg*, p2Arg*, p3Arg*, p4Arg*, uv1Arg*, uv2Arg*, uv3Arg*, uv4Arg*, col); + ImDrawList *list = reinterpret_cast(handle); + list->AddImageQuad(reinterpret_cast(textureID), *p1Arg, *p2Arg, *p3Arg, *p4Arg, *uv1Arg, *uv2Arg, *uv3Arg, *uv4Arg, col); } void iggPushClipRect(IggDrawList handle, IggVec2 const *min, IggVec2 const *max, IggBool intersectWithCurrentClipRect) From 3e299471961c3c3f5bd3106df9411136096ca785 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 22 Sep 2022 19:04:43 +0200 Subject: [PATCH 10/13] Remove windows build - see #184 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d5e4bd4..dcd58d16 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: go-version: [ 1.12, 1.18 ] - os: [ macos-latest, windows-latest, ubuntu-latest ] + os: [ macos-latest, ubuntu-latest ] steps: - name: Set up Go uses: actions/setup-go@v1 From 7d3a7418721dc3674e1deb955f35fa619aa7ece2 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 22 Sep 2022 19:40:55 +0200 Subject: [PATCH 11/13] Add reference to recommended alternative --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c551866..e93a5247 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/inkyblackness/imgui-go)](https://goreportcard.com/report/github.com/inkyblackness/imgui-go) [![Lint Status](https://github.com/inkyblackness/imgui-go/workflows/golangci-lint/badge.svg)](https://github.com/inkyblackness/imgui-go/actions) +## Sunsetting announcement +**This wrapper is about to be discontinued. Please consider using https://github.com/AllenDang/cimgui-go instead. +That project is an auto-generated wrapper and makes it easier to be at the latest version of *Dear ImGui*.** + +**This repository here, along with the examples, is planned to become read-only on 2022-12-31.** + +--- + This library is a [Go](https://www.golang.org) wrapper for **[Dear ImGui](https://github.com/ocornut/imgui)**. This wrapper started as a special-purpose wrapper for use within InkyBlackness. @@ -72,7 +80,10 @@ Contributions to support more build environments are happily accepted. See file ## Alternatives -Before this project was created, the following alternatives were considered - and ignored: +Since 2022-08, there is https://github.com/AllenDang/cimgui-go , which is an auto-generated wrapper that +makes it easier to be at the latest version of **Dear ImGui**. It is recommended to use that one instead. + +Before inkyblackness/imgui-go was created, the following alternatives were considered - and ignored: * `kdrag0n/go-imgui` (no longer available). Reasons for dismissal at time of decision: * Auto-generated bloat, which doesn't help * Was using old API (1.5x) From 999c006eec0db917f153fbac193e0951868b334d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 22 Sep 2022 10:58:48 -0700 Subject: [PATCH 12/13] Fix naming of getter functions to not start with "Get" --- FontAtlas.go | 2 +- State.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FontAtlas.go b/FontAtlas.go index 500c5ce1..d0fd0472 100644 --- a/FontAtlas.go +++ b/FontAtlas.go @@ -163,7 +163,7 @@ func (atlas FontAtlas) SetTextureID(id TextureID) { C.iggFontAtlasSetTextureID(atlas.handle(), id.handle()) } -func (atlas FontAtlas) GetTextureID() TextureID { +func (atlas FontAtlas) TextureID() TextureID { return TextureID(C.iggFontAtlasGetTextureID(atlas.handle())) } diff --git a/State.go b/State.go index aee1791d..4a00acc2 100644 --- a/State.go +++ b/State.go @@ -170,7 +170,7 @@ func IsWindowHovered() bool { } // Returns the key index corresponding to an imgui key. -func GetKeyIndex(key int) int { +func KeyIndex(key int) int { return int(C.iggGetKeyIndex(C.int(key))) } From d44eb5d063f2422904658546b3ff765d5d77fc75 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 22 Sep 2022 11:07:17 -0700 Subject: [PATCH 13/13] More lint nits --- FontAtlas.go | 1 + State.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/FontAtlas.go b/FontAtlas.go index d0fd0472..dfc43d95 100644 --- a/FontAtlas.go +++ b/FontAtlas.go @@ -163,6 +163,7 @@ func (atlas FontAtlas) SetTextureID(id TextureID) { C.iggFontAtlasSetTextureID(atlas.handle(), id.handle()) } +// TextureID returns the renderer-specific texture identifier for the font atlas. func (atlas FontAtlas) TextureID() TextureID { return TextureID(C.iggFontAtlasGetTextureID(atlas.handle())) } diff --git a/State.go b/State.go index 4a00acc2..8fcdd99b 100644 --- a/State.go +++ b/State.go @@ -169,7 +169,7 @@ func IsWindowHovered() bool { return IsWindowHoveredV(HoveredFlagsNone) } -// Returns the key index corresponding to an imgui key. +// KeyIndex returns the key index corresponding to an imgui key. func KeyIndex(key int) int { return int(C.iggGetKeyIndex(C.int(key))) }