Recently I've been toying with creating a Kivy-esque api in Nim with ImGui. It uses the handy ImGui wrapper library and is mostly just Nim convenience functions. ImGui has been interesting to learn. The whole immediate mode GUI-thing is a bit refreshing given how simple it can be. Still ImGui requires a fair bit of handholding.
The ImKivy api is inspired by Kivy and also a bit of Fidget. Fidget would be great but doesn't have the set of widgets Dear ImGui does (alas). Though I'm kind of curious if Pixie could be tied in with ImGui using Boxy.
import macros
import imkivy
widget ExampleWindow:
# Simple window
object:
show_demo: bool
somefloat: float32
counter: int
Window("Hello, world!"):
Text: "This is some useful text."
Checkbox("Demo Window", self.show_demo)
Slider("float", self.somefloat)
Horizontal:
Button("Button"):
size: (50, 20)
on_press: inc(self.counter)
Button("Button"):
size: (50, 20)
on_press: inc(self.counter)
Text("counter = %d", self.counter)
Text("Application average %.3f ms/frame (%.1f FPS)",
1000.0f / igGetIO().framerate, igGetIO().framerate)
Here's a longer example: ImKivy: Demo.
Note ImKivy isn't meant to be ready for production user facing UI's. It's more for experimenting with UI api's in Nim. Maybe it'd be handy for quick interactive tools. Stuff like the Horizontal macro above are hacky and would need a more sophisticated implementation to ensure ImGui's igSameLine() is called correctly in for-loops and such.
This is looks so cool, as i have been experimenting with Nim recently and making a static, easy to use, multiplatform ui looks not yet stable enough with all the port i tried.
I liked how fidget api but i did not work well for me due to missing controls.
imGui looks good but support they api is hard to digest for some one like me :)
Hope this will work well for me as i registered here to ask for html5 static ui port when nothing else worked for me.
Welcome and thanks! Though it's not really setup to run on HTML5 (like Fidget). Though you can get ImGui running on WebGL, but I've never done that. Also fonts in ImGui aren't very nice.
ImKivy is more of a pre-alpha experiment still, but I've covered more than half of the "core" ImGui basic widgets. It's also possible to still call ImGui directly. Partly I'm hoping that seeing Kivy-like api's in Nim could give people an idea of what's possible by abusing Nim template & a few macros a bit. ;)
If you're looking for a mature static-binary & cross-platform UI then Nim-QML is probably a better option, or WxWidgets. If you want to use Nim to make an electron style app there is NimView. That said, I'm probably going to use ImGui for some of my own development tools for embedded work. Mainly because it's kinda fun.