This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d720b0
commit 2a704ca
Showing
111 changed files
with
18,289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.DS_Store | ||
xcuserdata | ||
*.mode1v3 | ||
*.pbxuser | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.example.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>${MACOSX_DEPLOYMENT_TARGET}</string> | ||
<key>NSMainNibFile</key> | ||
<string>MainMenu</string> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// | ||
// Prefix header for all source files of the 'ConcordeExample' target in the 'ConcordeExample' project | ||
// | ||
|
||
#ifdef __OBJC__ | ||
#import <Cocoa/Cocoa.h> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
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 <Cocoa/Cocoa.h> | ||
#import "TUIKit.h" | ||
|
||
@interface ExampleAppDelegate : NSObject <NSApplicationDelegate> | ||
{ | ||
NSWindow *window; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
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 "ExampleAppDelegate.h" | ||
#import "ExampleView.h" | ||
|
||
@implementation ExampleAppDelegate | ||
|
||
- (void)dealloc | ||
{ | ||
[window release]; | ||
[super dealloc]; | ||
} | ||
|
||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | ||
{ | ||
CGRect b = CGRectMake(0, 0, 500, 450); | ||
|
||
window = [[NSWindow alloc] initWithContentRect:b | ||
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | ||
backing:NSBackingStoreBuffered | ||
defer:NO]; | ||
[window setMinSize:NSMakeSize(300, 250)]; | ||
[window center]; | ||
|
||
/* | ||
TUINSView is the bridge between the standard AppKit NSView-based heirarchy and the TUIView-based heirarchy | ||
*/ | ||
TUINSView *tuiContainer = [[TUINSView alloc] initWithFrame:b]; | ||
[window setContentView:tuiContainer]; | ||
[tuiContainer release]; | ||
|
||
ExampleView *example = [[ExampleView alloc] initWithFrame:b]; | ||
tuiContainer.rootView = example; | ||
[example release]; | ||
|
||
[window makeKeyAndOrderFront:nil]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
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 "TUIKit.h" | ||
|
||
@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 | ||
*/ | ||
|
||
@interface ExampleTabBar : TUIView | ||
{ | ||
id<ExampleTabBarDelegate> delegate; | ||
NSArray *tabViews; | ||
} | ||
|
||
- (id)initWithNumberOfTabs:(NSInteger)nTabs; | ||
|
||
@property (nonatomic, assign) id<ExampleTabBarDelegate> delegate; | ||
@property (nonatomic, readonly) NSArray *tabViews; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
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 "ExampleTabBar.h" | ||
|
||
@interface ExampleTab : TUIView | ||
@end | ||
@implementation ExampleTab | ||
|
||
- (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 | ||
[self setNeedsDisplay]; | ||
} | ||
|
||
- (void)mouseUp:(NSEvent *)event | ||
{ | ||
[super mouseUp: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 | ||
}]; | ||
|
||
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]; | ||
} | ||
} | ||
|
||
@end | ||
|
||
@implementation ExampleTabBar | ||
|
||
@synthesize delegate; | ||
@synthesize tabViews; | ||
|
||
- (id)initWithNumberOfTabs:(NSInteger)nTabs | ||
{ | ||
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); | ||
}; | ||
[self addSubview:t]; | ||
[_tabViews addObject:t]; | ||
[t release]; | ||
} | ||
|
||
tabViews = [[NSArray alloc] initWithArray:_tabViews]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[tabViews release]; | ||
[super dealloc]; | ||
} | ||
|
||
- (void)drawRect:(CGRect)rect | ||
{ | ||
// draw tab bar background | ||
|
||
CGRect b = self.bounds; | ||
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); | ||
|
||
// 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)); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
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 "TUIKit.h" | ||
|
||
@interface ExampleTableViewCell : TUITableViewCell | ||
{ | ||
TUITextRenderer *textRenderer; | ||
} | ||
|
||
@property (nonatomic, copy) NSAttributedString *attributedString; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
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 "ExampleTableViewCell.h" | ||
|
||
@implementation ExampleTableViewCell | ||
|
||
- (id)initWithStyle:(TUITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier | ||
{ | ||
if((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { | ||
textRenderer = [[TUITextRenderer alloc] init]; | ||
|
||
/* | ||
Add the text renderer to the view so events get routed to it properly. | ||
Text selection, dictionary popup, etc should just work. | ||
You can add more than one. | ||
The text renderer encapsulates an attributed string and a frame. | ||
The attributed string in this case is set by setAttributedString: | ||
which is configured by the table view delegate. The frame needs to be | ||
set before it can be drawn, we do that in drawRect: below. | ||
*/ | ||
self.textRenderers = [NSArray arrayWithObjects:textRenderer, nil]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[textRenderer release]; | ||
[super dealloc]; | ||
} | ||
|
||
- (NSAttributedString *)attributedString | ||
{ | ||
return textRenderer.attributedString; | ||
} | ||
|
||
- (void)setAttributedString:(NSAttributedString *)attributedString | ||
{ | ||
textRenderer.attributedString = attributedString; | ||
[self setNeedsDisplay]; | ||
} | ||
|
||
- (void)drawRect:(CGRect)rect | ||
{ | ||
CGRect b = self.bounds; | ||
CGContextRef ctx = TUIGraphicsGetCurrentContext(); | ||
|
||
// light gray background | ||
CGContextSetRGBFillColor(ctx, .97, .97, .97, 1); | ||
CGContextFillRect(ctx, b); | ||
|
||
// text | ||
CGRect textRect = CGRectOffset(b, 15, -15); | ||
textRenderer.frame = textRect; // set the frame so it knows where to draw itself | ||
[textRenderer draw]; | ||
|
||
// emboss | ||
CGContextSetRGBFillColor(ctx, 1, 1, 1, 0.9); // light at the top | ||
CGContextFillRect(ctx, CGRectMake(0, b.size.height-1, b.size.width, 1)); | ||
CGContextSetRGBFillColor(ctx, 0, 0, 0, 0.08); // dark at the bottom | ||
CGContextFillRect(ctx, CGRectMake(0, 0, b.size.width, 1)); | ||
} | ||
|
||
@end |
Oops, something went wrong.