paint method

void paint(
  1. Canvas canvas
)

Implementation

void paint(Canvas canvas) {
  final fillPaint =
      _dragType == DragType.none ? _fillPaint : _draggedFillPaint;
  final strokePaint =
      _dragType == DragType.none ? _strokePaint : _draggedStrokePaint;

  // Fill + stroke every segment. A single-column event has exactly one (its
  // live rect, carrying any drag offset); a spanning event has one per covered
  // column (#47) and never drags.
  final segments = _currentSegments();
  for (final segment in segments) {
    final screenSegment = _toScreen(segment);
    canvas.drawRect(screenSegment, fillPaint);
    canvas.drawRect(screenSegment, strokePaint);
  }

  // Resize handles are a drag/resize affordance; spanning events are read-only
  // in this first cut (#47), so only single-column events draw them.
  if (!entry.time.spansColumns) {
    final rect = segments.first;
    _paintHandle(canvas, rect.topLeft.translate(0.0, 1), rect.width);
    _paintHandle(canvas, rect.bottomLeft.translate(0.0, -1), rect.width);
  }

  // Title/content render in the start-column segment.
  final Rect screenRect = _toScreen(segments.first);
  Rect clipRect = Rect.fromPoints(
      screenRect.topLeft.translate(2,
          entry.titleStyle.fontSize != null ? entry.titleStyle.fontSize! : 8),
      screenRect.bottomRight.translate(
          -2,
          entry.titleStyle.fontSize != null
              ? -entry.titleStyle.fontSize!
              : -8));

  canvas.save();
  canvas.clipRect(clipRect);
  Offset cpos = screenRect.topLeft;
  cpos = cpos.translate(5.0, 10.0);
  _titlePainter.paint(canvas, cpos);
  cpos = cpos.translate(0.0, 15.0);
  _contentPainter.paint(canvas, cpos);
  canvas.restore();
}