12 Commits

Author SHA1 Message Date
Jeff Verkoeyen
9ecefd04e7 Delete deprecated math functions.
PiperOrigin-RevId: 404810846
2021-10-21 09:23:57 -07:00
Wenyu Zhang
46454f9f4b
[Math] Add MDCEdgeInsetsEqualToEdgeInsets to compare two UIEdgeInsets. (#7804)
Created to prepare for a fix for https://github.com/material-components/material-components-ios/issues/7752.

`UIEdgeInsetsEqualToEdgeInsets` directly compares `CGFloat` number within two . The `MDCEdgeInsetsEqualToEdgeInsets` added in this PR compares UIEdgeInsets using `MDCCGFloatEqual` to take epsilon into consideration.
2019-07-08 12:54:06 -04:00
Robert Moore
800188a649
{clang-format} Format the components. (#6347)
This is a follow-up to https://github.com/material-components/material-components-ios/pull/6027

```
find components \( -name "*.h" -or -name "*.m" \) | xargs clang-format -i
```
2019-01-23 11:08:43 -05:00
Robert Moore
03f3351ad5
Global replace of single-precision floats with CGFloat casts. (#5718)
Replacing all non-integral, single-precision floating point literals with double-precision values explicitly cast to CGFloat.  For example, `0.1f` should become `(CGFloat)0.1`.

Regex used:
```
([0-9]*\.)([0-9]*?)([1-9]+)([0-9]*?)[fF]
```

PiperOrigin-RevId: 220683126
2018-11-12 10:50:01 -05:00
Robert Moore
74a27253e8
Global replace of integral single-precision literals with integer literals. (#5709)
Global replace of integral single-precision literals with integer literals.

Regular expression used:
```perl
/[^\w]([0-9]+)\.[0]*[fF]/$1/
```
2018-11-08 14:02:04 -05:00
featherless
2181084272
[automated] Standardize our open source license stanza to what Xcode generates. (#4985)
Removes the need to copy-paste stanzas from other files anymore as we'll rely on #4478 to generate the correct stanza for us instead.

This was an automated change generated by running a find-and-replace regular expression:

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at

 http://www\.apache\.org/licenses/LICENSE-2\.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
/\*
Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.

Licensed under the Apache License, Version 2\.0 \(the "License"\);
you may not use this file except in compliance with the License\.
You may obtain a copy of the License at

http://www\.apache\.org/licenses/LICENSE-2\.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
See the License for the specific language governing permissions and
limitations under the License\.
\*/
```

```
/\*
 Copyright ([0-9]+)-present the Material Components for iOS authors\. All Rights Reserved\.
 Licensed under the Apache License, Version 2\.0 \(the "License"\);
 you may not use this file except in compliance with the License\.
 You may obtain a copy of the License at
 http://www\.apache\.org/licenses/LICENSE-2\.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
 See the License for the specific language governing permissions and
 limitations under the License\.
 \*/
```

```
// Copyright $1-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
```
2018-08-31 12:13:07 -04:00
Wenyu Zhang
7d33f7597e
[Math] added MDCCeilScaled and MDCFloorScaled (#1917) (#4867)
closes #1917
2018-08-23 12:32:55 -04:00
Robert Moore
04ca713388
[Math] Fix CGFloat errors in tests. (#4858)
An internal build failed (once) when compiling the Math tests because
double-precision floating point
values were being implicitly cast to single-precision. Marking each of these
as either single-precision float or CGFloat (where convenient). Except for the
tests that measure rounding errors, single- and double-precision isn't
important for the test outputs.

Sample error:

material_components_ios/components/private/Math/tests/unit/MDCMathTests.m:33:38: error: implicit conversion loses floating-point precision: 'double' to 'CGFloat' (aka 'float') [-Werror,-Wconversion]
  CGRect misalignedRect = CGRectMake(0.45, 0.78, 1.01, 5.98);
                          ~~~~~~~~~~ ^~~~
2018-08-21 09:10:27 -04:00
Robert Moore
65bf96dd7c [Math] MDCRectAlignToScale treats scale 0 as 1 (#2045)
Rather than potentially returning a CGRectNull and causing UIKit crashes
if it's assigned to a view's frame or bounds, treat a scale of 0 as a
scale of 1.

Closes #2044
2017-09-27 20:28:37 +09:00
Robert Moore
4fd3a41963 [Math] Round CGPoint and align UIView centers (#2042)
Although it is possible to currently align a CGRect (frame) to a
pixel-aligned bounding rectangle, in some cases manipulating the frame
is neither possible nor desirable (such as when the transform is not the
identity).  Adding two new methods to support rounding a CGPoint to a
pixel and aligning the center point of a UIVIew given its bounds.
2017-09-27 01:54:56 +09:00
Robert Moore
2a65ea5809 [Math] Adding more unit tests for rect alignment (#1751)
Adding unit tests for a scale of zero and CGRectNull inputs.

References #1723
2017-08-08 12:03:02 -04:00
Robert Moore
e03ad370c6 [Math] Align frames to pixel boundaries (#1730)
Adding a new function to realign a CGRect (frame) to pixel boundaries
based on the screen scale. After a review of the catalog, I'm updating
the areas where I found misaligned frames.

Closes #1723
2017-08-07 16:46:32 -04:00