drawIcon method

  1. @override
bool drawIcon(
  1. String iconKey,
  2. double x,
  3. double y,
  4. double size, {
  5. bool disabled = false,
})
override

Draws a registered icon (iconKey) into the given square, or returns false so the caller can render a placeholder glyph. When disabled is true the implementation should apply a ~40% alpha (Xojo Transparency).

Implementation

@override
bool drawIcon(
  String iconKey,
  double x,
  double y,
  double size, {
  bool disabled = false,
}) {
  final img = _IconImageCache.get(iconKey);
  if (img == null || !_IconImageCache.isLoaded(iconKey)) return false;
  if (disabled) ctx.globalAlpha = 0.4;
  ctx.drawImage(img, x, y, size, size);
  if (disabled) ctx.globalAlpha = 1.0;
  return true;
}