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

Method Draw

gui.go:3068–3155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3066}
3067
3068func (container *Container) Draw() {
3069
3070 r := container.Rectangle()
3071
3072 if container.WorldSpace {
3073 r = globals.Project.Camera.TranslateRect(r)
3074 }
3075
3076 rect := &sdl.Rect{int32(r.X), int32(r.Y), int32(r.W), int32(r.H)}
3077
3078 // We combine clipping rectangles here as necessary; this allows containers within containers to render correctly
3079 if len(globals.ClipRects) > 0 {
3080 prevRect := globals.ClipRects[len(globals.ClipRects)-1]
3081 if prevRect.X > rect.X {
3082 rect.X = prevRect.X
3083 }
3084
3085 if prevRect.X+prevRect.W < rect.X+rect.W {
3086 rect.W = (prevRect.X + prevRect.W) - rect.X
3087 }
3088
3089 if prevRect.Y > rect.Y {
3090 rect.Y = prevRect.Y
3091 }
3092
3093 if prevRect.Y+prevRect.H < rect.Y+rect.H {
3094 rect.H = (prevRect.Y + prevRect.H) - rect.Y
3095 }
3096 }
3097
3098 globals.Renderer.SetClipRect(rect)
3099 globals.ClipRects = append(globals.ClipRects, rect)
3100
3101 rows := append([]*ContainerRow{}, container.Rows...)
3102
3103 sort.SliceStable(rows, func(i, j int) bool { return i > j })
3104
3105 alternateColor := false
3106 for i := 0; i < len(rows); i++ {
3107
3108 row := rows[i]
3109
3110 if row.Visible == VisibleNormal {
3111
3112 if !row.AlternateBGColor {
3113 alternateColor = false
3114 }
3115
3116 row.alternateBGColorFlag = alternateColor
3117 row.Draw()
3118
3119 alternateColor = !alternateColor
3120
3121 }
3122
3123 }
3124
3125 if container.OnDraw != nil {

Callers

nothing calls this directly

Calls 5

RectangleMethod · 0.95
NeedScrollMethod · 0.95
TranslateRectMethod · 0.80
DrawMethod · 0.65
DrawOnTopMethod · 0.65

Tested by

no test coverage detected