ASDisplayNodeLayout.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // ASDisplayNodeLayout.h
  3. // AsyncDisplayKit
  4. //
  5. // Created by Michael Schneider on 08/26/16.
  6. //
  7. // Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  8. // This source code is licensed under the BSD-style license found in the
  9. // LICENSE file in the root directory of this source tree. An additional grant
  10. // of patent rights can be found in the PATENTS file in the same directory.
  11. //
  12. #pragma once
  13. #import "ASDimension.h"
  14. @class ASLayout;
  15. /*
  16. * Represents a connection between an ASLayout and a ASDisplayNode
  17. * ASDisplayNode uses this to store additional information that are necessary besides the layout
  18. */
  19. struct ASDisplayNodeLayout {
  20. ASLayout *layout;
  21. ASSizeRange constrainedSize;
  22. CGSize parentSize;
  23. BOOL requestedLayoutFromAbove;
  24. BOOL _dirty;
  25. /*
  26. * Create a new display node layout with
  27. * @param layout The layout to associate, usually returned from a call to -layoutThatFits:parentSize:
  28. * @param constrainedSize Constrained size used to create the layout
  29. * @param parentSize Parent size used to create the layout
  30. */
  31. ASDisplayNodeLayout(ASLayout *layout, ASSizeRange constrainedSize, CGSize parentSize)
  32. : layout(layout), constrainedSize(constrainedSize), parentSize(parentSize), requestedLayoutFromAbove(NO), _dirty(NO) {};
  33. /*
  34. * Creates a layout without any layout associated. By default this display node layout is dirty.
  35. */
  36. ASDisplayNodeLayout()
  37. : layout(nil), constrainedSize({{0, 0}, {0, 0}}), parentSize({0, 0}), requestedLayoutFromAbove(NO), _dirty(YES) {};
  38. /**
  39. * Returns if the display node layout is dirty as it was invalidated or it was created without a layout.
  40. */
  41. BOOL isDirty();
  42. /**
  43. * Returns if ASDisplayNode is still valid for a given constrained and parent size
  44. */
  45. BOOL isValidForConstrainedSizeParentSize(ASSizeRange constrainedSize, CGSize parentSize);
  46. /**
  47. * Invalidate the display node layout
  48. */
  49. void invalidate();
  50. };