()
| 4271 | } |
| 4272 | |
| 4273 | func (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 | } |
nothing calls this directly
no test coverage detected