Commit 4a70cfed authored by Adam Barth's avatar Adam Barth

Rename various text-related classes

 - Inline -> Pargraph. This class is actually a box, not an inline. It's really
   a wrapper for RenderParagraph, so Paragraph is the normal name.

 - InlineBase -> RenderInline. The name we used in C++ for the base class of
   all inlines was RenderInline, which removes the ugly "Base" suffix.

 - InlineText -> RenderText. Aligns this name with C++.

 - InlineStyle -> RenderStyled. Matches the foregoing pattern.
parent bd5b9566
......@@ -18,25 +18,25 @@ void main() {
for(FlexAlignItems alignItems in FlexAlignItems.values) {
TextStyle style = const TextStyle(color: const Color(0xFF000000));
RenderParagraph paragraph = new RenderParagraph(new InlineStyle(style, [new InlineText("${alignItems}")]));
RenderParagraph paragraph = new RenderParagraph(new RenderStyled(style, [new RenderText("${alignItems}")]));
table.add(new RenderPadding(child: paragraph, padding: new EdgeDims.only(top: 20.0)));
var row = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
style = new TextStyle(fontSize: 15.0, color: const Color(0xFF000000));
row.add(new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)),
child: new RenderParagraph(new InlineStyle(style, [new InlineText('foo foo foo')]))
child: new RenderParagraph(new RenderStyled(style, [new RenderText('foo foo foo')]))
));
style = new TextStyle(fontSize: 10.0, color: const Color(0xFF000000));
row.add(new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)),
child: new RenderParagraph(new InlineStyle(style, [new InlineText('foo foo foo')]))
child: new RenderParagraph(new RenderStyled(style, [new RenderText('foo foo foo')]))
));
var subrow = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
style = new TextStyle(fontSize: 25.0, color: const Color(0xFF000000));
subrow.add(new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)),
child: new RenderParagraph(new InlineStyle(style, [new InlineText('foo foo foo foo')]))
child: new RenderParagraph(new RenderStyled(style, [new RenderText('foo foo foo foo')]))
));
subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: new Size(30.0, 40.0)));
row.add(subrow);
......
......@@ -13,19 +13,19 @@ import 'package:sky/rendering/sky_binding.dart';
RenderBox getBox(double lh) {
RenderParagraph paragraph = new RenderParagraph(
new InlineStyle(
new RenderStyled(
new TextStyle(
color: const Color(0xFF0000A0)
),
[
new InlineText('test'),
new InlineStyle(
new RenderText('test'),
new RenderStyled(
new TextStyle(
fontFamily: 'serif',
fontSize: 50.0,
height: lh
),
[new InlineText('مرحبا Hello')]
[new RenderText('مرحبا Hello')]
)
]
)
......@@ -57,7 +57,7 @@ RenderBox getBox(double lh) {
paint.color = const Color(0xFFFF9000);
paint.setStyle(sky.PaintingStyle.stroke);
paint.strokeWidth = 3.0;
canvas.drawPath(path, paint);
canvas.drawPath(path, paint);
}
)
)
......
......@@ -84,9 +84,9 @@ porchetta bacon kevin meatball meatloaf pig beef ribs chicken. Brisket ribeye
andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola
alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
var text = new InlineStyle(
var text = new RenderStyled(
new TextStyle(color: const Color(0xFF009900)),
[new InlineText(meatyString)]);
[new RenderText(meatyString)]);
padding = new RenderPadding(
padding: const EdgeDims.all(10.0),
child: new RenderParagraph(text));
......
......@@ -21,7 +21,7 @@ void main() {
var table = new RenderFlex(direction: FlexDirection.vertical);
void addRow(FlexJustifyContent justify) {
RenderParagraph paragraph = new RenderParagraph(new InlineStyle(style, [new InlineText("${justify}")]));
RenderParagraph paragraph = new RenderParagraph(new RenderStyled(style, [new RenderText("${justify}")]));
table.add(new RenderPadding(child: paragraph, padding: new EdgeDims.only(top: 20.0)));
var row = new RenderFlex(direction: FlexDirection.horizontal);
row.add(new RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: new Size(80.0, 60.0)));
......
......@@ -32,9 +32,9 @@ andouille leberkas capicola meatloaf. Chicken pig ball tip pork picanha bresaola
alcatra. Pork pork belly alcatra, flank chuck drumstick biltong doner jowl.
Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
var text = new InlineStyle(
var text = new RenderStyled(
new TextStyle(color: const Color(0xFF009900)),
[new InlineText(meatyString)]);
[new RenderText(meatyString)]);
child = new RenderDecoratedBox(
decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
child: new RenderParagraph(text)
......
......@@ -80,7 +80,7 @@ class RenderTouchDemo extends RenderBox {
}
void main() {
var paragraph = new RenderParagraph(new InlineText("Touch me!"));
var paragraph = new RenderParagraph(new RenderText("Touch me!"));
var stack = new RenderStack(children: [
new RenderTouchDemo(),
paragraph,
......
......@@ -8,7 +8,7 @@ import 'package:sky/painting/text_style.dart';
import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/object.dart';
abstract class InlineBase {
abstract class RenderInline {
sky.Node _toDOM(sky.Document owner);
String toString([String prefix = '']);
......@@ -16,8 +16,8 @@ abstract class InlineBase {
}
}
class InlineText extends InlineBase {
InlineText(this.text) {
class RenderText extends RenderInline {
RenderText(this.text) {
assert(text != null);
}
......@@ -27,25 +27,25 @@ class InlineText extends InlineBase {
return owner.createText(text);
}
bool operator ==(other) => other is InlineText && text == other.text;
bool operator ==(other) => other is RenderText && text == other.text;
int get hashCode => text.hashCode;
String toString([String prefix = '']) => '${prefix}InlineText: "${text}"';
}
class InlineStyle extends InlineBase {
InlineStyle(this.style, this.children) {
class RenderStyled extends RenderInline {
RenderStyled(this.style, this.children) {
assert(style != null);
assert(children != null);
}
final TextStyle style;
final List<InlineBase> children;
final List<RenderInline> children;
sky.Node _toDOM(sky.Document owner) {
sky.Element parent = owner.createElement('t');
style.applyToCSSStyle(parent.style);
for (InlineBase child in children) {
for (RenderInline child in children) {
parent.appendChild(child._toDOM(owner));
}
return parent;
......@@ -58,7 +58,7 @@ class InlineStyle extends InlineBase {
bool operator ==(other) {
if (identical(this, other))
return true;
if (other is! InlineStyle
if (other is! RenderStyled
|| style != other.style
|| children.length != other.children.length)
return false;
......@@ -72,7 +72,7 @@ class InlineStyle extends InlineBase {
int get hashCode {
int value = 373;
value = 37 * value + style.hashCode;
for (InlineBase child in children)
for (RenderInline child in children)
value = 37 * value + child.hashCode;
return value;
}
......@@ -82,7 +82,7 @@ class InlineStyle extends InlineBase {
result.add('${prefix}InlineStyle:');
var indent = '${prefix} ';
result.add('${style.toString(indent)}');
for (InlineBase child in children) {
for (RenderInline child in children) {
result.add(child.toString(indent));
}
return result.join('\n');
......@@ -102,9 +102,8 @@ double _applyFloatingPointHack(double layoutValue) {
class RenderParagraph extends RenderBox {
RenderParagraph(InlineBase inlineValue) {
RenderParagraph(this._inline) {
_layoutRoot.rootElement = _document.createElement('p');
inline = inlineValue;
}
final sky.Document _document = new sky.Document();
......@@ -112,9 +111,9 @@ class RenderParagraph extends RenderBox {
BoxConstraints _constraintsForCurrentLayout; // when null, we don't have a current layout
InlineBase _inline;
InlineBase get inline => _inline;
void set inline (InlineBase value) {
RenderInline _inline;
RenderInline get inline => _inline;
void set inline (RenderInline value) {
if (_inline == value)
return;
_inline = value;
......
......@@ -445,17 +445,17 @@ class Flexible extends ParentDataNode {
: super(child, new FlexBoxParentData()..flex = flex, key: key);
}
class Inline extends LeafRenderObjectWrapper {
Inline({ Key key, this.text }) : super(key: key);
class Paragraph extends LeafRenderObjectWrapper {
Paragraph({ Key key, this.inline }) : super(key: key);
final InlineBase text;
final RenderInline inline;
RenderParagraph createNode() => new RenderParagraph(text);
RenderParagraph createNode() => new RenderParagraph(inline);
RenderParagraph get root => super.root;
void syncRenderObject(Widget old) {
super.syncRenderObject(old);
root.inline = text;
root.inline = inline;
}
}
......@@ -467,16 +467,16 @@ class StyledText extends Component {
final dynamic elements;
InlineBase _toInline(dynamic element) {
RenderInline _toInline(dynamic element) {
if (element is String)
return new InlineText(element);
return new RenderText(element);
if (element is Iterable && element.first is TextStyle)
return new InlineStyle(element.first, element.skip(1).map(_toInline).toList());
return new RenderStyled(element.first, element.skip(1).map(_toInline).toList());
throw new ArgumentError("invalid elements");
}
Widget build() {
return new Inline(text: _toInline(elements));
return new Paragraph(inline: _toInline(elements));
}
}
......@@ -487,7 +487,7 @@ class Text extends Component {
final TextStyle style;
Widget build() {
InlineBase text = new InlineText(data);
RenderInline inline = new RenderText(data);
TextStyle defaultStyle = DefaultTextStyle.of(this);
TextStyle combinedStyle;
if (defaultStyle != null) {
......@@ -499,8 +499,8 @@ class Text extends Component {
combinedStyle = style;
}
if (combinedStyle != null)
text = new InlineStyle(combinedStyle, [text]);
return new Inline(text: text);
inline = new RenderStyled(combinedStyle, [inline]);
return new Paragraph(inline: inline);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment