AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.16k stars 128 forks source link

UI does not refresh without moving mouse #701

Closed mikigal closed 9 months ago

mikigal commented 9 months ago

Hello,

I have running second thread which have to modify my UI. I'm chaning variables which are displayed by Giu from second thread using runtime.LockOSThread() Unfortunatelly GUI is refreshed only when I move mouse in application's window - when mouse is idle UI will never show new value

Here's my code (simplified to only loop incrementing variable - effect is the same as in original code):

var example = "0"

func main() {
    go startProcessing()
    window.Run(loop)
}

func startProcessing() {
    for i := 0; i < 9999; i++ {
        runtime.LockOSThread()
        example = strconv.Itoa(i)
                fmt.Println(example)
        runtime.UnlockOSThread()

        time.Sleep(1 * time.Second)
    }
}

func loop() {
    // Some widgets
    g.Label(example)
}

What am I doing wrong? Maybe I'm using LockOSThread() wrong, I never used it before. How can I force UI to refresh e. g. 60 times per second (60 FPS)?

issue

gucio321 commented 9 months ago

this is expected behavior. Quoting our FAQ page

Q: My app is refreshed only when I move my mouse or type something, so my constantly changing Widgets doesn't work A: Giu implements Power Saving Mode. UI is not re-rendered if no event happens. To baypass this, you need to call giu.Update() whenever you want to redraw UI.