MCPcopy Create free account
hub / github.com/SolarLune/masterplan / ImmediateIconButton

Function ImmediateIconButton

gui.go:370–408  ·  view source on GitHub ↗
(settings ImmediateIconButtonSettings)

Source from the content-addressed store, hash-verified

368}
369
370func ImmediateIconButton(settings ImmediateIconButtonSettings) bool {
371
372 clicked := false
373
374 dst := &settings.Dst
375 dst.W *= settings.Scale
376 dst.H *= settings.Scale
377
378 var insideButton = false
379 if settings.WorldSpace {
380 insideButton = globals.Mouse.RawWorldPosition().Inside(dst)
381 } else {
382 insideButton = globals.Mouse.RawPosition().Inside(dst)
383 }
384
385 if RawClickedInRect(dst, settings.WorldSpace) {
386 globals.Mouse.Button(sdl.BUTTON_LEFT).Consume()
387 clicked = true
388 }
389
390 guiTex := globals.GUITexture.Texture
391
392 tint := uint8(200)
393
394 if insideButton {
395 tint = 255
396 }
397
398 guiTex.SetColorMod(tint, tint, tint)
399 guiTex.SetAlphaMod(255)
400
401 if settings.WorldSpace {
402 settings.Dst = *globals.Project.Camera.TranslateRect(dst)
403 }
404 globals.Renderer.RenderTextureRotated(guiTex, &settings.Src, dst, settings.Rotation, &sdl.FPoint{float32(settings.Src.W / 2), float32(settings.Src.H / 2)}, settings.Flip)
405
406 return clicked
407
408}
409
410type Checkbox struct {
411 IconButton

Callers

nothing calls this directly

Calls 7

RawClickedInRectFunction · 0.85
InsideMethod · 0.80
RawWorldPositionMethod · 0.80
RawPositionMethod · 0.80
ConsumeMethod · 0.80
ButtonMethod · 0.80
TranslateRectMethod · 0.80

Tested by

no test coverage detected