jonegil / gui-with-gio

Tutorials for Gio, the GUI framework in Go.
https://jonegil.github.io/gui-with-gio/
Other
193 stars 40 forks source link

updated chapter 7, 8, 9, 10 according to the official doc #38

Closed zilllaiss closed 8 months ago

zilllaiss commented 8 months ago

Updated the chapters to latest gioui version. I mainly removed the select case syntax and replaced it with a simple goroutine (also moved it to the top of the function):

go func() {
    for range progressIncrementer {
        if boiling && progress < 1 {
          progress += 1.0 / 25.0 / boilDuration
          if progress >= 1 {
              progress = 1
          }

        w.Invalidate()
        }
    }
}()

This was done to follow the official doc syntax. Moreover, I think it's easier for beginner to follow as it's a little bit less of a boilerplate, although I suppose your tutorial for these chapters will need to be adjusted just a bit.

What do you think?

jonegil commented 8 months ago

First of all I'm thrilled that you updated these last chapters. I see tour thinking and think this works well. And at the same time I'm of two minds with regards to moving the goroutine into main since it has this tight coupling with the gui. Agreed, in this simple app there's no complexity in keeping it all in ones mind, but as an app grows I feal it could be better to separate. Let me chat with Chris and hear his perspective too.

Be that as it may, lets merge this one for now and I'll start working the docs.

Thumbs up.

jonegil commented 8 months ago

Ah, misread the initial comment on my phone. Your placement of the anonymous function inside draw() makes good sense. Nice one.