mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Formatting.
This commit is contained in:
parent
bf0197d516
commit
36091e459f
@ -11,61 +11,61 @@ Entity::Entity() = default;
|
||||
|
||||
Entity::~Entity() = default;
|
||||
|
||||
geom::Rect Entity::frame() const {
|
||||
geom::Point origin(_position.x - (_bounds.size.width * _anchorPoint.x),
|
||||
_position.y - (_bounds.size.height * _anchorPoint.y));
|
||||
geom::Rect Entity::GetFrame() const {
|
||||
geom::Point origin(position_.x - (bounds_.size.width * anchor_point_.x),
|
||||
position_.y - (bounds_.size.height * anchor_point_.y));
|
||||
|
||||
return geom::Rect(origin, _bounds.size);
|
||||
return geom::Rect(origin, bounds_.size);
|
||||
}
|
||||
|
||||
void Entity::setFrame(const geom::Rect& frame) {
|
||||
setBounds(geom::Rect(_bounds.origin, frame.size));
|
||||
setPosition(
|
||||
geom::Point(frame.origin.x + (_anchorPoint.x * frame.size.width),
|
||||
frame.origin.y + (_anchorPoint.y * frame.size.height)));
|
||||
void Entity::SetFrame(const geom::Rect& frame) {
|
||||
SetBounds(geom::Rect(bounds_.origin, frame.size));
|
||||
SetPosition(
|
||||
geom::Point(frame.origin.x + (anchor_point_.x * frame.size.width),
|
||||
frame.origin.y + (anchor_point_.y * frame.size.height)));
|
||||
}
|
||||
|
||||
const geom::Rect& Entity::bounds() const {
|
||||
return _bounds;
|
||||
const geom::Rect& Entity::GetBounds() const {
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
void Entity::setBounds(const geom::Rect& bounds) {
|
||||
_bounds = bounds;
|
||||
void Entity::SetBounds(const geom::Rect& bounds) {
|
||||
bounds_ = bounds;
|
||||
}
|
||||
|
||||
const geom::Point& Entity::position() const {
|
||||
return _position;
|
||||
const geom::Point& Entity::GetPosition() const {
|
||||
return position_;
|
||||
}
|
||||
|
||||
void Entity::setPosition(const geom::Point& position) {
|
||||
_position = position;
|
||||
void Entity::SetPosition(const geom::Point& position) {
|
||||
position_ = position;
|
||||
}
|
||||
|
||||
const geom::Point& Entity::anchorPoint() const {
|
||||
return _anchorPoint;
|
||||
const geom::Point& Entity::GetAnchorPoint() const {
|
||||
return anchor_point_;
|
||||
}
|
||||
|
||||
void Entity::setAnchorPoint(const geom::Point& anchorPoint) {
|
||||
_anchorPoint = anchorPoint;
|
||||
void Entity::SetAnchorPoint(const geom::Point& anchorPoint) {
|
||||
anchor_point_ = anchorPoint;
|
||||
}
|
||||
|
||||
const geom::Matrix& Entity::transformation() const {
|
||||
return _transformation;
|
||||
const geom::Matrix& Entity::GetTransformation() const {
|
||||
return transformation_;
|
||||
}
|
||||
|
||||
void Entity::setTransformation(const geom::Matrix& transformation) {
|
||||
_transformation = transformation;
|
||||
void Entity::SetTransformation(const geom::Matrix& transformation) {
|
||||
transformation_ = transformation;
|
||||
}
|
||||
|
||||
geom::Matrix Entity::modelMatrix() const {
|
||||
geom::Matrix Entity::GetModelMatrix() const {
|
||||
/*
|
||||
* The translation accounts for the offset in the origin of the bounds
|
||||
* of the entity and its position about its anchor point.
|
||||
*/
|
||||
auto translation = geom::Matrix::Translation(
|
||||
{-_bounds.origin.x + _position.x - (_bounds.size.width * _anchorPoint.x),
|
||||
-_bounds.origin.y + _position.y -
|
||||
(_bounds.size.height * _anchorPoint.y)});
|
||||
{-bounds_.origin.x + position_.x - (bounds_.size.width * anchor_point_.x),
|
||||
-bounds_.origin.y + position_.y -
|
||||
(bounds_.size.height * anchor_point_.y)});
|
||||
|
||||
/*
|
||||
* The transformation of an entity is applied about is anchor point. However,
|
||||
@ -73,56 +73,56 @@ geom::Matrix Entity::modelMatrix() const {
|
||||
* matrix adjustment and also the two matrix multiplications.
|
||||
*/
|
||||
|
||||
if (_transformation.isIdentity()) {
|
||||
if (transformation_.isIdentity()) {
|
||||
return translation;
|
||||
}
|
||||
|
||||
auto anchorAdjustment =
|
||||
geom::Matrix::Translation({-_anchorPoint.x * _bounds.size.width,
|
||||
-_anchorPoint.y * _bounds.size.height});
|
||||
geom::Matrix::Translation({-anchor_point_.x * bounds_.size.width,
|
||||
-anchor_point_.y * bounds_.size.height});
|
||||
|
||||
return translation * anchorAdjustment.invert() * _transformation *
|
||||
return translation * anchorAdjustment.invert() * transformation_ *
|
||||
anchorAdjustment;
|
||||
}
|
||||
|
||||
const Color& Entity::backgroundColor() const {
|
||||
return _backgroundColor;
|
||||
const Color& Entity::GetBackgroundColor() const {
|
||||
return background_color_;
|
||||
}
|
||||
|
||||
void Entity::setBackgroundColor(const Color& backgroundColor) {
|
||||
_backgroundColor = backgroundColor;
|
||||
void Entity::SetBackgroundColor(const Color& backgroundColor) {
|
||||
background_color_ = backgroundColor;
|
||||
}
|
||||
|
||||
const double& Entity::opacity() const {
|
||||
return _opacity;
|
||||
const double& Entity::GetOpacity() const {
|
||||
return opacity_;
|
||||
}
|
||||
|
||||
void Entity::setOpacity(double opacity) {
|
||||
_opacity = opacity;
|
||||
void Entity::SetOpacity(double opacity) {
|
||||
opacity_ = opacity;
|
||||
}
|
||||
|
||||
const Color& Entity::strokeColor() const {
|
||||
return _strokeColor;
|
||||
const Color& Entity::GetStrokeColor() const {
|
||||
return stroke_color_;
|
||||
}
|
||||
|
||||
void Entity::setStrokeColor(const Color& strokeColor) {
|
||||
_strokeColor = strokeColor;
|
||||
void Entity::SetStrokeColor(const Color& strokeColor) {
|
||||
stroke_color_ = strokeColor;
|
||||
}
|
||||
|
||||
double Entity::strokeSize() const {
|
||||
return _strokeSize;
|
||||
double Entity::GetStrokeSize() const {
|
||||
return stroke_size_;
|
||||
}
|
||||
|
||||
void Entity::setStrokeSize(double strokeSize) {
|
||||
_strokeSize = strokeSize;
|
||||
void Entity::SetStrokeSize(double strokeSize) {
|
||||
stroke_size_ = strokeSize;
|
||||
}
|
||||
|
||||
const geom::Path& Entity::path() const {
|
||||
return _path;
|
||||
const geom::Path& Entity::GetPath() const {
|
||||
return path_;
|
||||
}
|
||||
|
||||
void Entity::setPath(geom::Path path) {
|
||||
_path = std::move(path);
|
||||
void Entity::SetPath(geom::Path path) {
|
||||
path_ = std::move(path);
|
||||
}
|
||||
|
||||
} // namespace entity
|
||||
|
||||
@ -26,14 +26,14 @@ class Entity {
|
||||
*
|
||||
* @return the frame of the entity
|
||||
*/
|
||||
geom::Rect frame() const;
|
||||
geom::Rect GetFrame() const;
|
||||
|
||||
/**
|
||||
* Set the frame of the entity
|
||||
*
|
||||
* @param frame the new frame
|
||||
*/
|
||||
void setFrame(const geom::Rect& frame);
|
||||
void SetFrame(const geom::Rect& frame);
|
||||
|
||||
/**
|
||||
* The bounds specifies the origin and size of the entity in its own
|
||||
@ -41,14 +41,14 @@ class Entity {
|
||||
*
|
||||
* @return the bounds of the entity
|
||||
*/
|
||||
const geom::Rect& bounds() const;
|
||||
const geom::Rect& GetBounds() const;
|
||||
|
||||
/**
|
||||
* Set the bounds of the entity
|
||||
*
|
||||
* @param bounds the new bounds
|
||||
*/
|
||||
void setBounds(const geom::Rect& bounds);
|
||||
void SetBounds(const geom::Rect& bounds);
|
||||
|
||||
/**
|
||||
* The position specifies the coordinates of the anchor position of the
|
||||
@ -56,63 +56,63 @@ class Entity {
|
||||
*
|
||||
* @return the position of the entity
|
||||
*/
|
||||
const geom::Point& position() const;
|
||||
const geom::Point& GetPosition() const;
|
||||
|
||||
/**
|
||||
* Sets the position of the entity
|
||||
*
|
||||
* @param point the new position
|
||||
*/
|
||||
void setPosition(const geom::Point& point);
|
||||
void SetPosition(const geom::Point& point);
|
||||
|
||||
/**
|
||||
* The position of the anchor point within this node in unit space
|
||||
*
|
||||
* @return the anchor point
|
||||
*/
|
||||
const geom::Point& anchorPoint() const;
|
||||
const geom::Point& GetAnchorPoint() const;
|
||||
|
||||
/**
|
||||
* Sets the new anchor point of this node
|
||||
*
|
||||
* @param anchorPoint the new anchor point
|
||||
*/
|
||||
void setAnchorPoint(const geom::Point& anchorPoint);
|
||||
void SetAnchorPoint(const geom::Point& anchorPoint);
|
||||
|
||||
/**
|
||||
* The transformation that is applied to the entity about its anchor point
|
||||
*
|
||||
* @return the transformation applied to the node
|
||||
*/
|
||||
const geom::Matrix& transformation() const;
|
||||
const geom::Matrix& GetTransformation() const;
|
||||
|
||||
/**
|
||||
* Sets the transformation of the entity
|
||||
*
|
||||
* @param transformation the new transformation
|
||||
*/
|
||||
void setTransformation(const geom::Matrix& transformation);
|
||||
void SetTransformation(const geom::Matrix& transformation);
|
||||
|
||||
/**
|
||||
* The model matrix of the entity
|
||||
*
|
||||
* @return the view matrix
|
||||
*/
|
||||
geom::Matrix modelMatrix() const;
|
||||
geom::Matrix GetModelMatrix() const;
|
||||
|
||||
/**
|
||||
* The background color of the entity
|
||||
*
|
||||
* @return the background color
|
||||
*/
|
||||
const Color& backgroundColor() const;
|
||||
const Color& GetBackgroundColor() const;
|
||||
|
||||
/**
|
||||
* Set the new background color of the entity
|
||||
*
|
||||
* @param backgroundColor the new background color
|
||||
*/
|
||||
void setBackgroundColor(const Color& backgroundColor);
|
||||
void SetBackgroundColor(const Color& backgroundColor);
|
||||
|
||||
/**
|
||||
* The opacity of the entity. 0.0 is fully transparent and 1.0 is fully
|
||||
@ -120,38 +120,38 @@ class Entity {
|
||||
*
|
||||
* @return the opacity of the entity
|
||||
*/
|
||||
const double& opacity() const;
|
||||
const double& GetOpacity() const;
|
||||
|
||||
/**
|
||||
* Set the new opacity of the entity
|
||||
*
|
||||
* @param opacity the new opacity
|
||||
*/
|
||||
void setOpacity(double opacity);
|
||||
void SetOpacity(double opacity);
|
||||
|
||||
const Color& strokeColor() const;
|
||||
const Color& GetStrokeColor() const;
|
||||
|
||||
void setStrokeColor(const Color& strokeColor);
|
||||
void SetStrokeColor(const Color& strokeColor);
|
||||
|
||||
double strokeSize() const;
|
||||
double GetStrokeSize() const;
|
||||
|
||||
void setStrokeSize(double strokeSize);
|
||||
void SetStrokeSize(double strokeSize);
|
||||
|
||||
const geom::Path& path() const;
|
||||
const geom::Path& GetPath() const;
|
||||
|
||||
void setPath(geom::Path path);
|
||||
void SetPath(geom::Path path);
|
||||
|
||||
private:
|
||||
geom::Rect _bounds;
|
||||
geom::Point _position;
|
||||
geom::Point _anchorPoint = {0.5, 0.5};
|
||||
geom::Matrix _transformation;
|
||||
Color _backgroundColor;
|
||||
geom::Rect bounds_;
|
||||
geom::Point position_;
|
||||
geom::Point anchor_point_ = {0.5, 0.5};
|
||||
geom::Matrix transformation_;
|
||||
Color background_color_;
|
||||
|
||||
geom::Path _path;
|
||||
double _opacity = 1.0;
|
||||
Color _strokeColor = Color::Black();
|
||||
double _strokeSize = 1.0;
|
||||
geom::Path path_;
|
||||
double opacity_ = 1.0;
|
||||
Color stroke_color_ = Color::Black();
|
||||
double stroke_size_ = 1.0;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(Entity);
|
||||
};
|
||||
|
||||
@ -287,7 +287,7 @@ struct Matrix {
|
||||
static_assert(sizeof(struct Matrix) == sizeof(double) * 16,
|
||||
"The matrix must be of consistent size.");
|
||||
|
||||
static inline Vector4 operator*(const Vector4& v, const Matrix& m) {
|
||||
inline Vector4 operator*(const Vector4& v, const Matrix& m) {
|
||||
return Vector4(v.x * m.m[0] + v.y * m.m[4] + v.z * m.m[8] + v.w * m.m[12],
|
||||
v.x * m.m[1] + v.y * m.m[5] + v.z * m.m[9] + v.w * m.m[13],
|
||||
v.x * m.m[2] + v.y * m.m[6] + v.z * m.m[10] + v.w * m.m[14],
|
||||
|
||||
@ -29,17 +29,23 @@ struct Point {
|
||||
Point operator-() const { return {-x, -y}; }
|
||||
|
||||
Point operator+(const Point& p) const { return {x + p.x, y + p.y}; }
|
||||
|
||||
Point operator+(const Size& s) const { return {x + s.width, y + s.height}; }
|
||||
|
||||
Point operator-(const Point& p) const { return {x - p.x, y - p.y}; }
|
||||
|
||||
Point operator-(const Size& s) const { return {x - s.width, y - s.height}; }
|
||||
|
||||
Point operator*(double scale) const { return {x * scale, y * scale}; }
|
||||
|
||||
Point operator*(const Point& p) const { return {x * p.x, y * p.y}; }
|
||||
|
||||
Point operator*(const Size& s) const { return {x * s.width, y * s.height}; }
|
||||
|
||||
Point operator/(double d) const { return {x / d, y / d}; }
|
||||
|
||||
Point operator/(const Point& p) const { return {x / p.x, y / p.y}; }
|
||||
|
||||
Point operator/(const Size& s) const { return {x / s.width, y / s.height}; }
|
||||
|
||||
double distanceSquared(const Point& p) const;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user