| Index: sky/sdk/lib/painting/text_style.dart
|
| diff --git a/sky/sdk/lib/painting/text_style.dart b/sky/sdk/lib/painting/text_style.dart
|
| index d45929991b6007fb77c11a8b16e15cd62d4e933e..43e27e982a0c92e94d65fd09ae28929aafe9d47f 100644
|
| --- a/sky/sdk/lib/painting/text_style.dart
|
| +++ b/sky/sdk/lib/painting/text_style.dart
|
| @@ -32,13 +32,35 @@ enum TextAlign {
|
| center
|
| }
|
|
|
| +enum TextDecoration {
|
| + none,
|
| + underline,
|
| + overline,
|
| + lineThrough
|
| +}
|
| +
|
| +const underline = const <TextDecoration> [TextDecoration.underline];
|
| +const overline = const <TextDecoration> [TextDecoration.overline];
|
| +const lineThrough = const <TextDecoration> [TextDecoration.lineThrough];
|
| +
|
| +enum TextDecorationStyle {
|
| + solid,
|
| + double,
|
| + dotted,
|
| + dashed,
|
| + wavy
|
| +}
|
| +
|
| class TextStyle {
|
| const TextStyle({
|
| this.color,
|
| this.fontFamily,
|
| this.fontSize,
|
| this.fontWeight,
|
| - this.textAlign
|
| + this.textAlign,
|
| + List<TextDecoration> this.decoration,
|
| + this.decorationColor,
|
| + this.decorationStyle
|
| });
|
|
|
| final Color color;
|
| @@ -46,19 +68,39 @@ class TextStyle {
|
| final double fontSize; // in pixels
|
| final FontWeight fontWeight;
|
| final TextAlign textAlign;
|
| + final List<TextDecoration> decoration;
|
| + final Color decorationColor;
|
| + final TextDecorationStyle decorationStyle;
|
| +
|
| + String _decorationToString() {
|
| + assert(decoration != null);
|
| + const toCSS = const {
|
| + TextDecoration.none: 'none',
|
| + TextDecoration.underline: 'underline',
|
| + TextDecoration.overline: 'overline',
|
| + TextDecoration.lineThrough: 'lineThrough'
|
| + };
|
| + return decoration.map((d) => toCSS[d]).join(' ');
|
| + }
|
|
|
| TextStyle copyWith({
|
| Color color,
|
| double fontSize,
|
| FontWeight fontWeight,
|
| - TextAlign textAlign
|
| + TextAlign textAlign,
|
| + TextDecoration decoration,
|
| + Color decorationColor,
|
| + TextDecorationStyle decorationStyle
|
| }) {
|
| return new TextStyle(
|
| color: color != null ? color : this.color,
|
| fontFamily: fontFamily != null ? fontFamily : this.fontFamily,
|
| fontSize: fontSize != null ? fontSize : this.fontSize,
|
| fontWeight: fontWeight != null ? fontWeight : this.fontWeight,
|
| - textAlign: textAlign != null ? textAlign : this.textAlign
|
| + textAlign: textAlign != null ? textAlign : this.textAlign,
|
| + decoration: decoration != null ? decoration : this.decoration,
|
| + decorationColor: decorationColor != null ? decorationColor : this.decorationColor,
|
| + decorationStyle: decorationStyle != null ? decorationStyle : this.decorationStyle
|
| );
|
| }
|
|
|
| @@ -68,7 +110,10 @@ class TextStyle {
|
| fontFamily == other.fontFamily &&
|
| fontSize == other.fontSize &&
|
| fontWeight == other.fontWeight &&
|
| - textAlign == other.textAlign;
|
| + textAlign == other.textAlign &&
|
| + decoration == other.decoration &&
|
| + decorationColor == other.decorationColor &&
|
| + decorationStyle == other.decorationStyle;
|
| }
|
|
|
| int get hashCode {
|
| @@ -79,6 +124,9 @@ class TextStyle {
|
| value = 37 * value + fontSize.hashCode;
|
| value = 37 * value + fontWeight.hashCode;
|
| value = 37 * value + textAlign.hashCode;
|
| + value = 37 * value + decoration.hashCode;
|
| + value = 37 * value + decorationColor.hashCode;
|
| + value = 37 * value + decorationStyle.hashCode;
|
| return value;
|
| }
|
|
|
| @@ -113,6 +161,10 @@ class TextStyle {
|
| TextAlign.center: 'center',
|
| }[textAlign];
|
| }
|
| + if (decoration != null) {
|
| + cssStyle['text-decoration'] = _decorationToString();
|
| + }
|
| + // TODO(hansmuller): add support for decoration color and style.
|
| }
|
|
|
| String toString([String prefix = '']) {
|
| @@ -128,6 +180,12 @@ class TextStyle {
|
| result.add('${prefix}fontWeight: $fontWeight');
|
| if (textAlign != null)
|
| result.add('${prefix}textAlign: $textAlign');
|
| + if (decoration != null)
|
| + result.add('${prefix}decoration: ${_decorationToString()}');
|
| + if (decorationColor != null)
|
| + result.add('${prefix}decorationColor: $decorationColor');
|
| + if (decorationStyle != null)
|
| + result.add('${prefix}decorationStyle: $decorationStyle');
|
| if (result.isEmpty)
|
| return '${prefix}<no style specified>';
|
| return result.join('\n');
|
|
|