Add @override annotations to flutter framework

This commit is contained in:
Hixie
2016-03-14 13:31:43 -07:00
parent 9bc6d281fe
commit 797e27edd3
322 changed files with 2544 additions and 9 deletions

View File

@@ -47,6 +47,7 @@ abstract class ActionInterval extends Action {
/// The duration, in seconds, of the action.
///
/// double myTime = myAction.duration;
@override
double get duration => _duration;
double _duration;
@@ -58,6 +59,7 @@ abstract class ActionInterval extends Action {
bool _firstTick = true;
double _elapsed = 0.0;
@override
void step(double dt) {
if (_firstTick) {
_firstTick = false;
@@ -96,6 +98,7 @@ class ActionRepeat extends ActionInterval {
_duration = action.duration * numRepeats;
}
@override
void update(double t) {
int currentRepeat = math.min((t * numRepeats.toDouble()).toInt(), numRepeats - 1);
for (int i = math.max(_lastFinishedRepeat, 0); i < currentRepeat; i++) {
@@ -124,6 +127,7 @@ class ActionRepeatForever extends Action {
/// var myInifiniteLoop = new ActionRepeatForever(myAction);
ActionRepeatForever(this.action);
@override
void step(double dt) {
_elapsedInAction += dt;
while (_elapsedInAction > action.duration) {
@@ -176,6 +180,7 @@ class ActionSequence extends ActionInterval {
}
}
@override
void update(double t) {
if (t < _split) {
// Play first action
@@ -225,6 +230,7 @@ class ActionSequence extends ActionInterval {
action._finished = true;
}
@override
void _reset() {
super._reset();
_a._reset();
@@ -249,6 +255,7 @@ class ActionGroup extends ActionInterval {
}
}
@override
void update(double t) {
if (t >= 1.0) {
// Finish all unfinished actions
@@ -289,6 +296,7 @@ class ActionGroup extends ActionInterval {
}
}
@override
void _reset() {
for (Action action in _actions) {
action._reset();
@@ -307,9 +315,11 @@ class ActionDelay extends ActionInterval {
/// create custom instant actions, only the [fire] method should be overriden.
abstract class ActionInstant extends Action {
@override
void step(double dt) {
}
@override
void update(double t) {
fire();
_finished = true;
@@ -327,6 +337,7 @@ class ActionCallFunction extends ActionInstant {
/// var myAction = new ActionCallFunction(() { print("Hello!";) });
ActionCallFunction(this._function);
@override
void fire() {
_function();
}
@@ -341,6 +352,7 @@ class ActionRemoveNode extends ActionInstant {
/// var myAction = new ActionRemoveNode(myNode);
ActionRemoveNode(this._node);
@override
void fire() {
_node.removeFromParent();
}
@@ -423,6 +435,7 @@ class ActionTween extends ActionInterval {
}
}
@override
void update(double t) {
dynamic newVal;

View File

@@ -42,6 +42,7 @@ class ActionSpline extends ActionInterval {
double _dt;
@override
void update(double t) {
int p;

View File

@@ -48,10 +48,12 @@ class ConstraintRotationToMovement extends Constraint {
Point _lastPosition;
@override
void preUpdate(Node node, double dt) {
_lastPosition = node.position;
}
@override
void constrain(Node node, double dt) {
if (_lastPosition == null) return;
if (_lastPosition == node.position) return;
@@ -83,6 +85,7 @@ class ConstraintRotationToNode extends Constraint {
/// values are in the range 0.0 to 1.0
final double dampening;
@override
void constrain(Node node, double dt) {
Offset offset;
@@ -117,6 +120,7 @@ class ConstraintPositionToNode extends Constraint {
final Offset offset;
final double dampening;
@override
void constrain(Node node, double dt) {
Point targetPosition;

View File

@@ -89,6 +89,7 @@ class EffectLine extends Node {
TexturedLinePainter _painter;
double _offset = 0.0;
@override
void update(double dt) {
// Update scrolling position
if (animationMode == EffectLineAnimationMode.scroll) {
@@ -121,6 +122,7 @@ class EffectLine extends Node {
}
}
@override
void paint(Canvas canvas) {
if (points.length < 2) return;

View File

@@ -33,6 +33,7 @@ class Label extends Node {
TextPainter _painter;
double _width;
@override
void paint(Canvas canvas) {
if (_painter == null) {
_painter = new TextPainter(new TextSpan(style: _textStyle, text: _text));

View File

@@ -25,6 +25,7 @@ class Layer extends Node with SpritePaint {
..filterQuality = FilterQuality.low
..isAntiAlias = false;
@override
void _prePaint(Canvas canvas, Matrix4 matrix) {
super._prePaint(canvas, matrix);
@@ -32,6 +33,7 @@ class Layer extends Node with SpritePaint {
canvas.saveLayer(layerRect, _cachedPaint);
}
@override
void _postPaint(Canvas canvas, Matrix4 totalMatrix) {
canvas.restore();
super._postPaint(canvas, totalMatrix);

View File

@@ -38,6 +38,7 @@ class Node3D extends Node {
invalidateTransformMatrix();
}
@override
Matrix4 computeTransformMatrix() {
// Apply normal 2d transforms
Matrix4 matrix = super.computeTransformMatrix();

View File

@@ -49,6 +49,7 @@ class NodeWithSize extends Node {
}
}
@override
bool isPointInside (Point nodePoint) {
double minX = -size.width * pivot.x;

View File

@@ -196,6 +196,7 @@ class ParticleSystem extends Node {
if (colorSequence == null) colorSequence = new ColorSequence.fromStartAndEndColor(new Color(0xffffffff), new Color(0x00ffffff));
}
@override
void update(double dt) {
// TODO: Fix this (it's a temp fix for low framerates)
if (dt > 0.1) dt = 0.1;
@@ -359,6 +360,7 @@ class ParticleSystem extends Node {
_numEmittedParticles++;
}
@override
void paint(Canvas canvas) {
if (opacity == 0.0) return;

View File

@@ -16,6 +16,7 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
Canvas canvas;
@override
void drawSegment(Vector2 p1, Vector2 p2, box2d.Color3i color) {
Paint paint = new Paint()
..color = _toColor(color)
@@ -23,6 +24,7 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
canvas.drawLine(_toPoint(p1), _toPoint(p2), paint);
}
@override
void drawSolidPolygon(
List<Vector2> vertices,
int vertexCount,
@@ -40,6 +42,7 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
canvas.drawPath(path, paint);
}
@override
void drawCircle(Vector2 center, num radius, box2d.Color3i color, [Vector2 axis]) {
Paint paint = new Paint()
..color = _toColor(color)
@@ -49,6 +52,7 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
canvas.drawCircle(_toPoint(center), _scale(radius), paint);
}
@override
void drawSolidCircle(Vector2 center, num radius, Vector2 axis, box2d.Color3i color) {
Paint paint = new Paint()
..color = _toColor(color);
@@ -56,10 +60,12 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
canvas.drawCircle(_toPoint(center), _scale(radius), paint);
}
@override
void drawPoint(Vector2 point, num radiusOnScreen, box2d.Color3i color) {
drawSolidCircle(point, radiusOnScreen, null, color);
}
@override
void drawParticles(
List<Vector2> centers,
double radius,
@@ -69,6 +75,7 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
// TODO: Implement
}
@override
void drawParticlesWireframe(
List<Vector2> centers,
double radius,
@@ -78,11 +85,13 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
// TODO: Implement
}
@override
void drawTransform(box2d.Transform xf, box2d.Color3i color) {
drawCircle(xf.p, 0.1, color);
// TODO: Improve
}
@override
void drawStringXY(num x, num y, String s, box2d.Color3i color) {
// TODO: Implement
}

View File

@@ -9,36 +9,44 @@ part of flutter_sprites;
/// group.addChild(myNode);
class PhysicsGroup extends Node {
@override
void set scaleX(double scaleX) {
assert(false);
}
@override
void set scaleY(double scaleX) {
assert(false);
}
@override
void set skewX(double scaleX) {
assert(false);
}
@override
void set skewY(double scaleX) {
assert(false);
}
@override
void set physicsBody(PhysicsBody body) {
assert(false);
}
@override
void set position(Point position) {
super.position = position;
_invalidatePhysicsBodies(this);
}
@override
void set rotation(double rotation) {
super.rotation = rotation;
_invalidatePhysicsBodies(this);
}
@override
void set scale(double scale) {
super.scale = scale;
_invalidatePhysicsBodies(this);
@@ -57,6 +65,7 @@ class PhysicsGroup extends Node {
}
}
@override
void addChild(Node node) {
super.addChild(node);
@@ -80,6 +89,7 @@ class PhysicsGroup extends Node {
}
}
@override
void removeChild(Node node) {
super.removeChild(node);

View File

@@ -183,6 +183,7 @@ class PhysicsJointRevolute extends PhysicsJoint {
}
}
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
// Create Joint Definition
Vector2 vecAnchor = new Vector2(
@@ -288,6 +289,7 @@ class PhysicsJointPrismatic extends PhysicsJoint {
}
}
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.PrismaticJointDef b2Def = new box2d.PrismaticJointDef();
b2Def.initialize(bodyA._body, bodyB._body, bodyA._body.position, new Vector2(axis.dx, axis.dy));
@@ -318,6 +320,7 @@ class PhysicsJointWeld extends PhysicsJoint {
final double dampening;
final double frequency;
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.WeldJointDef b2Def = new box2d.WeldJointDef();
Vector2 middle = new Vector2(
@@ -369,6 +372,7 @@ class PhysicsJointPulley extends PhysicsJoint {
final Point anchorB;
final double ratio;
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.PulleyJointDef b2Def = new box2d.PulleyJointDef();
b2Def.initialize(
@@ -407,6 +411,7 @@ class PhysicsJointGear extends PhysicsJoint {
/// The ratio of the rotation for bodyA relative bodyB.
final double ratio;
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.GearJointDef b2Def = new box2d.GearJointDef();
b2Def.bodyA = bodyA._body;
@@ -452,6 +457,7 @@ class PhysicsJointDistance extends PhysicsJoint {
/// Dampening frequency.
final double frequency;
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.DistanceJointDef b2Def = new box2d.DistanceJointDef();
b2Def.initialize(
@@ -498,6 +504,7 @@ class PhysicsJointWheel extends PhysicsJoint {
/// Dampening frequency.
final double frequency;
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.WheelJointDef b2Def = new box2d.WheelJointDef();
b2Def.initialize(
@@ -533,6 +540,7 @@ class PhysicsJointFriction extends PhysicsJoint {
final double maxForce;
final double maxTorque;
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.FrictionJointDef b2Def = new box2d.FrictionJointDef();
b2Def.initialize(
@@ -565,6 +573,7 @@ class PhysicsJointConstantVolume extends PhysicsJoint {
final double dampening;
final double frequency;
@override
box2d.Joint _createB2Joint(PhysicsWorld physicsNode) {
box2d.ConstantVolumeJointDef b2Def = new box2d.ConstantVolumeJointDef();
for (PhysicsBody body in bodies) {

View File

@@ -30,6 +30,7 @@ class PhysicsShapeCircle extends PhysicsShape {
final Point point;
final double radius;
@override
box2d.Shape _createB2Shape(PhysicsWorld node, double scale) {
box2d.CircleShape shape = new box2d.CircleShape();
shape.p.x = scale * point.x / node.b2WorldToNodeConversionFactor;
@@ -52,6 +53,7 @@ class PhysicsShapePolygon extends PhysicsShape {
final List<Point> points;
@override
box2d.Shape _createB2Shape(PhysicsWorld node, double scale) {
List<Vector2> vectors = <Vector2>[];
for (Point point in points) {
@@ -84,6 +86,7 @@ class PhysicsShapeBox extends PhysicsShape {
final Point center;
final double rotation;
@override
box2d.Shape _createB2Shape(PhysicsWorld node, double scale) {
box2d.PolygonShape shape = new box2d.PolygonShape();
shape.setAsBox(
@@ -114,6 +117,7 @@ class PhysicsShapeChain extends PhysicsShape {
final List<Point> points;
final bool loop;
@override
box2d.Shape _createB2Shape(PhysicsWorld node, double scale) {
List<Vector2> vectors = <Vector2>[];
for (Point point in points) {
@@ -145,6 +149,7 @@ class PhysicsShapeEdge extends PhysicsShape {
final Point pointA;
final Point pointB;
@override
box2d.Shape _createB2Shape(PhysicsWorld node, double scale) {
box2d.EdgeShape shape = new box2d.EdgeShape();
shape.set(
@@ -172,10 +177,12 @@ class PhysicsShapeGroup extends PhysicsShape {
final List<PhysicsShape> shapes;
@override
box2d.Shape _createB2Shape(PhysicsWorld node, double scale) {
return null;
}
@override
void _invalidate() {
for (PhysicsShape shape in shapes) {
shape._invalidate();

View File

@@ -229,6 +229,7 @@ class PhysicsWorld extends Node {
}
}
@override
void addChild(Node node) {
super.addChild(node);
if (node.physicsBody != null) {
@@ -236,6 +237,7 @@ class PhysicsWorld extends Node {
}
}
@override
void removeChild(Node node) {
super.removeChild(node);
if (node.physicsBody != null) {
@@ -267,6 +269,7 @@ class PhysicsWorld extends Node {
_contactHandler.addContactCallback(callback, tagA, tagB, type);
}
@override
void paint(Canvas canvas) {
if (drawDebug) {
_debugDrawTransform = new Matrix4.fromFloat64List(canvas.getTotalMatrix());
@@ -423,17 +426,22 @@ class _ContactHandler extends box2d.ContactListener {
}
}
@override
void beginContact(box2d.Contact contact) {
handleCallback(PhysicsContactType.begin, contact, null, null);
}
@override
void endContact(box2d.Contact contact) {
handleCallback(PhysicsContactType.end, contact, null, null);
}
@override
void preSolve(box2d.Contact contact, box2d.Manifold oldManifold) {
handleCallback(PhysicsContactType.preSolve, contact, oldManifold, null);
}
@override
void postSolve(box2d.Contact contact, box2d.ContactImpulse impulse) {
handleCallback(PhysicsContactType.postSolve, contact, null, impulse);
}

View File

@@ -44,6 +44,7 @@ class Sprite extends NodeWithSize with SpritePaint {
pivot = new Point(0.5, 0.5);
}
@override
void paint(Canvas canvas) {
// Account for pivot point
applyTransformForPivot(canvas);

View File

@@ -57,6 +57,7 @@ class SpriteBox extends RenderBox {
}
}
@override
void attach() {
super.attach();
_scheduleTick();
@@ -138,6 +139,7 @@ class SpriteBox extends RenderBox {
/// var rootNode = mySpriteBox.rootNode;
NodeWithSize get rootNode => _rootNode;
@override
void performLayout() {
size = constraints.biggest;
_invalidateTransformMatrix();
@@ -189,6 +191,7 @@ class SpriteBox extends RenderBox {
}
}
@override
void handleEvent(PointerEvent event, _SpriteBoxHitTestEntry entry) {
if (!attached)
return;
@@ -238,6 +241,7 @@ class SpriteBox extends RenderBox {
}
}
@override
bool hitTest(HitTestResult result, { Point position }) {
result.add(new _SpriteBoxHitTestEntry(this, position));
return true;
@@ -333,6 +337,7 @@ class SpriteBox extends RenderBox {
_rootNode._invalidateToBoxTransformMatrix();
}
@override
void paint(PaintingContext context, Offset offset) {
final Canvas canvas = context.canvas;
canvas.save();

View File

@@ -24,8 +24,10 @@ class SpriteWidget extends SingleChildRenderObjectWidget {
/// var mySpriteWidget = new SpriteWidget(mySpriteTree, SpriteBoxTransformMode.fixedHeight);
SpriteWidget(this.rootNode, [this.transformMode = SpriteBoxTransformMode.letterbox]);
@override
SpriteBox createRenderObject(BuildContext context) => new SpriteBox(rootNode, transformMode);
@override
void updateRenderObject(BuildContext context, SpriteBox renderObject) {
renderObject
..rootNode = rootNode

View File

@@ -7,6 +7,7 @@ class TexturedLine extends Node {
TexturedLinePainter painter;
@override
void paint(Canvas canvas) {
painter.paint(canvas);
}

View File

@@ -30,6 +30,7 @@ class VirtualJoystick extends NodeWithSize {
Paint _paintHandle;
Paint _paintControl;
@override
bool handleEvent(SpriteBoxEvent event) {
if (event.type == PointerDownEvent) {
_pointerDownAt = event.boxPosition;
@@ -54,6 +55,7 @@ class VirtualJoystick extends NodeWithSize {
return true;
}
@override
void paint(Canvas canvas) {
applyTransformForPivot(canvas);
canvas.drawCircle(_handlePos, 25.0, _paintHandle);