| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library barback.asset_node; | 5 library barback.asset_node; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset.dart'; | 9 import 'asset.dart'; |
| 10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 /// It's an error to mark an already-available node as available. It should be | 185 /// It's an error to mark an already-available node as available. It should be |
| 186 /// marked as dirty first. | 186 /// marked as dirty first. |
| 187 void setAvailable(Asset asset) { | 187 void setAvailable(Asset asset) { |
| 188 assert(asset.id == node.id); | 188 assert(asset.id == node.id); |
| 189 assert(node._state != AssetState.REMOVED); | 189 assert(node._state != AssetState.REMOVED); |
| 190 assert(node._state != AssetState.AVAILABLE); | 190 assert(node._state != AssetState.AVAILABLE); |
| 191 node._state = AssetState.AVAILABLE; | 191 node._state = AssetState.AVAILABLE; |
| 192 node._asset = asset; | 192 node._asset = asset; |
| 193 node._stateChangeController.add(AssetState.AVAILABLE); | 193 node._stateChangeController.add(AssetState.AVAILABLE); |
| 194 } | 194 } |
| 195 | |
| 196 /// Sets the origin of [node] to [origin] and the transform to | |
| 197 /// `origin.transform`. | |
| 198 void setOrigin(AssetNode origin) { | |
| 199 node._origin = origin; | |
| 200 node._transform = origin.transform; | |
| 201 } | |
| 202 } | 195 } |
| 203 | 196 |
| 204 // TODO(nweiz): add an error state. | 197 // TODO(nweiz): add an error state. |
| 205 /// An enum of states that an [AssetNode] can be in. | 198 /// An enum of states that an [AssetNode] can be in. |
| 206 class AssetState { | 199 class AssetState { |
| 207 /// The node has a concrete asset loaded, available, and up-to-date. The asset | 200 /// The node has a concrete asset loaded, available, and up-to-date. The asset |
| 208 /// is accessible via [AssetNode.asset]. An asset can only be marked available | 201 /// is accessible via [AssetNode.asset]. An asset can only be marked available |
| 209 /// again from the [AssetState.DIRTY] state. | 202 /// again from the [AssetState.DIRTY] state. |
| 210 static final AVAILABLE = const AssetState._("available"); | 203 static final AVAILABLE = const AssetState._("available"); |
| 211 | 204 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 225 | 218 |
| 226 /// Whether this state is [AssetState.DIRTY]. | 219 /// Whether this state is [AssetState.DIRTY]. |
| 227 bool get isDirty => this == AssetState.DIRTY; | 220 bool get isDirty => this == AssetState.DIRTY; |
| 228 | 221 |
| 229 final String name; | 222 final String name; |
| 230 | 223 |
| 231 const AssetState._(this.name); | 224 const AssetState._(this.name); |
| 232 | 225 |
| 233 String toString() => name; | 226 String toString() => name; |
| 234 } | 227 } |
| OLD | NEW |