PureLayout+Internal.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // PureLayout+Internal.h
  3. // https://github.com/PureLayout/PureLayout
  4. //
  5. // Copyright (c) 2014-2015 Tyler Fox
  6. //
  7. // This code is distributed under the terms and conditions of the MIT license.
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining a copy
  10. // of this software and associated documentation files (the "Software"), to
  11. // deal in the Software without restriction, including without limitation the
  12. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  13. // sell copies of the Software, and to permit persons to whom the Software is
  14. // furnished to do so, subject to the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be included in
  17. // all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  25. // IN THE SOFTWARE.
  26. //
  27. #import "PureLayoutDefines.h"
  28. // Using generics with NSMutableArray is so common in the internal implementation of PureLayout that it gets a dedicated preprocessor macro for better readability.
  29. #define PL__NSMutableArray_of(type) PL__GENERICS(NSMutableArray, type)
  30. PL__ASSUME_NONNULL_BEGIN
  31. /** A constant that represents the smallest valid positive value for the multiplier of a constraint,
  32. since a value of 0 will cause the second item to be lost in the internal auto layout engine. */
  33. static const CGFloat kMULTIPLIER_MIN_VALUE = (CGFloat)0.00001; // very small floating point numbers (e.g. CGFLOAT_MIN) can cause problems
  34. /**
  35. A category that exposes the internal (private) helper methods of the ALView+PureLayout category.
  36. */
  37. @interface ALView (PureLayoutInternal)
  38. - (void)al_addConstraint:(NSLayoutConstraint *)constraint;
  39. - (ALView *)al_commonSuperviewWithView:(ALView *)otherView;
  40. - (NSLayoutConstraint *)al_alignAttribute:(ALAttribute)attribute toView:(ALView *)otherView forAxis:(ALAxis)axis;
  41. @end
  42. /**
  43. A category that exposes the internal (private) helper methods of the NSArray+PureLayout category.
  44. */
  45. @interface NSArray (PureLayoutInternal)
  46. - (ALView *)al_commonSuperviewOfViews;
  47. - (BOOL)al_containsMinimumNumberOfViews:(NSUInteger)minimumNumberOfViews;
  48. - (PL__NSArray_of(ALView *) *)al_copyViewsOnly;
  49. @end
  50. /**
  51. A category that exposes the internal (private) helper methods of the NSLayoutConstraint+PureLayout category.
  52. */
  53. @interface NSLayoutConstraint (PureLayoutInternal)
  54. + (BOOL)al_preventAutomaticConstraintInstallation;
  55. + (PL__NSMutableArray_of(NSLayoutConstraint *) *)al_currentArrayOfCreatedConstraints;
  56. + (BOOL)al_isExecutingPriorityConstraintsBlock;
  57. + (ALLayoutPriority)al_currentGlobalConstraintPriority;
  58. #if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
  59. + (nullable NSString *)al_currentGlobalConstraintIdentifier;
  60. #endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
  61. + (void)al_applyGlobalStateToConstraint:(NSLayoutConstraint *)constraint;
  62. + (NSLayoutAttribute)al_layoutAttributeForAttribute:(ALAttribute)attribute;
  63. + (ALLayoutConstraintAxis)al_constraintAxisForAxis:(ALAxis)axis;
  64. #if PL__PureLayout_MinBaseSDK_iOS_8_0
  65. + (ALMargin)al_marginForEdge:(ALEdge)edge;
  66. + (ALMarginAxis)al_marginAxisForAxis:(ALAxis)axis;
  67. #endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
  68. @end
  69. PL__ASSUME_NONNULL_END