setZoom sets [AppearanceSettingsData.Zoom] to the given value and then triggers necessary updating and makes a snackbar.
(zoom float32)
| 237 | // setZoom sets [AppearanceSettingsData.Zoom] to the given value and then triggers |
| 238 | // necessary updating and makes a snackbar. |
| 239 | func (w *renderWindow) setZoom(zoom float32) { |
| 240 | AppearanceSettings.Zoom = math32.Clamp(zoom, 10, 500) |
| 241 | AppearanceSettings.Apply() |
| 242 | UpdateAll() |
| 243 | errors.Log(SaveSettings(AppearanceSettings)) |
| 244 | |
| 245 | if ms := w.MainScene(); ms != nil { |
| 246 | b := NewBody().AddSnackbarText(fmt.Sprintf("%.f%%", AppearanceSettings.Zoom)) |
| 247 | NewStretch(b) |
| 248 | b.AddSnackbarIcon(icons.Remove, func(e events.Event) { |
| 249 | w.stepZoom(-1) |
| 250 | }) |
| 251 | b.AddSnackbarIcon(icons.Add, func(e events.Event) { |
| 252 | w.stepZoom(1) |
| 253 | }) |
| 254 | b.AddSnackbarButton("Reset", func(e events.Event) { |
| 255 | w.setZoom(100) |
| 256 | }) |
| 257 | b.DeleteChildByName("stretch") |
| 258 | b.RunSnackbar(ms) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | // resized updates internal buffers after a window has been resized. |
| 263 | func (w *renderWindow) resized() { |
no test coverage detected