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

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: rebase again 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
« no previous file with comments | « sky/examples/fn2/container.dart ('k') | sky/examples/raw/interactive_flex.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4608f4b6b334d766e8f026c92fa315e946ca7dc0
--- /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 Color backgroundColor;
+
+ RenderSolidColorBox(Color 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: const Color(0xFFFF0000));
+ else if (event.type == 'pointerup')
+ decoration = new BoxDecoration(backgroundColor: backgroundColor);
+ }
+}
« no previous file with comments | « sky/examples/fn2/container.dart ('k') | sky/examples/raw/interactive_flex.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698