layout method

  1. @override
void layout(
  1. FConstraints constraints
)
override

Implementation

@override
void layout(FConstraints constraints) {
  final measured = backend.render.measureTextEx(
    app.defaultFont, 'Ag', fontSize, fontSpacing,
  );

  final naturalWidth = constraints.minWidth == constraints.maxWidth
    ? constraints.maxWidth // parent forced an exact width, respect it
    : 160.0;               // otherwise fall back to a sensible default

  final naturalHeight = constraints.minHeight == constraints.maxHeight
    ? constraints.maxHeight // parent forced an exact height, respect it
    : measured.y;           // otherwise size to the font metrics
    // NOTE: keep this here because _paddingY is not used at all for now
    // : measured.y + _paddingY * 2

  size = constraints.constrain(.vec2(naturalWidth, naturalHeight));
}