membrane

Ben Sless 2021-10-17T07:07:32.125100Z

Man, that's amazing, I never did any UI work in my life and in about 3 hours of work got to this

🎉 1
phronmophobic 2021-10-17T07:10:39.125600Z

that looks great!

phronmophobic 2021-10-17T07:10:48.125900Z

I mean, not beautiful... but functional! 😄

Ben Sless 2021-10-17T07:17:52.126500Z

Beautiful can always come later

👍 1
Ben Sless 2021-10-17T07:19:03.127Z

Once I get html parsing I'll contribute the example to the repo 🙂

Ben Sless 2021-10-17T07:47:11.127200Z

Now needs scrolling

phronmophobic 2021-10-17T07:50:35.129100Z

just a warning, the built in scrollview is functional, but there's room for improvement. I haven't gotten to it yet because I personally prefer pagination over scrolling, but I should probably just fix it since it's usually one of the first things people try for some reason.

phronmophobic 2021-10-17T07:52:11.129600Z

the main issue is that it stops scrolling when your mouse leaves the scroll area, but it should work other than that

Ben Sless 2021-10-17T08:17:41.130800Z

Is there an example for scroll?

phronmophobic 2021-10-17T08:18:16.131Z

let me check

phronmophobic 2021-10-17T08:19:22.131200Z

not the best example, https://github.com/phronmophobic/membrane/blob/4a69da67c5924068fd9a47df77226e6529a01b99/src/membrane/re_frame.cljc#L133 nevermind, this only works with the re-frame components

phronmophobic 2021-10-17T08:20:33.131600Z

one sec, it should be pretty simple, let me just double check the syntax

phronmophobic 2021-10-17T08:23:12.132100Z

you should just be able to pass the body and the bounds of the scroll view and it should work

Ben Sless 2021-10-17T08:23:39.132300Z

👍

Ben Sless 2021-10-17T08:24:15.132500Z

why do I need the bounds? what do they mean?

phronmophobic 2021-10-17T08:25:03.132700Z

That's just the size of the scrollview

Ben Sless 2021-10-17T08:28:18.132900Z

and can the body be a vertical layout?

phronmophobic 2021-10-17T08:31:31.133100Z

the body can be anything

Ben Sless 2021-10-17T08:36:19.133400Z

okay, works, but sensitivity is wonky

phronmophobic 2021-10-17T08:37:04.133700Z

sensitivity with the scroll wheel or with how it tracks your mouse?

Ben Sless 2021-10-17T08:37:31.133900Z

wheel. slow crawl

phronmophobic 2021-10-17T08:38:01.134100Z

oh weird

phronmophobic 2021-10-17T08:41:00.134300Z

obviously, the scrollview should match whatever is normal for the OS, but as a work around you can wrap the scrollview with something like:

(def scroll-speed-factor 2)
(defn fix-scroll [elem]
  (ui/on-scroll (fn [[sx sy] pos]
                  (ui/scroll elem [(* scroll-speed-factor sx) (* scroll-speed-factor sy)] pos))
                elem))

;; usage
(fix-scroll
 (basic/scrollview {:scroll-bounds [200 150]
                    :body (ui/image ( "lines.png"))}))

phronmophobic 2021-10-17T08:42:04.134600Z

in fact, I think if you wrap your top level app with fix-scroll, it should fix it for any child scrollview

Ben Sless 2021-10-17T09:12:55.134800Z

Also, scrolling is inverted 🙃

Ben Sless 2021-10-17T09:13:07.135Z

I'll just multiply by a negative number?

👍 1
Ben Sless 2021-10-17T09:30:05.135300Z

works great!

Ben Sless 2021-10-17T08:07:11.130Z

Need to also polish the html parsing, but, it's readable 😮

phronmophobic 2021-10-17T08:15:35.130100Z

If you are ever feeling extra ambitious, you could use https://github.com/phronmophobic/clj-cef to render the html

Ben Sless 2021-10-17T08:17:05.130400Z

