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

Unified Diff: sky/examples/lib/solid_color_box.dart

Issue 1160013004: Implement RenderImage and Image for Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Implement code review feedback from Adam and improve demo Created 5 years, 7 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
Index: sky/examples/lib/solid_color_box.dart
diff --git a/sky/examples/lib/solid_color_box.dart b/sky/examples/lib/solid_color_box.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a3197a52375e39510f2274df0d0309930ee25c8a
--- /dev/null
+++ b/sky/examples/lib/solid_color_box.dart
@@ -0,0 +1,30 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'dart:sky';
+import 'package:sky/framework/rendering/box.dart';
+
+class RenderSolidColorBox extends RenderDecoratedBox {
+ final Size desiredSize;
+ final int backgroundColor;
+
+ RenderSolidColorBox(int backgroundColor, { this.desiredSize: const Size.infinite() })
+ : backgroundColor = backgroundColor,
+ super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
+
+ Size getIntrinsicDimensions(BoxConstraints constraints) {
+ return constraints.constrain(desiredSize);
+ }
+
+ void performLayout() {
+ size = constraints.constrain(desiredSize);
+ }
+
+ void handlePointer(PointerEvent event) {
+ if (event.type == 'pointerdown')
+ decoration = new BoxDecoration(backgroundColor: 0xFFFF0000);
+ else if (event.type == 'pointerup')
+ decoration = new BoxDecoration(backgroundColor: backgroundColor);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698