Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

minor reformatting fit. working on customization. merge with rss needed.

  • Loading branch information...
commit e80e1af3d4d0a23429f2e42fc556ed30f8a1fd08 1 parent b6b2a85
Alex Gray authored

Showing 39 changed files with 1,875 additions and 2,178 deletions. Show diff stats Hide diff stats

  1. +9 138 AHLayout.xcodeproj/project.pbxproj
  2. +1 1  AHLayout/AHAppDelegate.h
  3. +67 78 AHLayout/AHAppDelegate.m
  4. +1 1  AHLayout/AHLayout-Prefix.pch
  5. +63 66 AHLayout/AHLayout.h
  6. +831 992 AHLayout/AHLayout.m
  7. +7 7 AHLayout/ExampleView.h
  8. +92 91 AHLayout/ExampleView.m
  9. +2 2 AHLayout/main.m
  10. +2 2 TUIKit/NSBezierPath+TUIExtensions.h
  11. +57 57 TUIKit/NSColor+TUIExtensions.m
  12. +4 4 TUIKit/NSImage+TUIExtensions.m
  13. +30 30 TUIKit/TUIAccessibility.m
  14. +3 3 TUIKit/TUIAttributedString.m
  15. +11 11 TUIKit/TUIButton.h
  16. +3 3 TUIKit/TUICGAdditions.m
  17. +2 2 TUIKit/TUIControl+Accessibility.m
  18. +3 3 TUIKit/TUIGeometry.h
  19. +2 2 TUIKit/TUIImageView.m
  20. +56 56 TUIKit/TUILayoutConstraint.h
  21. +28 28 TUIKit/TUILayoutConstraint.m
  22. +3 3 TUIKit/TUILayoutManager.m
  23. +15 15 TUIKit/TUINSView+Accessibility.m
  24. +1 1  TUIKit/TUINSWindow.m
  25. +4 4 TUIKit/TUIPopover.h
  26. +186 186 TUIKit/TUIPopover.m
  27. +5 5 TUIKit/TUIProgressBar.m
  28. +7 7 TUIKit/TUIScrollView.h
  29. +181 181 TUIKit/TUITableView+Cell.m
  30. +29 29 TUIKit/TUITableView.h
  31. +86 86 TUIKit/TUITableView.m
  32. +2 2 TUIKit/TUITableViewSectionHeader.m
  33. +22 22 TUIKit/TUITextRenderer+Accessibility.m
  34. +1 1  TUIKit/TUITextRenderer.m
  35. +27 27 TUIKit/TUIView+Accessibility.m
  36. +9 9 TUIKit/TUIView+TUIBridgedView.m
  37. +20 20 TUIKit/TUIView.h
  38. +2 2 TUIKit/TUIView.m
  39. +1 1  TUIKit/TUIViewController.h
147 AHLayout.xcodeproj/project.pbxproj
@@ -7,87 +7,20 @@
7 7 objects = {
8 8
9 9 /* Begin PBXBuildFile section */
  10 + 7B427EAE170AE6600052FC31 /* AtoZ.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B427EAD170AE6600052FC31 /* AtoZ.framework */; };
