Fork me on GitHub
#membrane
<
2023-03-06
>
jlmr13:03:10

I’m playing around with some small components to understand the event model better. I can’t figure out why clicking the red rectangle in this example won’t trigger the ::self-destruct intent:

(defeffect ::increase-scale
  [$scale]
  (dispatch! :update $scale #(+ % 0.1)))

(defeffect ::decrease-scale
  [$scale]
  (dispatch! :update $scale #(- % 0.1)))

(defeffect ::self-destruct
  []
  (tap> ::self-destruct))

(defui thing
  [{:keys [context]}]
  (let [view-size (:membrane.stretch/container-size context)
        padding 50
        {:keys [scale]} context] 
    (ui/translate padding padding
                  [(ui/on-mouse-event
                    (fn [_ button mouse-down? _]
                      (when (not mouse-down?)
                        (case button
                          0 [[::increase-scale $scale]]
                          1 [[::decrease-scale $scale]]
                          nil)))
                    (ui/filled-rectangle [0.9 0.9 0.9 1] (- (first view-size) (* 2 padding)) (- (second view-size) (* 2 padding)))) 
                   (ui/scale scale scale
                             (ui/translate 10 10
                                           (ui/on-mouse-event
                                            (fn [_ _ mouse-down? _]
                                              (when (not mouse-down?)
                                                [[::self-destruct]]))
                                            (ui/filled-rectangle [1.0 0 0 1] 100 100))))])))

(skia/run (component/make-app #'thing {:membrane.component/context {:scale 1.0} }) {:include-container-info true})

phronmophobic01:03:58

There is an issue with effects that don't take any arguments (like ::self-destruct). Fixing now!

phronmophobic02:03:39

fixed! Note that the latest version requires an updated skialib.

com.phronemophobic/membrane {:mvn/version "0.12.2-beta"}

;; skialib deps
com.phronemophobic.membrane/skialib-macosx-aarch64 {:mvn/version "0.12-beta"}
com.phronemophobic.membrane/skialib-linux-x86-64 {:mvn/version "0.12-beta"}
com.phronemophobic.membrane/skialib-macosx-x86-64 {:mvn/version "0.12-beta"}

jlmr08:03:42

Yep, that fixed it, thanks!

jlmr13:03:48

I keep getting a Don't know how to create ISeq from: clojure.lang.Keyword error

genekim17:03:35

@smith.adriane Fantastic 2019 interview of Jack Rusher which I think is so relevant to some of the things you’re working on — listened to about 30m earlier today, but it was a much deeper discussion of many topics in his Strange Loop talk. https://futureofcoding.org/episodes/041.html PS: I tried spreadsheet out last night, but I think sound was borked. I will revisit it later today, and get it sent to you. Off the top of my head: 1. having touchpad scrolling match OS would be great (or maybe required for me, as clashing with the way my editor works screws with my head) 2. it took me a while to figure out that where you type a var name is actually editable — maybe putting it in a box would make it more obvious. (I only discovered after replaying your “Session 3” video, to see how you did it.) 3. resizing control didn’t work for me when I tried to make it larger than current window. 4. I was using it to try to render a markdown representation, and the map was displayed such that one field always took up all the space — having some sort of table view, or some way to navigate through the keys would be great. I’ll annotate the video where I run into these issues, and post later today. Thanks!!!

👂 2
genekim17:03:33

• 9m: got it working • 10m: I wish I could scroll right/left, to see all the map values • lower-right dragging is not in corner • can’t drag right and click; • not obvious I can type in the green value area • 12:30: used portal to look at the big map Oh, sound capture did work! Here it is. https://capture.dropbox.com/jVrkgEscbvtIi1qp

genekim18:03:58

Adrian, not sure how useful that video is — I didn't think my mic was working, so I stopped "thinking aloud" like I've usually done. I'll try to verbally annotate what this "first time use" session was like. I'll get to it in a couple of hours.

phronmophobic18:03:01

Thanks for sharing the video. It was definitely useful to see the first time experience. The main goal for the spreadsheet is to have a prototype for me to experiment with what new programming environments could or should be like. I'm a little wary of spending time on polishing things when big questions like "how do you save programs?" still haven't been addressed. It might be easier to explain over a pairing session sometime. I think getting the most out of the tool also requires a different workflow. I noticed it seemed like you wanted to treat it like portal, ie. 1. write some code in editor 2. tap value 3. look at in spreadsheet. The goal is to do something more like 1. look at in spreadsheet 2. play with in spreadsheet. Anyway, might be easier to explain sometime.

genekim19:03:44

My main issue was that I couldn't actually explore the big map in ss — it's been months since I looked at the code, was trying to orient myself, and figure out whether there was enough info in the map to do a membrane render of it. (I was actually very confused, because I thought it was a tree, not a sequence! :) Funny how bad memory is!! At any rate, I just needed to get a table view of the map. I have a plan of attack now — which may be amenable to the workflow you're describing. I'll keep you posted!

genekim19:03:59

And am definitely up for pairing session on this!

phronmophobic19:03:51

I would like to implement a table view at some point. I think getting the most out of the builtin viewer also requires a different workflow as well (although I am interested in getting more perspectives). I noticed that in portal, when they expand everything, you basically only see one row at at time anyway. Rather than trying to expand the map and scroll, I would recommend zooming on particular parts of the data by clicking on a row.

phronmophobic19:03:14

The easiest way is usually by clicking on the initial { for a map.

phronmophobic19:03:31

The other difference in workflow is that rather than trying to explore by viewing -> editing ->tapping, I usually view, and then have one or two cells below where I explore the data in place.