Lazy mode
is a library layer that prevents the contents of a window from being redrawn if the contents of the window remain the same.
The event loop of a typical GUI application looks like this:
changed := true
for {
// Redraw application state
if changed {
redrawAppState()
}
// Get next event
ev := <- app.Chan()
// Close application at the end
if isExitAppEvent(ev) {
break
}
// Change state of application
changed = changeAppState(ev)
}
Redrawing after each event can slow down the GUI application and cause flickering. It makes sense to draw only when the visual representation has changed.
How do you know if the visual representation is not the same? The state depends on the string values of the fields, the positions of many elements, the colors of these elements, etc. All values must be saved for comparison after a state change. To remove this logic from a GUI application, the library contains a lazy mode
layer. It stores raw drawing commands for all windows and redraws window if the new sequence of drawing commands is different.
Since lazy mode
does not impact library performance, it is enabled by default.
In lazy mode
, the event loop might look simpler:
for {
// Redraw application state
redrawAppState()
// Get next event
ev := <- app.Chan()
// Close application at the end
if isExitAppEvent(ev) {
break
}
// Change state of application
changeAppState(ev)
}
For details on the event loop, see Library Overview.