scarpe-team / scarpe

Scarpe - shoes but running on webview
Other
163 stars 29 forks source link

Display properties #415

Open noahgibbs opened 1 year ago

noahgibbs commented 1 year ago

Shoes has certain properties which are set/modified by the display side. For instance, if you say "@button.width" you get the displayed width, which is often different from the width Shoes style. Similarly, you can set the width Shoes style to "100%" and @button.width will instead give a width in pixels.

This requires sending a message to the display side and getting a value back. We don't currently have a convenient way to do that (possible, yes, convenient, no.)

Display properties will need to be able to override styles in many cases -- starting with width and height where, as stated above, the display property is a different thing than the Shoes style with the same name.

noahgibbs commented 11 months ago

Note: speedometer_app.rb example uses "left" display property, so it's a good test case for this.

noahgibbs commented 10 months ago

This is going to require taking CatsCradle (or similar Fiber-based flow control, but I assume CatsCradle) and using to run all the app code.

noahgibbs commented 10 months ago

CatsCradle cleanup before doing this is in #493. Still need to add CatsCradle to the app code, of course.

noahgibbs commented 10 months ago

Which are the display properties? Looks like at least top, left, width, height, margin (various), gutter, displace_left, displace_top, scroll_top, scroll_max. A lot of slot styles, plus anything that can be set to a percentage, seems like. Maybe also font size stuff since it can be a percent?

Could do UI like checkboxes and radio buttons that way, though I suspect we'd rather keep having JS notify Ruby and keep a "most recent" value we can return from Ruby (as we currently do.)

noahgibbs commented 10 months ago

Relevant manual excerpt:

### style() » styles

Gives you the full set of styles applied to this element, in the form of a
Hash.  While methods like `width` and `height` and `top` give you back specific
pixel dimensions, using `style[:width]` or `style[:top]`, you can get the
original setting (things like "100%" for width or "10px" for top.)

 Shoes.app do
   # A button which take up the whole page
   @b = button "All of it", width: 1.0, height: 1.0

   # When clicked, show the styles
   @b.click { alert(@b.style.inspect) }
 end
noahgibbs commented 10 months ago

Looks like Shoes3 returns 0 for the relevant display properties I've checked before first paint. So maybe I can just return 0 with no JS query when initially setting up the drawable tree, and then call the JS handler code in Fibers. That'll be much easier than changing how all of drawable-tree setup works. Probably won't even require a change in the Lacci API, which looked like it was going to be necessary to run initial setup code in a Fiber.

Though eventually we'll need it if we want to run code after the Shoes::App block -- that'll have to be in a Fiber. And if we want to do the right thing with ask/confirm/etc dialogs.

noahgibbs commented 9 months ago

I have a local branch with a prototype of this, but it's not working yet. This Fiber stuff is being really annoying...