-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Experiments and hacks attempting to implement SwiftUI-like layout flow #379
base: main
Are you sure you want to change the base?
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
TokamakCore
public in order to perform the layout in the renderer. The layout should actually reside inTokamakCore
with only a slim api to the renderer.The GTK renderer is my current experimentation playground.
Instead of always returning a
GtkWidget
for theAnyWidget
conformance 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
Text
where the GtkWidget is actually measured to return it's size, as well as_ShapeView
whose size doesn't rely on any actual measuring.Box
(a helper type used byHStack
andVStack
in 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
NotSwiftUI
sample 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 thesize
andlayout
protocol requirements intoTokamakCore
.Apologies for the extremely rough/messy state of this draft PR. :-)