Fork me on GitHub
#humbleui
<
2023-04-04
>
Quest18:04:08

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

2
Niki12:04:45

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

💯 2
Niki16:04:05

Suddenly Humble UI feels much more like real framework now

🎉 6
👍 2
Quest17:04:00

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 🙏

Niki17:04:54

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

Quest17:04:25

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

Niki16:04:08

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

👀 4
Quest17:04:36

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?)