Fork me on GitHub
#membrane
<
2022-12-17
>
adamfrey18:12:34

I've been working (when I find time) on a membrane backend for #C033FTUBWH5. It's not complete yet, but it can render the membrane todo app just fine with mouse and keyboard events propagating correctly. I just wanted to post here on the off chance that someone else was working on the exact same thing. I'm trying to use the basic humbleui components as a sort of "Native" component. For instance:

(extend-type membrane.basic_components.Textarea
  IDraw
  (draw [this]
    (let [[w h]      (mui/bounds this)
          text-input (hui/with-context
                       {:hui.text-field/padding-top (float 10)}
                       (hui/text-field
                        {:padding-top (float 10)
                         :cursor-width 1}
                        (atom {:text (:text this)
                               ;; :placeholder "type"
                               :from 1
                               :to   1})))]
      (hui.core/draw text-input *context* (IRect/makeWH w h) *canvas*))))

🎉 4
🆒 3
phronmophobic18:12:10

This is neat! > I'm trying to use the basic humbleui components as a sort of "Native" component. I hadn't considered that approach, but it's a cool idea. HumbleUI uses skija for graphics, so it should also be possible to use the skija backend to draw membrane components inside of HumbleUI. The current skija backend is based on an old version of skija, but hopefully still works. Let me know if you bump into any issues or if there's any way I can help.

adamfrey18:12:55

One of the impetuses for starting the humbleui backend was that I was running into weird issues with the built-in skija and skia backends on X11 Linux. From what I remember the click targets seemed off so I I'd have to click something like 30 pixels up and to the side in order to click a button or give focus to a text box. I'm new to graphics programming, so opening up the skia.clj file didn't help me much for debugging. Meanwhile I had no problem with the humbleui demos on my machine. So I thought I'd try to learn both libraries at once and see how they can work together. It's possible that the problem I ran into with membrane skia/skija could be something small. I don't have a mac to test on and compare.

phronmophobic19:12:46

Makes sense. The glfw library that the skija backend uses is wonky. When I get some time, I would like to update the skija backend to a newer skija version and use JWM rather than glfw.

phronmophobic19:12:01

> From what I remember the click targets seemed off so I I'd have to click something like 30 pixels up and to the side in order to click a button or give focus to a text box. If you have some example code that reproduces this, I can check it out.

adamfrey19:12:34

I'm pretty sure it happened to me on the membrane todo example. But I'll make a note to go back and confirm that. I'm using a tiling window manager where new windows automatically get sized to 50% of the screen. That might be a red herring but I didn't know if that was having an unintended effect.

jdavredbeard16:01:48

personally interested in seeing a membrane backend for humbleui! I'm understanding this effort to mean that you are using humbleui functions to create data representations of the ui components, which are passed to membrane, which could then use its integrations to render on various platforms?

phronmophobic20:01:56

I'm not totally sure, but I think he's going the opposite direction. In other words, he's extending membrane components and views with implementations with humble ui's drawing implementations so that membrane components/views can be used inside of humble ui.

adamfrey14:01:08

this is in a WIP state, but here's the humbleui backend for membrane that I'm using for my exploration purposes: https://gist.github.com/AdamFrey/3606d122ad1a55f57bf0317a617e931d

adamfrey14:01:12

So it mostly forgoes humbleui's layout code and instead just renders a hui/canvas element that can be painted into using a protocol for membrane types

jdavredbeard01:01:02

thank you for sharing and explaining! I'm still fairly new to clojure so this is a bit mind bending for me but I'm doing my best, in any case I'm impressed by all of this. re-reading the above discussion (and reading more about what humbleui is, and discovering the key point that it is intended to be desktop only) - this all makes more sense ~

jdavredbeard01:01:52

I stumbled in here because I'm looking to make a UI for my side project clojure app and was looking for an alternative to JS-based solutions - and found the Apropos video about Grease - cool work all around

😄 2
adamfrey16:01:37

We seem similarly motivated. I'm a clojure developer through and through and I'd like to lever a small and understandable tool to create user interfaces in various contexts for personal use and side-project potential. So right now I'm focusing on a personal use desktop app right now, but I'd love if I could take build complex looking web apps without worrying about CSS and I'm also very intrigued by the iOS possibility of membrane.