Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Unified Diff: sky/sdk/lib/framework/rendering/box.dart

Issue 1175763002: Add LinearBoxGradient and RadialBoxGradient decorations for RenderDecoratedBox. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: . Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« sky/examples/raw/shadowed_box.dart ('K') | « sky/examples/raw/shadowed_box.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/rendering/box.dart
diff --git a/sky/sdk/lib/framework/rendering/box.dart b/sky/sdk/lib/framework/rendering/box.dart
index 520625626635d6ad86ce6195cdedd370a5a71dee..7355ef99c2c50a2389905ea0e78fe8cec21594d2 100644
--- a/sky/sdk/lib/framework/rendering/box.dart
+++ b/sky/sdk/lib/framework/rendering/box.dart
@@ -655,19 +655,72 @@ class BoxShadow {
String toString() => 'BoxShadow($color, $offset, $blur)';
}
+abstract class BoxGradient {
+ String toString();
abarth-chromium 2015/06/09 21:23:39 You can skip this declaration. It's declared alre
Matt Perry 2015/06/09 21:38:28 Done.
+ sky.Shader createShader();
+}
+
+class LinearBoxGradient extends BoxGradient {
+ LinearBoxGradient({
+ this.endPoints,
+ this.colors,
+ this.colorStops,
+ this.tileMode: sky.TileMode.clamp
+ });
+
+ String toString() =>
+ 'LinearBoxGradient($endPoints, $colors, $colorStops, $tileMode)';
+
+ sky.Shader createShader() {
+ return new sky.Gradient.Linear(this.endPoints, this.colors, this.colorStops,
+ this.tileMode);
+ }
+
+ final List<Point> endPoints;
+ final List<Color> colors;
+ final List<double> colorStops;
+ final sky.TileMode tileMode;
+}
+
+class RadialBoxGradient extends BoxGradient {
+ RadialBoxGradient({
+ this.center,
+ this.radius,
+ this.colors,
+ this.colorStops,
+ this.tileMode: sky.TileMode.clamp
+ });
+
+ String toString() =>
+ 'RadialBoxGradient($center, $radius, $colors, $colorStops, $tileMode)';
+
+ sky.Shader createShader() {
+ return new sky.Gradient.Radial(this.center, this.radius, this.colors,
+ this.colorStops, this.tileMode);
+ }
+
+ final Point center;
+ final double radius;
+ final List<Color> colors;
+ final List<double> colorStops;
+ final sky.TileMode tileMode;
+}
+
// This must be immutable, because we won't notice when it changes
class BoxDecoration {
const BoxDecoration({
this.backgroundColor,
this.border,
this.borderRadius,
- this.boxShadow
+ this.boxShadow,
+ this.boxGradient
});
final Color backgroundColor;
final double borderRadius;
final Border border;
final List<BoxShadow> boxShadow;
+ final BoxGradient boxGradient;
abarth-chromium 2015/06/09 21:23:40 boxGradient -> gradient We should probably rename
Matt Perry 2015/06/09 21:38:28 Done.
String toString([String prefix = '']) {
List<String> result = [];
@@ -679,6 +732,8 @@ class BoxDecoration {
result.add('${prefix}borderRadius: $borderRadius');
if (boxShadow != null)
result.add('${prefix}boxShadow: ${boxShadow.map((shadow) => shadow.toString())}');
+ if (boxGradient != null)
+ result.add('${prefix}boxGradient: $boxGradient');
if (result.isEmpty)
return '${prefix}<no decorations specified>';
return result.join('\n');
@@ -720,6 +775,9 @@ class RenderDecoratedBox extends RenderProxyBox {
paint.setDrawLooper(builder.build());
}
+ if (_decoration.boxGradient != null)
+ paint.setShader(_decoration.boxGradient.createShader());
+
_cachedBackgroundPaint = paint;
}
@@ -730,7 +788,8 @@ class RenderDecoratedBox extends RenderProxyBox {
assert(size.width != null);
assert(size.height != null);
- if (_decoration.backgroundColor != null || _decoration.boxShadow != null) {
+ if (_decoration.backgroundColor != null || _decoration.boxShadow != null ||
+ _deocration.boxGradient != null) {
Rect rect = new Rect.fromLTRB(0.0, 0.0, size.width, size.height);
if (_decoration.borderRadius == null)
canvas.drawRect(rect, _backgroundPaint);
« sky/examples/raw/shadowed_box.dart ('K') | « sky/examples/raw/shadowed_box.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698