Skip to content

Commit

Permalink
Updating example project for table view fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian William Wolter committed Aug 14, 2011
1 parent 24ba66a commit 96bf769
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ExampleProject/ConcordeExample/ExampleSectionHeaderView.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#import "TUIKit.h"

@interface ExampleSectionHeaderView : TUIView {
@interface ExampleSectionHeaderView : TUITableViewSectionHeader {

TUITextRenderer * _labelRenderer;

Expand Down
26 changes: 24 additions & 2 deletions ExampleProject/ConcordeExample/ExampleSectionHeaderView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,27 @@ -(id)initWithFrame:(CGRect)frame {
if((self = [super initWithFrame:frame])) {
_labelRenderer = [[TUITextRenderer alloc] init];
self.textRenderers = [NSArray arrayWithObjects:_labelRenderer, nil];
self.opaque = TRUE;
}
return self;
}

/**
* @brief The header will become pinned
*/
-(void)headerWillBecomePinned {
self.opaque = FALSE;
[super headerWillBecomePinned];
}

/**
* @brief The header will become unpinned
*/
-(void)headerWillBecomeUnpinned {
self.opaque = TRUE;
[super headerWillBecomeUnpinned];
}

/**
* Drawing
*/
Expand All @@ -32,8 +49,13 @@ -(void)drawRect:(CGRect)rect {
if((g = TUIGraphicsGetCurrentContext()) != nil){
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:g flipped:FALSE]];

NSColor *start = [NSColor colorWithCalibratedRed:0.8 green:0.8 blue:0.8 alpha:1];
NSColor *end = [NSColor colorWithCalibratedRed:0.9 green:0.9 blue:0.9 alpha:1];
if(!self.pinnedToViewport){
[[NSColor whiteColor] set];
NSRectFill(self.bounds);
}

NSColor *start = [NSColor colorWithCalibratedRed:0.8 green:0.8 blue:0.8 alpha:0.9];
NSColor *end = [NSColor colorWithCalibratedRed:0.9 green:0.9 blue:0.9 alpha:0.9];
NSGradient *gradient = nil;

gradient = [[NSGradient alloc] initWithStartingColor:start endingColor:end];
Expand Down
42 changes: 42 additions & 0 deletions ExampleProject/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
5ED56736139DC35800031CDF /* CoreText+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5ED56732139DC35800031CDF /* CoreText+Additions.m */; };
D3502AAE13EA0FE4007C5CA7 /* TUITableView+Cell.m in Sources */ = {isa = PBXBuildFile; fileRef = D3502AAD13EA0FE4007C5CA7 /* TUITableView+Cell.m */; };
D3CE671313C6646B00D47B2D /* ExampleSectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = D3CE671213C6646B00D47B2D /* ExampleSectionHeaderView.m */; };
D3FA4CA913F85B7100860379 /* TUITableViewSectionHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CA813F85B7100860379 /* TUITableViewSectionHeader.m */; };
D3FA4CBA13F85BC100860379 /* TUIAccessibilityElement.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CAF13F85BC100860379 /* TUIAccessibilityElement.m */; };
D3FA4CBB13F85BC100860379 /* TUIButton+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CB113F85BC100860379 /* TUIButton+Accessibility.m */; };
D3FA4CBC13F85BC100860379 /* TUIControl+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CB313F85BC100860379 /* TUIControl+Accessibility.m */; };
D3FA4CBD13F85BC100860379 /* TUIControl+Private.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CB513F85BC100860379 /* TUIControl+Private.m */; };
D3FA4CBE13F85BC100860379 /* TUINSView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CB713F85BC100860379 /* TUINSView+Accessibility.m */; };
D3FA4CBF13F85BC100860379 /* TUIView+Accessibility.m in Sources */ = {isa = PBXBuildFile; fileRef = D3FA4CB913F85BC100860379 /* TUIView+Accessibility.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -186,6 +193,20 @@
D3502AAD13EA0FE4007C5CA7 /* TUITableView+Cell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUITableView+Cell.m"; sourceTree = "<group>"; };
D3CE671113C6646B00D47B2D /* ExampleSectionHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleSectionHeaderView.h; sourceTree = "<group>"; };
D3CE671213C6646B00D47B2D /* ExampleSectionHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleSectionHeaderView.m; sourceTree = "<group>"; };
D3FA4CA713F85B7100860379 /* TUITableViewSectionHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUITableViewSectionHeader.h; sourceTree = "<group>"; };
D3FA4CA813F85B7100860379 /* TUITableViewSectionHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUITableViewSectionHeader.m; sourceTree = "<group>"; };
D3FA4CAE13F85BC100860379 /* TUIAccessibilityElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIAccessibilityElement.h; sourceTree = "<group>"; };
D3FA4CAF13F85BC100860379 /* TUIAccessibilityElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIAccessibilityElement.m; sourceTree = "<group>"; };
D3FA4CB013F85BC100860379 /* TUIButton+Accessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIButton+Accessibility.h"; sourceTree = "<group>"; };
D3FA4CB113F85BC100860379 /* TUIButton+Accessibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIButton+Accessibility.m"; sourceTree = "<group>"; };
D3FA4CB213F85BC100860379 /* TUIControl+Accessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIControl+Accessibility.h"; sourceTree = "<group>"; };
D3FA4CB313F85BC100860379 /* TUIControl+Accessibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIControl+Accessibility.m"; sourceTree = "<group>"; };
D3FA4CB413F85BC100860379 /* TUIControl+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIControl+Private.h"; sourceTree = "<group>"; };
D3FA4CB513F85BC100860379 /* TUIControl+Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIControl+Private.m"; sourceTree = "<group>"; };
D3FA4CB613F85BC100860379 /* TUINSView+Accessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUINSView+Accessibility.h"; sourceTree = "<group>"; };
D3FA4CB713F85BC100860379 /* TUINSView+Accessibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUINSView+Accessibility.m"; sourceTree = "<group>"; };
D3FA4CB813F85BC100860379 /* TUIView+Accessibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TUIView+Accessibility.h"; sourceTree = "<group>"; };
D3FA4CB913F85BC100860379 /* TUIView+Accessibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TUIView+Accessibility.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -343,6 +364,8 @@
D3502AAD13EA0FE4007C5CA7 /* TUITableView+Cell.m */,
5ED566D5139DC35100031CDF /* TUITableViewCell.h */,
5ED566D6139DC35100031CDF /* TUITableViewCell.m */,
D3FA4CA713F85B7100860379 /* TUITableViewSectionHeader.h */,
D3FA4CA813F85B7100860379 /* TUITableViewSectionHeader.m */,
5ED56698139DC35100031CDF /* TUIActivityIndicatorView.h */,
5ED56699139DC35100031CDF /* TUIActivityIndicatorView.m */,
5ED56696139DC35100031CDF /* TUIAccessibility.h */,
Expand Down Expand Up @@ -374,6 +397,18 @@
5ED566A0139DC35100031CDF /* TUIButton+Content.m */,
5ED566F5139DC35100031CDF /* TUIViewNSViewContainer.h */,
5C55D83013A663E2000ED768 /* TUIViewNSViewContainer.m */,
D3FA4CAE13F85BC100860379 /* TUIAccessibilityElement.h */,
D3FA4CAF13F85BC100860379 /* TUIAccessibilityElement.m */,
D3FA4CB013F85BC100860379 /* TUIButton+Accessibility.h */,
D3FA4CB113F85BC100860379 /* TUIButton+Accessibility.m */,
D3FA4CB213F85BC100860379 /* TUIControl+Accessibility.h */,
D3FA4CB313F85BC100860379 /* TUIControl+Accessibility.m */,
D3FA4CB413F85BC100860379 /* TUIControl+Private.h */,
D3FA4CB513F85BC100860379 /* TUIControl+Private.m */,
D3FA4CB613F85BC100860379 /* TUINSView+Accessibility.h */,
D3FA4CB713F85BC100860379 /* TUINSView+Accessibility.m */,
D3FA4CB813F85BC100860379 /* TUIView+Accessibility.h */,
D3FA4CB913F85BC100860379 /* TUIView+Accessibility.m */,
5C90DB9A13A6D52000ECDD14 /* Extras */,
);
name = TUIKit;
Expand Down Expand Up @@ -495,6 +530,13 @@
D3CE671313C6646B00D47B2D /* ExampleSectionHeaderView.m in Sources */,
D3502AAE13EA0FE4007C5CA7 /* TUITableView+Cell.m in Sources */,
5ED06F2C13F4C98800B34CAE /* TUITextViewEditor.m in Sources */,
D3FA4CA913F85B7100860379 /* TUITableViewSectionHeader.m in Sources */,
D3FA4CBA13F85BC100860379 /* TUIAccessibilityElement.m in Sources */,
D3FA4CBB13F85BC100860379 /* TUIButton+Accessibility.m in Sources */,
D3FA4CBC13F85BC100860379 /* TUIControl+Accessibility.m in Sources */,
D3FA4CBD13F85BC100860379 /* TUIControl+Private.m in Sources */,
D3FA4CBE13F85BC100860379 /* TUINSView+Accessibility.m in Sources */,
D3FA4CBF13F85BC100860379 /* TUIView+Accessibility.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
9 changes: 9 additions & 0 deletions lib/UIKit/TUITableView+Cell.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

#import "TUITableView+Cell.h"

// Dragged cells should be just above pinned headers
#define kTUITableViewDraggedCellZPosition 1001

@interface TUITableView (CellPrivate)

- (BOOL)_preLayoutCells;
Expand Down Expand Up @@ -96,6 +99,9 @@ -(void)__updateDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset loca

// initialize defaults on the first drag
if(_currentDragToReorderIndexPath == nil || _previousDragToReorderIndexPath == nil){
// make sure the dragged cell is on top
_dragToReorderCell.layer.zPosition = kTUITableViewDraggedCellZPosition;
// setup index paths
[_currentDragToReorderIndexPath release];
_currentDragToReorderIndexPath = [cell.indexPath retain];
[_previousDragToReorderIndexPath release];
Expand Down Expand Up @@ -348,6 +354,9 @@ -(void)__endDraggingCell:(TUITableViewCell *)cell offset:(CGPoint)offset locatio
[_previousDragToReorderIndexPath release];
_previousDragToReorderIndexPath = nil;

// restore the dragged cell z-position
_dragToReorderCell.layer.zPosition = 0;
// and clean up
[_dragToReorderCell release];
_dragToReorderCell = nil;

Expand Down

0 comments on commit 96bf769

Please sign in to comment.