10 11 9AFD0C9F16A750A1004FA0CB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFD0C9E16A750A1004FA0CB /* Cocoa.framework */; };
11 12 9AFD0CA916A750A1004FA0CB /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9AFD0CA716A750A1004FA0CB /* InfoPlist.strings */; };
12 13 9AFD0CAB16A750A1004FA0CB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CAA16A750A1004FA0CB /* main.m */; };
13 14 9AFD0CAF16A750A1004FA0CB /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 9AFD0CAD16A750A1004FA0CB /* Credits.rtf */; };
14 15 9AFD0CB216A750A1004FA0CB /* AHAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CB116A750A1004FA0CB /* AHAppDelegate.m */; };
15 16 9AFD0CB516A750A1004FA0CB /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9AFD0CB316A750A1004FA0CB /* MainMenu.xib */; };
16   - 9AFD0D4D16A75116004FA0CB /* ABActiveRange.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CBD16A75115004FA0CB /* ABActiveRange.m */; };
17   - 9AFD0D4E16A75116004FA0CB /* CAAnimation+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CBF16A75115004FA0CB /* CAAnimation+TUIExtensions.m */; };
18   - 9AFD0D4F16A75116004FA0CB /* CALayer+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CC116A75115004FA0CB /* CALayer+TUIExtensions.m */; };
19   - 9AFD0D5016A75116004FA0CB /* CATransaction+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CC316A75115004FA0CB /* CATransaction+TUIExtensions.m */; };
20   - 9AFD0D5116A75116004FA0CB /* CoreText+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CC516A75115004FA0CB /* CoreText+Additions.m */; };
21   - 9AFD0D5216A75116004FA0CB /* NSAffineTransform+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CC716A75115004FA0CB /* NSAffineTransform+TUIExtensions.m */; };
22   - 9AFD0D5316A75116004FA0CB /* NSBezierPath+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CC916A75115004FA0CB /* NSBezierPath+TUIExtensions.m */; };
23   - 9AFD0D5416A75116004FA0CB /* NSClipView+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CCB16A75115004FA0CB /* NSClipView+TUIExtensions.m */; };
24   - 9AFD0D5516A75116004FA0CB /* NSColor+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CCD16A75115004FA0CB /* NSColor+TUIExtensions.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
25   - 9AFD0D5616A75116004FA0CB /* NSFont+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CCF16A75115004FA0CB /* NSFont+TUIExtensions.m */; };
26   - 9AFD0D5716A75116004FA0CB /* NSImage+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CD116A75115004FA0CB /* NSImage+TUIExtensions.m */; };
27   - 9AFD0D5816A75116004FA0CB /* NSScrollView+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CD316A75115004FA0CB /* NSScrollView+TUIExtensions.m */; };
28   - 9AFD0D5916A75116004FA0CB /* NSShadow+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CD516A75115004FA0CB /* NSShadow+TUIExtensions.m */; };
29   - 9AFD0D5A16A75116004FA0CB /* NSTextView+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CD716A75115004FA0CB /* NSTextView+TUIExtensions.m */; };
30   - 9AFD0D5B16A75116004FA0CB /* NSView+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CD916A75115004FA0CB /* NSView+TUIExtensions.m */; };
31   - 9AFD0D5C16A75116004FA0CB /* TUIAccessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CDB16A75115004FA0CB /* TUIAccessibility.m */; };
32   - 9AFD0D5D16A75116004FA0CB /* TUIActivityIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CDD16A75115004FA0CB /* TUIActivityIndicatorView.m */; };
33   - 9AFD0D5E16A75116004FA0CB /* TUIAttributedString.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CDF16A75115004FA0CB /* TUIAttributedString.m */; };
34   - 9AFD0D5F16A75116004FA0CB /* TUIButton+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CE316A75115004FA0CB /* TUIButton+Accessibility.m */; };
35   - 9AFD0D6016A75116004FA0CB /* TUIButton+Content.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CE416A75115004FA0CB /* TUIButton+Content.m */; };
36   - 9AFD0D6116A75116004FA0CB /* TUIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CE616A75115004FA0CB /* TUIButton.m */; };
37   - 9AFD0D6216A75116004FA0CB /* TUICAAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CE816A75115004FA0CB /* TUICAAction.m */; };
38   - 9AFD0D6316A75116004FA0CB /* TUICGAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CEA16A75115004FA0CB /* TUICGAdditions.m */; };
39   - 9AFD0D6416A75116004FA0CB /* TUIControl+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CEC16A75115004FA0CB /* TUIControl+Accessibility.m */; };
40   - 9AFD0D6516A75116004FA0CB /* TUIControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CEE16A75115004FA0CB /* TUIControl.m */; };
41   - 9AFD0D6616A75116004FA0CB /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CF016A75115004FA0CB /* TUIGeometry.m */; };
42   - 9AFD0D6716A75116004FA0CB /* TUIImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CF316A75115004FA0CB /* TUIImageView.m */; };
43   - 9AFD0D6816A75116004FA0CB /* TUILabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CF616A75115004FA0CB /* TUILabel.m */; };
44   - 9AFD0D6916A75116004FA0CB /* TUILayoutConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CF816A75115004FA0CB /* TUILayoutConstraint.m */; };
45   - 9AFD0D6A16A75116004FA0CB /* TUILayoutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CFA16A75115004FA0CB /* TUILayoutManager.m */; };
46   - 9AFD0D6B16A75116004FA0CB /* TUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CFC16A75115004FA0CB /* TUINavigationController.m */; };
47   - 9AFD0D6C16A75116004FA0CB /* TUINSView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0CFE16A75115004FA0CB /* TUINSView+Accessibility.m */; };
48   - 9AFD0D6D16A75116004FA0CB /* TUINSView+Hyperfocus.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0016A75115004FA0CB /* TUINSView+Hyperfocus.m */; };
49   - 9AFD0D6E16A75116004FA0CB /* TUINSView+NSTextInputClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0216A75115004FA0CB /* TUINSView+NSTextInputClient.m */; };
50   - 9AFD0D6F16A75116004FA0CB /* TUINSView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0516A75115004FA0CB /* TUINSView.m */; };
51   - 9AFD0D7016A75116004FA0CB /* TUINSWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0716A75115004FA0CB /* TUINSWindow.m */; };
52   - 9AFD0D7116A75116004FA0CB /* TUIPopover.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0916A75115004FA0CB /* TUIPopover.m */; };
53   - 9AFD0D7216A75116004FA0CB /* TUIProgressBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0B16A75115004FA0CB /* TUIProgressBar.m */; };
54   - 9AFD0D7316A75116004FA0CB /* TUIResponder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0D16A75115004FA0CB /* TUIResponder.m */; };
55   - 9AFD0D7416A75116004FA0CB /* TUIScroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D0F16A75115004FA0CB /* TUIScroller.m */; };
56   - 9AFD0D7516A75116004FA0CB /* TUIScrollView+TUIBridgedScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D1216A75115004FA0CB /* TUIScrollView+TUIBridgedScrollView.m */; };
57   - 9AFD0D7616A75116004FA0CB /* TUIScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D1416A75115004FA0CB /* TUIScrollView.m */; };
58   - 9AFD0D7716A75116004FA0CB /* TUIStretchableImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D1616A75115004FA0CB /* TUIStretchableImage.m */; };
59   - 9AFD0D7816A75116004FA0CB /* TUIStringDrawing.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D1816A75115004FA0CB /* TUIStringDrawing.m */; };
60   - 9AFD0D7916A75116004FA0CB /* TUITableView+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D1A16A75115004FA0CB /* TUITableView+Additions.m */; };
61   - 9AFD0D7A16A75116004FA0CB /* TUITableView+Cell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D1C16A75115004FA0CB /* TUITableView+Cell.m */; };
62   - 9AFD0D7B16A75116004FA0CB /* TUITableView+Derepeater.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D1E16A75115004FA0CB /* TUITableView+Derepeater.m */; };
63   - 9AFD0D7C16A75116004FA0CB /* TUITableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2016A75115004FA0CB /* TUITableView.m */; };
64   - 9AFD0D7D16A75116004FA0CB /* TUITableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2316A75115004FA0CB /* TUITableViewCell.m */; };
65   - 9AFD0D7E16A75116004FA0CB /* TUITableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2516A75115004FA0CB /* TUITableViewController.m */; };
66   - 9AFD0D7F16A75116004FA0CB /* TUITableViewSectionHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2716A75116004FA0CB /* TUITableViewSectionHeader.m */; };
67   - 9AFD0D8016A75116004FA0CB /* TUITextEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2916A75116004FA0CB /* TUITextEditor.m */; };
68   - 9AFD0D8116A75116004FA0CB /* TUITextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2B16A75116004FA0CB /* TUITextField.m */; };
69   - 9AFD0D8216A75116004FA0CB /* TUITextRenderer+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2D16A75116004FA0CB /* TUITextRenderer+Accessibility.m */; };
70   - 9AFD0D8316A75116004FA0CB /* TUITextRenderer+Event.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D2F16A75116004FA0CB /* TUITextRenderer+Event.m */; };
71   - 9AFD0D8416A75116004FA0CB /* TUITextRenderer+KeyBindings.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3016A75116004FA0CB /* TUITextRenderer+KeyBindings.m */; };
72   - 9AFD0D8516A75116004FA0CB /* TUITextRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3316A75116004FA0CB /* TUITextRenderer.m */; };
73   - 9AFD0D8616A75116004FA0CB /* TUITextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3516A75116004FA0CB /* TUITextView.m */; };
74   - 9AFD0D8716A75116004FA0CB /* TUITextViewEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3716A75116004FA0CB /* TUITextViewEditor.m */; };
75   - 9AFD0D8816A75116004FA0CB /* TUITooltipWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3916A75116004FA0CB /* TUITooltipWindow.m */; };
76   - 9AFD0D8916A75116004FA0CB /* TUIView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3B16A75116004FA0CB /* TUIView+Accessibility.m */; };
77   - 9AFD0D8A16A75116004FA0CB /* TUIView+Animation.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3C16A75116004FA0CB /* TUIView+Animation.m */; };
78   - 9AFD0D8B16A75116004FA0CB /* TUIView+Event.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D3E16A75116004FA0CB /* TUIView+Event.m */; };
79   - 9AFD0D8C16A75116004FA0CB /* TUIView+Layout.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D4016A75116004FA0CB /* TUIView+Layout.m */; };
80   - 9AFD0D8D16A75116004FA0CB /* TUIView+PasteboardDragging.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D4216A75116004FA0CB /* TUIView+PasteboardDragging.m */; };
81   - 9AFD0D8E16A75116004FA0CB /* TUIView+TUIBridgedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D4516A75116004FA0CB /* TUIView+TUIBridgedView.m */; };
82   - 9AFD0D8F16A75116004FA0CB /* TUIView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D4716A75116004FA0CB /* TUIView.m */; };
83   - 9AFD0D9016A75116004FA0CB /* TUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D4916A75116004FA0CB /* TUIViewController.m */; };
84   - 9AFD0D9116A75116004FA0CB /* TUIViewNSViewContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D4C16A75116004FA0CB /* TUIViewNSViewContainer.m */; };
85 17 9AFD0D9316A75145004FA0CB /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AFD0D9216A75145004FA0CB /* QuartzCore.framework */; };
86 18 9AFD0D9616A751CB004FA0CB /* AHLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D9516A751CB004FA0CB /* AHLayout.m */; };
87 19 9AFD0D9916A75322004FA0CB /* ExampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFD0D9816A75322004FA0CB /* ExampleView.m */; };
88 20 /* End PBXBuildFile section */
89 21
90 22 /* Begin PBXFileReference section */
  23 + 7B427EAD170AE6600052FC31 /* AtoZ.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AtoZ.framework; path = ../../../../../Library/Frameworks/AtoZ.framework; sourceTree = "<group>"; };
91 24 9AFD0C9A16A750A1004FA0CB /* AHLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AHLayout.app; sourceTree = BUILT_PRODUCTS_DIR; };
92 25 9AFD0C9E16A750A1004FA0CB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
93 26 9AFD0CA116A750A1004FA0CB /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
@@ -258,6 +191,7 @@
258 191 isa = PBXFrameworksBuildPhase;
259 192 buildActionMask = 2147483647;
260 193 files = (
  194 + 7B427EAE170AE6600052FC31 /* AtoZ.framework in Frameworks */,
