Thanks @sanette for showing me how to achieve what I wanted with Bogue.
I tend to cling to my belief that a way to create new widgets ends up being needed, even if you proved me wrong in that particular instance. That being said, I must admit that web interfaces have been around for a while and there’s no way to add new HTML elements, so maybe I am in fact wrong.
Well, you can create custom HTML elements using Web Components, but at the end of the day they are composed of the built-in elements, so conceptually the same as Bogue.
I am discovering Ocaml and wanted to try the Bogue gui.
Frustratingly, many attempts have all led to the same error message: Segmentation fault.
Here is how I proceeded:
a) Environment:
MacBook Pro 2022 M2
MacOS 13.6.1
Ocaml 5.1.1
VS Code with OCaml Platform v1.14.1
b) Dune init project bog
c) Creation of local switch
d) Setting sandbox to local switch
e) Installation of the bogue package
f) Addition of “bogue” to the libraries entry in bin/dune
g) Replacement of main.ml content with minimal example:
open Bogue
i) Dune exec bog
I get:
Loading Bogue 20221112 with config dir …/bog/_opam/share/bogue/themes/default
zsh: segmentation fault dune exec bog
j) When I check installed packages to verify dependencies of bogue, I see that “directories” is not listed by opam
k) upgrade to the last bogue version with:
opam pin add GitHub - sanette/bogue: GUI library for ocaml based on SDL2
I get: retrieved directories.0.5 (cached)
⊘ removed bogue.20221112
∗ installed directories.0.5
∗ installed bogue.20231209
Done.
l) Dune build
I get:
ld: warning: ignoring duplicate libraries: ‘-lSDL2’, ‘-lintegers_stubs’
m) Dune exec bog
I get:
Loading Bogue 20231209 with config dir …/bog/_opam/share/bogue/themes/default
zsh: segmentation fault dune exec bog
All my apologies for the very long message, but I am really puzzled and certain that something is wrong in my procedure.
Hi. I think it would be great if you add documentation relating bogue with html and css.
I am not clear on how to add padding, margin kind of stuff to widgets. How to add a box around input widget. It would be easier for me to relate since I’m from web background. Thanks!
Hi, yes, more documentation is always a good idea! Feel free to contribute
Concerning margins, styling, etc. of course you’re not going to have something as powerful and flexible as html+css, but everything you mentioned is actually doable with Bogue.
The main idea is to put a widget inside a larger Layout. This can be done manually (for instance with Layout.setx / sety) or “automatically” playing with the parameters of Layout.flat:
Hi, not yet, unfortunately. File chooser is one of the first on my TODO list. Actually I have started working on it, but it’s not ready yet. Hopefully soon!
For the moment you have to resort to system dialogs like zenity or kdialog.
Hi
I’m happy to announce a new version of Bogue (20240225). I would like to mention here two main changes:
This is the last version that supports SDL 2.0.9 (default in Debian 10)
Next version will use tsdl 1.0.0 which requires SDL 2.0.10 or later
Thanks to @edwin , this version (if using SDL >= 2.0.16) is much more power-friendly (when idle). You may now leave a Bogue app open (if idle) without worrying for your laptop battery (and the environment): energy consumption is now very close to zero. (powertop indicates instantaneous power of 0mW, which I think means less than 0.1mW on my laptop)
I’m having similar issues to @ypamine above. I’ve tried both with OCaml 5.1.0 and 5.1.1. In both cases, I will get a segmentation fault with just the following:
utop
utop # #thread;;
utop # #require "bogue";;
Loading Bogue 20240225 with config dir /Users/me/projects/bogue-tests/_opam/share/bogue/themes/default
[2] 10756 segmentation fault utop
I also get the same error with the minimal hello world example in the docs.
I’m on M1 Macbook Pro, Mac OS 14.3.1. sdl 2.30.1
Would be keen to check this out. Is it expected to work on Mac? Any troubleshooting steps I could take?
I’ll file an issue with appropriate docs in a few weeks (need time to get my DkCoder test+debug apparatus better for shared library issues). If my hypothesis was correct, then introducing a fixed arity function stub in tsdl for SDL_Log should fix the root cause.
My notes (including a temporary fix and how to tell if you are affected) were:
open Tsdl
(* Any use of [Sdl.log] that prints to the log will SIGSEGV on DkCoder
ARM64 macOS. "Works" on boguex.exe and by directly linking to homebrew's SDL
2.28.4, but the [Sdl.log] display garbage instead of the expected
[Sdl.log "Using SDL %u.%u.%u" a b c] from Bogue.B_trigger.
boguexe.exe and a DkCoder script example, respectively:
[61][0] : Warning: SDL initialized
2024-03-07 22:03:44.812 examples.exe[7961:10522604] INFO: ؠ&`
[62][0] : Event: SDL Events initialized
[73][0] : Warning: SDL initialized
2024-03-07 22:16:56.467 ocamlrunx[25764:10578085] INFO: (null)
[74][0] : Event: SDL Events initialized
Maybe because SDL_Log() is varargs and not two arguments like coded into
Tsdl? Regardless, avoid all logs until fixed! *)
let () = Sdl.log_set_all_priority Sdl.Log.priority_critical
So, try that let () statement before opening Bogue. And if you can, also remove all the Sdl.log statements from Bogue. If either of those works you have the same problem and a temporary fix.