swift-cross-ui icon indicating copy to clipboard operation
swift-cross-ui copied to clipboard

Implement a layout system

Open stackotter opened this issue 3 years ago • 2 comments

Currently, the layout of views is at the mercy of Gtk, which is not too great. Gtk supports styling through CSS, so the layout system would most likely just consist of generating css for each component according to certain layout rules. But there may be a better approach that I haven't thought of.

The SwiftGtk package currently doesn't support CSS styling which means that the styling feature request for SwiftGtk would have to be completed first.

stackotter avatar Mar 20 '22 07:03 stackotter

We now have some limited layout:

  • Alignment through Spacer:
/// horizontal alignment
HStack {
  Spacer()
  Content()
}
/// vertical alignment
VStack {
  Spacer()
  Content()
}
  • Forced minimum size using .frame(minWidth:maxWidth:)
Content().frame(minWidth: 200)
  • Padding
Content().padding(10)

Maybe we should define which layout features we would like next

Amzd avatar Jun 06 '23 16:06 Amzd

That's almost all of the main ones done, I can't really think of any off the top of my head other than navigation layouts, but that's also pretty good now. I feel like it's almost time to start trying to build some more complicated apps and just see what's missing in practice

stackotter avatar Jun 07 '23 11:06 stackotter