humbleui 2023-04-04

Here's a little gist for a Label that can text-wrap based on a fixed input width. https://gist.github.com/Quezion/74ff0685a92e54dc5eaf58f185214192 You can achieve the 'auto-wrapping' behavior in this gif by pulling the :window out of a dynamic's ctx and passing it along.

(ui/dynamic
 ctx
 [window-rect (window/window-rect (:window ctx))
  width (-> (- (._right window-rect) (._left window-rect))
            (* 0.99)
            (int))]
 (ui/center
  (ui/column
   (ui/wrap-label {:wrap-width width} (->> (cycle ["Foo" "Bar" "Baz"])
                                           (take 100)
                                           (interpose " ")
                                           (apply str))))))
The code isn't PR ready; besides being inefficient, there's probably some better way of specifying this behavior. Might involve extending :stretch to support floats and auto-set width of child elements? [:stretch 0.95 ...] Either way it'll be some weeks until I touch this again, so posting it here for the record

πŸ‘πŸ» 1

Nice! I think real implementation would require going into the depths of Skia and ICU, but this could do for now. Multi-line text is kind of a must, and I’ve been postponing it long enough. I might actually do a quick-and-dirty version for now based on your idea, if you don’t mind

πŸ’― 1

Suddenly Humble UI feels much more like real framework now

πŸ‘ 1
πŸŽ‰ 3

Thanks Niki, this really makes my morning! πŸ™‚ β€’ paragraph confirmed working as a drop-in replacement for wrap-label β€’ I had to update local JWM/HumbleUI, I see you've been busy β€’ Nice layout code, haven't seen loopr macro before Looking forward to more, but I'll be out for a couple weeks. (Still need to PR Win32 impl of SetTitlebarVisible, find a real fix for (dynamic (text-field ...)), & x-platform bring-to-front) A second thanks for all the help over the last weeks & back soon πŸ™

> find a real fix for (dynamic (text-field ...)), I’m working on it right now

That's awesome but no pressure. Knocking out paragraph in < 1 day is already some fantastic support πŸ˜‰ I expected this fix would take me several days to really grok what was happening in the library. I noticed that ctx :hui/focused? true was being inappropriately dropped by parent window/focusables but couldn't figure out why. Anyway, I'll keep an eye out for a PR; interested in knowing the mechanics happening here

If you are curious, I’m taking notes as I’m trying to figure it out. Peek here https://tonsky.notion.site/State-Management-d45ce7c481fa4c0fa1c82accbcbfc166

πŸ‘€ 2

Good notes. Humble UI's Endgame mentions should leverage Clojure macros; are you thinking akin to Membrane's defui (providing references and handling incidental state?)