Skip to content

Commit

Permalink
Update ImGui to v1.79
Browse files Browse the repository at this point in the history
  • Loading branch information
lmariscal committed Dec 19, 2020
1 parent 1ab6e05 commit 531d93b
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ tests/tmath
tests/topengl
tools/generator
tests/test
tests/tnull
imgui.ini
docs/

Expand Down
2 changes: 1 addition & 1 deletion imgui.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "1.78.0"
version = "1.79.0"
author = "Leonardo Mariscal"
description = "ImGui bindings for Nim"
license = "MIT"
Expand Down
96 changes: 75 additions & 21 deletions src/imgui.nim

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions tests/tnull.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import imgui, strformat
igDebugCheckVersionAndDataLayout(igGetVersion(), ImGuiIO.sizeof().uint32,

let version = igGetVersion()

igDebugCheckVersionAndDataLayout(version, ImGuiIO.sizeof().uint32,
ImGuiStyle.sizeof().uint32, ImVec2.sizeof().uint32,
ImVec4.sizeof().uint32, ImDrawVert.sizeof().uint32,
ImDrawIdx.sizeof().uint32).assert()

echo "CreateContext() - {igGetVersion()}".fmt
echo "CreateContext() - {version}".fmt
igCreateContext(nil)
let io = igGetIO()

Expand All @@ -25,7 +28,7 @@ for i in 0 ..< 20:

var f = 0.0f
igText("Hello World!")
igSliderFloat("float", f.addr, 0.0f, 1.0f, "%.3f", 1.0f)
igSliderFloat("float", f.addr, 0.0f, 1.0f, "%.3f")
igText("Applicaton average %.3f ms/frame (%.1f FPS)", 1000.0f / io.framerate, io.framerate)
igShowDemoWindow(nil)

Expand Down
14 changes: 12 additions & 2 deletions tools/generator.nim
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ proc genTypes(output: var string) =
if templateType == "ImGui*OrIndex":
templateType = "ImGuiPtrOrIndex"
templateType = templateType.translateType()
output.add(" {memberName}* {memberImGuiName}: ImVector[{templateType}]\n".fmt)

if templateType == "ImGuiTabBar": # Hope I don't regret this hardocoded if
output.add(" {memberName}* {memberImGuiName}: ptr ImPool\n".fmt)
elif templateType == "ImGuiColumns":
output.add(" {memberName}* {memberImGuiName}: ImVectorImGuiColumns\n".fmt)
else:
output.add(" {memberName}* {memberImGuiName}: ImVector[{templateType}]\n".fmt)
continue

let arrayData = memberName.translateArray()
Expand Down Expand Up @@ -273,10 +279,14 @@ proc genProcs(output: var string) =
if variation.contains("defaults") and variation["defaults"].kind == JObject and
variation["defaults"].contains(argName):
argDefault = variation["defaults"][argName].getStr()
argDefault = argDefault.replace("4294967295", "high(uint32)")
argDefault = argDefault.replace("(((ImU32)(255)<<24)|((ImU32)(255)<<16)|((ImU32)(255)<<8)|((ImU32)(255)<<0))", "high(uint32)")
argDefault = argDefault.replace("(((ImU32)(255)<<24)|((ImU32)(0)<<16)|((ImU32)(0)<<8)|((ImU32)(255)<<0))", "4278190335'u32")
argDefault = argDefault.replace("(((ImU32)(255)<<24)|((ImU32)(0)<<16)|((ImU32)(0)<<8)|((ImU32)(255)<<0))", "4278190335")
argDefault = argDefault.replace("4278190335", "4278190335'u32")
argDefault = argDefault.replace("FLT_MAX", "high(float32)")
argDefault = argDefault.replace("((void*)0)", "nil")
argDefault = argDefault.replace("NULL", "nil")
argDefault = argDefault.replace("~0", "-1")
argDefault = argDefault.replace("sizeof(float)", "sizeof(float32).int32")
argDefault = argDefault.replace("ImDrawCornerFlags_All", "ImDrawCornerFlags.All")
argDefault = argDefault.replace("ImGuiPopupPositionPolicy_Default", "ImGuiPopupPositionPolicy.Default")
Expand Down
2 changes: 1 addition & 1 deletion tools/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const notDefinedStructs* = """
ImDrawListPtr* = object
ImChunkStream* = ptr object
STB_TexteditState* {.importc: "STB_TexteditState", imgui_header.} = object
ImPool* = object
ImVectorImGuiColumns* {.importc: "ImVector_ImGuiColumns".} = object
#
"""
Expand Down

0 comments on commit 531d93b

Please sign in to comment.