261 195 9AFD0D9316A75145004FA0CB /* QuartzCore.framework in Frameworks */,
262 196 9AFD0C9F16A750A1004FA0CB /* Cocoa.framework in Frameworks */,
263 197 );
@@ -269,6 +203,7 @@
269 203 9AFD0C8F16A750A1004FA0CB = {
270 204 isa = PBXGroup;
271 205 children = (
  206 + 7B427EAD170AE6600052FC31 /* AtoZ.framework */,
272 207 9AFD0CBB16A75115004FA0CB /* TUIKit */,
273 208 9AFD0CA416A750A1004FA0CB /* AHLayout */,
274 209 9AFD0C9D16A750A1004FA0CB /* Frameworks */,
@@ -550,75 +485,6 @@
550 485 files = (
551 486 9AFD0CAB16A750A1004FA0CB /* main.m in Sources */,
552 487 9AFD0CB216A750A1004FA0CB /* AHAppDelegate.m in Sources */,
553   - 9AFD0D4D16A75116004FA0CB /* ABActiveRange.m in Sources */,
554   - 9AFD0D4E16A75116004FA0CB /* CAAnimation+TUIExtensions.m in Sources */,
555   - 9AFD0D4F16A75116004FA0CB /* CALayer+TUIExtensions.m in Sources */,
556   - 9AFD0D5016A75116004FA0CB /* CATransaction+TUIExtensions.m in Sources */,
557   - 9AFD0D5116A75116004FA0CB /* CoreText+Additions.m in Sources */,
558   - 9AFD0D5216A75116004FA0CB /* NSAffineTransform+TUIExtensions.m in Sources */,
559   - 9AFD0D5316A75116004FA0CB /* NSBezierPath+TUIExtensions.m in Sources */,
560   - 9AFD0D5416A75116004FA0CB /* NSClipView+TUIExtensions.m in Sources */,
561   - 9AFD0D5516A75116004FA0CB /* NSColor+TUIExtensions.m in Sources */,
562   - 9AFD0D5616A75116004FA0CB /* NSFont+TUIExtensions.m in Sources */,
563   - 9AFD0D5716A75116004FA0CB /* NSImage+TUIExtensions.m in Sources */,
564   - 9AFD0D5816A75116004FA0CB /* NSScrollView+TUIExtensions.m in Sources */,
565   - 9AFD0D5916A75116004FA0CB /* NSShadow+TUIExtensions.m in Sources */,
566   - 9AFD0D5A16A75116004FA0CB /* NSTextView+TUIExtensions.m in Sources */,
567   - 9AFD0D5B16A75116004FA0CB /* NSView+TUIExtensions.m in Sources */,
568   - 9AFD0D5C16A75116004FA0CB /* TUIAccessibility.m in Sources */,
569   - 9AFD0D5D16A75116004FA0CB /* TUIActivityIndicatorView.m in Sources */,
570   - 9AFD0D5E16A75116004FA0CB /* TUIAttributedString.m in Sources */,
571   - 9AFD0D5F16A75116004FA0CB /* TUIButton+Accessibility.m in Sources */,
572   - 9AFD0D6016A75116004FA0CB /* TUIButton+Content.m in Sources */,
573   - 9AFD0D6116A75116004FA0CB /* TUIButton.m in Sources */,
574   - 9AFD0D6216A75116004FA0CB /* TUICAAction.m in Sources */,
575   - 9AFD0D6316A75116004FA0CB /* TUICGAdditions.m in Sources */,
576   - 9AFD0D6416A75116004FA0CB /* TUIControl+Accessibility.m in Sources */,
577   - 9AFD0D6516A75116004FA0CB /* TUIControl.m in Sources */,
578   - 9AFD0D6616A75116004FA0CB /* TUIGeometry.m in Sources */,
579   - 9AFD0D6716A75116004FA0CB /* TUIImageView.m in Sources */,
580   - 9AFD0D6816A75116004FA0CB /* TUILabel.m in Sources */,
581   - 9AFD0D6916A75116004FA0CB /* TUILayoutConstraint.m in Sources */,
582   - 9AFD0D6A16A75116004FA0CB /* TUILayoutManager.m in Sources */,
583   - 9AFD0D6B16A75116004FA0CB /* TUINavigationController.m in Sources */,
584   - 9AFD0D6C16A75116004FA0CB /* TUINSView+Accessibility.m in Sources */,
585   - 9AFD0D6D16A75116004FA0CB /* TUINSView+Hyperfocus.m in Sources */,
586   - 9AFD0D6E16A75116004FA0CB /* TUINSView+NSTextInputClient.m in Sources */,
587   - 9AFD0D6F16A75116004FA0CB /* TUINSView.m in Sources */,
588   - 9AFD0D7016A75116004FA0CB /* TUINSWindow.m in Sources */,
589   - 9AFD0D7116A75116004FA0CB /* TUIPopover.m in Sources */,
590   - 9AFD0D7216A75116004FA0CB /* TUIProgressBar.m in Sources */,
591   - 9AFD0D7316A75116004FA0CB /* TUIResponder.m in Sources */,
592   - 9AFD0D7416A75116004FA0CB /* TUIScroller.m in Sources */,
593   - 9AFD0D7516A75116004FA0CB /* TUIScrollView+TUIBridgedScrollView.m in Sources */,
594   - 9AFD0D7616A75116004FA0CB /* TUIScrollView.m in Sources */,
595   - 9AFD0D7716A75116004FA0CB /* TUIStretchableImage.m in Sources */,
596   - 9AFD0D7816A75116004FA0CB /* TUIStringDrawing.m in Sources */,
597   - 9AFD0D7916A75116004FA0CB /* TUITableView+Additions.m in Sources */,
598   - 9AFD0D7A16A75116004FA0CB /* TUITableView+Cell.m in Sources */,
599   - 9AFD0D7B16A75116004FA0CB /* TUITableView+Derepeater.m in Sources */,
600   - 9AFD0D7C16A75116004FA0CB /* TUITableView.m in Sources */,
601   - 9AFD0D7D16A75116004FA0CB /* TUITableViewCell.m in Sources */,
602   - 9AFD0D7E16A75116004FA0CB /* TUITableViewController.m in Sources */,
603   - 9AFD0D7F16A75116004FA0CB /* TUITableViewSectionHeader.m in Sources */,
604   - 9AFD0D8016A75116004FA0CB /* TUITextEditor.m in Sources */,
605   - 9AFD0D8116A75116004FA0CB /* TUITextField.m in Sources */,
606   - 9AFD0D8216A75116004FA0CB /* TUITextRenderer+Accessibility.m in Sources */,
607   - 9AFD0D8316A75116004FA0CB /* TUITextRenderer+Event.m in Sources */,
608   - 9AFD0D8416A75116004FA0CB /* TUITextRenderer+KeyBindings.m in Sources */,
609   - 9AFD0D8516A75116004FA0CB /* TUITextRenderer.m in Sources */,
610   - 9AFD0D8616A75116004FA0CB /* TUITextView.m in Sources */,
611   - 9AFD0D8716A75116004FA0CB /* TUITextViewEditor.m in Sources */,
612   - 9AFD0D8816A75116004FA0CB /* TUITooltipWindow.m in Sources */,
613   - 9AFD0D8916A75116004FA0CB /* TUIView+Accessibility.m in Sources */,
614   - 9AFD0D8A16A75116004FA0CB /* TUIView+Animation.m in Sources */,
615   - 9AFD0D8B16A75116004FA0CB /* TUIView+Event.m in Sources */,
616   - 9AFD0D8C16A75116004FA0CB /* TUIView+Layout.m in Sources */,
617   - 9AFD0D8D16A75116004FA0CB /* TUIView+PasteboardDragging.m in Sources */,
618   - 9AFD0D8E16A75116004FA0CB /* TUIView+TUIBridgedView.m in Sources */,
619   - 9AFD0D8F16A75116004FA0CB /* TUIView.m in Sources */,
620   - 9AFD0D9016A75116004FA0CB /* TUIViewController.m in Sources */,
621   - 9AFD0D9116A75116004FA0CB /* TUIViewNSViewContainer.m in Sources */,
622 488 9AFD0D9616A751CB004FA0CB /* AHLayout.m in Sources */,
623 489 9AFD0D9916A75322004FA0CB /* ExampleView.m in Sources */,
624 490 );
@@ -711,10 +577,12 @@
711 577 isa = XCBuildConfiguration;
712 578 buildSettings = {
713 579 COMBINE_HIDPI_IMAGES = YES;
  580 + FRAMEWORK_SEARCH_PATHS = /Library/Frameworks;
714 581 GCC_PRECOMPILE_PREFIX_HEADER = YES;
715 582 GCC_PREFIX_HEADER = "AHLayout/AHLayout-Prefix.pch";
716 583 INFOPLIST_FILE = "AHLayout/AHLayout-Info.plist";
717 584 PRODUCT_NAME = "$(TARGET_NAME)";
  585 + SDKROOT = "";
718 586 WRAPPER_EXTENSION = app;
719 587 };
720 588 name = Debug;
@@ -723,10 +591,12 @@
723 591 isa = XCBuildConfiguration;
724 592 buildSettings = {
725 593 COMBINE_HIDPI_IMAGES = YES;
  594 + FRAMEWORK_SEARCH_PATHS = /Library/Frameworks;
726 595 GCC_PRECOMPILE_PREFIX_HEADER = YES;
727 596 GCC_PREFIX_HEADER = "AHLayout/AHLayout-Prefix.pch";
728 597 INFOPLIST_FILE = "AHLayout/AHLayout-Info.plist";
729 598 PRODUCT_NAME = "$(TARGET_NAME)";
  599 + SDKROOT = "";
730 600 WRAPPER_EXTENSION = app;
731 601 };
732 602 name = Release;
@@ -750,6 +620,7 @@
750 620 9AFD0CBA16A750A1004FA0CB /* Release */,
751 621 );
752 622 defaultConfigurationIsVisible = 0;
  623 + defaultConfigurationName = Release;
753 624 };
754 625 /* End XCConfigurationList section */
755 626 };
2  AHLayout/AHAppDelegate.h
@@ -3,7 +3,7 @@
3 3 // AHLayout
4 4 //
5 5 // Created by John Wright on 1/16/13.
6   -// Copyright (c) 2013 Airheart. All rights reserved.
  6 +// CPright (c) 2013 Airheart. All rights reserved.
7 7 //
8 8
9 9 #import <Cocoa/Cocoa.h>
145 AHLayout/AHAppDelegate.m
@@ -3,102 +3,91 @@
3 3 // AHLayout
4 4 //
5 5 // Created by John Wright on 1/16/13.
6   -// Copyright (c) 2013 Airheart. All rights reserved.
  6 +// CPright (c) 2013 Airheart. All rights reserved.
7 7 //
8 8
9 9 #import "AHAppDelegate.h"
10 10 #import "AHLayout.h"
11 11 #import "ExampleView.h"
  12 +#import <AtoZ/AtoZ.h>
12 13
13   -@implementation AHAppDelegate {
14   - AHLayout *_horizontalLayout;
15   - AHLayout *_verticalLayout;
16   - TUIButton *button;
17   - TUIButton *removeButton;
18   - BOOL collapsed;
19   - NSMutableArray *_vertObjects;
20   - NSMutableArray *_horizObjects;
21 14
22   -}
  15 +@interface AHAppDelegate ()
  16 +@property AHLayout *horizontalLayout, *verticalLayout;
  17 +@property TUIButton *button, *removeButton;
  18 +@property BOOL collapsed;
  19 +@property NSMA *vertObjects, *horizObjects;
  20 +@end
  21 +@implementation AHAppDelegate
  22 +@synthesize button, removeButton, collapsed;
