Permalink
Browse files

merging upstrream

  • Loading branch information...
2 parents 41f4d8d + 57a6f05 commit cef8e1bf081ac0ee8656451238d9a5d6f00a8c40 @mralexgray committed Apr 2, 2013
Showing with 8,178 additions and 2,652 deletions.
  1. +22 −0 CONTRIBUTING.md
  2. 0 ExampleProject/Example/Example-Info.plist
  3. 0 ExampleProject/Example/Example-Prefix.pch
  4. 0 ExampleProject/Example/ExampleAppDelegate.h
  5. 0 ExampleProject/Example/ExampleAppDelegate.m
  6. +2 −2 ExampleProject/Example/ExampleScrollView.h
  7. +2 −2 ExampleProject/Example/ExampleScrollView.m
  8. 0 ExampleProject/Example/ExampleSectionHeaderView.h
  9. +8 −0 ExampleProject/Example/ExampleSectionHeaderView.m
  10. +6 −9 ExampleProject/Example/ExampleTabBar.h
  11. +154 −46 ExampleProject/Example/ExampleTabBar.m
  12. +16 −0 ExampleProject/Example/ExampleTableViewController.h
  13. +228 −0 ExampleProject/Example/ExampleTableViewController.m
  14. BIN ExampleProject/Example/clock.png
  15. BIN ExampleProject/Example/clock@2x.png
  16. 0 ExampleProject/Example/en.lproj/Credits.rtf
  17. 0 ExampleProject/Example/en.lproj/InfoPlist.strings
  18. +23 −71 ExampleProject/Example/en.lproj/MainMenu.xib
  19. BIN ExampleProject/Example/large-image.jpeg
  20. +0 −8 ExampleProject/Example/main.m
  21. +62 −0 LICENSE.md
  22. +0 −27 LICENSE.txt
  23. +7 −8 README.md
  24. +31 −0 TwUI-cop.podspec
  25. +168 −81 TwUI.xcodeproj/project.pbxproj
  26. 0 TwUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  27. 0 TwUI.xcodeproj/xcshareddata/xcschemes/Dynamic Library.xcscheme
  28. 0 TwUI.xcodeproj/xcshareddata/xcschemes/Static Library.xcscheme
  29. 0 TwUI.xcodeproj/xcshareddata/xcschemes/TwUI.xcscheme
  30. +2 −2 lib/Support/ABActiveRange.h
  31. +1 −1 lib/Support/ABActiveRange.m
  32. +4 −6 lib/Support/CoreText+Additions.h
  33. +38 −5 lib/Support/CoreText+Additions.m
  34. +11 −1 lib/UIKit/{TUIKit.m → NSAffineTransform+TUIExtensions.h}
  35. +50 −0 lib/UIKit/NSAffineTransform+TUIExtensions.m
  36. +44 −0 lib/UIKit/NSBezierPath+TUIExtensions.h
  37. +230 −0 lib/UIKit/NSBezierPath+TUIExtensions.m
  38. +13 −1 lib/UIKit/NSColor+TUIExtensions.m
  39. +5 −2 lib/UIKit/{TUIView+NSTextInputClient.m → NSShadow+TUIExtensions.h}
  40. +11 −2 lib/UIKit/{TUIView+NSTextInputClient.h → NSShadow+TUIExtensions.m}
  41. +34 −9 lib/UIKit/TUIActivityIndicatorView.h
  42. +121 −51 lib/UIKit/TUIActivityIndicatorView.m
  43. +9 −14 lib/UIKit/TUIAttributedString.h
  44. +0 −13 lib/UIKit/TUIAttributedString.m
  45. +0 −172 lib/UIKit/TUIButton+Content.m
  46. +187 −48 lib/UIKit/TUIButton.h
  47. +547 −181 lib/UIKit/TUIButton.m
  48. +12 −13 lib/UIKit/TUICGAdditions.h
  49. +12 −11 lib/UIKit/TUICGAdditions.m
  50. +51 −0 lib/UIKit/TUICarouselNavigationController.h
  51. +389 −0 lib/UIKit/TUICarouselNavigationController.m
  52. +0 −16 lib/UIKit/TUIControl+Private.h
  53. +0 −23 lib/UIKit/TUIControl+Private.m
  54. +0 −149 lib/UIKit/TUIControl+TargetAction.m
  55. +259 −46 lib/UIKit/TUIControl.h
  56. +330 −106 lib/UIKit/TUIControl.m
  57. +29 −17 lib/UIKit/TUIGeometry.h
  58. +31 −1 lib/UIKit/TUIGeometry.m
  59. +9 −4 lib/UIKit/TUIKit.h
  60. +1 −0 lib/UIKit/TUILabel.m
  61. +1 −1 lib/UIKit/TUILayoutConstraint.h
  62. +1 −0 lib/UIKit/TUILayoutManager.h
  63. +10 −0 lib/UIKit/TUILayoutManager.m
  64. +10 −15 lib/UIKit/TUINSView+Private.h
  65. +1 −4 lib/UIKit/TUINSView.h
  66. +204 −155 lib/UIKit/TUINSView.m
  67. +50 −0 lib/UIKit/TUINavigationController.h
  68. +451 −0 lib/UIKit/TUINavigationController.m
  69. +5 −8 lib/UIKit/TUIPopover.h
  70. +91 −102 lib/UIKit/TUIPopover.m
  71. +3 −6 lib/UIKit/TUIProgressBar.h
  72. +1 −1 lib/UIKit/TUIProgressBar.m
  73. +0 −248 lib/UIKit/TUIScrollKnob.m
  74. +28 −0 lib/UIKit/TUIScrollView+Private.h
  75. +53 −46 lib/UIKit/TUIScrollView.h
  76. +571 −388 lib/UIKit/TUIScrollView.m
  77. +8 −20 lib/UIKit/{TUIScrollKnob.h → TUIScroller.h}
  78. +490 −0 lib/UIKit/TUIScroller.m
  79. +79 −0 lib/UIKit/TUISlider.h
  80. +221 −0 lib/UIKit/TUISlider.m
  81. +1 −1 lib/UIKit/TUIStretchableImage.m
  82. +0 −17 lib/UIKit/TUIStyledView.h
  83. +0 −40 lib/UIKit/TUIStyledView.m
  84. +31 −0 lib/UIKit/TUITableOutlineView.h
  85. +565 −0 lib/UIKit/TUITableOutlineView.m
  86. +2 −0 lib/UIKit/TUITableView+Additions.h
  87. +10 −0 lib/UIKit/TUITableView+Additions.m
  88. +8 −0 lib/UIKit/TUITableView+Cell.m
  89. +24 −9 lib/UIKit/TUITableView.h
  90. +510 −193 lib/UIKit/TUITableView.m
  91. +7 −0 lib/UIKit/TUITableViewCell+Private.h
  92. +161 −20 lib/UIKit/TUITableViewCell.h
  93. +324 −92 lib/UIKit/TUITableViewCell.m
  94. +59 −0 lib/UIKit/TUITableViewController.h
  95. +82 −0 lib/UIKit/TUITableViewController.m
  96. +34 −0 lib/UIKit/TUITableViewMultiselection+Cell.h
  97. +393 −0 lib/UIKit/TUITableViewMultiselection+Cell.m
  98. +6 −0 lib/UIKit/TUITextEditor.h
  99. +47 −3 lib/UIKit/TUITextEditor.m
  100. +1 −1 lib/UIKit/TUITextField.m
  101. +52 −12 lib/UIKit/TUITextRenderer+Event.m
  102. +190 −11 lib/UIKit/TUITextRenderer+KeyBindings.m
  103. +17 −0 lib/UIKit/TUITextRenderer+Private.h
  104. +21 −4 lib/UIKit/TUITextRenderer.h
  105. +29 −16 lib/UIKit/TUITextRenderer.m
  106. +2 −0 lib/UIKit/TUITextView.h
  107. +50 −12 lib/UIKit/TUITextView.m
  108. +12 −0 lib/UIKit/TUIView+Event.h
  109. +71 −40 lib/UIKit/TUIView+Event.m
  110. +1 −0 lib/UIKit/TUIView+Layout.h
  111. +4 −0 lib/UIKit/TUIView+Layout.m
  112. +4 −0 lib/UIKit/TUIView+Private.h
  113. +9 −7 lib/UIKit/TUIView.h
  114. +11 −9 lib/UIKit/TUIView.m
  115. +3 −4 lib/UIKit/TUIViewController.h
  116. +0 −19 lib/UIKit/TUIViewController.m
