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

Method Draw

gui.go:4273–4336  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4271}
4272
4273func (ds *DraggableLabel) Draw() {
4274
4275 menuColor := getThemeColor(GUIMenuColor)
4276 fontColor := getThemeColor(GUIFontColor)
4277
4278 shadow := NewColor(0, 0, 0, 150)
4279
4280 softness := float32(0.5)
4281 ds.rect.X += (ds.TargetRect.X - ds.rect.X) * softness
4282 ds.rect.Y += (ds.TargetRect.Y - ds.rect.Y) * softness
4283 ds.rect.W += (ds.TargetRect.W - ds.rect.W) * softness
4284 ds.rect.H += (ds.TargetRect.H - ds.rect.H) * softness
4285
4286 rect := globals.Project.Camera.TranslateRect(ds.rect)
4287
4288 if ds.Dragging {
4289 FillRect(rect.X+16, rect.Y+16, rect.W, rect.H, shadow)
4290 }
4291 FillRect(rect.X, rect.Y, rect.W, rect.H, fontColor)
4292 FillRect(rect.X+2, rect.Y+2, rect.W-4, rect.H-4, menuColor)
4293 ds.currentFillAmount += (ds.FillAmount - ds.currentFillAmount) * 0.4
4294 if ds.currentFillAmount > 0.01 {
4295 if ds.Vertical && !ds.verticalEditing {
4296 FillRect(rect.X+2, rect.Y+2, rect.W-4, (rect.H-4)*ds.currentFillAmount, getThemeColor(GUICompletedColor))
4297 } else {
4298 FillRect(rect.X+2, rect.Y+2, (rect.W-4)*ds.currentFillAmount, rect.H-4, getThemeColor(GUICompletedColor))
4299 }
4300 }
4301
4302 // Draggable icon
4303 globals.GUITexture.Texture.SetColorMod(fontColor.RGB())
4304 globals.GUITexture.Texture.SetAlphaMod(128)
4305 globals.Renderer.RenderTexture(globals.GUITexture.Texture, &sdl.FRect{0, 288, 32, 32}, &sdl.FRect{rect.X, rect.Y, 32, 32})
4306
4307 if !ds.Vertical || ds.verticalEditing {
4308 ds.Label.Draw()
4309 } else {
4310 ds.Label.currentAlpha += (ds.Label.Alpha - ds.Label.currentAlpha) * 0.2
4311 ds.Label.RendererResult.Image.Texture.SetAlphaMod(uint8(ds.Label.currentAlpha * 255))
4312 t := (1 + math.Sin(globals.Time*math.Pi*2)) * 0.5
4313
4314 r := *ds.rect
4315 r.Y += 32
4316 r.H -= 32
4317
4318 color := getThemeColor(GUIFontColor)
4319 if globals.Mouse.WorldPosition().Inside(&r) {
4320 color = color.Mix(color.Invert(), t*0.75)
4321 }
4322 ds.Label.RendererResult.Image.Texture.SetColorMod(color.RGB())
4323
4324 labelSize := ds.Label.TextSize()
4325 rect := *ds.Label.Rect
4326 rect.X += 2
4327 rect.W = labelSize.X
4328 if rect.W < 32 {
4329 rect.W = 32
4330 }

Callers

nothing calls this directly

Calls 11

getThemeColorFunction · 0.85
NewColorFunction · 0.85
FillRectFunction · 0.85
TranslateRectMethod · 0.80
RGBMethod · 0.80
InsideMethod · 0.80
WorldPositionMethod · 0.80
MixMethod · 0.80
InvertMethod · 0.80
TextSizeMethod · 0.80
DrawMethod · 0.65

Tested by

no test coverage detected