Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into remove-tuicolor

Conflicts:
	lib/UIKit/TUIKit.h
  • Loading branch information...
commit 049f703decbf88ab742e674a66768a97b688a063 2 parents 53cadad + 574340d
Justin Spahr-Summers jspahrsummers authored
14 ExampleProject/ConcordeExample/ExampleView.m
View
@@ -129,7 +129,7 @@ - (NSInteger)tableView:(TUITableView *)table numberOfRowsInSection:(NSInteger)se
return 25;
}
-- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(TUIFastIndexPath *)indexPath
+- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50.0;
}
@@ -144,7 +144,7 @@ - (TUIView *)tableView:(TUITableView *)tableView headerViewForSection:(NSInteger
return view;
}
-- (TUITableViewCell *)tableView:(TUITableView *)tableView cellForRowAtIndexPath:(TUIFastIndexPath *)indexPath
+- (TUITableViewCell *)tableView:(TUITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ExampleTableViewCell *cell = reusableTableCellOfClass(tableView, ExampleTableViewCell);
@@ -157,7 +157,7 @@ - (TUITableViewCell *)tableView:(TUITableView *)tableView cellForRowAtIndexPath:
return cell;
}
-- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event
+- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(NSIndexPath *)indexPath withEvent:(NSEvent *)event
{
if([event clickCount] == 1) {
// do something cool
@@ -167,7 +167,7 @@ - (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndex
// show context menu
}
}
-- (BOOL)tableView:(TUITableView *)tableView shouldSelectRowAtIndexPath:(TUIFastIndexPath *)indexPath forEvent:(NSEvent *)event{
+- (BOOL)tableView:(TUITableView *)tableView shouldSelectRowAtIndexPath:(NSIndexPath *)indexPath forEvent:(NSEvent *)event{
switch (event.type) {
case NSRightMouseDown:
return NO;
@@ -176,19 +176,19 @@ - (BOOL)tableView:(TUITableView *)tableView shouldSelectRowAtIndexPath:(TUIFastI
return YES;
}
--(BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(TUIFastIndexPath *)indexPath {
+-(BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// return TRUE to enable row reordering by dragging; don't implement this method or return
// FALSE to disable
return TRUE;
}
--(void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath {
+-(void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
// update the model to reflect the changed index paths; since this example isn't backed by
// a "real" model, after dropping a cell the table will revert to it's previous state
NSLog(@"Move dragged row: %@ => %@", fromIndexPath, toIndexPath);
}
--(TUIFastIndexPath *)tableView:(TUITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(TUIFastIndexPath *)fromPath toProposedIndexPath:(TUIFastIndexPath *)proposedPath {
+-(NSIndexPath *)tableView:(TUITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)fromPath toProposedIndexPath:(NSIndexPath *)proposedPath {
// optionally revise the drag-to-reorder drop target index path by returning a different index path
// than proposedPath. if proposedPath is suitable, return that. if this method is not implemented,
// proposedPath is used by default.
12 TwUI.xcodeproj/project.pbxproj
View
@@ -30,7 +30,6 @@
5EE983C513BE7834005F430D /* TUICGAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4813BE6E1900C85CB5 /* TUICGAdditions.m */; };
5EE983C713BE7834005F430D /* TUIControl+TargetAction.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4B13BE6E1900C85CB5 /* TUIControl+TargetAction.m */; };
5EE983C813BE7834005F430D /* TUIControl.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */; };
- 5EE983C913BE7834005F430D /* TUIFastIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */; };
5EE983CB13BE7834005F430D /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
5EE983CE13BE7834005F430D /* TUIImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5913BE6E1900C85CB5 /* TUIImageView.m */; };
5EE983CF13BE7834005F430D /* TUILabel.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5D13BE6E1900C85CB5 /* TUILabel.m */; };
@@ -143,7 +142,6 @@
CB5E322613BE70CA004B7899 /* TUICGAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4813BE6E1900C85CB5 /* TUICGAdditions.m */; };
CB5E322913BE70CA004B7899 /* TUIControl+TargetAction.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4B13BE6E1900C85CB5 /* TUIControl+TargetAction.m */; };
CB5E322B13BE70CA004B7899 /* TUIControl.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */; };
- CB5E322D13BE70CA004B7899 /* TUIFastIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */; };
CB5E323113BE70CA004B7899 /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
CB5E323713BE70CA004B7899 /* TUIImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5913BE6E1900C85CB5 /* TUIImageView.m */; };
CB5E323913BE70CA004B7899 /* TUIKit.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5B13BE6E1900C85CB5 /* TUIKit.m */; };
@@ -195,8 +193,6 @@
CBB74CA213BE6E1900C85CB5 /* TUIControl+TargetAction.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4B13BE6E1900C85CB5 /* TUIControl+TargetAction.m */; };
CBB74CA313BE6E1900C85CB5 /* TUIControl.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C4C13BE6E1900C85CB5 /* TUIControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
CBB74CA413BE6E1900C85CB5 /* TUIControl.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */; };
- CBB74CA513BE6E1900C85CB5 /* TUIFastIndexPath.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C4E13BE6E1900C85CB5 /* TUIFastIndexPath.h */; settings = {ATTRIBUTES = (Public, ); }; };
- CBB74CA613BE6E1900C85CB5 /* TUIFastIndexPath.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */; };
CBB74CA913BE6E1900C85CB5 /* TUIGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C5213BE6E1900C85CB5 /* TUIGeometry.h */; settings = {ATTRIBUTES = (Public, ); }; };
CBB74CAA13BE6E1900C85CB5 /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
CBB74CAF13BE6E1900C85CB5 /* TUIImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C5813BE6E1900C85CB5 /* TUIImageView.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -500,8 +496,6 @@
CBB74C4B13BE6E1900C85CB5 /* TUIControl+TargetAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIControl+TargetAction.m"; sourceTree = "<group>"; };
CBB74C4C13BE6E1900C85CB5 /* TUIControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIControl.h; sourceTree = "<group>"; };
CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIControl.m; sourceTree = "<group>"; };
- CBB74C4E13BE6E1900C85CB5 /* TUIFastIndexPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIFastIndexPath.h; sourceTree = "<group>"; };
- CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIFastIndexPath.m; sourceTree = "<group>"; };
CBB74C5213BE6E1900C85CB5 /* TUIGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIGeometry.h; sourceTree = "<group>"; };
CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIGeometry.m; sourceTree = "<group>"; };
CBB74C5813BE6E1900C85CB5 /* TUIImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIImageView.h; sourceTree = "<group>"; };
@@ -795,8 +789,6 @@
CBB74C4B13BE6E1900C85CB5 /* TUIControl+TargetAction.m */,
CBB74C4C13BE6E1900C85CB5 /* TUIControl.h */,
CBB74C4D13BE6E1900C85CB5 /* TUIControl.m */,
- CBB74C4E13BE6E1900C85CB5 /* TUIFastIndexPath.h */,
- CBB74C4F13BE6E1900C85CB5 /* TUIFastIndexPath.m */,
CBB74C5213BE6E1900C85CB5 /* TUIGeometry.h */,
CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */,
D0C7650415B6156A00E7AC2C /* TUIHostView.h */,
@@ -966,7 +958,6 @@
CBB74C9E13BE6E1900C85CB5 /* TUICGAdditions.h in Headers */,
30D39A0D156D8F71006ECDAE /* TUIProgressBar.h in Headers */,
CBB74CA313BE6E1900C85CB5 /* TUIControl.h in Headers */,
- CBB74CA513BE6E1900C85CB5 /* TUIFastIndexPath.h in Headers */,
CBB74CA913BE6E1900C85CB5 /* TUIGeometry.h in Headers */,
88D81CFF1577EF0D009D453B /* TUIStyledView.h in Headers */,
887C227B15C1C7BB006EC31D /* NSFont+TUIExtensions.h in Headers */,
@@ -1283,7 +1274,6 @@
5EE983C513BE7834005F430D /* TUICGAdditions.m in Sources */,
5EE983C713BE7834005F430D /* TUIControl+TargetAction.m in Sources */,
5EE983C813BE7834005F430D /* TUIControl.m in Sources */,
- 5EE983C913BE7834005F430D /* TUIFastIndexPath.m in Sources */,
5EE983CB13BE7834005F430D /* TUIGeometry.m in Sources */,
5EE983CE13BE7834005F430D /* TUIImageView.m in Sources */,
5EE983CF13BE7834005F430D /* TUILabel.m in Sources */,
@@ -1356,7 +1346,6 @@
CBB74C9F13BE6E1900C85CB5 /* TUICGAdditions.m in Sources */,
CBB74CA213BE6E1900C85CB5 /* TUIControl+TargetAction.m in Sources */,
CBB74CA413BE6E1900C85CB5 /* TUIControl.m in Sources */,
- CBB74CA613BE6E1900C85CB5 /* TUIFastIndexPath.m in Sources */,
CBB74CAA13BE6E1900C85CB5 /* TUIGeometry.m in Sources */,
CBB74CB013BE6E1900C85CB5 /* TUIImageView.m in Sources */,
CBB74CB213BE6E1900C85CB5 /* TUIKit.m in Sources */,
@@ -1443,7 +1432,6 @@
CB5E322613BE70CA004B7899 /* TUICGAdditions.m in Sources */,
CB5E322913BE70CA004B7899 /* TUIControl+TargetAction.m in Sources */,
CB5E322B13BE70CA004B7899 /* TUIControl.m in Sources */,
- CB5E322D13BE70CA004B7899 /* TUIFastIndexPath.m in Sources */,
CB5E323113BE70CA004B7899 /* TUIGeometry.m in Sources */,
CB5E323713BE70CA004B7899 /* TUIImageView.m in Sources */,
CB5E323913BE70CA004B7899 /* TUIKit.m in Sources */,
2  lib/UIKit/TUIControl+Accessibility.m
View
@@ -31,7 +31,7 @@ - (NSString *)accessibilityActionDescription:(NSString *)action
- (void)accessibilityPerformAction:(NSString *)action
{
if([action isEqualToString:NSAccessibilityPressAction]) {
- [self sendActionsForControlEvents:TUIControlEventAllTouchEvents];
+ [self sendActionsForControlEvents:TUIControlEventAllMouseEvents];
}
}
10 lib/UIKit/TUIControl.h
View
@@ -17,13 +17,13 @@
#import "TUIView.h"
enum {
- TUIControlEventTouchDown = 1 << 0,
- TUIControlEventTouchDownRepeat = 1 << 1,
- TUIControlEventTouchUpInside = 1 << 6,
- TUIControlEventTouchUpOutside = 1 << 7,
+ TUIControlEventMouseDown = 1 << 0,
+ TUIControlEventMouseDownRepeat = 1 << 1,
+ TUIControlEventMouseUpInside = 1 << 6,
+ TUIControlEventMouseUpOutside = 1 << 7,
TUIControlEventValueChanged = 1 << 12,
TUIControlEventEditingDidEndOnExit = 1 << 19,
- TUIControlEventAllTouchEvents = 0x00000FFF,
+ TUIControlEventAllMouseEvents = 0x00000FFF,
TUIControlEventAllEditingEvents = 0x000F0000,
TUIControlEventApplicationReserved = 0x0F000000,
TUIControlEventSystemReserved = 0xF0000000,
8 lib/UIKit/TUIControl.m
View
@@ -134,9 +134,9 @@ - (void)mouseDown:(NSEvent *)event
// handle touch down
if([event clickCount] < 2) {
- [self sendActionsForControlEvents:TUIControlEventTouchDown];
+ [self sendActionsForControlEvents:TUIControlEventMouseDown];
} else {
- [self sendActionsForControlEvents:TUIControlEventTouchDownRepeat];
+ [self sendActionsForControlEvents:TUIControlEventMouseDownRepeat];
}
// needs display
@@ -154,10 +154,10 @@ - (void)mouseUp:(NSEvent *)event
if([self eventInside:event]) {
if(![self didDrag]) {
- [self sendActionsForControlEvents:TUIControlEventTouchUpInside];
+ [self sendActionsForControlEvents:TUIControlEventMouseUpInside];
}
} else {
- [self sendActionsForControlEvents:TUIControlEventTouchUpOutside];
+ [self sendActionsForControlEvents:TUIControlEventMouseUpOutside];
}
// needs display
47 lib/UIKit/TUIFastIndexPath.h
View
@@ -1,47 +0,0 @@
-/*
- Copyright 2011 Twitter, Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this work except in compliance with the License.
- You may obtain a copy of the License in the LICENSE file, or at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import <Foundation/Foundation.h>
-
-#ifndef TUIFastIndexPath_DANGEROUS_ISEQUAL
-// maybe default this to 0?
-#define TUIFastIndexPath_DANGEROUS_ISEQUAL 1
-#endif
-
-#define TUIFastIndexPathFromNSIndexPath(indexPath) (((indexPath) != nil) ? [TUIFastIndexPath indexPathForRow:(indexPath).row inSection:(indexPath).section] : nil)
-#define NSIndexPathFromTUIFastIndexPath(indexPath) (((indexPath) != nil) ? [NSIndexPath indexPathForRow:(indexPath).row inSection:(indexPath).section] : nil)
-
-/**
- Note TUITableView uses this extensively, if you use want to use NSIndexPath to talk to table views you should turn TUIFastIndexPath_DANGEROUS_ISEQUAL to 0
- */
-@interface TUIFastIndexPath : NSObject <NSCopying, NSCoding> // only supports 2-index sec/row, fast versions of -hash, -isEqual, etc
-{
-@public
- NSUInteger section;
- NSUInteger row;
-}
-
-+ (TUIFastIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section;
-
-// duck type to NSIndexPath
-@property(nonatomic, readonly) NSUInteger section;
-@property(nonatomic, readonly) NSUInteger row;
-
-- (NSComparisonResult)compare:(TUIFastIndexPath *)i;
-- (BOOL)isEqual:(TUIFastIndexPath *)i;
-
-
-@end
137 lib/UIKit/TUIFastIndexPath.m
View
@@ -1,137 +0,0 @@
-/*
- Copyright 2011 Twitter, Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this work except in compliance with the License.
- You may obtain a copy of the License in the LICENSE file, or at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import "TUIFastIndexPath.h"
-
-/**
- Twitter for Mac timelines only use 1-section table views, with <1000 tweets in a list at a time
- This pre-allocated hunk of instances is all we ever really need to touch. Was a measurable win for us.
- */
-#define CACHE_COMMON_INDEX_PATHS 1024*10
-
-static struct TUIFastIndexPath_staticStruct {
- Class isa;
- NSInteger section;
- NSInteger row;
-} CommonIndexPaths[CACHE_COMMON_INDEX_PATHS];
-
-@interface TUIFastIndexPath_staticClass : TUIFastIndexPath
-@end
-
-@implementation TUIFastIndexPath_staticClass
-@end
-
-@implementation TUIFastIndexPath
-
-+ (void)initialize
-{
- if(self == [TUIFastIndexPath class]) {
- Class staticCls = [TUIFastIndexPath_staticClass class];
- for(int i = 0; i < CACHE_COMMON_INDEX_PATHS; ++i) {
- struct TUIFastIndexPath_staticStruct *f = &CommonIndexPaths[i];
- f->isa = staticCls;
- f->section = 0;
- f->row = i;
- }
- }
-}
-
-+ (TUIFastIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section
-{
- if(section == 0) {
- if(row < CACHE_COMMON_INDEX_PATHS) {
- return (__bridge TUIFastIndexPath *)&CommonIndexPaths[row];
- }
- }
-
- // actually have to make one
- TUIFastIndexPath *f = [[TUIFastIndexPath alloc] init];
- f->row = row;
- f->section = section;
- return f;
-}
-
-- (id)copyWithZone:(NSZone *)zone
-{
- return self; // change me if we ever do mutable index paths
-}
-
-- (id)initWithCoder:(NSCoder *)coder
-{
- self = [self init];
- section = [coder decodeIntegerForKey:@"s"];
- row = [coder decodeIntegerForKey:@"r"];
- return self;
-}
-
-- (void)encodeWithCoder:(NSCoder *)coder
-{
- [coder encodeInteger:section forKey:@"s"];
- [coder encodeInteger:row forKey:@"r"];
-}
-
-- (NSString *)description
-{
- return [NSString stringWithFormat:@"[%ld,%ld]", section, row];
-}
-
-- (NSUInteger)section
-{
- return section;
-}
-
-- (NSUInteger)row
-{
- return row;
-}
-
-- (NSUInteger)hash
-{
- return ((section << 28) ^ row); // assume we're going to have a lot more rows than sections
-}
-
-- (NSComparisonResult)compare:(TUIFastIndexPath *)i
-{
- NSUInteger s = i->section;
- NSUInteger r = i->row;
- if(section < s)
- return NSOrderedAscending;
- if(section > s)
- return NSOrderedDescending;
- if(row < r)
- return NSOrderedAscending;
- if(row > r)
- return NSOrderedDescending;
- return NSOrderedSame;
-}
-
-- (BOOL)isEqual:(TUIFastIndexPath *)i
-{
- if(!i)
- return NO;
-#if TUIFastIndexPath_DANGEROUS_ISEQUAL
- return ((row == i->row) && (section == i->section)); // assume it's a TUIFastIndexPath - this may be stupid for your app
-#else
- if([i isKindOfClass:[TUIFastIndexPath class]]
- return ((row == i->row) && (section == i->section));
- else if([i isKindOfClass:[NSIndexPath class]]) // we never hit this in T2
- return ((row == i.row) && (section == i.section));
- else
- return NO;
-#endif
-}
-
-@end
1  lib/UIKit/TUIKit.h
View
@@ -29,7 +29,6 @@
#import "TUIBridgedView.h"
#import "TUIButton.h"
#import "TUICGAdditions.h"
-#import "TUIFastIndexPath.h"
#import "TUIHostView.h"
#import "TUIImageView.h"
#import "TUILabel.h"
2  lib/UIKit/TUIStretchableImage.m
View
@@ -66,7 +66,7 @@ - (void)drawInRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSComposi
CGFloat verticalEdgeLength = fmax(0, size.height - insets.top - insets.bottom);
// Length of sides that run horizontally.
- CGFloat horizontalEdgeLength = fmax(0, size.height - insets.left - insets.right);
+ CGFloat horizontalEdgeLength = fmax(0, size.width - insets.left - insets.right);
NSImage *(^imageWithRect)(CGRect) = ^ id (CGRect rect){
CGImageRef part = CGImageCreateWithImageInRect(image, rect);
19 lib/UIKit/TUITableView+Cell.m
View
@@ -15,7 +15,6 @@
*/
#import "TUITableView+Cell.h"
-#import "TUIFastIndexPath.h"
// Dragged cells should be just above pinned headers
#define kTUITableViewDraggedCellZPosition 1001
@@ -122,7 +121,7 @@ -(void)__updateDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset loca
[self beginContinuousScrollForDragAtPoint:location animated:TRUE];
TUITableViewInsertionMethod insertMethod = TUITableViewInsertionMethodAtIndex;
- TUIFastIndexPath *currentPath = nil;
+ NSIndexPath *currentPath = nil;
NSInteger sectionIndex = -1;
// determine the current index path the cell is occupying
@@ -132,13 +131,13 @@ -(void)__updateDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset loca
// if we're on a section header (but not the first one, which can't move) which is above the origin
// index path we insert after the last index in the section above
NSInteger targetSectionIndex = sectionIndex - 1;
- currentPath = [TUIFastIndexPath indexPathForRow:[self numberOfRowsInSection:targetSectionIndex] - 1 inSection:targetSectionIndex];
+ currentPath = [NSIndexPath indexPathForRow:[self numberOfRowsInSection:targetSectionIndex] - 1 inSection:targetSectionIndex];
insertMethod = TUITableViewInsertionMethodAfterIndex;
}else{
// if we're on a section header below the origin index we insert before the first index in the
// section below
NSInteger targetSectionIndex = sectionIndex;
- currentPath = [TUIFastIndexPath indexPathForRow:0 inSection:targetSectionIndex];
+ currentPath = [NSIndexPath indexPathForRow:0 inSection:targetSectionIndex];
insertMethod = TUITableViewInsertionMethodBeforeIndex;
}
}
@@ -149,7 +148,7 @@ -(void)__updateDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset loca
// allow the delegate to revise the proposed index path if it wants to
if(self.delegate != nil && [self.delegate respondsToSelector:@selector(tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:)]){
- TUIFastIndexPath *proposedPath = currentPath;
+ NSIndexPath *proposedPath = currentPath;
currentPath = [self.delegate tableView:self targetIndexPathForMoveFromRowAtIndexPath:cell.indexPath toProposedIndexPath:currentPath];
// revised index paths always use the "at" insertion method
switch([currentPath compare:proposedPath]){
@@ -176,8 +175,8 @@ -(void)__updateDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset loca
NSComparisonResult currentDragDirection = (_previousDragToReorderIndexPath != nil) ? [currentPath compare:_previousDragToReorderIndexPath] : NSOrderedSame;
// ordered index paths for enumeration
- TUIFastIndexPath *fromIndexPath = nil;
- TUIFastIndexPath *toIndexPath = nil;
+ NSIndexPath *fromIndexPath = nil;
+ NSIndexPath *toIndexPath = nil;
if(currentDragDirection == NSOrderedAscending){
fromIndexPath = currentPath;
@@ -225,7 +224,7 @@ -(void)__updateDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset loca
}
// update rows
- [self enumerateIndexPathsFromIndexPath:fromIndexPath toIndexPath:toIndexPath withOptions:0 usingBlock:^(TUIFastIndexPath *indexPath, BOOL *stop) {
+ [self enumerateIndexPathsFromIndexPath:fromIndexPath toIndexPath:toIndexPath withOptions:0 usingBlock:^(NSIndexPath *indexPath, BOOL *stop) {
TUITableViewCell *displacedCell;
if((displacedCell = [self cellForRowAtIndexPath:indexPath]) != nil && ![displacedCell isEqual:cell]){
CGRect frame = [self rectForRowAtIndexPath:indexPath];
@@ -281,7 +280,7 @@ -(void)__endDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset locatio
// finalize drag to reorder if we have a drag index
if(_currentDragToReorderIndexPath != nil){
- TUIFastIndexPath *targetIndexPath;
+ NSIndexPath *targetIndexPath;
switch(_currentDragToReorderInsertionMethod){
case TUITableViewInsertionMethodBeforeIndex:
@@ -290,7 +289,7 @@ -(void)__endDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset locatio
targetIndexPath = _currentDragToReorderIndexPath;
break;
case TUITableViewInsertionMethodAfterIndex:
- targetIndexPath = [TUIFastIndexPath indexPathForRow:_currentDragToReorderIndexPath.row + 1 inSection:_currentDragToReorderIndexPath.section];
+ targetIndexPath = [NSIndexPath indexPathForRow:_currentDragToReorderIndexPath.row + 1 inSection:_currentDragToReorderIndexPath.section];
break;
case TUITableViewInsertionMethodAtIndex:
default:
68 lib/UIKit/TUITableView.h
View
@@ -16,8 +16,6 @@
#import "TUIScrollView.h"
-@class TUIFastIndexPath;
-
typedef enum {
TUITableViewStylePlain, // regular table view
TUITableViewStyleGrouped, // grouped table view—headers stick to the top of the table view and scroll with it
@@ -44,24 +42,24 @@ typedef enum {
@protocol TUITableViewDelegate<NSObject, TUIScrollViewDelegate>
-- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(TUIFastIndexPath *)indexPath;
+- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
@optional
-- (void)tableView:(TUITableView *)tableView willDisplayCell:(TUITableViewCell *)cell forRowAtIndexPath:(TUIFastIndexPath *)indexPath; // called after the cell's frame has been set but before it's added as a subview
-- (void)tableView:(TUITableView *)tableView didSelectRowAtIndexPath:(TUIFastIndexPath *)indexPath; // happens on left/right mouse down, key up/down
-- (void)tableView:(TUITableView *)tableView didDeselectRowAtIndexPath:(TUIFastIndexPath *)indexPath;
-- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event; // happens on left/right mouse up (can look at clickCount)
+- (void)tableView:(TUITableView *)tableView willDisplayCell:(TUITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; // called after the cell's frame has been set but before it's added as a subview
+- (void)tableView:(TUITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; // happens on left/right mouse down, key up/down
+- (void)tableView:(TUITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath;
+- (void)tableView:(TUITableView *)tableView didClickRowAtIndexPath:(NSIndexPath *)indexPath withEvent:(NSEvent *)event; // happens on left/right mouse up (can look at clickCount)
-- (BOOL)tableView:(TUITableView*)tableView shouldSelectRowAtIndexPath:(TUIFastIndexPath*)indexPath forEvent:(NSEvent*)event; // YES, if not implemented
-- (NSMenu *)tableView:(TUITableView *)tableView menuForRowAtIndexPath:(TUIFastIndexPath *)indexPath withEvent:(NSEvent *)event;
+- (BOOL)tableView:(TUITableView*)tableView shouldSelectRowAtIndexPath:(NSIndexPath*)indexPath forEvent:(NSEvent*)event; // YES, if not implemented
+- (NSMenu *)tableView:(TUITableView *)tableView menuForRowAtIndexPath:(NSIndexPath *)indexPath withEvent:(NSEvent *)event;
// the following are good places to update or restore state (such as selection) when the table data reloads
- (void)tableViewWillReloadData:(TUITableView *)tableView;
- (void)tableViewDidReloadData:(TUITableView *)tableView;
// the following is optional for row reordering
-- (TUIFastIndexPath *)tableView:(TUITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(TUIFastIndexPath *)fromPath toProposedIndexPath:(TUIFastIndexPath *)proposedPath;
+- (NSIndexPath *)tableView:(TUITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)fromPath toProposedIndexPath:(NSIndexPath *)proposedPath;
@end
@@ -81,19 +79,19 @@ typedef enum {
NSMutableDictionary * _visibleItems;
NSMutableDictionary * _reusableTableCells;
- TUIFastIndexPath * _selectedIndexPath;
- TUIFastIndexPath * _indexPathShouldBeFirstResponder;
+ NSIndexPath * _selectedIndexPath;
+ NSIndexPath * _indexPathShouldBeFirstResponder;
NSInteger _futureMakeFirstResponderToken;
- TUIFastIndexPath * _keepVisibleIndexPathForReload;
+ NSIndexPath * _keepVisibleIndexPathForReload;
CGFloat _relativeOffsetForReload;
// drag-to-reorder state
TUITableViewCell * _dragToReorderCell;
CGPoint _currentDragToReorderLocation;
CGPoint _currentDragToReorderMouseOffset;
- TUIFastIndexPath * _currentDragToReorderIndexPath;
+ NSIndexPath * _currentDragToReorderIndexPath;
TUITableViewInsertionMethod _currentDragToReorderInsertionMethod;
- TUIFastIndexPath * _previousDragToReorderIndexPath;
+ NSIndexPath * _previousDragToReorderIndexPath;
TUITableViewInsertionMethod _previousDragToReorderInsertionMethod;
struct {
@@ -122,7 +120,7 @@ typedef enum {
/**
The table view itself has mechanisms for maintaining scroll position. During a live resize the table view should automatically "do the right thing". This method may be useful during a reload if you want to stay in the same spot. Use it instead of -reloadData.
*/
-- (void)reloadDataMaintainingVisibleIndexPath:(TUIFastIndexPath *)indexPath relativeOffset:(CGFloat)relativeOffset;
+- (void)reloadDataMaintainingVisibleIndexPath:(NSIndexPath *)indexPath relativeOffset:(CGFloat)relativeOffset;
// Forces a re-calculation and re-layout of the table. This is most useful for animating the relayout. It is potentially _more_ expensive than -reloadData since it has to allow for animating.
- (void)reloadLayout;
@@ -132,35 +130,35 @@ typedef enum {
- (CGRect)rectForHeaderOfSection:(NSInteger)section;
- (CGRect)rectForSection:(NSInteger)section;
-- (CGRect)rectForRowAtIndexPath:(TUIFastIndexPath *)indexPath;
+- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSIndexSet *)indexesOfSectionsInRect:(CGRect)rect;
- (NSIndexSet *)indexesOfSectionHeadersInRect:(CGRect)rect;
-- (TUIFastIndexPath *)indexPathForCell:(TUITableViewCell *)cell; // returns nil if cell is not visible
+- (NSIndexPath *)indexPathForCell:(TUITableViewCell *)cell; // returns nil if cell is not visible
- (NSArray *)indexPathsForRowsInRect:(CGRect)rect; // returns nil if rect not valid
-- (TUIFastIndexPath *)indexPathForRowAtPoint:(CGPoint)point;
-- (TUIFastIndexPath *)indexPathForRowAtVerticalOffset:(CGFloat)offset;
+- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point;
+- (NSIndexPath *)indexPathForRowAtVerticalOffset:(CGFloat)offset;
- (NSInteger)indexOfSectionWithHeaderAtPoint:(CGPoint)point;
- (NSInteger)indexOfSectionWithHeaderAtVerticalOffset:(CGFloat)offset;
-- (void)enumerateIndexPathsUsingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block;
-- (void)enumerateIndexPathsWithOptions:(NSEnumerationOptions)options usingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block;
-- (void)enumerateIndexPathsFromIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath withOptions:(NSEnumerationOptions)options usingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block;
+- (void)enumerateIndexPathsUsingBlock:(void (^)(NSIndexPath *indexPath, BOOL *stop))block;
+- (void)enumerateIndexPathsWithOptions:(NSEnumerationOptions)options usingBlock:(void (^)(NSIndexPath *indexPath, BOOL *stop))block;
+- (void)enumerateIndexPathsFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath withOptions:(NSEnumerationOptions)options usingBlock:(void (^)(NSIndexPath *indexPath, BOOL *stop))block;
- (TUIView *)headerViewForSection:(NSInteger)section;
-- (TUITableViewCell *)cellForRowAtIndexPath:(TUIFastIndexPath *)indexPath; // returns nil if cell is not visible or index path is out of range
+- (TUITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath; // returns nil if cell is not visible or index path is out of range
- (NSArray *)visibleCells; // no particular order
- (NSArray *)sortedVisibleCells; // top to bottom
- (NSArray *)indexPathsForVisibleRows;
-- (void)scrollToRowAtIndexPath:(TUIFastIndexPath *)indexPath atScrollPosition:(TUITableViewScrollPosition)scrollPosition animated:(BOOL)animated;
+- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(TUITableViewScrollPosition)scrollPosition animated:(BOOL)animated;
-- (TUIFastIndexPath *)indexPathForSelectedRow; // return nil or index path representing section and row of selection.
-- (TUIFastIndexPath *)indexPathForFirstRow;
-- (TUIFastIndexPath *)indexPathForLastRow;
+- (NSIndexPath *)indexPathForSelectedRow; // return nil or index path representing section and row of selection.
+- (NSIndexPath *)indexPathForFirstRow;
+- (NSIndexPath *)indexPathForLastRow;
-- (void)selectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(TUITableViewScrollPosition)scrollPosition;
-- (void)deselectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated;
+- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(TUITableViewScrollPosition)scrollPosition;
+- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated;
/**
Above the top cell, only visible if you pull down (if you have scroll bouncing enabled)
@@ -184,19 +182,19 @@ typedef enum {
- (NSInteger)tableView:(TUITableView *)table numberOfRowsInSection:(NSInteger)section;
-- (TUITableViewCell *)tableView:(TUITableView *)tableView cellForRowAtIndexPath:(TUIFastIndexPath *)indexPath;
+- (TUITableViewCell *)tableView:(TUITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
@optional
- (TUIView *)tableView:(TUITableView *)tableView headerViewForSection:(NSInteger)section;
// the following are required to support row reordering
-- (BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(TUIFastIndexPath *)indexPath;
-- (void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath;
+- (BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;
+- (void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath;
// the following are required to support row reordering
-- (BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(TUIFastIndexPath *)indexPath;
-- (void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath;
+- (BOOL)tableView:(TUITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;
+- (void)tableView:(TUITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath;
/**
Default is 1 if not implemented
93 lib/UIKit/TUITableView.m
View
@@ -15,7 +15,6 @@
*/
#import "TUITableView.h"
-#import "TUIFastIndexPath.h"
#import "TUINSView.h"
#import "TUINSWindow.h"
#import "TUITableView+Cell.h"
@@ -82,7 +81,7 @@ - (void)_setupRowHeights
}
for(int i = 0; i < numberOfRows; ++i) {
- CGFloat h = roundf([_tableView.delegate tableView:_tableView heightForRowAtIndexPath:[TUIFastIndexPath indexPathForRow:i inSection:sectionIndex]]);
+ CGFloat h = roundf([_tableView.delegate tableView:_tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:sectionIndex]]);
rowInfo[i].offset = sectionHeight;
rowInfo[i].height = h;
sectionHeight += h;
@@ -236,7 +235,7 @@ - (CGRect)rectForSection:(NSInteger)section
return CGRectZero;
}
-- (CGRect)rectForRowAtIndexPath:(TUIFastIndexPath *)indexPath
+- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger section = indexPath.section;
NSInteger row = indexPath.row;
@@ -342,7 +341,7 @@ - (TUIView *)headerViewForSection:(NSInteger)section {
}
}
-- (TUITableViewCell *)cellForRowAtIndexPath:(TUIFastIndexPath *)indexPath // returns nil if cell is not visible or index path is out of range
+- (TUITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath // returns nil if cell is not visible or index path is out of range
{
return [_visibleItems objectForKey:indexPath];
}
@@ -376,9 +375,9 @@ - (NSArray *)indexPathsForVisibleRows
return INDEX_PATHS_FOR_VISIBLE_ROWS;
}
-- (TUIFastIndexPath *)indexPathForCell:(TUITableViewCell *)c
+- (NSIndexPath *)indexPathForCell:(TUITableViewCell *)c
{
- for(TUIFastIndexPath *i in _visibleItems) {
+ for(NSIndexPath *i in _visibleItems) {
TUITableViewCell *cell = [_visibleItems objectForKey:i];
if(cell == c)
return i;
@@ -431,7 +430,7 @@ - (NSArray *)indexPathsForRowsInRect:(CGRect)rect
for(TUITableViewSection *section in _sectionInfo) {
NSInteger numberOfRows = [section numberOfRows];
for(NSInteger row = 0; row < numberOfRows; ++row) {
- TUIFastIndexPath *indexPath = [TUIFastIndexPath indexPathForRow:row inSection:sectionIndex];
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:sectionIndex];
CGRect cellRect = [self rectForRowAtIndexPath:indexPath];
if(CGRectIntersectsRect(cellRect, rect)) {
[indexPaths addObject:indexPath];
@@ -453,12 +452,12 @@ - (NSArray *)indexPathsForRowsInRect:(CGRect)rect
* @param point location in the table view
* @return index path of the row at @p point
*/
-- (TUIFastIndexPath *)indexPathForRowAtPoint:(CGPoint)point {
+- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point {
NSInteger sectionIndex = 0;
for(TUITableViewSection *section in _sectionInfo){
for(NSInteger row = 0; row < [section numberOfRows]; row++){
- TUIFastIndexPath *indexPath = [TUIFastIndexPath indexPathForRow:row inSection:sectionIndex];
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:sectionIndex];
CGRect cellRect = [self rectForRowAtIndexPath:indexPath];
if(CGRectContainsPoint(cellRect, point)){
return indexPath;
@@ -479,12 +478,12 @@ - (TUIFastIndexPath *)indexPathForRowAtPoint:(CGPoint)point {
* @param offset y-coordinate offset in the table view
* @return index path of the row at @p offset
*/
-- (TUIFastIndexPath *)indexPathForRowAtVerticalOffset:(CGFloat)offset {
+- (NSIndexPath *)indexPathForRowAtVerticalOffset:(CGFloat)offset {
NSInteger sectionIndex = 0;
for(TUITableViewSection *section in _sectionInfo){
for(NSInteger row = 0; row < [section numberOfRows]; row++){
- TUIFastIndexPath *indexPath = [TUIFastIndexPath indexPathForRow:row inSection:sectionIndex];
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:sectionIndex];
CGRect cellRect = [self rectForRowAtIndexPath:indexPath];
if(offset >= cellRect.origin.y && offset <= (cellRect.origin.y + cellRect.size.height)){
return indexPath;
@@ -559,7 +558,7 @@ - (NSInteger)indexOfSectionWithHeaderAtVerticalOffset:(CGFloat)offset {
* @brief Enumerate index paths
* @see #enumerateIndexPathsFromIndexPath:toIndexPath:withOptions:usingBlock:
*/
-- (void)enumerateIndexPathsUsingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block {
+- (void)enumerateIndexPathsUsingBlock:(void (^)(NSIndexPath *indexPath, BOOL *stop))block {
[self enumerateIndexPathsFromIndexPath:nil toIndexPath:nil withOptions:0 usingBlock:block];
}
@@ -567,7 +566,7 @@ - (void)enumerateIndexPathsUsingBlock:(void (^)(TUIFastIndexPath *indexPath, BOO
* @brief Enumerate index paths
* @see #enumerateIndexPathsFromIndexPath:toIndexPath:withOptions:usingBlock:
*/
-- (void)enumerateIndexPathsWithOptions:(NSEnumerationOptions)options usingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block {
+- (void)enumerateIndexPathsWithOptions:(NSEnumerationOptions)options usingBlock:(void (^)(NSIndexPath *indexPath, BOOL *stop))block {
[self enumerateIndexPathsFromIndexPath:nil toIndexPath:nil withOptions:options usingBlock:block];
}
@@ -582,7 +581,7 @@ - (void)enumerateIndexPathsWithOptions:(NSEnumerationOptions)options usingBlock:
* @param options enumeration options (not currently supported; pass 0)
* @param block the block to enumerate with
*/
-- (void)enumerateIndexPathsFromIndexPath:(TUIFastIndexPath *)fromIndexPath toIndexPath:(TUIFastIndexPath *)toIndexPath withOptions:(NSEnumerationOptions)options usingBlock:(void (^)(TUIFastIndexPath *indexPath, BOOL *stop))block {
+- (void)enumerateIndexPathsFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath withOptions:(NSEnumerationOptions)options usingBlock:(void (^)(NSIndexPath *indexPath, BOOL *stop))block {
NSInteger sectionLowerBound = (fromIndexPath != nil) ? fromIndexPath.section : 0;
NSInteger sectionUpperBound = (toIndexPath != nil) ? toIndexPath.section : [self numberOfSections] - 1;
NSInteger rowLowerBound = (fromIndexPath != nil) ? fromIndexPath.row : 0;
@@ -593,7 +592,7 @@ - (void)enumerateIndexPathsFromIndexPath:(TUIFastIndexPath *)fromIndexPath toInd
NSInteger rowCount = [self numberOfRowsInSection:i];
for(NSInteger j = irow; j < rowCount && j <= ((rowUpperBound < 0 || i < sectionUpperBound) ? rowCount - 1 : rowUpperBound) /* inclusive */; j++){
BOOL stop = FALSE;
- block([TUIFastIndexPath indexPathForRow:j inSection:i], &stop);
+ block([NSIndexPath indexPathForRow:j inSection:i], &stop);
if(stop) return;
}
irow = 0; // ...then use zero for subsequent iterations
@@ -601,9 +600,9 @@ - (void)enumerateIndexPathsFromIndexPath:(TUIFastIndexPath *)fromIndexPath toInd
}
-- (TUIFastIndexPath *)_topVisibleIndexPath
+- (NSIndexPath *)_topVisibleIndexPath
{
- TUIFastIndexPath *topVisibleIndex = nil;
+ NSIndexPath *topVisibleIndex = nil;
NSArray *v = [INDEX_PATHS_FOR_VISIBLE_ROWS sortedArrayUsingSelector:@selector(compare:)];
if([v count])
topVisibleIndex = [v objectAtIndex:0];
@@ -657,7 +656,7 @@ - (BOOL)_preLayoutCells
// save scroll position
CGFloat previousOffset = 0.0f;
- TUIFastIndexPath *savedIndexPath = nil;
+ NSIndexPath *savedIndexPath = nil;
CGFloat relativeOffset = 0.0;
if(_tableFlags.maintainContentOffsetAfterReload) {
previousOffset = self.contentSize.height + self.contentOffset.y;
@@ -790,7 +789,7 @@ - (void)_layoutCells:(BOOL)visibleCellsNeedRelayout
if(visibleCellsNeedRelayout) {
// update remaining visible cells if needed
- for(TUIFastIndexPath *i in _visibleItems) {
+ for(NSIndexPath *i in _visibleItems) {
TUITableViewCell *cell = [_visibleItems objectForKey:i];
cell.frame = [self rectForRowAtIndexPath:i];
cell.layer.zPosition = 0;
@@ -816,7 +815,7 @@ - (void)_layoutCells:(BOOL)visibleCellsNeedRelayout
[indexPathsToAdd removeObjectsInArray:oldVisibleIndexPaths];
// remove offscreen cells
- for(TUIFastIndexPath *i in indexPathsToRemove) {
+ for(NSIndexPath *i in indexPathsToRemove) {
TUITableViewCell *cell = [self cellForRowAtIndexPath:i];
// don't reuse the dragged cell
if(_dragToReorderCell == nil || ![cell isEqual:_dragToReorderCell]){
@@ -827,7 +826,7 @@ - (void)_layoutCells:(BOOL)visibleCellsNeedRelayout
}
// add new cells
- for(TUIFastIndexPath *i in indexPathsToAdd) {
+ for(NSIndexPath *i in indexPathsToAdd) {
if([_visibleItems objectForKey:i]) {
NSLog(@"!!! Warning: already have a cell in place for index path %@\n\n\n", i);
} else {
@@ -915,7 +914,7 @@ - (BOOL)pullDownViewIsVisible
return NO;
}
-- (void)reloadDataMaintainingVisibleIndexPath:(TUIFastIndexPath *)indexPath relativeOffset:(CGFloat)relativeOffset
+- (void)reloadDataMaintainingVisibleIndexPath:(NSIndexPath *)indexPath relativeOffset:(CGFloat)relativeOffset
{
_keepVisibleIndexPathForReload = indexPath;
_relativeOffsetForReload = relativeOffset;
@@ -934,7 +933,7 @@ - (void)reloadData
// need to recycle all visible cells, have them be regenerated on layoutSubviews
// because the same cells might have different content
- for(TUIFastIndexPath *i in _visibleItems) {
+ for(NSIndexPath *i in _visibleItems) {
TUITableViewCell *cell = [_visibleItems objectForKey:i];
[self _enqueueReusableCell:cell];
[cell removeFromSuperview];
@@ -1004,7 +1003,7 @@ - (void)reloadLayout
[self _layoutCells:YES];
}
-- (void)scrollToRowAtIndexPath:(TUIFastIndexPath *)indexPath atScrollPosition:(TUITableViewScrollPosition)scrollPosition animated:(BOOL)animated
+- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(TUITableViewScrollPosition)scrollPosition animated:(BOOL)animated
{
CGRect v = [self visibleRect];
CGRect r = [self rectForRowAtIndexPath:indexPath];
@@ -1035,24 +1034,24 @@ - (void)scrollToRowAtIndexPath:(TUIFastIndexPath *)indexPath atScrollPosition:(T
}
-- (TUIFastIndexPath *)indexPathForSelectedRow
+- (NSIndexPath *)indexPathForSelectedRow
{
return _selectedIndexPath;
}
-- (TUIFastIndexPath *)indexPathForFirstRow
+- (NSIndexPath *)indexPathForFirstRow
{
- return [TUIFastIndexPath indexPathForRow:0 inSection:0];
+ return [NSIndexPath indexPathForRow:0 inSection:0];
}
-- (TUIFastIndexPath *)indexPathForLastRow
+- (NSIndexPath *)indexPathForLastRow
{
NSInteger sec = [self numberOfSections] - 1;
NSInteger row = [self numberOfRowsInSection:sec] - 1;
- return [TUIFastIndexPath indexPathForRow:row inSection:sec];
+ return [NSIndexPath indexPathForRow:row inSection:sec];
}
-- (void)_makeRowAtIndexPathFirstResponder:(TUIFastIndexPath *)indexPath
+- (void)_makeRowAtIndexPathFirstResponder:(NSIndexPath *)indexPath
{
TUITableViewCell *cell = [self cellForRowAtIndexPath:indexPath];
// only cells that accept first responder should be made first responder
@@ -1064,9 +1063,9 @@ - (void)_makeRowAtIndexPathFirstResponder:(TUIFastIndexPath *)indexPath
}
}
-- (void)selectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(TUITableViewScrollPosition)scrollPosition
+- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(TUITableViewScrollPosition)scrollPosition
{
- TUIFastIndexPath *oldIndexPath = [self indexPathForSelectedRow];
+ NSIndexPath *oldIndexPath = [self indexPathForSelectedRow];
// if([indexPath isEqual:oldIndexPath]) {
// // just scroll to visible
// } else {
@@ -1092,7 +1091,7 @@ - (void)selectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animat
[self scrollToRowAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
}
-- (void)deselectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated
+- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated
{
if([indexPath isEqual:_selectedIndexPath]) {
@@ -1111,10 +1110,10 @@ - (void)deselectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)anim
}
-- (TUIFastIndexPath *)indexPathForFirstVisibleRow
+- (NSIndexPath *)indexPathForFirstVisibleRow
{
- TUIFastIndexPath *firstIndexPath = nil;
- for(TUIFastIndexPath *indexPath in _visibleItems) {
+ NSIndexPath *firstIndexPath = nil;
+ for(NSIndexPath *indexPath in _visibleItems) {
if(firstIndexPath == nil || [indexPath compare:firstIndexPath] == NSOrderedAscending) {
firstIndexPath = indexPath;
}
@@ -1122,10 +1121,10 @@ - (TUIFastIndexPath *)indexPathForFirstVisibleRow
return firstIndexPath;
}
-- (TUIFastIndexPath *)indexPathForLastVisibleRow
+- (NSIndexPath *)indexPathForLastVisibleRow
{
- TUIFastIndexPath *lastIndexPath = nil;
- for(TUIFastIndexPath *indexPath in _visibleItems) {
+ NSIndexPath *lastIndexPath = nil;
+ for(NSIndexPath *indexPath in _visibleItems) {
if(lastIndexPath == nil || [indexPath compare:lastIndexPath] == NSOrderedDescending) {
lastIndexPath = indexPath;
}
@@ -1138,14 +1137,14 @@ - (BOOL)performKeyAction:(NSEvent *)event
// no selection or selected cell not visible and this is not repeative key press
BOOL noCurrentSelection = (_selectedIndexPath == nil || ([self cellForRowAtIndexPath:_selectedIndexPath] == nil && ![event isARepeat]));;
- typedef TUIFastIndexPath * (^TUITableViewCalculateNextIndexPathBlock)(TUIFastIndexPath *lastIndexPath);
- void (^selectValidIndexPath)(TUIFastIndexPath *startForNoSelection, TUITableViewCalculateNextIndexPathBlock calculateNextIndexPath) = ^(TUIFastIndexPath *startForNoSelection, TUITableViewCalculateNextIndexPathBlock calculateNextIndexPath) {
+ typedef NSIndexPath * (^TUITableViewCalculateNextIndexPathBlock)(NSIndexPath *lastIndexPath);
+ void (^selectValidIndexPath)(NSIndexPath *startForNoSelection, TUITableViewCalculateNextIndexPathBlock calculateNextIndexPath) = ^(NSIndexPath *startForNoSelection, TUITableViewCalculateNextIndexPathBlock calculateNextIndexPath) {
NSParameterAssert(calculateNextIndexPath != nil);
BOOL foundValidNextRow = NO;
- TUIFastIndexPath *lastIndexPath = _selectedIndexPath;
+ NSIndexPath *lastIndexPath = _selectedIndexPath;
while(!foundValidNextRow) {
- TUIFastIndexPath *newIndexPath;
+ NSIndexPath *newIndexPath;
if(noCurrentSelection && lastIndexPath == nil) {
newIndexPath = startForNoSelection;
} else {
@@ -1165,7 +1164,7 @@ - (BOOL)performKeyAction:(NSEvent *)event
switch([[event charactersIgnoringModifiers] characterAtIndex:0]) {
case NSUpArrowFunctionKey: {
- selectValidIndexPath([self indexPathForLastVisibleRow], ^(TUIFastIndexPath *lastIndexPath) {
+ selectValidIndexPath([self indexPathForLastVisibleRow], ^(NSIndexPath *lastIndexPath) {
NSUInteger section = lastIndexPath.section;
NSUInteger row = lastIndexPath.row;
if(row > 0) {
@@ -1181,14 +1180,14 @@ - (BOOL)performKeyAction:(NSEvent *)event
}
}
- return [TUIFastIndexPath indexPathForRow:row inSection:section];
+ return [NSIndexPath indexPathForRow:row inSection:section];
});
return YES;
}
case NSDownArrowFunctionKey: {
- selectValidIndexPath([self indexPathForFirstVisibleRow], ^(TUIFastIndexPath *lastIndexPath) {
+ selectValidIndexPath([self indexPathForFirstVisibleRow], ^(NSIndexPath *lastIndexPath) {
NSUInteger section = lastIndexPath.section;
NSUInteger row = lastIndexPath.row;
NSUInteger rowsInSection = [self numberOfRowsInSection:section];
@@ -1206,7 +1205,7 @@ - (BOOL)performKeyAction:(NSEvent *)event
}
}
- return [TUIFastIndexPath indexPathForRow:row inSection:section];
+ return [NSIndexPath indexPathForRow:row inSection:section];
});
return YES;
4 lib/UIKit/TUITableViewCell.h
View
@@ -16,8 +16,6 @@
#import "TUIView.h"
-@class TUIFastIndexPath;
-
typedef enum {
TUITableViewCellStyleDefault,
} TUITableViewCellStyle;
@@ -45,7 +43,7 @@ typedef enum {
- (void)prepareForDisplay; // after frame is set, before it is brought onscreen
@property (weak, nonatomic, readonly) TUITableView *tableView;
-@property (strong, nonatomic, readonly) TUIFastIndexPath *indexPath;
+@property (strong, nonatomic, readonly) NSIndexPath *indexPath;
@property (nonatomic, readonly, getter=isHighlighted) BOOL highlighted;
@property (nonatomic, assign, getter=isSelected) BOOL selected;
3  lib/UIKit/TUITableViewCell.m
View
@@ -15,7 +15,6 @@
*/
#import "TUITableViewCell.h"
-#import "TUIFastIndexPath.h"
#import "TUINSWindow.h"
#import "TUITableView+Cell.h"
#import "TUITableView.h"
@@ -59,7 +58,7 @@ - (TUITableView *)tableView
return (TUITableView *)self.superview;
}
-- (TUIFastIndexPath *)indexPath
+- (NSIndexPath *)indexPath
{
return [self.tableView indexPathForCell:self];
}
2  lib/UIKit/TUITextField.m
View
@@ -79,7 +79,7 @@ - (TUIButton *)clearButton
{
TUIButton *b = [TUIButton button];
[b setImage:[NSImage imageNamed:@"clear-button.png"] forState:TUIControlStateNormal];
- [b addTarget:self action:@selector(clear:) forControlEvents:TUIControlEventTouchUpInside];
+ [b addTarget:self action:@selector(clear:) forControlEvents:TUIControlEventMouseUpInside];
return b;
}
2  lib/UIKit/TUIView.h
View
@@ -147,7 +147,7 @@ extern CGRect(^TUIViewCenteredLayout)(TUIView*);
- (id)initWithFrame:(CGRect)frame;
/**
- Default is YES. if set to NO, user events (touch, keys) are ignored and removed from the event queue.
+ Default is YES. if set to NO, user events (clicks, keys) are ignored and removed from the event queue.
*/
@property (nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
27 lib/UIKit/TUIView.m
View
@@ -339,10 +339,6 @@ static void TUISetCurrentContextScaleFactor(CGFloat s)
- (void)displayLayer:(CALayer *)layer
{
- if (_viewFlags.delegateWillDisplayLayer) {
- [_viewDelegate viewWillDisplayLayer:self];
- }
-
typedef void (*DrawRectIMP)(id,SEL,CGRect);
SEL drawRectSEL = @selector(drawRect:);
DrawRectIMP drawRectIMP = (DrawRectIMP)[self methodForSelector:drawRectSEL];
@@ -353,13 +349,17 @@ - (void)displayLayer:(CALayer *)layer
return;
}
- CGRect rectToDraw = self.bounds;
- if (!CGRectEqualToRect(_context.dirtyRect, CGRectZero)) {
- rectToDraw = _context.dirtyRect;
- _context.dirtyRect = CGRectZero;
- }
-
void (^drawBlock)(void) = ^{
+ if (_viewFlags.delegateWillDisplayLayer) {
+ [_viewDelegate viewWillDisplayLayer:self];
+ }
+
+ CGRect rectToDraw = self.bounds;
+ if (!CGRectEqualToRect(_context.dirtyRect, CGRectZero)) {
+ rectToDraw = _context.dirtyRect;
+ _context.dirtyRect = CGRectZero;
+ }
+
CGContextRef context = [self _CGContext];
TUIGraphicsPushContext(context);
@@ -407,8 +407,13 @@ - (void)displayLayer:(CALayer *)layer
} else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), drawBlock);
}
- } else {
+ } else if ([NSThread isMainThread] || dispatch_get_current_queue() == dispatch_get_main_queue()) {
drawBlock();
+ } else {
+ // On Mac OS X 10.6 (and possibly other versions), spinning a run loop in
+ // a background thread can result in -displayLayer: calls, so make sure we
+ // only invoke -drawRect: on the main thread.
+ dispatch_async(dispatch_get_main_queue(), drawBlock);
}
}
8 lib/UIKit/TUIViewNSViewContainer.m
View
@@ -163,7 +163,15 @@ - (void)drawRect:(CGRect)rect {
}
CGContextRef context = [NSGraphicsContext currentContext].graphicsPort;
+ CGContextSaveGState(context);
+
+ if ([self.rootView isFlipped]) {
+ CGContextTranslateCTM(context, 0, self.bounds.size.height);
+ CGContextScaleCTM(context, 1, -1);
+ }
+
[self.rootView.layer renderInContext:context];
+ CGContextRestoreGState(context);
}
- (void)startRenderingContainedView; {
Please sign in to comment.
Something went wrong with that request. Please try again.