View
@@ -0,0 +1,22 @@
+We love that you're interested in contributing to this project!
+
+**This fork of TwUI is feature-frozen.** Only _critical bug fixes_ will be
+accepted, and most significant changes in behavior will be rejected. We'd prefer
+to focus feature work on
+[Rebel](https://github.com/blog/1300-rebel-a-framework-for-improving-appkit).
+
+## Prefer Pull Requests
+
+If you know exactly how to fix the bug being reported, please open a pull
+request instead of an issue. Pull requests are easier than patches or inline
+code blocks for discussing and merging the changes.
+
+If you can't make the change yourself, please open an issue after making sure
+that one isn't already logged.
+
+## Contributing Code
+
+All code contributions should match our [coding
+conventions](https://github.com/github/objective-c-conventions).
+
+Thanks for contributing! :boom::camel:
View
No changes.
View
No changes.
View
No changes.
View
No changes.
View
@@ -19,7 +19,7 @@
@interface ExampleScrollView : TUIView
{
- TUIScrollView * _scrollView;
+ TUIScrollView * _scrollView;
}
-@end
+@end
View
@@ -25,7 +25,7 @@ - (id)initWithFrame:(CGRect)frame
_scrollView = [[TUIScrollView alloc] initWithFrame:self.bounds];
_scrollView.autoresizingMask = TUIViewAutoresizingFlexibleSize;
- _scrollView.scrollIndicatorStyle = TUIScrollViewIndicatorStyleDark;
+ _scrollView.scrollIndicatorStyle = TUIScrollViewIndicatorStyleDefault;
[self addSubview:_scrollView];
TUIImageView *imageView = [[TUIImageView alloc] initWithImage:[NSImage imageNamed:@"large-image.jpeg"]];
@@ -37,4 +37,4 @@ - (id)initWithFrame:(CGRect)frame
}
-@end
+@end
View
No changes.
View
@@ -68,4 +68,12 @@ -(void)drawRect:(CGRect)rect {
}
+//- (void)setFrame:(CGRect)frame;
+//{
+// if ([[[self.labelRenderer attributedString] string] hasSuffix:@"5"]) {
+// NSLog(@"cll %@ fr: %@", [self.labelRenderer.attributedString string], NSStringFromRect(frame));
+// }
+// [super setFrame:frame];
+//}
+
@end
View
@@ -19,23 +19,20 @@
@class ExampleTabBar;
@protocol ExampleTabBarDelegate <NSObject>
+
@required
- (void)tabBar:(ExampleTabBar *)tabBar didSelectTab:(NSInteger)index;
-@end
-/*
- An example of how to build a custom UI control, in this case a simple tab bar
- */
+@end
+// An example of how to build a custom UI control, in this case a simple tab bar.
@interface ExampleTabBar : TUIView
-{
- id<ExampleTabBarDelegate> __unsafe_unretained delegate;
- NSArray *tabViews;
-}
-- (id)initWithNumberOfTabs:(NSInteger)nTabs;
+- (id)initWithNumberOfTabs:(NSUInteger)count;
@property (nonatomic, unsafe_unretained) id<ExampleTabBarDelegate> delegate;
@property (nonatomic, readonly) NSArray *tabViews;
+- (BOOL)isHighlightingTab:(TUIView *)tab;
+
@end
View
@@ -16,82 +16,190 @@
#import "ExampleTabBar.h"
-@interface ExampleTab : TUIView
+@interface ExampleTab : TUIControl
+
+@property (nonatomic, assign) CGFloat originalPosition;
+@property (nonatomic, strong) NSTimer *flashTimer;
+
@end
+
@implementation ExampleTab
-- (ExampleTabBar *)tabBar
-{
+// Convinience to call delegate methods, since by default, our
+// superview SHOULD be a tab bar, and nothing else. This will
+// horribly crash if you add an ExampleTab to anything but a tab bar.
+- (ExampleTabBar *)tabBar {
return (ExampleTabBar *)self.superview;
}
-- (void)mouseDown:(NSEvent *)event
-{
- [super mouseDown:event]; // always call super when overriding mouseXXX: methods - lots of plumbing happens in TUIView
+// If a tracking event occurs within a tab, we want to move the
+// tab around, so return YES.
+- (BOOL)beginTrackingWithEvent:(NSEvent *)event {
[self setNeedsDisplay];
+
+ // So the tab doesn't move over just on mouse pressed.
+ self.originalPosition = [self convertPoint:[event locationInWindow] fromView:nil].x;
+
+ return YES;
+}
+
+// Find the tab that was being dragged- although this isn't the
+// most efficient way, this will suffice for now.
+- (BOOL)continueTrackingWithEvent:(NSEvent *)event {
+
+ // Offset the tab's x origin by whatever we dragged by.
+ CGFloat currentPosition = [self convertPoint:event.locationInWindow fromView:nil].x;
+
+ CGRect draggedRect = self.frame;
+ draggedRect.origin.x += roundf(currentPosition - self.originalPosition);
+ self.frame = draggedRect;
+
+ return YES;
}
-- (void)mouseUp:(NSEvent *)event
-{
- [super mouseUp:event];
+// Restore tabs to their original condition.
+- (void)endTrackingWithEvent:(NSEvent *)event {
- // rather than a simple -setNeedsDisplay, let's fade it back out
- [TUIView animateWithDuration:0.5 animations:^{
- [self redraw]; // -redraw forces a .contents update immediately based on drawRect, and it happens inside an animation block, so CoreAnimation gives us a cross-fade for free
+ // By nature, the event *must* be inside the tab's bounds, otherwise the
+ // tracking process will not be invoked. If we were dragged, we were NOT
+ // pressed, so don't call the delegate.
+ CGFloat currentPosition = [self convertPoint:event.locationInWindow fromView:nil].x;
+ if(self.originalPosition == currentPosition)
+ [self.tabBar.delegate tabBar:self.tabBar didSelectTab:self.tag];
+
+ // Since tracking is done, move the tab back. This whole ordeal lets us
+ // "stretch" our tabs around.
+ CGFloat originalPoint = self.tag * (self.tabBar.bounds.size.width / self.tabBar.tabViews.count);
+ [TUIView animateWithDuration:0.25f animations:^{
+ CGRect draggedRect = self.frame;
+ draggedRect.origin.x = roundf(originalPoint);
+ self.frame = draggedRect;
}];
- if([self eventInside:event]) { // only perform the action if the mouse up happened inside our bounds - ignores mouse down, drag-out, mouse up
- [[self tabBar].delegate tabBar:[self tabBar] didSelectTab:self.tag];
- }
+ // Rather than a simple -setNeedsDisplay, let's fade it back out.
+ [TUIView animateWithDuration:0.25f animations:^{
+
+ // -redraw forces a .contents update immediately based on drawRect,
+ // and it happens inside an animation block, so CoreAnimation gives
+ // us a cross-fade for free.
+ [self redraw];
+ }];
+}
+
+// End control tracking when cancelled for any reason.
+- (void)cancelTrackingWithEvent:(NSEvent *)event {
+ [self endTrackingWithEvent:event];
+}
+
+// When the tab is tapped with two fingers, let it pulse, otherwise
+// do nothing. To let it pulse, use the selected property and toggle it.
+- (void)touchesBeganWithEvent:(NSEvent *)event {
+ if([self touchesMatchingPhase:NSTouchPhaseTouching forEvent:event].count != 2)
+ return;
+
+ // Using -redraw within an animation block lets us crossfade
+ // the tab selection. When we finish this animation, queue
+ // the pulsing with a timer set repeat the -flash method.
+ [TUIView animateWithDuration:0.25f animations:^{
+ self.selected = YES;
+ [self redraw];
+ } completion:^(BOOL finished) {
+ if(finished) {
+ self.flashTimer = [NSTimer scheduledTimerWithTimeInterval:0.25f
+ target:self selector:@selector(flash)
+ userInfo:nil repeats:YES];
+ }
+ }];
+}
+
+// If the touches have ended, invalidate the timer and animate
+// back to the standard state, setting .selected as NO.
+- (void)touchesEndedWithEvent:(NSEvent *)event {
+ [self.flashTimer invalidate];
+ self.flashTimer = nil;
+
+ [TUIView animateWithDuration:0.25f animations:^{
+ self.selected = NO;
+ [self redraw];
+ }];
+}
+
+// End touch tracking when cancelled for any reason.
+- (void)touchesCancelledWithEvent:(NSEvent *)event {
+ [self touchesEndedWithEvent:event];
+}
+
+// This method, called from a timer, should pulse the tab by
+// flipping the .selected property value, and animating the change.
+- (void)flash {
+ [TUIView animateWithDuration:0.25f animations:^{
+ self.selected = !self.selected;
+ [self redraw];
+ }];
}
@end
-@implementation ExampleTabBar
+@interface ExampleTabBar ()
+
+@property (nonatomic, assign) ExampleTab *draggingTab;
-@synthesize delegate;
-@synthesize tabViews;
+@end
+
+@implementation ExampleTabBar
-- (id)initWithNumberOfTabs:(NSInteger)nTabs
-{
+- (id)initWithNumberOfTabs:(NSUInteger)count {
if((self = [super initWithFrame:CGRectZero])) {
- NSMutableArray *_tabViews = [NSMutableArray arrayWithCapacity:nTabs];
- for(int i = 0; i < nTabs; ++i) {
- ExampleTab *t = [[ExampleTab alloc] initWithFrame:CGRectZero];
- t.tag = i;
- t.layout = ^(TUIView *v) { // the layout of an individual tab is a function of the superview bounds, the number of tabs, and the current tab index
- CGRect b = v.superview.bounds; // reference the passed-in 'v' rather than 't' to avoid a retain cycle
- float width = b.size.width / nTabs;
- float x = i * width;
- return CGRectMake(roundf(x), 0, roundf(width), b.size.height);
+ NSMutableArray *tabs = [NSMutableArray arrayWithCapacity:count];
+
+ for(int i = 0; i < count; ++i) {
+ ExampleTab *tab = [[ExampleTab alloc] initWithFrame:CGRectZero];
+ tab.acceptsTouchEvents = YES;
+ tab.wantsRestingTouches = YES;
+ tab.tag = i;
+
+ // The layout of an individual tab is a function of the superview bounds,
+ // the number of tabs, and the current tab index.
+ // Reference the passed-in 'view' rather than 'tab' to avoid a retain cycle.
+ tab.layout = ^(TUIView *view) {
+ CGRect rect = view.superview.bounds;
+ CGFloat width = (rect.size.width / count);
+ return CGRectMake(roundf(i * width), 0, roundf(width), CGRectGetHeight(rect));
};
- [self addSubview:t];
- [_tabViews addObject:t];
+
+ [self addSubview:tab];
+ [tabs addObject:tab];
}
- tabViews = [[NSArray alloc] initWithArray:_tabViews];
+ _tabViews = [[NSArray alloc] initWithArray:tabs];
}
return self;
}
-- (void)drawRect:(CGRect)rect
-{
- // draw tab bar background
-
- CGRect b = self.bounds;
+- (void)drawRect:(CGRect)rect {
CGContextRef ctx = TUIGraphicsGetCurrentContext();
- // gray gradient
- CGFloat colorA[] = { 0.85, 0.85, 0.85, 1.0 };
- CGFloat colorB[] = { 0.71, 0.71, 0.71, 1.0 };
- CGContextDrawLinearGradientBetweenPoints(ctx, CGPointMake(0, b.size.height), colorA, CGPointMake(0, 0), colorB);
+ // Drawing the bar gradient using CGContextRef functions.
+ CGFloat colorA[] = { 0.85f, 0.85f, 0.85f, 1.0f };
+ CGFloat colorB[] = { 0.71f, 0.71f, 0.71f, 1.0f };
+ CGContextDrawLinearGradientBetweenPoints(ctx, CGPointMake(0, CGRectGetHeight(self.bounds)),
+ colorA, CGPointMake(0, 0), colorB);
+
+ // Drawing the separator etch using Cocoa Graphics objects.
+ [[NSColor colorWithCalibratedWhite:1.0f alpha:0.5f] set];
+ [[NSBezierPath bezierPathWithRect:CGRectMake(0, CGRectGetHeight(self.bounds) - 2, CGRectGetWidth(self.bounds), 1)] fill];
+ [[NSColor colorWithCalibratedWhite:0.0f alpha:0.25f] set];
+ [[NSBezierPath bezierPathWithRect:CGRectMake(0, CGRectGetHeight(self.bounds) - 1, CGRectGetWidth(self.bounds), 1)] fill];
+}
+
+- (BOOL)isHighlightingTab:(TUIView *)tab {
+ if(![self.tabViews containsObject:tab])
+ return NO;
- // top emboss
- CGContextSetRGBFillColor(ctx, 1, 1, 1, 0.5);
- CGContextFillRect(ctx, CGRectMake(0, b.size.height-2, b.size.width, 1));
- CGContextSetRGBFillColor(ctx, 0, 0, 0, 0.3);
- CGContextFillRect(ctx, CGRectMake(0, b.size.height-1, b.size.width, 1));
+ if([(ExampleTab *)tab state] & (TUIControlStateHighlighted | TUIControlStateSelected))
+ return YES;
+ else return NO;
}
@end
@@ -0,0 +1,16 @@
+//
+// ExampleTableViewController.h
+// Example
+//
+// Created by Max Goedjen on 11/13/12.
+//
+//
+
+#import "TUIKit.h"
+#import "TUITableOutlineView.h"
+
+@interface ExampleTableViewController : TUIViewController <TUITableViewDelegate, TUITableViewDataSource>
+
+@property (nonatomic, strong) TUITableOutlineView *tableView;
+
+@end
Oops, something went wrong.

0 comments on commit cef8e1b

Please sign in to comment.