Giter Site home page Giter Site logo

Flexbox - like layout API about fyne HOT 7 OPEN

fyne-io avatar fyne-io commented on May 8, 2024
Flexbox - like layout API

from fyne.

Comments (7)

ohir avatar ohir commented on May 8, 2024 4

@andydotxyz

The long term plan was to use Cassowary [...]
[Flexbox] why it wouldn’t be appropriate?

Because of the technical debt to pay in years to come. Fyne is still a newborn and currently has no 'default layout engine'. Any that will come will hook up all user base. So if Flexbox will come first, the incentives to keep it will be strong. Assuming Cassowary will be next, Flexbox — even as a wrapper — still will call for maintenance.

Thinking of layout in Constraint terms, while needs a bit of mental switch from other layouting methods, has already proven its merits and advantages both on iOS and Android. I can not asses whether implementing it in Fyne will take twice as much effort as Flex, but even if thrice, it should be well amortized over the first or second maintenance cycle.

Everything that can be done with Flexbox cassowary computed layout can do. But not vice versa. Esp. with layouts where the same message needs to be shown in 40 glyphs of Icelandic or in four of Chinese.
$ 0.02

P.S. With constraints layout engine Fyne might leech on an Android Studio / Xcode allowing Fyne to get on board also designers.

from fyne.

steveoc64 avatar steveoc64 commented on May 8, 2024

Stage 2 would then be to apply struct tags to the original struct to then enable an auto-builder to create the UI, and do 2way binding to the underlying struct.

type Account struct {
  Name string  `flex: gridcols=6,label="Name",span=1"
  Address string `flex: label="Address",span=2,onchange=ChangeAddress`
 Comments string `flex: label="Account Comments",span=5,rows=4`
}

func (m *Account) ChangeAddress(old, new string) error {
  fmt.Println("Address was", old, "is now", new)
  return nil
}

myAccount := &Account{}

// then
myForm := NewFlexGrid().Build(myAccount)  // uses struct tags to auto-build the elements, and 2-way bind them to the model
// can now inject myForm into a dialog, or other widget, etc

from fyne.

andydotxyz avatar andydotxyz commented on May 8, 2024

Sounds pretty handy. One challenge will be that with the current container setup there will be duplication as the user has to pass items into the layout and the container. Perhaps we can improve that too?

from fyne.

tv42 avatar tv42 commented on May 8, 2024

Drive-by note: it's probably worth looking into whether to copy ideas from Flexbox or CSS Grids, or both.

from fyne.

ohir avatar ohir commented on May 8, 2024

As Fyne is fully scallable I think it would be better to implement constraints based layout (Cassowary), and then steer toward having it as the only layout engine. While its (constraints layout) concepts are somewhat new to the web developers base, its code and algorithms are solid rock. Both Flexbox and CSS Grids layouts have proved to be hard and/or resource hungry if applied in i18n/l10n demanding apps.
$ 0.02

from fyne.

andydotxyz avatar andydotxyz commented on May 8, 2024

The long term plan was to use Cassowary and rebuild others as helpful wrappers. But if people think flex box would be helpful then it could still work. All of the layout maths in Fyne is scaled dynamically so I can’t see a reason why it wouldn’t be appropriate?

from fyne.

andydotxyz avatar andydotxyz commented on May 8, 2024

After our conversation yesterday I wondered if adding hints (inspired by the options at the top of this post) to a standard grid layout may meet most use-cases for this request. By adding rowspan or colspan you could easily set up more complicated grids. By keeping it an underlying grid layout you end up with something like the bootstrap grid - define the number of columns and the space will be split equally, with cells filling the defined space.

I feel better about this simple approach than trying to aim for flex-box - I worry that we will fail to meet expectations in so many ways if we try to match the web layouts people are currenly working with.

from fyne.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.