summaryrefslogtreecommitdiffstats
path: root/ui/gfx/point_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Move geometric types to a separate, more lightweight target.ben@chromium.org2013-12-181-174/+0
| | | | | | | | | R=sky@chromium.org http://crbug.com/327489 Review URL: https://codereview.chromium.org/109433013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241649 0039d316-1c4b-4281-b951-d872f2087c98
* Rename ClampToMin and ClampToMaxvollick@chromium.org2013-05-301-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | I find these function names confusing. I have to stop and read the code each time I try to use them to figure out what they're going to do. Part of the confusion is that ClampToMin sets the components to the _maximum_ of the two sizes/vectors. It's also not clear from the function name which of the two objects is acting as the 'Min'. This is mitigated by the parameter names and local variables passed to the function, but it would be nice if the name of the function itself made this clear. a.ClampToLowerBound(b) makes it clear both that b is acting as the lower bound and how and when a is going to be altered. Other names I've considered (for ClampToMin -- the suggestions for ClampToMax are analagous): ClampIfSmallerThan(other) SetComponentsToMax(other) Union(other) (for sizes) R=danakj,sky BUG=None Review URL: https://chromiumcodereview.appspot.com/14367021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203017 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Add methods to clamp Sizes, Points, and Vectors from above or below.danakj@chromium.org2012-11-101-0/+52
| | | | | | | | | | | | | | | | | | Tests: PointTest.Clamp PointTest.ClampF SizeTest.Clamp SizeTest.ClampF Vector2dTest.Clamp Vector2dTest.ClampF Vector3dTest.ClampF R=sky,enne BUG=147395 Review URL: https://codereview.chromium.org/11361186 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167014 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Prefer +/- operators to apply offsets.danakj@chromium.org2012-11-101-1/+0
| | | | | | | | | | | | | | | | | Adds +/- operators to gfx::Rect that are applied to its origin Point. Removes gfx::Point method a.OffsetFrom(b) in favor of (b - a). Begin use +/- instead of Offset() in ui/gfx/ and cc/ New tests: ui_unittests:RectTest.Offset R=pkasting,enne BUG=158416 Review URL: https://codereview.chromium.org/11293194 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167012 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Make gfx::Point::Scale() mutate the class, similar to gfx::Rect.danakj@chromium.org2012-11-091-0/+22
| | | | | | | | | | | | | | We add gfx::ScalePoint() as a non-mutating version of the Scale method. Tests: ui_unittests:PointTest.Scale R=sky BUG=160158 Review URL: https://codereview.chromium.org/11369144 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166979 0039d316-1c4b-4281-b951-d872f2087c98
* ui/gfx: Put unittests back into gfx namespace.tfarina@chromium.org2012-11-021-70/+52
| | | | | | | | | TEST=ui_unittests R=sky@chromium.org Review URL: https://codereview.chromium.org/11360043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165761 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Add gfx::ToRoundedPoint() method.danakj@chromium.org2012-10-311-0/+36
| | | | | | | | | | | | | | | This acts like ToRoundedSize, it returns a Point from a PointF, where each component is rounded to the nearest integer. Tests: ui_unittests:PointTest.ToRoundedPoint BUG=147395 R=sky Review URL: https://codereview.chromium.org/11369013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165261 0039d316-1c4b-4281-b951-d872f2087c98
* Add Vector2d classes that represent offsets, instead of using Point.danakj@chromium.org2012-10-311-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously Point served two purposes, to be a position in 2d space, and also an offset from the origin. This introduces a Vector2d class to represent an offset, allowing typesafety checks for geometric operations. The following are now the case: Point +/- Vector = Point - A point plus/minus an offset gives you a point at a position offset by the vector. Vector +/- Vector = Vector - Two offsets can be added together to make a new offset. Point - Point = Vector - Subtracting one point from another gives you the offset between the two points. We add some new methods to perform these operations: Rect::OffsetFromOrigin() gives the offset between the position of the rect and the origin. Point::OffsetFromOrigin() gives the offset between the point and the origin. PointAtOffsetFromOrigin(Vector2d) converts a Vector2d to a Point at the given offset away from the origin. Rect::Offset(), Point::Add(), and Point::Subtract() now receive a Vector2d instead of a point. BUG=147395 R=sky Review URL: https://codereview.chromium.org/11269022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165198 0039d316-1c4b-4281-b951-d872f2087c98
* ui: Build fix for gcc 4.6.3, default version of ubuntu 12.04.tfarina@chromium.org2012-10-181-7/+8
| | | | | | | | | | | | | | | | EXPECT_EQ(true, ...) or EXPECT_EQ(false, ...) cause errors like: $ converting 'true' to pointer type for argument 1 of '...'. Switch us to use EXPECT_TRUE/EXPECT_FALSE where appropriate. This came from https://codereview.chromium.org/11141010/ (r161762). TBR=sky@chromium.org Review URL: https://codereview.chromium.org/11139009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162727 0039d316-1c4b-4281-b951-d872f2087c98
* Add IsOrigin() method to gfx::Point classes.danakj@chromium.org2012-10-121-0/+18
| | | | | | | | | | | This method returns true if the point contains only zeros, and false otherwise. BUG=147395 R=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/11093034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161463 0039d316-1c4b-4281-b951-d872f2087c98
* Implicit coversion operators from integer geometry types to floating point.danakj@chromium.org2012-10-111-0/+31
This change allows you to call a function that expects a floating point object with an integer object and have things just work. The addition operator for Points is outside the Point classes so it can add/subtract integer and float points together implicitly. Tested to verify compilation with: ui_unittests:RectTest.ToRectF ui_unittests:SizeTest.ToSizeF ui_unittests:PointTest.ToPointF BUG=147395 R=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/11028127 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161415 0039d316-1c4b-4281-b951-d872f2087c98