()
| 1454 | } |
| 1455 | |
| 1456 | func (ic *ImageContents) Draw() { |
| 1457 | |
| 1458 | var texture *sdl.Texture |
| 1459 | |
| 1460 | if ic.Card.IsSelected() { |
| 1461 | for index, button := range ic.Buttons { |
| 1462 | button.Rect.X = ic.Card.DisplayRect.X + (float32(index) * 32) |
| 1463 | button.Rect.Y = ic.Card.DisplayRect.Y - 32 |
| 1464 | button.Draw() |
| 1465 | } |
| 1466 | } |
| 1467 | |
| 1468 | resource := ic.Resource |
| 1469 | if resource == nil { |
| 1470 | resource = ic.DefaultImage |
| 1471 | // There is something in the filepath, but it's not valid |
| 1472 | if len(ic.FilepathLabel.Text) > 3 { |
| 1473 | resource = ic.BrokenImage |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | if resource != nil { |
| 1478 | |
| 1479 | ready := resource.FinishedDownloading() && (!resource.IsGIF() || resource.AsGIF().LoadingProgress() >= 1) |
| 1480 | |
| 1481 | if ready { |
| 1482 | |
| 1483 | var shadowTexture *sdl.Texture |
| 1484 | |
| 1485 | if resource.IsTexture() { |
| 1486 | texture = resource.AsImage().Texture |
| 1487 | shadowTexture = resource.AsImage().ShadowTexture |
| 1488 | } else if ic.GifPlayer != nil { |
| 1489 | texture = ic.GifPlayer.Texture() |
| 1490 | } |
| 1491 | |
| 1492 | if texture == nil { |
| 1493 | texture = ic.BrokenImage.AsImage().Texture |
| 1494 | } |
| 1495 | |
| 1496 | if resource == ic.DefaultImage { |
| 1497 | texture.SetColorMod(getThemeColor(GUIBlankImageColor).RGB()) |
| 1498 | } |
| 1499 | |
| 1500 | color := ColorWhite.Clone() |
| 1501 | |
| 1502 | if ic.Card.IsSelected() && globals.Settings.Get(SettingsFlashSelected).AsBool() { |
| 1503 | color = color.Sub(uint8(math.Sin(globals.Time*math.Pi*2+float64((ic.Card.Rect.X+ic.Card.Rect.Y)*0.004))*30 + 30)) |
| 1504 | } |
| 1505 | |
| 1506 | texture.SetColorMod(color.RGB()) |
| 1507 | |
| 1508 | if shadowTexture != nil && (!ic.Card.VisualDragging || ic.Card.PinnedTo == nil || !ic.Card.PinnedTo.VisualDragging) { |
| 1509 | |
| 1510 | p := ic.Card.ShadowDisplayPosition |
| 1511 | p.X += ic.Card.DisplayRect.W / 16 |
| 1512 | p.Y += ic.Card.DisplayRect.H / 16 |
| 1513 |
nothing calls this directly
no test coverage detected