WIP: Experiments and hacks attempting to implement SwiftUI-like layout flow#379
WIP: Experiments and hacks attempting to implement SwiftUI-like layout flow#379mortenbekditlevsen wants to merge 25 commits intomainfrom
Conversation
…nto TokamakCore to make everything fit nicely together. Use CGPoint instead of CGAffineTransform for context since the latter has issues in .concatenate. Will create a separate PR to fix that.
…nitialized array used by CGAffineTransform concatenation
…a bit of an annoying protocol conformance to Target
…this logic to StackHelper to keep it separate and to reuse between HStack and VStack
…t bit of mutable state
|
Hi @j-f1 , The scope of the task also became slightly daunting - there are a few general areas that I've not tried to tackle yet at all:
I did try to merge main into this branch earlier, but I had the idea that the layout functionality might live on I haven't yet looked into all of your additions, but please let me know if there is something you would like to discuss. :-) |
Please don't look at this yet - it's horrible! :-)
Currently I made a lot of types in
TokamakCorepublic in order to perform the layout in the renderer. The layout should actually reside inTokamakCorewith only a slim api to the renderer.The GTK renderer is my current experimentation playground.
Instead of always returning a
GtkWidgetfor theAnyWidgetconformance it's now ok to be a 'virtual' (pure layout) widget and not return any actual control.A 'context' is used to keep a stack of offsets used during layout - as well as a reference to the last actual widget container where all child elements should be added.
The only implementation of the sizing/layout is for
Textwhere the GtkWidget is actually measured to return it's size, as well as_ShapeViewwhose size doesn't rely on any actual measuring.Box(a helper type used byHStackandVStackin the GTK renderer) implements an extremely naive version of a layout. It's completely wrong, but shows how the sizing/layout could be tied together.For the actual algorithm I propose to use the MIT licensed
NotSwiftUIsample code from Objc.io. Perhaps only paying members of the Swift Talk video series have access, but I do have access through my work.This naturally requires Tokamak to include the LICENSE text with copyright notice from objc.io.
I am currently experimenting with
Overlay, but I think now is the time to move thesizeandlayoutprotocol requirements intoTokamakCore.Apologies for the extremely rough/messy state of this draft PR. :-)