Nice to have:
Are there some existing API that could be a starting point ? What should be the next move, in your opinion?
It should be compiled to a DLL
Oh?
- Multi-threading ready with clear rules what can be done in a background thread and what not and how to communicate between threads.
I think the lib should just have a boolean inBackgroundThread: bool parameter for those backgroundable proc. For UI most thing should be main thread for responsiveness.
- This can imply that it works well on embedded devices, but also and more importantly that it can be used in security critical applications.
Are there even GUIs that are cleared for mission-critical applications?
Nice to have:
- If you only work with the very high level APIs and restrict yourself to certain widgets, make it so that it supports a textmode UI as well.
If I were to write a UI library, given how hard and time-consuming it is to wrote UI libs, I would instead start with text first, especially because most people using Nim in productions are using it for CLI-based tools.
Once those are made very appealing, upgrade to GUI.
There is a lot to do with text-based UI already, status-bar, progress-bars, see https://github.com/Textualize/rich which IMO is the based console UI, and certainly the one with best docs, I've seen.
Isn't Fidget quite close to this?
I've come to believe that the most challenging piece with a custom GUI is text input. Even more so than text rendering! Well at least since Treeform did much of the hard work on fonts. :)
For text input you need to handle shortcuts, different alphabets, left-to-right, repeating inputs, etc. I believe it'd be worth considering reusing OS native text input, and I believe it's what browsers do (did?).
Well speaking of browsers, supporting a (sane) subset of html rendering would be an interesting approach: https://sciter.com/ :P Actually I always did think sciter was pretty impressive demonstration of what one person could do if focused. The author said it took him about 9 months of full time work.
Both approaches are mutually exclusive and require a separated code. Even a general concept how a GUI library works is separated for both ways.
I don't agree. It's mostly the existing distinction between peekEvent vs waitForEvent.
It is usually done via canvas widget. So that widget is needed. And this mean just abilities to drawing in the library.
Yes, but there is a difference between "here is a canvas widget" and "every widget was built on top of this canvas and so should be yours".
I gave libagar a spin with futhark. Works great.
This is the hello world example from their docs.
import futhark, strutils
importc:
path "/usr/include/agar"
"agar/core.h"
"agar/gui.h"
{.passl: "-lag_core -lag_gui".}
assert 0 == AgInitCore(nil, 0)
assert 0 == AgInitGraphics("")
var window = AgWindowNew(0)
let label = AgLabelNew(window, 0, "Hello, World!")
AgWindowShow(window)
assert 0 == AgEventLoopProc()
# libagar install cmd for Arch Linux, adapt to your OS
$ pakku -S agar
# futhark runs into a compiler limit, work around with loop iterations
$ nim c --maxLoopIterationsVM:100000000 agar.nim
$ ./agar
Et voila, a window.
That was a lot easier than I thought.
Now I wonder if libagar is any good! Looks comprehensive for sure.
I dont care for subpixel polaristion
Please do!
If you mean subpixel rendering/aliasing/hinting (= aliasing using colors, not just gray tones), the absence of it lets fonts look blurry. Example in the below Image (part of a bug report).
Please do!
Nah, that's like GPU support. Once you have widgets and portability and it working on 80% of the platforms that Nim runs on, you can care about subpixels and GPUs.
Glad to see one person (@elcritch) is working on this. ;-]
Just want to note that it took a lot of reading to become aware of the figuro project. Is it too soon to add it to https://github.com/nim-lang/Nim/wiki/Curated-Packages#gui or https://github.com/ringabout/awesome-nim ?
I guess my concern is that a web search about Nim GUI libraries will point to lists of bindings and incomplete/abandoned projects, with no mention of figuro. I think more promotion of the project might not only help it but the Nim language by showing people the current active direction in this realm.
Maybe we would benefit from a different general list of active projects that people can contribute to.
A "1.0" release might not be too far off. I'd definitely like a scaleable text editor in place. Though the current text view panels handle pretty large text already. I've been using it to read markdown version of Hacker News. Just being smart in breaking up larger text into separate Text paragraphs should scale well for many apps.
Actually scaling issues will be around handling large number of nodes. Currently updating layout does the entire tree. Generally with Nim that's fast enough for now, but probably will only scale to ~1000 nodes for 60fps? Still that wouldn't be a block for a 1.0 release as it's just optimization.
My main goal now is making finishing a basic set of widgets including menus. That's important because it's also creating (finding) the idioms and patterns for making apps with Figuro. That's needed because it's a hybrid of web and native GUI programming approaches. Handling stuff like HTML web components slot mechanism, etc or more tradition MVC stuff, etc.
@derek-v-s I appreciate the shoutout!