MCPcopy Create free account
hub / github.com/cogentcore/core / setZoom

Method setZoom

core/renderwindow.go:239–260  ·  view source on GitHub ↗

setZoom sets [AppearanceSettingsData.Zoom] to the given value and then triggers necessary updating and makes a snackbar.

(zoom float32)

Source from the content-addressed store, hash-verified

237// setZoom sets [AppearanceSettingsData.Zoom] to the given value and then triggers
238// necessary updating and makes a snackbar.
239func (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.
263func (w *renderWindow) resized() {

Callers 1

stepZoomMethod · 0.95

Calls 14

MainSceneMethod · 0.95
stepZoomMethod · 0.95
ClampFunction · 0.92
LogFunction · 0.92
UpdateAllFunction · 0.85
SaveSettingsFunction · 0.85
NewBodyFunction · 0.85
NewStretchFunction · 0.85
AddSnackbarTextMethod · 0.80
AddSnackbarIconMethod · 0.80
AddSnackbarButtonMethod · 0.80
DeleteChildByNameMethod · 0.80

Tested by

no test coverage detected