just used Crouton for now

phronmophobic 2021-10-17T08:17:32.130600Z

neat!

Ben Sless 2021-10-17T13:37:11.135800Z

any way to mess around with the font inside a label or text area?

phronmophobic 2021-10-17T19:07:31.136Z

Yes.

;; label
(ui/label "my-text" (ui/font "font-path.ttf" 22))

;; text area
(basic/textarea {:text text, :font (ui/font "font-path.ttf" 22)})

Ben Sless 2021-10-17T19:59:28.136200Z

I thought more like applying font formatting, i.e. "foo bar bazz"

Ben Sless 2021-10-17T20:00:59.136400Z

in the same text area

phronmophobic 2021-10-17T20:01:08.136600Z

not currently

Ben Sless 2021-10-17T20:01:31.136800Z

I could wrap each word in an area but that seems excessive

phronmophobic 2021-10-17T20:02:08.137Z

yea, I'm not actually sure what the API for that should be

phronmophobic 2021-10-17T20:04:42.137200Z

potentially, I could just use the https://github.com/mogenslund/liquid/blob/master/src/liq/buffer.cljcin liquid. I can't remember if they assume a mono spaced font though

Ben Sless 2021-10-17T20:04:45.137500Z

which font to look up is part of rendering, no reason it should be uniform to one text area. I can imagine a sort of (with-face text {,,,}) form which overrides lookup

phronmophobic 2021-10-17T20:06:16.137800Z

not sure I understand how with-face would be used

Ben Sless 2021-10-17T20:07:09.138Z

text area will be able to render string or sequence of String | Face<String>

phronmophobic 2021-10-17T20:07:18.138300Z

it seems like it might work for displaying text, but I would probably want something that works with editable text as well

Ben Sless 2021-10-17T20:08:32.138500Z

might be worth checking how Emacs and Vim do it, too 🤔

👍 1
phronmophobic 2021-10-17T20:09:05.138800Z

the liquid buffers are pretty similar to how code mirror does it.

phronmophobic 2021-10-17T20:09:35.139Z

Another idea I had was to simply embed emacs as a text editor

phronmophobic 2021-10-17T20:10:09.139200Z

which sorta worked. the biggest downside is that it only works with mono spaced fonts

phronmophobic 2021-10-17T20:10:32.139400Z

there exists a github issue to add a RichTextView to membrane, https://github.com/phronmophobic/membrane/issues/8

phronmophobic 2021-10-17T20:10:43.139700Z

not much there, but it exists

phronmophobic 2021-10-17T20:12:24.139900Z

what I would be looking for is a data format that: • supports non mono spaced fonts • is "easy" to edit • allows for markup like italics, bold, strikethrough, etc • allows for color markup

phronmophobic 2021-10-17T20:13:23.140100Z

nice to haves would be: • support for multiple fonts • support for emoji Although, both of those have some undefined behavior with respect to layout

phronmophobic 2021-10-17T20:16:04.140400Z

For your use case, do you need an editable text area with markup or just for display?

Ben Sless 2021-10-18T03:41:54.140800Z

Just display

phronmophobic 2021-10-18T05:08:11.141Z

and which kinds of markup? • bold • italic • other?

Ben Sless 2021-10-18T05:28:17.141200Z

Bold and italic first, option to switch fonts would be nice, too (i.e. monospace and regular) Support for text selection would be nice, too, but not critical

phronmophobic 2021-10-18T05:30:49.141400Z

ok, that doesn't seem too bad. I'll see if there's a simple workaround

Ben Sless 2021-10-17T05:49:56.123700Z

I modeled the domain in the example like so • top stories ◦ story • comments Story element has a button to update comments, but the story shouldn't know about comments. How should I handle this? bubble effect upwards?

Ben Sless 2021-10-17T06:44:29.124Z

I think I got it

phronmophobic 2021-10-17T06:57:40.124500Z

Yup, bubble the effect upward to someone that has the right context.