membrane

phronmophobic 2021-10-15T07:03:56.094600Z

there definitely might be. One thing I've realized is that a lot of the stuff in membrane.ui assumes floating point coordinates, but some UIs like terminal have integer coordinate systems

phronmophobic 2021-10-15T07:05:03.095800Z

related, I think it would be better to have the ui model be more firmly grounded on 2d geometry

phronmophobic 2021-10-15T07:06:15.096600Z

well, for 2d UI anyway. Obviously, 3d geometry is important if you're making a 3d UI.

phronmophobic 2021-10-15T07:07:35.097800Z

User interfaces in 3d (usually games) do a much better job of having a stronger mathematical basis since not having a strong theoretical foundation will bring you down much quicker when you're doing 3d

phronmophobic 2021-10-15T07:10:58.099700Z

One of the things I'm interested in when I get the chance is to 1. try a new UI model, 2. extend the current UI model to work under the new model I think it can be done without breaking any existing code which, if true, would prove some of the strengths of clojure's default modeling constructs.

phronmophobic 2021-10-15T07:20:23.106500Z

When I say "ui model", I mean is a few things: • descriptions of what to draw like fills, strokes, paths, images, and text. Fills and strokes are currently a bit clunky. Text is definitely an area that could be simplified and expanded. • descriptions for events. there's a few places where behavior is coupled that can be simplified and broken down further. • common abstractions like ui/bounds and ui/origin that events and layout are based on. (`ui/bounds` is currently overloaded and should probably be broken into things like hit detection, pixel extents, framing for layout, etc). There should probably be even more common abstractions. Having said that, the reason I haven't yet is that the current UI model works well enough to test the other ideas I have. Even with some of the weaknesses, it feels much better to me than html/css, but I'm probably a bit biased 😄.

Ben Sless 2021-10-15T07:57:01.106600Z

I've never done ui work, myself, but just going by what you said in talks and docs, it looks like you also want a geometry abstraction layer

Ben Sless 2021-10-15T07:59:29.106700Z

It has two benefits, one is that you finally get to talk about geometry (just data), second is if it ever gets computationally expensive the abstraction boundary gives you room to optimize

Ben Sless 2021-10-15T19:19:58.111100Z

Trying to port cljfx's HN reader

phronmophobic 2021-10-15T19:20:18.111500Z

nice!

Ben Sless 2021-10-15T19:22:23.111700Z

Was super easy

Ben Sless 2021-10-15T19:22:39.112Z

(defui item-row
  [{:keys [time type descendants title kids id score url by expanded?]}]
  (on
   :mouse-down
   (fn [_] [[:update $expanded? not]])
   ;; put the items side by side
   (horizontal-layout
    (translate 5 5 (ui/checkbox $expanded?))
    (spacer 5 0)
    (vertical-layout
     (horizontal-layout
      (spacer 5 0)
      (ui/label score)
      (spacer 10 0)
      (basic/button {:text title :on-click (fn [] [[::load-url url]])}))
     (horizontal-layout
      (spacer 5 0)
      (ui/label (str "By: " by))
      (spacer 5 0)
      (ui/label (str "At: " (str (java.time.Instant/ofEpochSecond time))))
      (spacer 5 0)
      (basic/button {:text (str "Comments: " (count kids))
                     :on-click (fn [] [[::load-comments kids]])})
      )))))

Ben Sless 2021-10-15T19:22:42.112200Z

At least the first part

phronmophobic 2021-10-15T19:25:35.112400Z

looks great

Ben Sless 2021-10-15T19:36:05.112700Z

Here, a little more sensible

(defui story-item
  [{:keys [time type descendants title kids id score url by expanded?]}]
  (horizontal-layout
   ;; (translate 5 5 (ui/checkbox $expanded?))
   (spacer 5 0)
   (vertical-layout
    (horizontal-layout
     (spacer 5 0)
     (ui/label score)
     (spacer 10 0)
     (basic/button {:text title :on-click (fn [] [[::load-url url]])}))
    (horizontal-layout
     (spacer 5 0)
     (ui/label (str "By: " by))
     (spacer 5 0)
     (ui/label (str "At: " (str (java.time.Instant/ofEpochSecond time))))
     (spacer 5 0)
     (basic/button {:text (str "Comments: " (count kids))
                    :on-click (fn [] [[::load-comments kids]])})
     ))))

phronmophobic 2021-10-15T19:38:21.113400Z

for the checkbox, you can do (basic/checkbox {:checked? expanded?}) and it should "bind" expanded? to the checked value

Ben Sless 2021-10-15T19:38:54.114300Z

Yeah, but I decided I didn't want a checkbox at the moment

👍 1
phronmophobic 2021-10-15T19:39:00.114500Z

everything in membrane.ui is stateless.

Ben Sless 2021-10-15T19:43:43.114900Z

This should probably render the comments:

(defui comment-item
  [{:keys [by text time kids]}]
  (vertical-layout
   (horizontal-layout
    (spacer 5 0)
    (ui/label text))
   (horizontal-layout
    (spacer 5 0)
    (label-by by)
    (spacer 5 0)
    (label-at time))
   (when kids
     (horizontal-layout
      (spacer 5 0)
      (apply
       vertical-layout
       (mapv comment-item kids))))))

Ben Sless 2021-10-15T19:44:34.115100Z

sans spacing for readability

Ben Sless 2021-10-15T20:10:57.116200Z

Also thinking text element components could be useful, esp when translating to web. (text foo (paragraph bar) bazz), etc

phronmophobic 2021-10-15T20:19:52.116800Z

yea, trying to do everything with just ui/label isn't great

phronmophobic 2021-10-15T20:21:42.118300Z

text is pretty painful to deal with so I've been putting off trying to figure out the right API for that. It's also pretty complicated with kerning, letter spacing, line height, bounding boxes, fonts, style, emoji, wrapping, aligning (baseline, center, vertical)

phronmophobic 2021-10-15T20:22:27.119Z

also there's markup like bold/italic, underlining, color, etc

phronmophobic 2021-10-15T20:23:45.119600Z

and emoji! 🙂 😄 😱 🙃

😨 1
Ben Sless 2021-10-15T20:39:58.119700Z

On one hand, yeah, on the other, surrounding it with "constructors" lets you do plenty of calculations and formatting That's before getting in to efficient text editing data structures

phronmophobic 2021-10-15T20:43:03.120400Z

> That's before getting in to efficient text editing data structures There's actually already a pretty good library for that https://github.com/mogenslund/liquid/blob/master/src/liq/buffer.cljc

Ben Sless 2021-10-15T20:51:52.121900Z

was thinking of ropes, actually

phronmophobic 2021-10-15T21:24:11.122100Z

my understanding was that ropes don't allow for markup

Ben Sless 2021-10-16T06:37:25.122300Z

Wonder how Xi did it

phronmophobic 2021-10-15T20:45:15.121700Z

yea, I think there's definitely an 80/20 featureset that can be done without https://en.wikipedia.org/wiki/TeX making the perfect text library

Ben Sless 2021-10-15T06:58:02.093300Z

Do you think there can be a benefit to abstract the representation of coordinates to types and protocols, instead of tying it to the vector representation?