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

Side by Side Diff: sky/sdk/lib/painting/box_painter.dart

Issue 1212343009: SkyDemo.apk should show thumbmails when offline (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « sky/sdk/example/demo_launcher/lib/main.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:async';
5 import 'dart:math' as math; 6 import 'dart:math' as math;
6 import 'dart:sky' as sky; 7 import 'dart:sky' as sky;
7 import 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path; 8 import 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path;
8 9
9 import '../base/lerp.dart'; 10 import '../base/lerp.dart';
10 import 'shadows.dart'; 11 import 'shadows.dart';
11 import 'package:sky/mojo/net/image_cache.dart' as image_cache; 12 import 'package:sky/mojo/net/image_cache.dart' as image_cache;
12 13
13 class BorderSide { 14 class BorderSide {
14 const BorderSide({ 15 const BorderSide({
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 enum BackgroundFit { fill, contain, cover, none, scaleDown } 134 enum BackgroundFit { fill, contain, cover, none, scaleDown }
134 135
135 enum BackgroundRepeat { repeat, repeatX, repeatY, noRepeat } 136 enum BackgroundRepeat { repeat, repeatX, repeatY, noRepeat }
136 137
137 // TODO(jackson): We should abstract this out into a separate class 138 // TODO(jackson): We should abstract this out into a separate class
138 // that handles the image caching and so forth, which has callbacks 139 // that handles the image caching and so forth, which has callbacks
139 // for "size changed" and "image changed". This would also enable us 140 // for "size changed" and "image changed". This would also enable us
140 // to do animated images. 141 // to do animated images.
141 142
142 class BackgroundImage { 143 class BackgroundImage {
143 final String src;
144 final BackgroundFit fit; 144 final BackgroundFit fit;
145 final BackgroundRepeat repeat; 145 final BackgroundRepeat repeat;
146 BackgroundImage({ 146 BackgroundImage({
147 this.src, 147 Future<sky.Image> image,
148 this.fit: BackgroundFit.scaleDown, 148 this.fit: BackgroundFit.scaleDown,
149 this.repeat: BackgroundRepeat.noRepeat 149 this.repeat: BackgroundRepeat.noRepeat
150 }) { 150 }) {
151 image_cache.load(src).then((image) { 151 image.then((resolvedImage) {
152 if (image == null) 152 if (resolvedImage == null)
153 return; 153 return;
154 _image = image; 154 _image = resolvedImage;
155 _size = new Size(image.width.toDouble(), image.height.toDouble()); 155 _size = new Size(resolvedImage.width.toDouble(), resolvedImage.height.toDo uble());
156 for (Function listener in _listeners) { 156 for (Function listener in _listeners) {
157 listener(); 157 listener();
158 } 158 }
159 }); 159 });
160 } 160 }
161 161
162 sky.Image _image; 162 sky.Image _image;
163 sky.Image get image => _image; 163 sky.Image get image => _image;
164 164
165 Size _size; 165 Size _size;
166 166
167 final List<Function> _listeners = new List<Function>(); 167 final List<Function> _listeners = new List<Function>();
168 168
169 void addChangeListener(Function listener) { 169 void addChangeListener(Function listener) {
170 _listeners.add(listener); 170 _listeners.add(listener);
171 } 171 }
172 172
173 void removeChangeListener(Function listener) { 173 void removeChangeListener(Function listener) {
174 _listeners.remove(listener); 174 _listeners.remove(listener);
175 } 175 }
176 176
177 String toString() => 'BackgroundImage($src, $fit, $repeat)'; 177 String toString() => 'BackgroundImage($fit, $repeat)';
178 } 178 }
179 179
180 enum Shape { rectangle, circle } 180 enum Shape { rectangle, circle }
181 181
182 // This must be immutable, because we won't notice when it changes 182 // This must be immutable, because we won't notice when it changes
183 class BoxDecoration { 183 class BoxDecoration {
184 const BoxDecoration({ 184 const BoxDecoration({
185 this.backgroundColor, // null = don't draw background color 185 this.backgroundColor, // null = don't draw background color
186 this.backgroundImage, // null = don't draw background image 186 this.backgroundImage, // null = don't draw background image
187 this.border, // null = don't draw border 187 this.border, // null = don't draw border
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 path.close(); 381 path.close();
382 canvas.drawPath(path, paint); 382 canvas.drawPath(path, paint);
383 } 383 }
384 384
385 void paint(sky.Canvas canvas, Rect rect) { 385 void paint(sky.Canvas canvas, Rect rect) {
386 _paintBackgroundColor(canvas, rect); 386 _paintBackgroundColor(canvas, rect);
387 _paintBackgroundImage(canvas, rect); 387 _paintBackgroundImage(canvas, rect);
388 _paintBorder(canvas, rect); 388 _paintBorder(canvas, rect);
389 } 389 }
390 } 390 }
OLDNEW
« no previous file with comments | « sky/sdk/example/demo_launcher/lib/main.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698