23 23
24 24 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
25 25 {
26   - TUINSView *containerView = [[TUINSView alloc] initWithFrame:[_window.contentView frame]];
27   - self.window.contentView = containerView;
28   - CGRect b = [self.window.contentView frame];
29   -
30   - TUIView *v = [[TUIView alloc] initWithFrame:b];
31   - v.backgroundColor = [NSColor grayColor];
32   -
33   - CGRect horizFrame = b;
34   - horizFrame.origin.y = b.size.height - 100;
35   - horizFrame.size.height = 100;
36   - _horizontalLayout = [[AHLayout alloc] initWithFrame:horizFrame];
37   - _horizontalLayout.typeOfLayout = AHLayoutHorizontal;
38   - _horizontalLayout.backgroundColor = [NSColor whiteColor];
39   - _horizontalLayout.autoresizingMask = TUIViewAutoresizingFlexibleBottomMargin | TUIViewAutoresizingFlexibleWidth;
40   - _horizontalLayout.dataSource = self;
41   - _horizontalLayout.clipsToBounds = YES;
42   - _horizontalLayout.spaceBetweenViews = 10;
43   - _horizontalLayout.viewClass = [ExampleView class];
44   - [v addSubview:_horizontalLayout];
45   -
46   - CGRect vertFrame = b;
47   - vertFrame.size.height -= 100;
48   - _verticalLayout = [[AHLayout alloc] initWithFrame:vertFrame];
49   - _verticalLayout.backgroundColor = [NSColor whiteColor];
50   - _verticalLayout.autoresizingMask = TUIViewAutoresizingFlexibleSize;
51   - _verticalLayout.dataSource = self;
52   - _verticalLayout.clipsToBounds = YES;
53   - _verticalLayout.viewClass = [ExampleView class];
54   - [v addSubview:_verticalLayout];
55   -
56   - containerView.rootView = v;
57   -
58   - _vertObjects = [NSMutableArray array];
59   -
60   - for (int i=0; i <50; i++) {
61   - [_vertObjects addObject:[NSMutableDictionary dictionary]];
62   - }
63   -
64   - _horizObjects = [NSMutableArray array];
65   -
66   - for (int i=0; i <50; i++) {
67   - [_horizObjects addObject:[NSMutableDictionary dictionary]];
68   - }
69   -
70   - TUILabel *label = [[TUILabel alloc] initWithFrame:CGRectMake(containerView.rootView.frame.size.width/2, 0, 250, 50)];
71   - label.text = @"Right click on any cell for options";
72   - label.font = [NSFont boldSystemFontOfSize:12];
73   - label.backgroundColor = [NSColor clearColor];
74   - [containerView.rootView addSubview:label];
75   -
76   - [_verticalLayout reloadData];
77   - [_horizontalLayout reloadData];
  26 +
  27 + TUINSView *containerView = [TUINSView.alloc initWithFrame:[_window.contentView frame]];
  28 + self.window.contentView = containerView;
  29 + CGRect b = [self.window.contentView frame];
  30 +
  31 + TUIV*v = [TUIView.alloc initWithFrame:b];
  32 +// v.backgroundColor = [NSColor grayColor];
  33 +
  34 + CGRect horizFrame, vertFrame; horizFrame = vertFrame = b;
  35 + horizFrame.origin.y = b.size.height - 100;
  36 + horizFrame.size.height = 100;
  37 + [v addSubview:_horizontalLayout = [AHLayout.alloc initWithFrame:horizFrame]];
  38 + _horizontalLayout.typeOfLayout = AHLayoutHorizontal;
  39 + _horizontalLayout.bgC = LINEN;
  40 + _horizontalLayout.arMASK = TUIViewAutoresizingFlexibleBottomMargin | TUIViewAutoresizingFlexibleWidth;
  41 + _horizontalLayout.dataSource = self;
  42 + _horizontalLayout.clipsToBounds = YES;
  43 + _horizontalLayout.spaceBetweenViews = 0;
  44 + _horizontalLayout.viewClass = ExampleView.class;
  45 +// _horizontalLayout];
  46 +
  47 + vertFrame.size.height -= 100;
  48 + [v addSubview:_verticalLayout = [AHLayout.alloc initWithFrame:vertFrame]];
  49 + _verticalLayout.backgroundColor = RED;
  50 + _verticalLayout.autoresizingMask = TUIViewAutoresizingFlexibleSize;
  51 + _verticalLayout.dataSource = self;
  52 + _verticalLayout.clipsToBounds = YES;
  53 + _verticalLayout.viewClass = ExampleView.class;
  54 +
  55 + containerView.rootView = v;
  56 +
  57 + _horizObjects = [[NSC.randomPalette withMinItems:199] map:^id(id obj) {
  58 + return @{@"color": @{ @"name" : [obj nameOfColor], @"color": obj} };
  59 + }].mutableCopy;
  60 + _vertObjects = [NSMD newInstances:50];
  61 +
  62 +
  63 + TUILabel *label;
  64 + [containerView.rootView addSubview: label = [TUILabel.alloc initWithFrame:
  65 + CGRectMake(containerView.rootView.width / 2, 0, 250, 50)]];
  66 + label.text = @"Right click on any cell for options";
  67 + label.font = AtoZ.controlFont;
  68 + label.backgroundColor = [NSColor clearColor];
  69 +// addSubview:label];
  70 +
  71 + [_verticalLayout reloadData];
  72 + [_horizontalLayout reloadData];
78 73 }
79 74
80 75 #pragma mark - AHLayoutDataSource methods
81 76
82   --(TUIView*) layout:(AHLayout *)l viewForIndex:(NSInteger)index {
83   - ExampleView *v = (ExampleView*) [_verticalLayout dequeueReusableView];
84   - if ([l isEqual:_verticalLayout]) {
85   - v.objects = _vertObjects;
86   - } else {
87   - v.objects = _horizObjects;
88   - }
89   - return v;
  77 +- (TUIV*) layout:(AHLayout*)l viewForIndex:(NSI)index
  78 +{
  79 + ExampleView *v = (ExampleView*) _verticalLayout.dequeueReusableView;
  80 + v.objects = l == _verticalLayout ? _vertObjects : _horizObjects;
  81 + return v;
90 82 }
91 83
92   -- (NSUInteger)numberOfViewsInLayout:(AHLayout *)l {
93   - return [l isEqual:_verticalLayout] ? [_vertObjects count] : [_horizObjects count];
  84 +- (NSUI)numberOfViewsInLayout:(AHLayout*)l { return l == _verticalLayout ? _vertObjects.count
  85 + : _horizObjects.count;
94 86 }
95 87
96   --(CGSize) layout:(AHLayout *)l sizeOfViewAtIndex:(NSUInteger)index {
97   - if ([l isEqual:_verticalLayout]) {
98   - CGRect b = [self.window.contentView frame];
99   - return CGSizeMake(b.size.width, 100);
100   - }
101   - return CGSizeMake(100, 100);
  88 +- (CGS) layout:(AHLayout*)l sizeOfViewAtIndex:(NSUI)index {
  89 +
  90 + return l == _verticalLayout ? CGSizeMake(_window.width, 100) : CGSizeMake(100, 100);
102 91 }
103 92
104 93 @end
2  AHLayout/AHLayout-Prefix.pch
@@ -3,5 +3,5 @@
3 3 //
4 4
5 5 #ifdef __OBJC__
6   - #import <Cocoa/Cocoa.h>
  6 + #import <Cocoa/Cocoa.h>
7 7 #endif
129 AHLayout/AHLayout.h
@@ -3,102 +3,99 @@
3 3 // Swift
4 4 //
5 5 // Created by John Wright on 11/13/11.
6   -// Copyright (c) 2011 AirHeart. All rights reserved.
  6 +// CPright (c) 2011 AirHeart. All rights reserved.
7 7 //
8 8
9 9 #define kAHLayoutViewHeight @"kAHLayoutViewHeight"
10 10 #define kAHLayoutViewWidth @"kAHLayoutViewWidth"
11 11
12   -#import "TUIKit.h"
  12 +//#import "TUIKit.h"
  13 +#import <AtoZ/AtoZ.h>
13 14
14 15 @interface NSString(TUICompare)
15   -
16   --(NSComparisonResult)compareNumberStrings:(NSString *)str;
17   -
  16 +- (NSComparisonResult)compareNumberStrings:(NSString *)str;
18 17 @end
  18 +typedef NS_ENUM( NSUI, AHLayoutScrollPosition ){
  19 +AHLayoutScrollPositionNone, AHLayoutScrollPositionTop,
  20 +AHLayoutScrollPositionMiddle, AHLayoutScrollPositionBottom,
  21 +AHLayoutScrollPositionToVisible // currently the only supported arg
  22 +};
  23 +// a callback handler to be used in various layout operations
  24 +typedef NS_ENUM( NSUI, AHLayoutType) { AHLayoutVertical, AHLayoutHorizontal };
19 25
20 26 #define kAHLayoutAnimation @"AHLayoutAnimation"
21   -
22 27 @class AHLayout;
23 28 @class AHLayoutObject;
24 29 typedef void(^AHLayoutHandler)(AHLayout *layout);
25   -typedef void(^AHLayoutViewAnimationBlock)(AHLayout *layout, TUIView *view);
26   -
27   -typedef enum {
28   - AHLayoutScrollPositionNone,
29   - AHLayoutScrollPositionTop,
30   - AHLayoutScrollPositionMiddle,
31   - AHLayoutScrollPositionBottom,
32   - AHLayoutScrollPositionToVisible, // currently the only supported arg
33   -} AHLayoutScrollPosition;
34   -
35   -
36   -// a callback handler to be used in various layout operations
37   -typedef enum {
38   - AHLayoutVertical,
39   - AHLayoutHorizontal,
40   -} AHLayoutType;
41   -
  30 +typedef void(^AHLayoutViewAnimationBlock)(AHLayout *layout, TUIV*view);
42 31
43 32 @protocol AHLayoutDataSource;
44   -
45 33 @interface AHLayout : TUIScrollView <TUIScrollViewDelegate>
46 34
47   -@property (nonatomic, weak) NSObject<AHLayoutDataSource> *dataSource;
48   -
49   -@property (nonatomic, weak) Class viewClass;
50   -@property (nonatomic) AHLayoutType typeOfLayout;
51   -@property (nonatomic) CGFloat spaceBetweenViews;
52   -@property (nonatomic, readonly) NSInteger numberOfViews;
53   -@property (nonatomic, strong) NSDate *reloadedDate;
54   -@property (nonatomic, copy) AHLayoutHandler reloadHandler;
55   -@property (nonatomic, readonly) NSArray *visibleViews;
56   -@property (nonatomic) BOOL didFirstLayout;
  35 +@property (NATOM,WK) NSObject<AHLayoutDataSource> *dataSource;
  36 +@property (NATOM,WK) Class viewClass;
  37 +@property (NATOM) AHLayoutType typeOfLayout;
  38 +@property (NATOM) CGFloat spaceBetweenViews;
  39 +@property (NATOM,RONLY) NSI numberOfViews;
  40 +@property (NATOM,STRNG) NSDate *reloadedDate;
  41 +@property (NATOM,CP) AHLayoutHandler reloadHandler;
  42 +@property (NATOM,RONLY) NSA *visibleViews;
  43 +@property (NATOM) BOOL didFirstLayout;
57 44
58 45 #pragma mark - General
59 46
60   -- (TUIView *)dequeueReusableView;
61   -- (void)reloadData;
62   -- (TUIView*) viewForIndex:(NSUInteger) index;
63   --(NSInteger) indexForView:(TUIView*)v;
64   -- (NSUInteger)indexOfViewAtPoint:(CGPoint) point;
65   -- (TUIView*) viewAtPoint:(CGPoint) point;
66   -- (void)scrollToViewAtIndex:(NSUInteger)index atScrollPosition:(AHLayoutScrollPosition)scrollPosition animated:(BOOL)animated;
67   -- (CGRect) rectForViewAtIndex:(NSUInteger) index;
68   --(TUIView*) replaceViewForObjectAtIndex:(NSUInteger) index withSize:(CGSize) size;
69   --(NSUInteger) objectIndexAtTopOfScreen;
70   -
  47 +- (TUIV*) dequeueReusableView;
  48 +- (void) reloadData;
  49 +- (NSI) indexForView: (TUIV*) v;
  50 +- (TUIV*) viewForIndex: (NSUI) index;
  51 +- (NSUI) indexOfViewAtPoint: (CGP) point;
  52 +- (TUIV*) viewAtPoint: (CGP) point;
  53 +- (NSUI) objectIndexAtTopOfScreen;
  54 +- (CGR) rectForViewAtIndex: (NSUI) index;
  55 +- (TUIV*) replaceViewForObjectAtIndex: (NSUI) index withSize:(CGSZ) size;
  56 +- (void) scrollToViewAtIndex: (NSUI) index atScrollPosition:(AHLayoutScrollPosition)scrollPosition
  57 + animated:(BOOL)animated;
71 58 #pragma mark - Layout transactions
72   --(void) beginUpdates;
73   --(void) endUpdates;
  59 +- (void) beginUpdates;
  60 +- (void) endUpdates;
74 61
75 62 #pragma mark - Resizing
76   -- (void) resizeViewsAtIndexes:(NSArray*) objectIndexes sizes:(NSArray*) sizes animationBlock:(void (^)())animationBlock completion:(void (^)())completionBlock;
77   --(void) resizeViewsToSize:(CGSize) size scrollToObjectIndex:(NSUInteger) scrollToObjectIndex animationBlock:(void (^)())animationBlock completionBlock:(void (^)())completion;
78   -- (void) resizeViewAtIndex:(NSUInteger) index toSize:(CGSize) size animationBlock:(void (^)())animationBlock completionBlock:(void (^)())completionBlock;
79   -
  63 +- (void) resizeViewsAtIndexes:(NSA*) objectIndexes sizes:(NSA*) sizes
  64 + animationBlock:(void (^)())animationBlock completion:(void (^)())completionBlock;
  65 +
  66 +- (void) resizeViewsToSize:(CGSZ) size scrollToObjectIndex:(NSUI) scrollToObjectIndex
  67 + animationBlock:(void (^)())animationBlock completionBlock:(void (^)())completion;
  68 +
  69 +- (void) resizeViewAtIndex:(NSUI) index toSize:(CGSZ) size animationBlock:(void (^)())animationBlock
  70 + completionBlock:(void (^)())completionBlock;
80 71 #pragma mark - Adding and removing views
81   --(void) insertViewAtIndex:(NSUInteger) index;
82   --(void) insertViewAtIndex:(NSUInteger) index animationBlock:(AHLayoutViewAnimationBlock)animationBlock completionBlock:(void (^)())completionBlock;
83   --(void)removeViewsAtIndexes:(NSIndexSet *)indexes animationBlock:(AHLayoutViewAnimationBlock)animationBlock completionBlock:(void (^)())completionBlock;
84   --(void) prependNumOfViews:(NSInteger) numOfObjects animationBlock:(void (^)())animationBlock completionBlock:(void (^)())completionBlock;
  72 +- (void) insertViewAtIndex:(NSUI) index;
85 73
86   -# pragma mark - Scrolling
  74 +- (void) insertViewAtIndex:(NSUI) index
  75 + animationBlock:(AHLayoutViewAnimationBlock)animationBlock
  76 + completionBlock:(void (^)())completionBlock;
87 77
88   -@end
  78 +- (void)removeViewsAtIndexes:(NSIS*)indexes
  79 + animationBlock:(AHLayoutViewAnimationBlock)animationBlock
  80 + completionBlock:(void (^)())completionBlock;
  81 +
  82 +- (void) prependNumOfViews:(NSI) numOfObjects
  83 + animationBlock:(void (^)())animationBlock
  84 + completionBlock:(void (^)())completionBlock;
89 85
90   -//////////////////////////////////////////////////////////////
91   -#pragma mark Protocol AHLayoutDataSource
92   -//////////////////////////////////////////////////////////////
  86 +# pragma mark - Scrolling
  87 +@end
93 88
94   -@protocol AHLayoutDataSource <NSObject>
95 89
96   -@required
97   -// Populating subview items
98   -- (NSUInteger)numberOfViewsInLayout:(AHLayout *)layout;
99   -- (CGSize)layout:(AHLayout *)layout sizeOfViewAtIndex:(NSUInteger)index;
100   -- (TUIView *)layout:(AHLayout *)layout viewForIndex:(NSInteger)index;
  90 +#pragma mark Protocol AHLayoutDataSource *********
101 91
  92 +@protocol AHLayoutDataSource <NSObject>
  93 +@required // Populating subview items
  94 +- (NSUI) numberOfViewsInLayout:(AHLayout *)layout;
  95 +- (CGSZ) layout:(AHLayout*)layout sizeOfViewAtIndex:(NSUI)index;
  96 +- (TUIV*) layout:(AHLayout*)layout viewForIndex:(NSI)index;
  97 +@optional
  98 +- (TUIV*) layout:(AHLayout*)layout objectAtIndex:(NSI)index;
102 99 @end
103 100
104 101
1,823 AHLayout/AHLayout.m
@@ -4,7 +4,7 @@
4 4 // Swift
5 5 //
6 6 // Created by John Wright on 11/13/11.
7   -// Copyright (c) 2011 AirHeart. All rights reserved.
  7 +// CPright (c) 2011 AirHeart. All rights reserved.
8 8 //
9 9
10 10 // ARC is compatible with iOS 4.0 upwards, but you need at least Xcode 4.2 with Clang LLVM 3.0 to compile it.
@@ -12,697 +12,586 @@
12 12 #if !__has_feature(objc_arc)
13 13 #error This project must be compiled with ARC (Xcode 4.2+ with LLVM 3.0 and above)
14 14 #endif
15   -
16 15 #import "AHLayout.h"
17 16
18 17 @implementation NSString(TUICompare)
19   -
20   --(NSComparisonResult)compareNumberStrings:(NSString *)str {
21   - NSNumber * me = [NSNumber numberWithInt:[self intValue]];
22   - NSNumber * you = [NSNumber numberWithInt:[str intValue]];
23   -
24   - return [you compare:me];
  18 +- (NSComparisonResult)compareNumberStrings:(NSString *)str {
  19 + NSNumber * me = [NSNumber numberWithInt:[self intValue]];
  20 + NSNumber * you = [NSNumber numberWithInt:[str intValue]];
  21 +
  22 + return [you compare:me];
25 23 }
26   -
27 24 @end
28   -
29 25 #define kAHLayoutDefaultAnimationDuration 0.5
30   -
31 26 @interface AHLayoutObject : NSObject
32   -
33   -@property (nonatomic) CGSize size;
34   -@property (nonatomic) CGRect oldFrame;
35   -@property (nonatomic, readonly) CGRect calculatedFrame;
36   -@property (nonatomic) BOOL markedForInsertion;
37   -@property (nonatomic) BOOL markedForRemoval;
38   -@property (nonatomic) BOOL markedForUpdate;
39   -@property (nonatomic, strong) CAAnimation *animation;
40   -@property (nonatomic) CGFloat x;
41   -@property (nonatomic) CGFloat y;
42   -@property (nonatomic) NSInteger index;
43   -@property (nonatomic, strong) NSString *indexString;
44   -
  27 +@property (NATOM,STRNG) CAA *animation;
  28 +@property (NATOM,STRNG) NSS *indexString;
  29 +@property (NATOM,RONLY) CGR calculatedFrame;
  30 +@property (NATOM) CGSZ size;
  31 +@property (NATOM) CGR oldFrame;
  32 +@property (NATOM) CGF x, y;
  33 +@property (NATOM) NSI index;
  34 +@property (NATOM) BOOL markedForInsertion, markedForRemoval, markedForUpdate;
45 35 @end
46 36
47 37 @implementation AHLayoutObject
48   -
49   -@synthesize oldFrame;
50   -@synthesize size;
51   -@synthesize x;
52   -@synthesize y;
53   -@synthesize animation;
54   -@synthesize markedForInsertion;
55   -@synthesize markedForRemoval;
56   -@synthesize markedForUpdate;
57   -@synthesize index;
58   -@synthesize indexString;
59   -
60   --(CGRect) calculatedFrame {
61   - return CGRectMake(self.x, self.y, self.size.width, self.size.height);
  38 +@synthesize oldFrame, size, x, y, animation, markedForInsertion, markedForRemoval, markedForUpdate, index, indexString;
  39 +- (CGR) calculatedFrame {
  40 + return CGRectMake(self.x, self.y, self.size.width, self.size.height);
62 41 }
63   -
64 42 @end
65 43
66 44 @class AHLayoutTransaction;
67   -
68 45 @interface AHLayout()
69   -
70   -@property (nonatomic, strong) NSMutableDictionary *objectViewsMap;
71   -@property (nonatomic, readonly) AHLayoutTransaction *updatingTransaction;
72   -@property (nonatomic, strong) AHLayoutTransaction *executingTransaction;
73   -@property (nonatomic, strong) NSMutableArray *objects;
74   -
75   --(void) executeNextLayoutTransaction;
76   -- (void) enqueueReusableView:(TUIView *)view;
77   -- (TUIView *)createView;
78   -
  46 +@property (NATOM,RONLY) AHLayoutTransaction *updatingTransaction;
  47 +@property (NATOM,STRNG) AHLayoutTransaction *executingTransaction;
  48 +@property (NATOM,STRNG) NSMD *objectViewsMap;
  49 +@property (NATOM,STRNG) NSMA *objects;
  50 +- (void) executeNextLayoutTransaction;
  51 +- (void) enqueueReusableView:(TUIV*)view;
  52 +- (TUIV*)createView;
79 53 @end
80 54
81   -typedef enum {
82   - AHLayoutTransactionPhaseNormal,
83   - AHLayoutTransactionPhasePrelayout,
84   - AHLayoutTransactionPhaseAnimating,
85   - AHLayoutTransactionPhaseDoneAnimating,
86   -} AHLayoutTransactionPhase;
87   -
88   -
  55 +typedef NS_ENUM(NSUI, AHLayoutTransactionPhase) { AHLayoutTransactionPhaseNormal, AHLayoutTransactionPhasePrelayout,
  56 + AHLayoutTransactionPhaseAnimating, AHLayoutTransactionPhaseDoneAnimating, };
89 57 @interface AHLayoutTransaction : NSObject
90   -
91   -@property (nonatomic, weak) AHLayout *layout;
92   -@property (nonatomic, copy) AHLayoutHandler animationBlock;
93   -@property (nonatomic, copy) AHLayoutViewAnimationBlock viewAnimationBlock;
94   -@property (nonatomic) BOOL shouldAnimate;
95   -@property (nonatomic) CGSize contentSize;
96   -@property (nonatomic) CGRect nextVisibleRect;
97   -@property (nonatomic) AHLayoutTransactionPhase phase;
98   -@property (nonatomic) NSInteger scrollToObjectIndex;
99   -@property (nonatomic, strong) NSMutableArray *changeList;
100   -@property (nonatomic) CGSize objectSize;
101   -@property (nonatomic) BOOL calculated;
102   -@property (nonatomic) CGFloat animationDuration;
103   -@property (nonatomic) CGPoint contentOffset;
104   -@property (nonatomic) BOOL maintainContentOffset;
105   -@property (nonatomic) BOOL shouldNotCallDelegate;
106   -
107   --(void) applyLayout;
108   --(void) addCompletionBlock:(AHLayoutHandler) block;
109   -
110   --(CGPoint) calculateNextContentOffset;
111   --(void) calculateContentSize;
112   -- (CGPoint)modifyContentOffset:(CGPoint)c forRect:(CGRect)rect inVisibleRect:(CGRect) visible horizontal:(BOOL)horizontal;
113   --(void) calculateNextVisibleRect;
114   --(void) calculateObjectOffsets;
115   --(void) calculateObjectOffsetsVertical;
116   --(void) calculateObjectOffsetsHorizontal;
117   -
118   --(NSMutableArray *)objectIndexesInRect:(CGRect)rect;
119   --(NSString*) indexKeyForObject:(AHLayoutObject*) object;
120   -
121   --(void) moveViews;
122   --(void) addNewlyVisibleSubviews;
123   --(TUIView*) addSubviewForObject:(AHLayoutObject*) object atIndex:(NSString*) objectIndex;
124   --(void) rebaseForInsertionsAndRemovals;
125   --(void) processChangeList;
126   --(void) cleanup;
127   --(void) moveObjectsAfterPoint:(CGPoint) point byIndexAmount:(NSInteger) indexAmount;
  58 +@property (NATOM,STRNG) NSMA *changeList;
  59 +@property (NATOM,WK) AHLayout *layout;
  60 +@property (NATOM,CP) AHLayoutHandler animationBlock;
  61 +@property (NATOM,CP) AHLayoutViewAnimationBlock viewAnimationBlock;
  62 +@property (NATOM) AHLayoutTransactionPhase phase;
  63 +@property (NATOM) CGR nextVisibleRect;
  64 +@property (NATOM) NSI scrollToObjectIndex;
  65 +@property (NATOM) CGSZ objectSize, contentSize;
  66 +@property (NATOM) CGF animationDuration;
  67 +@property (NATOM) CGP contentOffset;
  68 +@property (NATOM) BOOL maintainContentOffset, shouldNotCallDelegate, shouldAnimate, calculated;;
  69 +- (void) applyLayout;
  70 +- (void) addCompletionBlock:(AHLayoutHandler) block;
  71 +- (CGP) calculateNextContentOffset;
  72 +- (void) calculateContentSize;
  73 +- (CGP) modifyContentOffset:(CGP)c forRect:(CGR)rect inVisibleRect:(CGR) visible horizontal:(BOOL)horizontal;
  74 +- (void) calculateNextVisibleRect;
  75 +- (void) calculateObjectOffsets;
  76 +- (void) calculateObjectOffsetsVertical;
  77 +- (void) calculateObjectOffsetsHorizontal;
  78 +
  79 +- (NSMA *)objectIndexesInRect:(CGR)rect;
  80 +- (NSS*) indexKeyForObject:(AHLayoutObject*) object;
  81 +
  82 +- (void) moveViews;
  83 +- (void) addNewlyVisibleSubviews;
  84 +- (TUIV*) addSubviewForObject:(AHLayoutObject*) object atIndex:(NSS*) objectIndex;
  85 +- (void) rebaseForInsertionsAndRemovals;
  86 +- (void) processChangeList;
  87 +- (void) cleanup;
  88 +- (void) moveObjectsAfterPoint:(CGP) point byIndexAmount:(NSI) indexAmount;
128 89 @end
129 90
130 91 @implementation AHLayoutTransaction {
131   - NSMutableArray *completionBlocks;
132   - BOOL calculatedContentSize;
133   - NSMutableArray *objectIndexesToBringIntoView;
134   - BOOL shouldChangeContentOffset;
135   - BOOL preLayoutPass;
136   - CGRect lastBounds;
137   - NSMutableArray *viewsToRemove;
  92 + NSMA *completionBlocks;
  93 + BOOL calculatedContentSize;
  94 + NSMA *objectIndexesToBringIntoView;
  95 + BOOL shouldChangeContentOffset;
  96 + BOOL preLayoutPass;
  97 + CGRect lastBounds;
  98 + NSMA *viewsToRemove;
138 99 }
139 100
140   -@synthesize layout;
141   -@synthesize animationBlock;
142   -@synthesize shouldAnimate;
143   -@synthesize contentSize;
144   -@synthesize nextVisibleRect;
145   -@synthesize phase;
146   -@synthesize scrollToObjectIndex;
147   -@synthesize changeList;
148   -@synthesize objectSize;
149   -@synthesize calculated;
150   -@synthesize animationDuration;
151   -@synthesize contentOffset;
  101 +@synthesize layout, animationBlock, shouldAnimate, contentSize, nextVisibleRect, phase, scrollToObjectIndex, changeList, objectSize, calculated, animationDuration, contentOffset;
152 102
153 103 #pragma mark - Getters and Setters
154   -
155   --(id) init {
156   - self = [super init];
157   - if (self) {
158   - scrollToObjectIndex = -1;
159   - }
160   - return self;
  104 +- (id) init {
  105 + if (self != super.init ) return nil;
  106 + scrollToObjectIndex = -1;
  107 + return self;
161 108 }
162   -
163   --(void) addCompletionBlock:(AHLayoutHandler)block {
164   - if (block == nil) return;
165   - if (!completionBlocks) {
166   - completionBlocks = [NSMutableArray array];
167   - }
168   - [completionBlocks addObject:[block copy]];
169   -}
170   -
171   --(NSMutableArray*) changeList {
172   - if (!changeList) {
173   - changeList = [NSMutableArray array];
174   - }
175   - return changeList;
  109 +- (void) addCompletionBlock:(AHLayoutHandler)block {
  110 + if (block == nil) return;
  111 + if (!completionBlocks) completionBlocks = NSMA.new;
  112 + [completionBlocks addObject:[block copy]];
176 113 }
  114 +- (NSMA*) changeList { return changeList = changeList ?: NSMA.new; }
177 115
178 116 #pragma mark - Layout
  117 +- (void) applyLayout {
  118 +
  119 +
  120 + CGRect bounds = layout.bounds;
  121 + CGFloat resizingYOffset, resizingXOffset; resizingYOffset = resizingXOffset = 0.0;
179 122
180   -
181   --(void) applyLayout {
182   -
183   -
184   - CGRect bounds = layout.bounds;
185   -
186   - CGFloat resizingYOffset = 0.0;
187   - CGFloat resizingXOffset = 0.0;
188   - if ([self.layout.nsView inLiveResize]) {
189   - resizingYOffset = (lastBounds.size).height - bounds.size.height;
190   - resizingXOffset = (lastBounds.size).width - bounds.size.width;
191   - }
192   -
193   -
194   - // save off some current offset info
195   - CGFloat previousYOffset = self.layout.contentSize.height + self.layout.contentOffset.y;
196   - CGFloat previousXOffset = self.layout.contentSize.width + self.layout.contentOffset.x;
197   - CGFloat relativeOffset = 0.0f;
198   - NSInteger savedIndex = -1;
199   - if (layout.objects.count > 0 && [self.layout.nsView inLiveResize]) {
200   - savedIndex = [layout objectIndexAtTopOfScreen];
201   - if (savedIndex >=0) {
202   - CGRect v = [self.layout visibleRect];
203   - CGRect r = [self.layout rectForViewAtIndex:savedIndex];
204   - if (layout.typeOfLayout == AHLayoutHorizontal) {
205   - relativeOffset = ((v.origin.x + v.size.width) - (r.origin.x + r.size.width));
206   - relativeOffset += (lastBounds.size.width - bounds.size.width);
207   - relativeOffset += resizingXOffset;
208   - } else {
209   - relativeOffset = ((v.origin.y + v.size.height) - (r.origin.y + r.size.height));
210   - relativeOffset += (lastBounds.size.height - bounds.size.height);
211   - relativeOffset += resizingYOffset;
212   - }
213   - }
214   - }
215   -
216   -
217   - if (!calculated || !CGSizeEqualToSize(bounds.size, lastBounds.size)) {
218   - if (!self.shouldNotCallDelegate) {
219   - self.contentSize = CGSizeZero; //reset the contentSize
220   - }
221   - [self calculateContentSize];
222   - [self processChangeList];
223   - [self calculateObjectOffsets];
224   - calculated = YES;
225   - }
226   - lastBounds = bounds;
227   -
228   -
229   - if (self.shouldAnimate && phase != AHLayoutTransactionPhaseDoneAnimating) {
230   - if (phase == AHLayoutTransactionPhaseNormal) {
231   - phase = AHLayoutTransactionPhasePrelayout;
232   - self.shouldAnimate = NO;
233   -
234   - // Perform a prelayout transaction where we bring in needed subviews
235   - // into their old location so that the animations looks ok
236   - [CATransaction begin];
237   - __weak NSMutableArray *weakCompletionBlocks = completionBlocks;
238   - __weak AHLayoutTransaction *weakSelf = self;
239   - [CATransaction setCompletionBlock:^{
240   -
241   - // In this CATransaction we animate the layout
242   - weakSelf.phase = AHLayoutTransactionPhaseAnimating;
243   - [CATransaction begin];
244   - [CATransaction setCompletionBlock:^{
245   - if (changeList.count > 0) {
246   - for (AHLayoutObject *object in changeList) {
247   - object.markedForInsertion = NO;
248   - object.markedForRemoval = NO;
249   - object.markedForUpdate = NO;
250   - }
251   - [changeList removeAllObjects];
252   - }
253   - weakSelf.phase = AHLayoutTransactionPhaseNormal;
254   - shouldAnimate = NO;
255   - if (viewsToRemove.count > 0) {
256   - for (TUIView *v in viewsToRemove) {
257   - [v removeFromSuperview];
258   - [self.layout enqueueReusableView:v];
259   - }
260   - }
261   - if (!CGRectEqualToRect(layout.visibleRect, nextVisibleRect)) {
262   - NSLog(@"Visible rect calculation is wrong\nTransaction: %@\nLayout: %@", NSStringFromRect(nextVisibleRect), NSStringFromRect(layout.visibleRect));
263   - }
264   - for (AHLayoutHandler block in weakCompletionBlocks) block(weakSelf.layout);
265   - }];
266   -
267   - CGFloat duration = weakSelf.animationDuration > 0 ? weakSelf.animationDuration : kAHLayoutDefaultAnimationDuration;
268   -
269   - layout.contentSize = contentSize;
270   -
271   - [TUIView animateWithDuration:duration animations:^{
272   - // Time for the key animation...
273   - // animate changing the content offset, moving the views,
274   - // and a user supplied animation block together
275   - weakSelf.layout.contentOffset = contentOffset;
276   - [self moveViews];
277   - if (weakSelf.animationBlock) weakSelf.animationBlock(weakSelf.layout);
278   - }];
279   - [CATransaction commit];
280   - }];
281   -
282   -
283   - // Process insertions and removals
284   - [weakSelf rebaseForInsertionsAndRemovals];
285   -
286   - AHLayoutObject *scrollToObject = nil;
287   - if (scrollToObjectIndex >= 0 && layout.objects.count > scrollToObjectIndex) {
288   - scrollToObject = [layout.objects objectAtIndex:scrollToObjectIndex];
289   - }
290   -
291   - contentOffset = layout.contentOffset;
292   - [self calculateNextVisibleRect];
293   - // Now refine the contentOffset a bit more to make sure we scroll to the right object
294   - if (scrollToObject) {
295   - // scroll the view to bottom or left
296   - CGRect r = scrollToObject.calculatedFrame;
297   - contentOffset = self.layout.typeOfLayout == AHLayoutHorizontal ? CGPointMake(-r.origin.x, 0) : CGPointMake(0, -r.origin.y);
298   - }
299   - contentOffset = [self fixContentOffset:contentOffset forSize:contentSize inBounds:layout.bounds];
300   - [self calculateNextVisibleRect];
301   -
302   - objectIndexesToBringIntoView = [self objectIndexesInRect:nextVisibleRect];
303   -
304   - // Bring in any needed views needed for the animation
305   - // Existing subviews will come in using their old frames
306   - [self addNewlyVisibleSubviews];
307   -
308   - // This ensures that the newly added subviews are added before the animation
309   - // This will kick off multiple layout passes all occuring with old frames before the animation
310   - [CATransaction commit];
311   - }
312   - } else {
313   - [TUIView setAnimationsEnabled:NO block:^{
314   - // maintain position after new layout
315   - if (savedIndex >=0 && relativeOffset >= 0) {
316   - CGRect v = [self.layout visibleRect];
  123 + if ([self.layout.nsView inLiveResize]) {
  124 + resizingYOffset = (lastBounds.size).height - bounds.size.height;
  125 + resizingXOffset = (lastBounds.size).width - bounds.size.width;
  126 + }
  127 +
  128 + // save off some current offset info
  129 + CGFloat previousYOffset = self.layout.contentSize.height + self.layout.contentOffset.y;
  130 + CGFloat previousXOffset = self.layout.contentSize.width + self.layout.contentOffset.x;
  131 + CGFloat relativeOffset = 0.0f;
  132 + NSI savedIndex = -1;
  133 + if (layout.objects.count > 0 && [self.layout.nsView inLiveResize]) {
  134 + savedIndex = [layout objectIndexAtTopOfScreen];
  135 + if (savedIndex >=0) {
  136 + CGRect v = [self.layout visibleRect];
  137 + CGRect r = [self.layout rectForViewAtIndex:savedIndex];
  138 + if (layout.typeOfLayout == AHLayoutHorizontal) {
  139 + relativeOffset = ((v.origin.x + v.size.width) - (r.origin.x + r.size.width));
  140 + relativeOffset += (lastBounds.size.width - bounds.size.width);
  141 + relativeOffset += resizingXOffset;
  142 + } else {
  143 + relativeOffset = ((v.origin.y + v.size.height) - (r.origin.y + r.size.height));
  144 + relativeOffset += (lastBounds.size.height - bounds.size.height);
  145 + relativeOffset += resizingYOffset;
  146 + }
  147 + }
  148 + }
  149 +
  150 +
  151 + if (!calculated || !CGSizeEqualToSize(bounds.size, lastBounds.size)) {
  152 + if (!self.shouldNotCallDelegate) self.contentSize = CGSizeZero; //reset the contentSize
  153 + [self calculateContentSize];
  154 + [self processChangeList];
  155 + [self calculateObjectOffsets];
  156 + calculated = YES;
  157 + }
  158 + lastBounds = bounds;
  159 +
  160 + if (self.shouldAnimate && phase != AHLayoutTransactionPhaseDoneAnimating) {
  161 + if (phase == AHLayoutTransactionPhaseNormal) {
  162 + phase = AHLayoutTransactionPhasePrelayout;
  163 + self.shouldAnimate = NO;
  164 + // Perform a prelayout transaction where we bring in needed subviews
  165 + // into their old location so that the animations looks ok
  166 + [CATransaction begin];
  167 + __weak NSMA *weakCompletionBlocks = completionBlocks;
  168 + __weak AHLayoutTransaction *weakSelf = self;
  169 + [CATransaction setCompletionBlock:^{
  170 + // In this CATransaction we animate the layout
  171 + weakSelf.phase = AHLayoutTransactionPhaseAnimating;
  172 + [CATransaction begin];
  173 + [CATransaction setCompletionBlock:^{
  174 + if (changeList.count > 0) {
  175 + for (AHLayoutObject *object in changeList)
  176 + object.markedForInsertion = object.markedForRemoval = object.markedForUpdate = NO;
  177 + [changeList removeAllObjects];
  178 + }
  179 + weakSelf.phase = AHLayoutTransactionPhaseNormal;
  180 + shouldAnimate = NO;
  181 + if (viewsToRemove.count > 0) {
  182 + for (TUIV*v in viewsToRemove) {
  183 + [v removeFromSuperview];
  184 + [self.layout enqueueReusableView:v];
  185 + }
  186 + }
  187 + if (!CGRectEqualToRect(layout.visibleRect, nextVisibleRect)) {
  188 + NSLog(@"Visible rect calculation is wrong\nTransaction: %@\nLayout: %@", NSStringFromRect(nextVisibleRect), NSStringFromRect(layout.visibleRect));
  189 + }
  190 + for (AHLayoutHandler block in weakCompletionBlocks) block(weakSelf.layout);
  191 + }];
  192 +
  193 + CGFloat duration = weakSelf.animationDuration > 0 ? weakSelf.animationDuration : kAHLayoutDefaultAnimationDuration;
  194 +
  195 + layout.contentSize = contentSize;
  196 +
  197 + [TUIView animateWithDuration:duration animations:^{
  198 + // Time for the key animation...
  199 + // animate changing the content offset, moving the views,
  200 + // and a user supplied animation block together
  201 + weakSelf.layout.contentOffset = contentOffset;
  202 + [self moveViews];
  203 + if (weakSelf.animationBlock) weakSelf.animationBlock(weakSelf.layout);
  204 + }];
  205 + [CATransaction commit];
  206 + }];
  207 +
  208 + // Process insertions and removals
  209 + [weakSelf rebaseForInsertionsAndRemovals];
  210 + AHLayoutObject *scrollToObject = nil;
  211 + if (scrollToObjectIndex >= 0 && layout.objects.count > scrollToObjectIndex)
  212 + scrollToObject = [layout.objects objectAtIndex:scrollToObjectIndex];
  213 +
  214 + contentOffset = layout.contentOffset;
  215 + [self calculateNextVisibleRect];
  216 + // Now refine the contentOffset a bit more to make sure we scroll to the right object
  217 + if (scrollToObject) {
  218 + // scroll the view to bottom or left
  219 + CGRect r = scrollToObject.calculatedFrame;
  220 + contentOffset = self.layout.typeOfLayout == AHLayoutHorizontal ? CGPointMake(-r.origin.x, 0)
  221 + : CGPointMake(0, -r.origin.y);
  222 + }
  223 + contentOffset = [self fixContentOffset:contentOffset forSize:contentSize inBounds:layout.bounds];
  224 + [self calculateNextVisibleRect];
  225 +
  226 + objectIndexesToBringIntoView = [self objectIndexesInRect:nextVisibleRect];
  227 +
  228 + // Bring in any needed views needed for the animation
  229 + // Existing subviews will come in using their old frames
  230 + [self addNewlyVisibleSubviews];
  231 + // This ensures that the newly added subviews are added before the animation
  232 + // This will kick off multiple layout passes all occuring with old frames before the animation
  233 + [CATransaction commit];
  234 + }
  235 + } else {
  236 + [TUIView setAnimationsEnabled:NO block:^{
  237 + // maintain position after new layout
  238 + if (savedIndex >=0 && relativeOffset >= 0) {
  239 + CGRect v = [self.layout visibleRect];
317 240 CGRect r = [self.layout rectForViewAtIndex:savedIndex];
318   - if (layout.typeOfLayout == AHLayoutHorizontal) {
319   - r.origin.x -= (v.size.width - r.size.width);
320   - r.size.width += (v.size.width - r.size.width);
321   - r.origin.x += relativeOffset;
322   - } else {
323   - r.origin.y -= (v.size.height - r.size.height);
324   - r.size.height += (v.size.height - r.size.height);
325   - r.origin.y += relativeOffset;
326   - }
  241 + if (layout.typeOfLayout == AHLayoutHorizontal) {
  242 + r.origin.x -= (v.size.width - r.size.width);
  243 + r.size.width += (v.size.width - r.size.width);
  244 + r.origin.x += relativeOffset;
  245 + } else {
  246 + r.origin.y -= (v.size.height - r.size.height);
  247 + r.size.height += (v.size.height - r.size.height);
  248 + r.origin.y += relativeOffset;
  249 + }
327 250 [self.layout scrollRectToVisible:r animated:NO];
328   - }
329   - else if (self.maintainContentOffset) {
330   - if (layout.typeOfLayout == AHLayoutHorizontal) {
331   - CGFloat newOffset = previousXOffset - self.contentSize.width - resizingXOffset;
332   - self.contentOffset = CGPointMake(newOffset, self.layout.contentOffset.y);
333   - } else {
334   - CGFloat newOffset = previousYOffset - self.contentSize.height - resizingYOffset;
335   - self.contentOffset = CGPointMake(self.layout.contentOffset.x, newOffset);
336   - }
337   - }
338   -
339   - layout.contentSize = contentSize;
340   - if (!layout.didFirstLayout && (layout.objects.count > 0)) {
341   - [layout scrollToTopAnimated:NO];
342   - layout.didFirstLayout = YES;
343   - }
344   - [self calculateNextVisibleRect];
345   -
346   - objectIndexesToBringIntoView = [self objectIndexesInRect:nextVisibleRect];
347   - [self addNewlyVisibleSubviews];
348   - [self moveViews];
349   - [self cleanup];
350   - }];
351   - }
352   -
  251 + }
  252 + else if (self.maintainContentOffset) {
  253 + if (layout.typeOfLayout == AHLayoutHorizontal) {
  254 + CGFloat newOffset = previousXOffset - self.contentSize.width - resizingXOffset;
  255 + self.contentOffset = CGPointMake(newOffset, self.layout.contentOffset.y);
  256 + } else {
  257 + CGFloat newOffset = previousYOffset - self.contentSize.height - resizingYOffset;
  258 + self.contentOffset = CGPointMake(self.layout.contentOffset.x, newOffset);
  259 + }
  260 + }
  261 +
  262 + layout.contentSize = contentSize;
  263 + if (!layout.didFirstLayout && (layout.objects.count > 0)) {
  264 + [layout scrollToTopAnimated:NO];
  265 + layout.didFirstLayout = YES;
  266 + }
  267 + [self calculateNextVisibleRect];
  268 +
  269 + objectIndexesToBringIntoView = [self objectIndexesInRect:nextVisibleRect];
  270 + [self addNewlyVisibleSubviews];
  271 + [self moveViews];
  272 + [self cleanup];
  273 + }];
  274 + }