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

Method Update

gui.go:3013–3066  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3011}
3012
3013func (container *Container) Update() {
3014
3015 pos := globals.Mouse.Position()
3016 if container.WorldSpace {
3017 pos = globals.Mouse.WorldPosition()
3018 }
3019
3020 if !pos.Inside(container.Rect) {
3021 globals.Mouse.HiddenPosition = true
3022 }
3023
3024 if container.NeedScroll() && container.DisplayScrollbar {
3025 container.Scrollbar.Rect.H = container.Rect.H - 48
3026 container.Scrollbar.Rect.W = 16
3027 container.Scrollbar.Rect.X = container.Rect.X + container.Rect.W - container.Scrollbar.Rect.W
3028 container.Scrollbar.Rect.Y = container.Rect.Y + 48
3029
3030 if wheel := globals.Mouse.Wheel(); wheel != 0 && pos.Inside(container.Rect) {
3031 container.Scrollbar.SetValue(container.Scrollbar.TargetValue - float32(wheel)/container.overallHeight*100)
3032 globals.Mouse.wheel = 0 // Consume the wheel movement
3033 }
3034
3035 container.Scrollbar.Update()
3036
3037 } else {
3038 if container.Scrollbar.Value != 0 {
3039 container.Scrollbar.TargetValue = 0
3040 container.Scrollbar.Value = 0
3041 }
3042 }
3043
3044 perc := float32(0)
3045
3046 if idealSize := container.IdealSize(); container.NeedScroll() && idealSize.Y > 32 {
3047 perc = ((idealSize.Y - container.Rect.H) / container.Rect.H) * container.Scrollbar.Value
3048 }
3049
3050 container.overallHeight = float32(0)
3051 y := float32(math.Round(float64(-perc * container.Rect.H)))
3052 for _, row := range container.Rows {
3053 if row.Visible != VisibleCollapsed {
3054 diff := row.Update(y)
3055 y += diff
3056 container.overallHeight += diff
3057 }
3058 }
3059
3060 if container.OnUpdate != nil {
3061 container.OnUpdate()
3062 }
3063
3064 globals.Mouse.HiddenPosition = false
3065
3066}
3067
3068func (container *Container) Draw() {
3069

Callers

nothing calls this directly

Calls 8

NeedScrollMethod · 0.95
IdealSizeMethod · 0.95
WorldPositionMethod · 0.80
InsideMethod · 0.80
WheelMethod · 0.80
UpdateMethod · 0.65
PositionMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected