mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[Layout] Layout API based on content area (#2110)
* Initial commit for adding a size constraint to ASLayoutable's * Some more commits * Fix sample projects in extra/ * Remove preferredFrameSize test of ASEditableTextNode * Remove preferredFrameSize from examples_extra * Add deprecation warning to -[ASDisplayNode preferredFrameSize] * Add deprecation warning to -[ASDisplayNode measureWithSizeRange:] * Commit * Commit * Remove ASRelativeSizeRange * Make ASRelativeSize private * Adjust examples * Improve setting of -[ASLayoutable size] with points or fractions * Add ASWrapperLayoutSpec * Improve creation of ASRelativeDimension * Add `preferredFrameSize` back and add deprecated logging * Add `layoutSpecBlock` setter and getter and add locking for it * Add better documentation and fix macros to create ASRelativeDimension * Create new ASSizeRangeMake with just a CGSize as parameter * Update Kitten and Social App Layout example * Add layoutThatFits: and deprecate measure: * Rename ASRelativeDimension to ASDimension * Fix examples for ASDimension renaming * Remove fancy height and width setter * Fix ASDimension helper * Rename -[ASLayout layoutableObject] to -[ASLayout layoutable] * Update layout related methods and more clearer documentation around how to use it * Deprecate old ASLayout class constructors * Don't unnecessary recalculate layout if constrained or parent size did not change * Use shared pointer for ASDisplayNodeLayout * Fix rebase conflicts * Add documentation and move implementation in mm file of ASDisplayNodeLayout * Fix test errors * Rename ASSize to ASLayoutableSize * Address comments * Rename setSizeFromCGSize to setSizeWithCGSize * Improve inline functions in ASDimension * Fix rebase conflicts
This commit is contained in:
committed by
Adlai Holler
parent
2bfeb6de92
commit
8897614f0e
@@ -248,26 +248,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/** @name Managing dimensions */
|
||||
|
||||
/**
|
||||
* @abstract Asks the node to measure and return the size that best fits its subnodes.
|
||||
*
|
||||
* @param constrainedSize The maximum size the receiver should fit in.
|
||||
*
|
||||
* @return A new size that fits the receiver's subviews.
|
||||
*
|
||||
* @discussion Though this method does not set the bounds of the view, it does have side effects--caching both the
|
||||
* constraint and the result.
|
||||
*
|
||||
* @warning Subclasses must not override this; it calls -measureWithSizeRange: with zero min size.
|
||||
* -measureWithSizeRange: caches results from -calculateLayoutThatFits:. Calling this method may
|
||||
* be expensive if result is not cached.
|
||||
*
|
||||
* @see measureWithSizeRange:
|
||||
* @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:]
|
||||
*/
|
||||
- (CGSize)measure:(CGSize)constrainedSize;
|
||||
|
||||
/**
|
||||
* @abstract Asks the node to measure a layout based on given size range.
|
||||
* @abstract Asks the node to return a layout based on given size range.
|
||||
*
|
||||
* @param constrainedSize The minimum and maximum sizes the receiver should fit in.
|
||||
*
|
||||
@@ -281,8 +262,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*
|
||||
* @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:]
|
||||
*/
|
||||
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize;
|
||||
|
||||
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize;
|
||||
|
||||
/**
|
||||
* @abstract Provides a way to declare a block to provide an ASLayoutSpec without having to subclass ASDisplayNode and
|
||||
@@ -317,16 +297,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
@property (nonatomic, readonly, assign) ASSizeRange constrainedSizeForCalculatedLayout;
|
||||
|
||||
/**
|
||||
* @abstract Provides a default intrinsic content size for calculateSizeThatFits:. This is useful when laying out
|
||||
* a node that either has no intrinsic content size or should be laid out at a different size than its intrinsic content
|
||||
* size. For example, this property could be set on an ASImageNode to display at a size different from the underlying
|
||||
* image size.
|
||||
*
|
||||
* @return The preferred frame size of this node
|
||||
*/
|
||||
@property (nonatomic, assign, readwrite) CGSize preferredFrameSize;
|
||||
|
||||
/** @name Managing the nodes hierarchy */
|
||||
|
||||
|
||||
@@ -625,7 +595,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
* Convenience methods for debugging.
|
||||
*/
|
||||
|
||||
@interface ASDisplayNode (Debugging) <ASLayoutableAsciiArtProtocol>
|
||||
|
||||
/**
|
||||
@@ -838,6 +807,20 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)cancelLayoutTransition;
|
||||
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
/**
|
||||
* @abstract Provides a default intrinsic content size for calculateSizeThatFits:. This is useful when laying out
|
||||
* a node that either has no intrinsic content size or should be laid out at a different size than its intrinsic content
|
||||
* size. For example, this property could be set on an ASImageNode to display at a size different from the underlying
|
||||
* image size.
|
||||
*
|
||||
* @return The preferred frame size of this node
|
||||
*
|
||||
* @deprecated Deprecated in version 2.0: Use sizing properties instead: height, minHeight, maxHeight, width, minWidth, maxWidth
|
||||
*/
|
||||
@property (nonatomic, assign, readwrite) CGSize preferredFrameSize ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user