Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #34 from github/remove-tuicolor

Kill TUIColor
  • Loading branch information...
commit 95d8adec09d1a8ebeaf34ae48cdbee628ac53ce3 2 parents 574340d + 049f703
@joshaber joshaber authored
Showing with 245 additions and 472 deletions.
  1. +1 −1  ExampleProject/ConcordeExample/ExampleScrollView.m
  2. +1 −1  ExampleProject/ConcordeExample/ExampleTableViewCell.m
  3. +5 −5 ExampleProject/ConcordeExample/ExampleView.m
  4. +20 −16 TwUI.xcodeproj/project.pbxproj
  5. +27 −0 lib/UIKit/NSColor+TUIExtensions.h
  6. +93 −0 lib/UIKit/NSColor+TUIExtensions.m
  7. +1 −2  lib/UIKit/NSImage+TUIExtensions.h
  8. +5 −4 lib/UIKit/NSImage+TUIExtensions.m
  9. +1 −2  lib/UIKit/TUIActivityIndicatorView.m
  10. +5 −7 lib/UIKit/TUIAttributedString.h
  11. +10 −11 lib/UIKit/TUIAttributedString.m
  12. +10 −10 lib/UIKit/TUIButton+Content.m
  13. +6 −6 lib/UIKit/TUIButton.h
  14. +5 −6 lib/UIKit/TUIButton.m
  15. +0 −89 lib/UIKit/TUIColor.h
  16. +0 −235 lib/UIKit/TUIColor.m
  17. +1 −1  lib/UIKit/TUIKit.h
  18. +6 −21 lib/UIKit/TUILabel.h
  19. +7 −3 lib/UIKit/TUILabel.m
  20. +2 −3 lib/UIKit/TUIPopover.h
  21. +5 −5 lib/UIKit/TUIPopover.m
  22. +3 −4 lib/UIKit/TUIProgressBar.m
  23. +3 −4 lib/UIKit/TUIScrollKnob.m
  24. +1 −2  lib/UIKit/TUIStringDrawing.h
  25. +1 −2  lib/UIKit/TUIStringDrawing.m
  26. +1 −1  lib/UIKit/TUIStyledView.h
  27. +0 −1  lib/UIKit/TUIStyledView.m
  28. +3 −5 lib/UIKit/TUITextRenderer.h
  29. +6 −5 lib/UIKit/TUITextRenderer.m
  30. +3 −5 lib/UIKit/TUITextView.h
  31. +5 −6 lib/UIKit/TUITextView.m
  32. +1 −2  lib/UIKit/TUIView.h
  33. +6 −5 lib/UIKit/TUIView.m
  34. +1 −2  lib/UIKit/TUIViewController.m
View
2  ExampleProject/ConcordeExample/ExampleScrollView.m
@@ -21,7 +21,7 @@ @implementation ExampleScrollView
- (id)initWithFrame:(CGRect)frame
{
if((self = [super initWithFrame:frame])) {
- self.backgroundColor = [TUIColor colorWithWhite:0.9 alpha:1.0];
+ self.backgroundColor = [NSColor colorWithCalibratedWhite:0.9 alpha:1.0];
_scrollView = [[TUIScrollView alloc] initWithFrame:self.bounds];
_scrollView.autoresizingMask = TUIViewAutoresizingFlexibleSize;
View
2  ExampleProject/ConcordeExample/ExampleTableViewCell.m
@@ -40,7 +40,7 @@ - (id)initWithStyle:(TUITableViewCellStyle)style reuseIdentifier:(NSString *)reu
[textField.cell setScrollable:YES];
self.textFieldContainer = [[TUIViewNSViewContainer alloc] initWithNSView:textField];
- self.textFieldContainer.backgroundColor = [TUIColor blueColor];
+ self.textFieldContainer.backgroundColor = [NSColor blueColor];
[self addSubview:self.textFieldContainer];
}
return self;
View
10 ExampleProject/ConcordeExample/ExampleView.m
@@ -25,7 +25,7 @@ @implementation ExampleView
- (id)initWithFrame:(CGRect)frame
{
if((self = [super initWithFrame:frame])) {
- self.backgroundColor = [TUIColor colorWithWhite:0.9 alpha:1.0];
+ self.backgroundColor = [NSColor colorWithCalibratedWhite:0.9 alpha:1.0];
// if you're using a font a lot, it's best to allocate it once and re-use it
exampleFont1 = [NSFont fontWithName:@"HelveticaNeue" size:15];
@@ -60,7 +60,7 @@ Note by default scroll views (and therefore table views) don't
// setup individual tabs
for(TUIView *tabView in _tabBar.tabViews) {
- tabView.backgroundColor = [TUIColor clearColor]; // will also set opaque=NO
+ tabView.backgroundColor = [NSColor clearColor]; // will also set opaque=NO
// let's just teach the tabs how to draw themselves right here - no need to subclass anything
tabView.drawRect = ^(TUIView *v, CGRect rect) {
@@ -92,7 +92,7 @@ Note by default scroll views (and therefore table views) don't
CGContextClipToMask(ctx, r, image.tui_CGImage);
CGContextDrawLinearGradientBetweenPoints(ctx, CGPointMake(0, r.size.height), (CGFloat[]){0,0,1,1}, CGPointZero, (CGFloat[]){0,0.6,1,1});
- NSImage *innerShadow = [image tui_innerShadowWithOffset:CGSizeMake(0, -1) radius:3.0 color:[TUIColor blackColor] backgroundColor:[TUIColor cyanColor]];
+ NSImage *innerShadow = [image tui_innerShadowWithOffset:CGSizeMake(0, -1) radius:3.0 color:[NSColor blackColor] backgroundColor:[NSColor cyanColor]];
CGContextSetBlendMode(ctx, kCGBlendModeOverlay);
CGContextDrawImage(ctx, r, innerShadow.tui_CGImage);
}];
@@ -138,7 +138,7 @@ - (TUIView *)tableView:(TUITableView *)tableView headerViewForSection:(NSInteger
{
ExampleSectionHeaderView *view = [[ExampleSectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, 100, 32)];
TUIAttributedString *title = [TUIAttributedString stringWithString:[NSString stringWithFormat:@"Example Section %d", (int)section]];
- title.color = [TUIColor blackColor];
+ title.color = [NSColor blackColor];
title.font = exampleFont2;
view.labelRenderer.attributedString = title;
return view;
@@ -149,7 +149,7 @@ - (TUITableViewCell *)tableView:(TUITableView *)tableView cellForRowAtIndexPath:
ExampleTableViewCell *cell = reusableTableCellOfClass(tableView, ExampleTableViewCell);
TUIAttributedString *s = [TUIAttributedString stringWithString:[NSString stringWithFormat:@"example cell %d", (int)indexPath.row]];
- s.color = [TUIColor blackColor];
+ s.color = [NSColor blackColor];
s.font = exampleFont1;
[s setFont:exampleFont2 inRange:NSMakeRange(8, 4)]; // make the word "cell" bold
cell.attributedString = s;
View
36 TwUI.xcodeproj/project.pbxproj
@@ -28,7 +28,6 @@
5EE983C313BE7834005F430D /* TUIButton+Content.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4413BE6E1900C85CB5 /* TUIButton+Content.m */; };
5EE983C413BE7834005F430D /* TUIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4613BE6E1900C85CB5 /* TUIButton.m */; };
5EE983C513BE7834005F430D /* TUICGAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4813BE6E1900C85CB5 /* TUICGAdditions.m */; };
- 5EE983C613BE7834005F430D /* TUIColor.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4A13BE6E1900C85CB5 /* TUIColor.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 */; };
5EE983CB13BE7834005F430D /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
@@ -141,7 +140,6 @@
CB5E322213BE70CA004B7899 /* TUIButton+Content.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4413BE6E1900C85CB5 /* TUIButton+Content.m */; };
CB5E322413BE70CA004B7899 /* TUIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4613BE6E1900C85CB5 /* TUIButton.m */; };
CB5E322613BE70CA004B7899 /* TUICGAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4813BE6E1900C85CB5 /* TUICGAdditions.m */; };
- CB5E322813BE70CA004B7899 /* TUIColor.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4A13BE6E1900C85CB5 /* TUIColor.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 */; };
CB5E323113BE70CA004B7899 /* TUIGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C5313BE6E1900C85CB5 /* TUIGeometry.m */; };
@@ -192,8 +190,6 @@
CBB74C9D13BE6E1900C85CB5 /* TUIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4613BE6E1900C85CB5 /* TUIButton.m */; };
CBB74C9E13BE6E1900C85CB5 /* TUICGAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C4713BE6E1900C85CB5 /* TUICGAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
CBB74C9F13BE6E1900C85CB5 /* TUICGAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4813BE6E1900C85CB5 /* TUICGAdditions.m */; };
- CBB74CA013BE6E1900C85CB5 /* TUIColor.h in Headers */ = {isa = PBXBuildFile; fileRef = CBB74C4913BE6E1900C85CB5 /* TUIColor.h */; settings = {ATTRIBUTES = (Public, ); }; };
- CBB74CA113BE6E1900C85CB5 /* TUIColor.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB74C4A13BE6E1900C85CB5 /* TUIColor.m */; };
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 */; };
@@ -342,6 +338,12 @@
D0C7657415B6341800E7AC2C /* TUICAAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C7657015B6341800E7AC2C /* TUICAAction.m */; };
D0C7657515B6341800E7AC2C /* TUICAAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C7657015B6341800E7AC2C /* TUICAAction.m */; };
D0C7657615B6341800E7AC2C /* TUICAAction.m in Sources */ = {isa = PBXBuildFile; fileRef = D0C7657015B6341800E7AC2C /* TUICAAction.m */; };
+ D0EA12F115C34FEA00FAA603 /* NSColor+TUIExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = D0EA12EF15C34FEA00FAA603 /* NSColor+TUIExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D0EA12F215C34FEA00FAA603 /* NSColor+TUIExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = D0EA12EF15C34FEA00FAA603 /* NSColor+TUIExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D0EA12F315C34FEA00FAA603 /* NSColor+TUIExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = D0EA12EF15C34FEA00FAA603 /* NSColor+TUIExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D0EA12F415C34FEA00FAA603 /* NSColor+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = D0EA12F015C34FEA00FAA603 /* NSColor+TUIExtensions.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ D0EA12F515C34FEA00FAA603 /* NSColor+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = D0EA12F015C34FEA00FAA603 /* NSColor+TUIExtensions.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+ D0EA12F615C34FEA00FAA603 /* NSColor+TUIExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = D0EA12F015C34FEA00FAA603 /* NSColor+TUIExtensions.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -491,8 +493,6 @@
CBB74C4613BE6E1900C85CB5 /* TUIButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIButton.m; sourceTree = "<group>"; };
CBB74C4713BE6E1900C85CB5 /* TUICGAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUICGAdditions.h; sourceTree = "<group>"; };
CBB74C4813BE6E1900C85CB5 /* TUICGAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUICGAdditions.m; sourceTree = "<group>"; };
- CBB74C4913BE6E1900C85CB5 /* TUIColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUIColor.h; sourceTree = "<group>"; };
- CBB74C4A13BE6E1900C85CB5 /* TUIColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUIColor.m; sourceTree = "<group>"; };
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>"; };
@@ -587,6 +587,8 @@
D0C7656D15B6322A00E7AC2C /* TUIViewNSViewContainer+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TUIViewNSViewContainer+Private.h"; sourceTree = "<group>"; };
D0C7656F15B6341800E7AC2C /* TUICAAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TUICAAction.h; sourceTree = "<group>"; };
D0C7657015B6341800E7AC2C /* TUICAAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TUICAAction.m; sourceTree = "<group>"; };
+ D0EA12EF15C34FEA00FAA603 /* NSColor+TUIExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSColor+TUIExtensions.h"; sourceTree = "<group>"; };
+ D0EA12F015C34FEA00FAA603 /* NSColor+TUIExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSColor+TUIExtensions.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -733,20 +735,20 @@
children = (
CBB74C3913BE6E1900C85CB5 /* ABActiveRange.h */,
CBB74C3A13BE6E1900C85CB5 /* ABActiveRange.m */,
- CBB74C3B13BE6E1900C85CB5 /* CoreText+Additions.h */,
- CBB74C3C13BE6E1900C85CB5 /* CoreText+Additions.m */,
884E8F591538809C000F7A8D /* CAAnimation+TUIExtensions.h */,
884E8F5A1538809C000F7A8D /* CAAnimation+TUIExtensions.m */,
D0C7652015B6232100E7AC2C /* CALayer+TUIExtensions.h */,
D0C7652115B6232100E7AC2C /* CALayer+TUIExtensions.m */,
D0C7652215B6232100E7AC2C /* CATransaction+TUIExtensions.h */,
D0C7652315B6232100E7AC2C /* CATransaction+TUIExtensions.m */,
+ CBB74C3B13BE6E1900C85CB5 /* CoreText+Additions.h */,
+ CBB74C3C13BE6E1900C85CB5 /* CoreText+Additions.m */,
+ 887C227915C1C7BB006EC31D /* NSFont+TUIExtensions.h */,
+ 887C227A15C1C7BB006EC31D /* NSFont+TUIExtensions.m */,
D040611115B6A7CC00F753ED /* NSTextView+TUIExtensions.h */,
D040611215B6A7CC00F753ED /* NSTextView+TUIExtensions.m */,
D0C7656F15B6341800E7AC2C /* TUICAAction.h */,
D0C7657015B6341800E7AC2C /* TUICAAction.m */,
- 887C227915C1C7BB006EC31D /* NSFont+TUIExtensions.h */,
- 887C227A15C1C7BB006EC31D /* NSFont+TUIExtensions.m */,
);
name = Support;
path = lib/Support;
@@ -757,6 +759,8 @@
children = (
D0C7655915B6297200E7AC2C /* NSClipView+TUIExtensions.h */,
D0C7655A15B6297200E7AC2C /* NSClipView+TUIExtensions.m */,
+ D0EA12EF15C34FEA00FAA603 /* NSColor+TUIExtensions.h */,
+ D0EA12F015C34FEA00FAA603 /* NSColor+TUIExtensions.m */,
D05D239E15BF7239000ED14F /* NSImage+TUIExtensions.h */,
D05D239F15BF7239000ED14F /* NSImage+TUIExtensions.m */,
D0C7655B15B6297300E7AC2C /* NSScrollView+TUIExtensions.h */,
@@ -778,8 +782,6 @@
CBB74C4613BE6E1900C85CB5 /* TUIButton.m */,
CBB74C4713BE6E1900C85CB5 /* TUICGAdditions.h */,
CBB74C4813BE6E1900C85CB5 /* TUICGAdditions.m */,
- CBB74C4913BE6E1900C85CB5 /* TUIColor.h */,
- CBB74C4A13BE6E1900C85CB5 /* TUIColor.m */,
88CC1F2D13E365B500827793 /* TUIControl+Accessibility.h */,
88CC1F2E13E365B500827793 /* TUIControl+Accessibility.m */,
886EBA7D13D64393006DE018 /* TUIControl+Private.h */,
@@ -939,6 +941,7 @@
D07AA82815BDD72F00F736C0 /* TUINSView+NSTextInputClient.h in Headers */,
D05DEE8E15BF645D005D8769 /* TUIStretchableImage.h in Headers */,
D05D23A215BF7239000ED14F /* NSImage+TUIExtensions.h in Headers */,
+ D0EA12F315C34FEA00FAA603 /* NSColor+TUIExtensions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -954,7 +957,6 @@
CBB74C9C13BE6E1900C85CB5 /* TUIButton.h in Headers */,
CBB74C9E13BE6E1900C85CB5 /* TUICGAdditions.h in Headers */,
30D39A0D156D8F71006ECDAE /* TUIProgressBar.h in Headers */,
- CBB74CA013BE6E1900C85CB5 /* TUIColor.h in Headers */,
CBB74CA313BE6E1900C85CB5 /* TUIControl.h in Headers */,
CBB74CA913BE6E1900C85CB5 /* TUIGeometry.h in Headers */,
88D81CFF1577EF0D009D453B /* TUIStyledView.h in Headers */,
@@ -1011,6 +1013,7 @@
D07AA82615BDD72F00F736C0 /* TUINSView+NSTextInputClient.h in Headers */,
D05DEE8C15BF645D005D8769 /* TUIStretchableImage.h in Headers */,
D05D23A015BF7239000ED14F /* NSImage+TUIExtensions.h in Headers */,
+ D0EA12F115C34FEA00FAA603 /* NSColor+TUIExtensions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1043,6 +1046,7 @@
D07AA82715BDD72F00F736C0 /* TUINSView+NSTextInputClient.h in Headers */,
D05DEE8D15BF645D005D8769 /* TUIStretchableImage.h in Headers */,
D05D23A115BF7239000ED14F /* NSImage+TUIExtensions.h in Headers */,
+ D0EA12F215C34FEA00FAA603 /* NSColor+TUIExtensions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1268,7 +1272,6 @@
5EE983C313BE7834005F430D /* TUIButton+Content.m in Sources */,
5EE983C413BE7834005F430D /* TUIButton.m in Sources */,
5EE983C513BE7834005F430D /* TUICGAdditions.m in Sources */,
- 5EE983C613BE7834005F430D /* TUIColor.m in Sources */,
5EE983C713BE7834005F430D /* TUIControl+TargetAction.m in Sources */,
5EE983C813BE7834005F430D /* TUIControl.m in Sources */,
5EE983CB13BE7834005F430D /* TUIGeometry.m in Sources */,
@@ -1325,6 +1328,7 @@
D07AA82B15BDD79A00F736C0 /* TUINSView+NSTextInputClient.m in Sources */,
D05DEE9115BF645D005D8769 /* TUIStretchableImage.m in Sources */,
D05D23A515BF7239000ED14F /* NSImage+TUIExtensions.m in Sources */,
+ D0EA12F615C34FEA00FAA603 /* NSColor+TUIExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1340,7 +1344,6 @@
CBB74C9B13BE6E1900C85CB5 /* TUIButton+Content.m in Sources */,
CBB74C9D13BE6E1900C85CB5 /* TUIButton.m in Sources */,
CBB74C9F13BE6E1900C85CB5 /* TUICGAdditions.m in Sources */,
- CBB74CA113BE6E1900C85CB5 /* TUIColor.m in Sources */,
CBB74CA213BE6E1900C85CB5 /* TUIControl+TargetAction.m in Sources */,
CBB74CA413BE6E1900C85CB5 /* TUIControl.m in Sources */,
CBB74CAA13BE6E1900C85CB5 /* TUIGeometry.m in Sources */,
@@ -1402,6 +1405,7 @@
D05DEE8F15BF645D005D8769 /* TUIStretchableImage.m in Sources */,
D05D23A315BF7239000ED14F /* NSImage+TUIExtensions.m in Sources */,
887C227C15C1C7BB006EC31D /* NSFont+TUIExtensions.m in Sources */,
+ D0EA12F415C34FEA00FAA603 /* NSColor+TUIExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1426,7 +1430,6 @@
CB5E322213BE70CA004B7899 /* TUIButton+Content.m in Sources */,
CB5E322413BE70CA004B7899 /* TUIButton.m in Sources */,
CB5E322613BE70CA004B7899 /* TUICGAdditions.m in Sources */,
- CB5E322813BE70CA004B7899 /* TUIColor.m in Sources */,
CB5E322913BE70CA004B7899 /* TUIControl+TargetAction.m in Sources */,
CB5E322B13BE70CA004B7899 /* TUIControl.m in Sources */,
CB5E323113BE70CA004B7899 /* TUIGeometry.m in Sources */,
@@ -1484,6 +1487,7 @@
D07AA82A15BDD79A00F736C0 /* TUINSView+NSTextInputClient.m in Sources */,
D05DEE9015BF645D005D8769 /* TUIStretchableImage.m in Sources */,
D05D23A415BF7239000ED14F /* NSImage+TUIExtensions.m in Sources */,
+ D0EA12F515C34FEA00FAA603 /* NSColor+TUIExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
27 lib/UIKit/NSColor+TUIExtensions.h
@@ -0,0 +1,27 @@
+//
+// NSColor+TUIExtensions.h
+//
+// Created by Justin Spahr-Summers on 01.12.11.
+// Copyright (c) 2011 Bitswift. All rights reserved.
+//
+
+#import <AppKit/AppKit.h>
+
+/*
+ * Extensions to NSColor that add interoperability with CGColor.
+ */
+@interface NSColor (TUIExtensions)
+
+/*
+ * The CGColor corresponding to the receiver.
+ */
+@property (nonatomic, readonly) CGColorRef tui_CGColor;
+
+/*
+ * Returns an NSColor corresponding to the given CGColor.
+ *
+ * This method will not handle pattern colors.
+ */
++ (NSColor *)tui_colorWithCGColor:(CGColorRef)color;
+
+@end
View
93 lib/UIKit/NSColor+TUIExtensions.m
@@ -0,0 +1,93 @@
+//
+// NSColor+TUIExtensions.m
+//
+// Created by Justin Spahr-Summers on 01.12.11.
+// Copyright (c) 2011 Bitswift. All rights reserved.
+//
+
+#import "NSColor+TUIExtensions.h"
+#import "NSImage+TUIExtensions.h"
+
+// CGPatterns involve some complex memory management which doesn't mesh well
+// with ARC.
+#if __has_feature(objc_arc)
+#error "This file cannot be compiled with ARC."
+#endif
+
+static void drawCGImagePattern (void *info, CGContextRef context) {
+ CGImageRef image = info;
+
+ size_t width = CGImageGetWidth(image);
+ size_t height = CGImageGetHeight(image);
+
+ CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
+}
+
+static void releasePatternInfo (void *info) {
+ CFRelease(info);
+}
+
+@implementation NSColor (TUIExtensions)
+
++ (NSColor *)tui_colorWithCGColor:(CGColorRef)color; {
+ if (!color)
+ return nil;
+
+ CGColorSpaceRef colorSpaceRef = CGColorGetColorSpace(color);
+
+ NSColorSpace *colorSpace = [[NSColorSpace alloc] initWithCGColorSpace:colorSpaceRef];
+ NSColor *result = [self colorWithColorSpace:colorSpace components:CGColorGetComponents(color) count:(size_t)CGColorGetNumberOfComponents(color)];
+ [colorSpace release];
+
+ return result;
+}
+
+- (CGColorRef)tui_CGColor; {
+ if ([self.colorSpaceName isEqualToString:NSPatternColorSpace]) {
+ CGImageRef patternImage = self.patternImage.tui_CGImage;
+ if (!patternImage)
+ return NULL;
+
+ size_t width = CGImageGetWidth(patternImage);
+ size_t height = CGImageGetHeight(patternImage);
+
+ CGRect patternBounds = CGRectMake(0, 0, width, height);
+ CGPatternRef pattern = CGPatternCreate(
+ (void *)CFRetain(patternImage),
+ patternBounds,
+ CGAffineTransformIdentity,
+ width,
+ height,
+ kCGPatternTilingConstantSpacingMinimalDistortion,
+ YES,
+ &(CGPatternCallbacks){
+ .version = 0,
+ .drawPattern = &drawCGImagePattern,
+ .releaseInfo = &releasePatternInfo
+ }
+ );
+
+ CGColorSpaceRef colorSpaceRef = CGColorSpaceCreatePattern(NULL);
+
+ CGColorRef result = CGColorCreateWithPattern(colorSpaceRef, pattern, (CGFloat[]){ 1.0 });
+
+ CGColorSpaceRelease(colorSpaceRef);
+ CGPatternRelease(pattern);
+
+ return (CGColorRef)[(id)result autorelease];
+ }
+
+ NSColorSpace *colorSpace = [NSColorSpace genericRGBColorSpace];
+ NSColor *color = [self colorUsingColorSpace:colorSpace];
+
+ NSInteger count = [color numberOfComponents];
+ CGFloat components[count];
+ [color getComponents:components];
+
+ CGColorSpaceRef colorSpaceRef = colorSpace.CGColorSpace;
+ CGColorRef result = CGColorCreate(colorSpaceRef, components);
+
+ return (CGColorRef)[(id)result autorelease];
+}
+
+@end
View
3  lib/UIKit/NSImage+TUIExtensions.h
@@ -17,7 +17,6 @@
#import <Cocoa/Cocoa.h>
#import "TUIGeometry.h"
-@class TUIColor;
@class TUIStretchableImage;
@interface NSImage (TUIExtensions)
@@ -63,6 +62,6 @@
- (NSImage *)tui_roundImage:(CGFloat)radius;
- (NSImage *)tui_invertedMask;
- (NSImage *)tui_embossMaskWithOffset:(CGSize)offset; // subtract reciever from itself offset by 'offset', use as a mask to draw emboss
-- (NSImage *)tui_innerShadowWithOffset:(CGSize)offset radius:(CGFloat)radius color:(TUIColor *)color backgroundColor:(TUIColor *)backgroundColor; // 'backgroundColor' is used as the color the shadow is drawn with, it is mostly masked out, but a halo will remain, leading to artifacts unless it is close enough to the background color
+- (NSImage *)tui_innerShadowWithOffset:(CGSize)offset radius:(CGFloat)radius color:(NSColor *)color backgroundColor:(NSColor *)backgroundColor; // 'backgroundColor' is used as the color the shadow is drawn with, it is mostly masked out, but a halo will remain, leading to artifacts unless it is close enough to the background color
@end
View
9 lib/UIKit/NSImage+TUIExtensions.m
@@ -15,8 +15,8 @@
*/
#import "NSImage+TUIExtensions.h"
+#import "NSColor+TUIExtensions.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUIStretchableImage.h"
@implementation NSImage (TUIExtensions)
@@ -162,7 +162,7 @@ - (NSImage *)tui_invertedMask
}];
}
-- (NSImage *)tui_innerShadowWithOffset:(CGSize)offset radius:(CGFloat)radius color:(TUIColor *)color backgroundColor:(TUIColor *)backgroundColor
+- (NSImage *)tui_innerShadowWithOffset:(CGSize)offset radius:(CGFloat)radius color:(NSColor *)color backgroundColor:(NSColor *)backgroundColor
{
CGFloat padding = ceil(radius);
NSImage *paddedImage = [self tui_pad:padding];
@@ -170,13 +170,14 @@ - (NSImage *)tui_innerShadowWithOffset:(CGSize)offset radius:(CGFloat)radius col
CGContextSaveGState(ctx);
CGRect r = CGRectMake(0, 0, paddedImage.size.width, paddedImage.size.height);
CGContextClipToMask(ctx, r, paddedImage.tui_CGImage); // clip to image
- CGContextSetShadowWithColor(ctx, offset, radius, color.CGColor);
+ CGContextSetShadowWithColor(ctx, offset, radius, color.tui_CGColor);
CGContextBeginTransparencyLayer(ctx, NULL);
{
CGContextClipToMask(ctx, r, [[paddedImage tui_invertedMask] tui_CGImage]); // clip to inverted
- CGContextSetFillColorWithColor(ctx, backgroundColor.CGColor);
+ CGContextSetFillColorWithColor(ctx, backgroundColor.tui_CGColor);
CGContextFillRect(ctx, r); // draw with shadow
}
+
CGContextEndTransparencyLayer(ctx);
CGContextRestoreGState(ctx);
}];
View
3  lib/UIKit/TUIActivityIndicatorView.m
@@ -15,7 +15,6 @@
*/
#import "TUIActivityIndicatorView.h"
-#import "TUIColor.h"
@implementation TUIActivityIndicatorView
@@ -26,7 +25,7 @@ - (id)initWithActivityIndicatorStyle:(TUIActivityIndicatorViewStyle)style
_activityIndicatorViewStyle = style;
spinner = [[TUIView alloc] initWithFrame:self.bounds];
- spinner.backgroundColor = [TUIColor blackColor];
+ spinner.backgroundColor = [NSColor blackColor];
spinner.alpha = 0.2;
spinner.layer.cornerRadius = 10.0;
[self addSubview:spinner];
View
12 lib/UIKit/TUIAttributedString.h
@@ -20,8 +20,6 @@ extern NSString * const TUIAttributedStringBackgroundColorAttributeName;
extern NSString * const TUIAttributedStringBackgroundFillStyleName;
extern NSString * const TUIAttributedStringPreDrawBlockName;
-@class TUIColor;
-
typedef void (^TUIAttributedStringPreDrawBlock)(NSAttributedString *attributedString, NSRange substringRange, CGRect rects[], CFIndex rectCount);
typedef enum {
@@ -61,8 +59,8 @@ typedef enum {
// write-only properties, reading will return nil
@property (nonatomic, retain) NSFont *font;
-@property (nonatomic, retain) TUIColor *color;
-@property (nonatomic, retain) TUIColor *backgroundColor;
+@property (nonatomic, retain) NSColor *color;
+@property (nonatomic, retain) NSColor *backgroundColor;
@property (nonatomic, assign) TUIBackgroundFillStyle backgroundFillStyle;
@property (nonatomic, retain) NSShadow *shadow;
@property (nonatomic, assign) TUITextAlignment alignment; // setting this will set lineBreakMode to word wrap, use setAlignment:lineBreakMode: for more control
@@ -74,8 +72,8 @@ typedef enum {
- (NSRange)_stringRange;
- (void)setFont:(NSFont *)font inRange:(NSRange)range;
-- (void)setColor:(TUIColor *)color inRange:(NSRange)range;
-- (void)setBackgroundColor:(TUIColor *)color inRange:(NSRange)range;
+- (void)setColor:(NSColor *)color inRange:(NSRange)range;
+- (void)setBackgroundColor:(NSColor *)color inRange:(NSRange)range;
- (void)setBackgroundFillStyle:(TUIBackgroundFillStyle)fillStyle inRange:(NSRange)range;
- (void)setPreDrawBlock:(TUIAttributedStringPreDrawBlock)block inRange:(NSRange)range; // the pre-draw block is called before the text or text background has been drawn
- (void)setShadow:(NSShadow *)shadow inRange:(NSRange)range;
@@ -86,7 +84,7 @@ typedef enum {
@interface NSShadow (TUIAdditions)
-+ (NSShadow *)shadowWithRadius:(CGFloat)radius offset:(CGSize)offset color:(TUIColor *)color;
++ (NSShadow *)shadowWithRadius:(CGFloat)radius offset:(CGSize)offset color:(NSColor *)color;
@end
View
21 lib/UIKit/TUIAttributedString.m
@@ -15,7 +15,6 @@
*/
#import "TUIAttributedString.h"
-#import "TUIColor.h"
NSString * const TUIAttributedStringBackgroundColorAttributeName = @"TUIAttributedStringBackgroundColorAttributeName";
NSString * const TUIAttributedStringBackgroundFillStyleName = @"TUIAttributedStringBackgroundFillStyleName";
@@ -47,9 +46,9 @@ - (void)setFont:(NSFont *)font inRange:(NSRange)range
}
}
-- (void)setColor:(TUIColor *)color inRange:(NSRange)range
+- (void)setColor:(NSColor *)color inRange:(NSRange)range
{
- [self addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[color CGColor] range:range];
+ [self addAttribute:NSForegroundColorAttributeName value:color range:range];
}
- (void)setShadow:(NSShadow *)shadow inRange:(NSRange)range
@@ -67,19 +66,19 @@ - (void)setFont:(NSFont *)font
[self setFont:font inRange:[self _stringRange]];
}
-- (void)setColor:(TUIColor *)color
+- (void)setColor:(NSColor *)color
{
[self setColor:color inRange:[self _stringRange]];
}
-- (void)setBackgroundColor:(TUIColor *)color
+- (void)setBackgroundColor:(NSColor *)color
{
[self setBackgroundColor:color inRange:[self _stringRange]];
}
-- (void)setBackgroundColor:(TUIColor *)color inRange:(NSRange)range
+- (void)setBackgroundColor:(NSColor *)color inRange:(NSRange)range
{
- [self addAttribute:TUIAttributedStringBackgroundColorAttributeName value:(id)[color CGColor] range:range];
+ [self addAttribute:TUIAttributedStringBackgroundColorAttributeName value:color range:range];
}
- (void)setBackgroundFillStyle:(TUIBackgroundFillStyle)fillStyle
@@ -208,7 +207,7 @@ - (NSFont *)font
return nil;
}
-- (TUIColor *)color
+- (NSColor *)color
{
return nil;
}
@@ -233,7 +232,7 @@ - (CGFloat)lineHeight
return 0.0;
}
-- (TUIColor *)backgroundColor
+- (NSColor *)backgroundColor
{
return nil;
}
@@ -258,12 +257,12 @@ - (void)setText:(NSString *)text {
@implementation NSShadow (TUIAdditions)
-+ (NSShadow *)shadowWithRadius:(CGFloat)radius offset:(CGSize)offset color:(TUIColor *)color
++ (NSShadow *)shadowWithRadius:(CGFloat)radius offset:(CGSize)offset color:(NSColor *)color
{
NSShadow *shadow = [[NSShadow alloc] init];
[shadow setShadowBlurRadius:radius];
[shadow setShadowOffset:offset];
- [shadow setShadowColor:[color nsColor]];
+ [shadow setShadowColor:color];
return shadow;
}
View
20 lib/UIKit/TUIButton+Content.m
@@ -19,8 +19,8 @@
@interface TUIButtonContent : NSObject
@property (nonatomic, strong) NSString *title;
-@property (nonatomic, strong) TUIColor *titleColor;
-@property (nonatomic, strong) TUIColor *shadowColor;
+@property (nonatomic, strong) NSColor *titleColor;
+@property (nonatomic, strong) NSColor *shadowColor;
@property (nonatomic, strong) NSImage *image;
@property (nonatomic, strong) NSImage *backgroundImage;
@end
@@ -55,7 +55,7 @@ - (void)setTitle:(NSString *)title forState:(TUIControlState)state
[self _stateDidChange];
}
-- (void)setTitleColor:(TUIColor *)color forState:(TUIControlState)state
+- (void)setTitleColor:(NSColor *)color forState:(TUIControlState)state
{
[self _stateWillChange];
[[self _contentForState:state] setTitleColor:color];
@@ -63,7 +63,7 @@ - (void)setTitleColor:(TUIColor *)color forState:(TUIControlState)state
[self _stateDidChange];
}
-- (void)setTitleShadowColor:(TUIColor *)color forState:(TUIControlState)state
+- (void)setTitleShadowColor:(NSColor *)color forState:(TUIControlState)state
{
[self _stateWillChange];
[[self _contentForState:state] setShadowColor:color];
@@ -92,12 +92,12 @@ - (NSString *)titleForState:(TUIControlState)state
return [[self _contentForState:state] title];
}
-- (TUIColor *)titleColorForState:(TUIControlState)state
+- (NSColor *)titleColorForState:(TUIControlState)state
{
return [[self _contentForState:state] titleColor];
}
-- (TUIColor *)titleShadowColorForState:(TUIControlState)state
+- (NSColor *)titleShadowColorForState:(TUIControlState)state
{
return [[self _contentForState:state] shadowColor];
}
@@ -122,9 +122,9 @@ - (NSString *)currentTitle
return title;
}
-- (TUIColor *)currentTitleColor
+- (NSColor *)currentTitleColor
{
- TUIColor *color = [self titleColorForState:self.state];
+ NSColor *color = [self titleColorForState:self.state];
if(color == nil) {
color = [self titleColorForState:TUIControlStateNormal];
}
@@ -132,9 +132,9 @@ - (TUIColor *)currentTitleColor
return color;
}
-- (TUIColor *)currentTitleShadowColor
+- (NSColor *)currentTitleShadowColor
{
- TUIColor *color = [self titleShadowColorForState:self.state];
+ NSColor *color = [self titleShadowColorForState:self.state];
if(color == nil) {
color = [self titleShadowColorForState:TUIControlStateNormal];
}
View
12 lib/UIKit/TUIButton.h
@@ -74,20 +74,20 @@ typedef enum {
@interface TUIButton (Content)
- (void)setTitle:(NSString *)title forState:(TUIControlState)state;
-- (void)setTitleColor:(TUIColor *)color forState:(TUIControlState)state;
-- (void)setTitleShadowColor:(TUIColor *)color forState:(TUIControlState)state;
+- (void)setTitleColor:(NSColor *)color forState:(TUIControlState)state;
+- (void)setTitleShadowColor:(NSColor *)color forState:(TUIControlState)state;
- (void)setImage:(NSImage *)image forState:(TUIControlState)state;
- (void)setBackgroundImage:(NSImage *)image forState:(TUIControlState)state;
- (NSString *)titleForState:(TUIControlState)state;
-- (TUIColor *)titleColorForState:(TUIControlState)state;
-- (TUIColor *)titleShadowColorForState:(TUIControlState)state;
+- (NSColor *)titleColorForState:(TUIControlState)state;
+- (NSColor *)titleShadowColorForState:(TUIControlState)state;
- (NSImage *)imageForState:(TUIControlState)state;
- (NSImage *)backgroundImageForState:(TUIControlState)state;
@property(nonatomic, readonly, strong) NSString *currentTitle;
-@property(nonatomic, readonly, strong) TUIColor *currentTitleColor;
-@property(nonatomic, readonly, strong) TUIColor *currentTitleShadowColor;
+@property(nonatomic, readonly, strong) NSColor *currentTitleColor;
+@property(nonatomic, readonly, strong) NSColor *currentTitleShadowColor;
@property(nonatomic, readonly, strong) NSImage *currentImage;
@property(nonatomic, readonly, strong) NSImage *currentBackgroundImage;
@end
View
11 lib/UIKit/TUIButton.m
@@ -16,7 +16,6 @@
#import "TUIButton.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUIControl+Private.h"
#import "TUIImageView.h"
#import "TUILabel.h"
@@ -43,7 +42,7 @@ - (id)initWithFrame:(CGRect)frame
_buttonFlags.buttonType = TUIButtonTypeCustom;
_buttonFlags.dimsInBackground = 1;
_buttonFlags.firstDraw = 1;
- self.backgroundColor = [TUIColor clearColor];
+ self.backgroundColor = [NSColor clearColor];
self.needsDisplayWhenWindowsKeyednessChanges = YES;
self.reversesTitleShadowWhenHighlighted = NO;
}
@@ -97,7 +96,7 @@ - (TUILabel *)titleLabel
if(!_titleView) {
_titleView = [[TUILabel alloc] initWithFrame:CGRectZero];
_titleView.userInteractionEnabled = NO;
- _titleView.backgroundColor = [TUIColor clearColor];
+ _titleView.backgroundColor = [NSColor clearColor];
_titleView.hidden = YES; // we'll be drawing it ourselves
[self addSubview:_titleView];
}
@@ -108,7 +107,7 @@ - (TUIImageView *)imageView
{
if(!_imageView) {
_imageView = [[TUIImageView alloc] initWithFrame:CGRectZero];
- _imageView.backgroundColor = [TUIColor clearColor];
+ _imageView.backgroundColor = [NSColor clearColor];
_imageView.hidden = YES;
}
return _imageView;
@@ -215,12 +214,12 @@ - (void)drawRect:(CGRect)r
_titleView.text = title;
}
- TUIColor *color = self.currentTitleColor;
+ NSColor *color = self.currentTitleColor;
if(color != nil) {
_titleView.textColor = color;
}
- TUIColor *shadowColor = self.currentTitleShadowColor;
+ NSColor *shadowColor = self.currentTitleShadowColor;
// they may have manually set the renderer's shadow color, in which case we
// don't want to reset it to nothing
if(shadowColor != nil) {
View
89 lib/UIKit/TUIColor.h
@@ -1,89 +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>
-
-@interface TUIColor : NSObject
-{
- CGColorRef _cgColor; // backing color
- NSColor *_nsColor; // created on demand
-}
-
-+ (TUIColor *)colorWithWhite:(CGFloat)white alpha:(CGFloat)alpha;
-+ (TUIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
-+ (TUIColor *)colorWithCGColor:(CGColorRef)cgColor;
-+ (TUIColor *)colorWithNSColor:(NSColor *)nsColor;
-+ (TUIColor *)colorWithPatternImage:(NSImage *)image;
-
-- (TUIColor *)initWithWhite:(CGFloat)white alpha:(CGFloat)alpha;
-- (TUIColor *)initWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;
-- (TUIColor *)initWithCGColor:(CGColorRef)cgColor;
-- (TUIColor *)initWithPatternImage:(NSImage *)image;
-
-// cached
-+ (TUIColor *)blackColor; // 0.0 white
-+ (TUIColor *)darkGrayColor; // 0.333 white
-+ (TUIColor *)lightGrayColor; // 0.667 white
-+ (TUIColor *)whiteColor; // 1.0 white
-+ (TUIColor *)grayColor; // 0.5 white
-+ (TUIColor *)redColor; // 1.0, 0.0, 0.0 RGB
-+ (TUIColor *)greenColor; // 0.0, 1.0, 0.0 RGB
-+ (TUIColor *)blueColor; // 0.0, 0.0, 1.0 RGB
-+ (TUIColor *)cyanColor; // 0.0, 1.0, 1.0 RGB
-+ (TUIColor *)yellowColor; // 1.0, 1.0, 0.0 RGB
-+ (TUIColor *)magentaColor; // 1.0, 0.0, 1.0 RGB
-+ (TUIColor *)orangeColor; // 1.0, 0.5, 0.0 RGB
-+ (TUIColor *)purpleColor; // 0.5, 0.0, 0.5 RGB
-+ (TUIColor *)brownColor; // 0.6, 0.4, 0.2 RGB
-+ (TUIColor *)clearColor; // 0.0 white, 0.0 alpha
-
-// UIKit Additions
-
-+ (TUIColor *)selectedGradientBottomBlue;
-+ (TUIColor *)graphiteColor;
-
-+ (TUIColor *)linkColor;
-
-/**
- Sets fill and stroke for the current context
- */
-- (void)set;
-
-- (void)setFill;
-- (void)setStroke;
-
-- (TUIColor *)colorWithAlphaComponent:(CGFloat)alpha;
-
-@property (nonatomic, readonly) CGColorRef CGColor;
-
-@property (nonatomic, readonly) CGFloat alphaComponent;
-
-/**
- It is the caller's responsibility to ensure the reciever is an RGBA color. Pass NULL for components you don't care about.
- */
-- (void)getRed:(CGFloat *)r green:(CGFloat *)g blue:(CGFloat *)b alpha:(CGFloat *)a;
-
-/**
- It is the caller's responsibility to ensure the reciever is an Luminance/Alpha color. Pass NULL for components you don't care about.
- */
-- (void)getWhite:(CGFloat *)w alpha:(CGFloat *)a;
-
-/**
- Not cached
- */
-@property (strong, nonatomic, readonly) NSColor *nsColor;
-
-@end
View
235 lib/UIKit/TUIColor.m
@@ -1,235 +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 "TUIColor.h"
-#import "TUICGAdditions.h"
-
-@implementation TUIColor
-
-+ (TUIColor *)colorWithPatternImage:(NSImage *)image
-{
- return [[self alloc] initWithPatternImage:image];
-}
-
-+ (TUIColor *)colorWithNSColor:(NSColor *)nsColor
-{
- nsColor = [nsColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
- CGFloat r, g, b, a;
- [nsColor getRed:&r green:&g blue:&b alpha:&a];
- return [self colorWithRed:r green:g blue:b alpha:a];
-}
-
-+ (TUIColor *)colorWithWhite:(CGFloat)white alpha:(CGFloat)alpha
-{
- return [[self alloc] initWithWhite:white alpha:alpha];
-}
-
-+ (TUIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha
-{
- return [[self alloc] initWithRed:red green:green blue:blue alpha:alpha];
-}
-
-+ (TUIColor *)colorWithCGColor:(CGColorRef)cgColor
-{
- return [[self alloc] initWithCGColor:cgColor];
-}
-
-- (TUIColor *)initWithWhite:(CGFloat)white alpha:(CGFloat)alpha
-{
- CGColorRef c = CGColorCreateGenericGray(white, alpha);
- self = [self initWithCGColor:c];
- CGColorRelease(c);
- return self;
-}
-
-- (TUIColor *)initWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha
-{
- CGColorRef c = CGColorCreateGenericRGB(red, green, blue, alpha);
- self = [self initWithCGColor:c];
- CGColorRelease(c);
- return self;
-}
-
-- (TUIColor *)initWithCGColor:(CGColorRef)cgColor
-{
- if((self = [super init]))
- {
- _cgColor = cgColor;
- CGColorRetain(_cgColor);
- }
- return self;
-}
-
-static void patternDraw(void *info, CGContextRef ctx)
-{
- NSImage *image = (__bridge NSImage *)info;
-
- CGRect rect;
- rect.origin = CGPointZero;
- rect.size = image.size;
-
- CGImageRef cgImage = [image CGImageForProposedRect:&rect context:nil hints:nil];
- CGContextDrawImage(ctx, rect, cgImage);
-}
-
-static void patternRelease(void *info)
-{
- // transfer the object back to ARC, thus releasing it
- (void)(__bridge_transfer NSImage *)info;
-}
-
-- (TUIColor *)initWithPatternImage:(NSImage *)image
-{
- if((self = [super init]))
- {
- CGRect bounds;
- bounds.origin = CGPointZero;
- bounds.size = image.size;
-
- CGPatternCallbacks callbacks;
- callbacks.version = 0;
- callbacks.drawPattern = patternDraw;
- callbacks.releaseInfo = patternRelease;
-
- CGColorSpaceRef colorSpace = CGColorSpaceCreatePattern(NULL);
- CGPatternRef pattern = CGPatternCreate((__bridge_retained void *)image, bounds, CGAffineTransformIdentity, bounds.size.width, bounds.size.height, kCGPatternTilingConstantSpacing, YES, &callbacks);
- CGFloat components[] = {1.0, 1.0, 1.0, 1.0};
- _cgColor = CGColorCreateWithPattern(colorSpace, pattern, components);
- CGPatternRelease(pattern);
- CGColorSpaceRelease(colorSpace);
- }
- return self;
-}
-
-- (void)dealloc
-{
- CGColorRelease(_cgColor);
-}
-
-- (CGColorRef)CGColor
-{
- return _cgColor;
-}
-
-- (void)set
-{
- [self setFill];
- [self setStroke];
-}
-
-- (void)setFill
-{
- CGContextSetFillColorWithColor(TUIGraphicsGetCurrentContext(), _cgColor);
-}
-
-- (void)setStroke
-{
- CGContextSetStrokeColorWithColor(TUIGraphicsGetCurrentContext(), _cgColor);
-}
-
-- (TUIColor *)colorWithAlphaComponent:(CGFloat)alpha
-{
- CGColorRef c = CGColorCreateCopyWithAlpha(_cgColor, alpha);
- TUIColor *a = [TUIColor colorWithCGColor:c];
- CGColorRelease(c);
- return a;
-}
-
-#define CACHED_COLOR(NAME, IMPLEMENTATION) \
-+ (TUIColor *)NAME { \
- static __strong TUIColor *c = nil; \
- if(!c) \
- c = (IMPLEMENTATION); \
- return c; \
-}
-
-CACHED_COLOR(clearColor, [self colorWithWhite:0.0 alpha:0.0])
-CACHED_COLOR(blackColor, [self colorWithWhite:0.0 alpha:1.0])
-CACHED_COLOR(darkGrayColor, [self colorWithWhite:0.333 alpha:1.0])
-CACHED_COLOR(lightGrayColor, [self colorWithWhite:0.667 alpha:1.0])
-CACHED_COLOR(whiteColor, [self colorWithWhite:1.0 alpha:1.0])
-CACHED_COLOR(grayColor, [self colorWithWhite:0.5 alpha:1.0])
-CACHED_COLOR(redColor, [self colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0])
-CACHED_COLOR(greenColor, [self colorWithRed:0.0 green:1.0 blue:0.0 alpha:1.0])
-CACHED_COLOR(blueColor, [self colorWithRed:0.0 green:0.0 blue:1.0 alpha:1.0])
-CACHED_COLOR(cyanColor, [self colorWithRed:0.0 green:1.0 blue:1.0 alpha:1.0])
-CACHED_COLOR(yellowColor, [self colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0])
-CACHED_COLOR(magentaColor, [self colorWithRed:1.0 green:0.0 blue:1.0 alpha:1.0])
-CACHED_COLOR(orangeColor, [self colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0])
-CACHED_COLOR(purpleColor, [self colorWithRed:0.5 green:0.0 blue:0.5 alpha:1.0])
-CACHED_COLOR(brownColor, [self colorWithRed:0.6 green:0.4 blue:0.2 alpha:1.0])
-CACHED_COLOR(selectedGradientBottomBlue, [self colorWithRed:0.0 green:0.38 blue:0.92 alpha:1.0])
-CACHED_COLOR(graphiteColor, [self colorWithRed:0.45 green:0.49 blue:0.58 alpha:1.0])
-
-+ (TUIColor *)linkColor
-{
- return [TUIColor colorWithRed:13.0f/255.0f green:140.0f/255.0f blue:231.0f/255.0f alpha:1.0f];
-}
-
-- (NSColor *)nsColor
-{
- if(!_nsColor) {
- size_t n = CGColorGetNumberOfComponents(_cgColor);
- const CGFloat *components = CGColorGetComponents(_cgColor);
- if(n == 4) {
- // assume RGBA -- fixme
- _nsColor = [NSColor colorWithCalibratedRed:components[0] green:components[1] blue:components[2] alpha:components[3]];
- } else if(n == 2) {
- // assume LA -- fixme
- _nsColor = [NSColor colorWithCalibratedWhite:components[0] alpha:components[1]];
- }
- }
- return _nsColor;
-}
-
-- (CGFloat)alphaComponent
-{
- return CGColorGetAlpha(_cgColor);
-}
-
-- (void)getRed:(CGFloat *)r green:(CGFloat *)g blue:(CGFloat *)b alpha:(CGFloat *)a
-{
- switch(CGColorGetNumberOfComponents(_cgColor)) {
- case 4: { // assume RGBA
- const CGFloat *components = CGColorGetComponents(_cgColor);
- if(r) *r = components[0];
- if(g) *g = components[1];
- if(b) *b = components[2];
- if(a) *a = components[3];
- break;
- }
- default:
- // fail silently
- break;
- }
-}
-
-- (void)getWhite:(CGFloat *)w alpha:(CGFloat *)a
-{
- switch(CGColorGetNumberOfComponents(_cgColor)) {
- case 2: { // assume LA
- const CGFloat *components = CGColorGetComponents(_cgColor);
- if(w) *w = components[0];
- if(a) *a = components[1];
- break;
- }
- default:
- // fail silently
- break;
- }
-}
-
-@end
View
2  lib/UIKit/TUIKit.h
@@ -19,6 +19,7 @@
#import "CAAnimation+TUIExtensions.h"
#import "CoreText+Additions.h"
#import "NSClipView+TUIExtensions.h"
+#import "NSColor+TUIExtensions.h"
#import "NSImage+TUIExtensions.h"
#import "NSScrollView+TUIExtensions.h"
#import "NSView+TUIExtensions.h"
@@ -28,7 +29,6 @@
#import "TUIBridgedView.h"
#import "TUIButton.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUIHostView.h"
#import "TUIImageView.h"
#import "TUILabel.h"
View
27 lib/UIKit/TUILabel.h
@@ -23,27 +23,12 @@
*/
@interface TUILabel : TUIView
-{
- TUITextRenderer *renderer;
- struct {
- unsigned int selectable:1;
- } _textLabelFlags;
-
- NSString *_text;
- NSFont *_font;
- TUIColor *_textColor;
- TUITextAlignment _alignment;
- TUILineBreakMode _lineBreakMode;
-}
-
-@property(nonatomic,copy) NSString *text;
-@property(nonatomic,strong) NSAttributedString *attributedString;
-
-@property(nonatomic,getter=isSelectable) BOOL selectable;
+@property(nonatomic, copy) NSString *text;
+@property(nonatomic, strong) NSAttributedString *attributedString;
+@property(nonatomic, getter=isSelectable) BOOL selectable;
@property(nonatomic, readonly) TUITextRenderer *renderer;
-@property(nonatomic,strong) NSFont *font;
-@property(nonatomic,strong) TUIColor *textColor;
-@property(nonatomic,assign) TUITextAlignment alignment;
+@property(nonatomic, strong) NSFont *font;
+@property(nonatomic, strong) NSColor *textColor;
+@property(nonatomic, assign) TUITextAlignment alignment;
@property(nonatomic, assign) TUILineBreakMode lineBreakMode;
-
@end
View
10 lib/UIKit/TUILabel.m
@@ -15,13 +15,17 @@
*/
#import "TUILabel.h"
-#import "TUIColor.h"
#import "TUINSView.h"
#import "TUIStringDrawing.h"
#import "TUITextRenderer.h"
#import "TUIView+Private.h"
-@interface TUILabel ()
+@interface TUILabel () {
+ struct {
+ unsigned int selectable:1;
+ } _textLabelFlags;
+}
+
- (void)_recreateAttributedString;
@end
@@ -138,7 +142,7 @@ - (void)setFont:(NSFont *)font
self.attributedString = nil;
}
-- (void)setTextColor:(TUIColor *)textColor
+- (void)setTextColor:(NSColor *)textColor
{
if(textColor == _textColor) return;
View
5 lib/UIKit/TUIPopover.h
@@ -18,7 +18,6 @@
@class TUIPopover;
@class TUIViewController;
-@class TUIColor;
enum _TUIPopoverViewControllerBehaviour
{
@@ -68,7 +67,7 @@ typedef void (^TUIPopoverDelegateBlock)(TUIPopover *popover);
- (CGPathRef)newPopoverPathForEdge:(CGRectEdge)popoverEdge inFrame:(CGRect)frame; //override in subclasses to change the shape of the popover, but still use the default drawing.
//Used in the default implementation
-@property (nonatomic, strong) TUIColor *strokeColor;
-@property (nonatomic, strong) TUIColor *fillColor;
+@property (nonatomic, strong) NSColor *strokeColor;
+@property (nonatomic, strong) NSColor *fillColor;
@end
View
10 lib/UIKit/TUIPopover.m
@@ -16,8 +16,8 @@
#import "TUIPopover.h"
#import "CAAnimation+TUIExtensions.h"
+#import "NSColor+TUIExtensions.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUINSView.h"
#import "TUINSWindow.h"
#import "TUIViewController.h"
@@ -479,8 +479,8 @@ - (id)initWithFrame:(CGRect)frame popoverEdge:(CGRectEdge)popoverEdge originScre
_popoverEdge = popoverEdge;
_screenOriginRect = originScreenRect;
- _strokeColor = [TUIColor blackColor];
- _fillColor = [TUIColor whiteColor];
+ _strokeColor = [NSColor blackColor];
+ _fillColor = [NSColor whiteColor];
__block __unsafe_unretained TUIPopoverBackgroundView *weakSelf = self;
self.drawRect = ^ (TUIView *view, CGRect rect)
@@ -488,11 +488,11 @@ - (id)initWithFrame:(CGRect)frame popoverEdge:(CGRectEdge)popoverEdge originScre
TUIPopoverBackgroundView *strongSelf = weakSelf;
CGContextRef context = TUIGraphicsGetCurrentContext();
CGPathRef outerBorder = [strongSelf newPopoverPathForEdge:self.popoverEdge inFrame:self.bounds];
- CGContextSetStrokeColorWithColor(context, self.strokeColor.CGColor);
+ CGContextSetStrokeColorWithColor(context, self.strokeColor.tui_CGColor);
CGContextAddPath(context, outerBorder);
CGContextStrokePath(context);
- CGContextSetFillColorWithColor(context, self.fillColor.CGColor);
+ CGContextSetFillColorWithColor(context, self.fillColor.tui_CGColor);
CGContextAddPath(context, outerBorder);
CGContextFillPath(context);
View
7 lib/UIKit/TUIProgressBar.m
@@ -17,7 +17,6 @@
#import "TUIProgressBar.h"
#import "CAAnimation+TUIExtensions.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
NSString *GHUIProgressBarSetNeedsDisplayObservationContext = @"GHUIProgressBarSetNeedsDisplayObservationContext";
@@ -59,7 +58,7 @@ - (id)initWithFrame:(CGRect)frame style:(TUIProgressBarStyle)style {
self = [super initWithFrame:frame];
if(self == nil) return nil;
- self.backgroundColor = [TUIColor clearColor];
+ self.backgroundColor = [NSColor clearColor];
self.clipsToBounds = YES;
_style = style;
@@ -280,7 +279,7 @@ - (void)setIndeterminate:(BOOL)indeterminate
TUIView *animationClippingView = [[TUIView alloc] initWithFrame:[self fillRect]];
animationClippingView.clipsToBounds = YES;
animationClippingView.opaque = NO;
- animationClippingView.backgroundColor = [TUIColor clearColor];
+ animationClippingView.backgroundColor = [NSColor clearColor];
CGPathRef clipPath = TUICGPathCreateRoundedRect(animationClippingView.bounds, ceil(NSHeight(animationClippingView.bounds) / 2.0));
CAShapeLayer *clipLayer = [[CAShapeLayer alloc] init];
@@ -291,7 +290,7 @@ - (void)setIndeterminate:(BOOL)indeterminate
CGRect animationViewFrame = CGRectMake(NSMinX(animationClippingView.bounds),NSMinY(animationClippingView.bounds), (NSWidth(animationClippingView.bounds) * 2.0), NSHeight(animationClippingView.bounds));
self.animationView = [[TUIView alloc] initWithFrame:animationViewFrame];
self.animationView.opaque = NO;
- self.animationView.backgroundColor = [TUIColor clearColor];
+ self.animationView.backgroundColor = [NSColor clearColor];
self.animationView.drawRect = ^ (TUIView *view, CGRect dirtyRect) {
CGRect patternBounds = CGRectMake(0.0, 0.0, GHUIProgressBarBarberPolePatternWidth, NSHeight(view.bounds));
View
7 lib/UIKit/TUIScrollKnob.m
@@ -16,7 +16,6 @@
#import "TUIScrollKnob.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUIScrollView.h"
@interface TUIScrollKnob ()
@@ -37,7 +36,7 @@ - (id)initWithFrame:(CGRect)frame
knob = [[TUIView alloc] initWithFrame:CGRectMake(0, 0, 12, 12)];
knob.layer.cornerRadius = 4.0;
knob.userInteractionEnabled = NO;
- knob.backgroundColor = [TUIColor blackColor];
+ knob.backgroundColor = [NSColor blackColor];
[self addSubview:knob];
[self _updateKnob];
[self _updateKnobColor:0.0];
@@ -129,11 +128,11 @@ -(void)setScrollIndicatorStyle:(unsigned int)style {
_scrollKnobFlags.scrollIndicatorStyle = style;
switch(style){
case TUIScrollViewIndicatorStyleLight:
- knob.backgroundColor = [TUIColor whiteColor];
+ knob.backgroundColor = [NSColor whiteColor];
break;
case TUIScrollViewIndicatorStyleDark:
default:
- knob.backgroundColor = [TUIColor blackColor];
+ knob.backgroundColor = [NSColor blackColor];
break;
}
}
View
3  lib/UIKit/TUIStringDrawing.h
@@ -18,7 +18,6 @@
#import "TUIAttributedString.h"
@class NSFont;
-@class TUIColor;
@interface NSAttributedString (TUIStringDrawing)
@@ -41,7 +40,7 @@
//- (CGSize)drawInRect:(CGRect)rect withFont:(NSFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment;
#endif
-- (CGSize)ab_drawInRect:(CGRect)rect color:(TUIColor *)color font:(NSFont *)font;
+- (CGSize)ab_drawInRect:(CGRect)rect color:(NSColor *)color font:(NSFont *)font;
- (CGSize)ab_drawInRect:(CGRect)rect withFont:(NSFont *)font lineBreakMode:(TUILineBreakMode)lineBreakMode alignment:(TUITextAlignment)alignment;
@end
View
3  lib/UIKit/TUIStringDrawing.m
@@ -16,7 +16,6 @@
#import "TUIAttributedString.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUIStringDrawing.h"
#import "TUITextRenderer.h"
@@ -89,7 +88,7 @@ - (CGSize)ab_sizeWithFont:(NSFont *)font constrainedToSize:(CGSize)size
#endif
-- (CGSize)ab_drawInRect:(CGRect)rect color:(TUIColor *)color font:(NSFont *)font
+- (CGSize)ab_drawInRect:(CGRect)rect color:(NSColor *)color font:(NSFont *)font
{
TUIAttributedString *s = [TUIAttributedString stringWithString:self];
s.color = color;
View
2  lib/UIKit/TUIStyledView.h
@@ -11,7 +11,7 @@
@interface TUIStyledView : TUIView
-@property (nonatomic, strong) TUIColor *strokeColor;
+@property (nonatomic, strong) NSColor *strokeColor;
@property (nonatomic, assign) CGFloat strokeWidth;
@end
View
1  lib/UIKit/TUIStyledView.m
@@ -8,7 +8,6 @@
#import "TUIStyledView.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUITextRenderer.h"
@implementation TUIStyledView
View
8 lib/UIKit/TUITextRenderer.h
@@ -18,7 +18,6 @@
#import "CoreText+Additions.h"
@class NSFont;
-@class TUIColor;
@class TUIView;
@protocol ABActiveTextRange;
@@ -39,8 +38,7 @@ typedef enum {
@protocol TUITextRendererDelegate;
-@interface TUITextRenderer : TUIResponder
-{
+@interface TUITextRenderer : TUIResponder {
NSAttributedString *attributedString;
CGRect frame;
TUIView *__unsafe_unretained view; // unsafe_unretained
@@ -58,7 +56,7 @@ typedef enum {
CGSize shadowOffset;
CGFloat shadowBlur;
- TUIColor *shadowColor;
+ NSColor *shadowColor;
NSMutableDictionary *lineRects;
@@ -83,7 +81,7 @@ typedef enum {
@property (nonatomic, assign) CGSize shadowOffset;
@property (nonatomic, assign) CGFloat shadowBlur;
-@property (nonatomic, strong) TUIColor *shadowColor; // default = nil for no shadow
+@property (nonatomic, strong) NSColor *shadowColor; // default = nil for no shadow
@property (nonatomic, assign) TUITextVerticalAlignment verticalAlignment;
View
11 lib/UIKit/TUITextRenderer.m
@@ -16,9 +16,9 @@
#import "TUITextRenderer.h"
#import "ABActiveRange.h"
+#import "NSColor+TUIExtensions.h"
#import "TUIAttributedString.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUIStringDrawing.h"
#import "TUITextRenderer+Event.h"
#import "TUIView.h"
@@ -286,9 +286,10 @@ - (void)drawInContext:(CGContextRef)context
rect = CGRectInset(rect, -2, -1);
rect.size.height -= 1;
rect = CGRectIntegral(rect);
- TUIColor *color = [TUIColor colorWithWhite:1.0 alpha:1.0];
- [color set];
- CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 8, color.CGColor);
+ NSColor *color = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
+ [color setFill];
+
+ CGContextSetShadowWithColor(context, CGSizeMake(0, 0), 8, color.tui_CGColor);
CGContextFillRoundRect(context, rect, 10);
}
@@ -312,7 +313,7 @@ - (void)drawInContext:(CGContextRef)context
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
if(shadowColor)
- CGContextSetShadowWithColor(context, shadowOffset, shadowBlur, shadowColor.CGColor);
+ CGContextSetShadowWithColor(context, shadowOffset, shadowBlur, shadowColor.tui_CGColor);
CTFrameDraw(f, context); // draw actual text
View
8 lib/UIKit/TUITextView.h
@@ -20,12 +20,10 @@
@class TUITextEditor;
@class NSFont;
-@class TUIColor;
@protocol TUITextViewDelegate;
-@interface TUITextView : TUIControl
-{
+@interface TUITextView : TUIControl {
id<TUITextViewDelegate> __unsafe_unretained delegate;
TUIViewDrawRect drawFrame;
@@ -33,7 +31,7 @@
TUITextRenderer *placeholderRenderer;
NSFont *font;
- TUIColor *textColor;
+ NSColor *textColor;
TUITextAlignment textAlignment;
BOOL editable;
@@ -68,7 +66,7 @@
@property (nonatomic, copy) NSString *text;
@property (nonatomic, copy) NSString *placeholder;
@property (nonatomic, strong) NSFont *font;
-@property (nonatomic, strong) TUIColor *textColor;
+@property (nonatomic, strong) NSColor *textColor;
@property (nonatomic, assign) TUITextAlignment textAlignment;
@property (nonatomic, assign) TUIEdgeInsets contentInset;
View
11 lib/UIKit/TUITextView.m
@@ -16,7 +16,6 @@
#import "TUITextView.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUINSView.h"
#import "TUINSWindow.h"
#import "TUITextViewEditor.h"
@@ -119,7 +118,7 @@ - (Class)textEditorClass
- (id)initWithFrame:(CGRect)frame
{
if((self = [super initWithFrame:frame])) {
- self.backgroundColor = [TUIColor clearColor];
+ self.backgroundColor = [NSColor clearColor];
renderer = [[[self textEditorClass] alloc] init];
renderer.delegate = self;
@@ -127,13 +126,13 @@ - (id)initWithFrame:(CGRect)frame
cursor = [[TUIView alloc] initWithFrame:CGRectZero];
cursor.userInteractionEnabled = NO;
- cursor.backgroundColor = [TUIColor linkColor];
+ cursor.backgroundColor = [NSColor colorWithCalibratedRed:13 / 255.0 green:140 / 255.0 blue:231 / 255.0 alpha:1];
[self addSubview:cursor];
self.autocorrectedResults = [NSMutableDictionary dictionary];
self.font = [NSFont fontWithName:@"HelveticaNeue" size:12];
- self.textColor = [TUIColor blackColor];
+ self.textColor = [NSColor blackColor];
[self _updateDefaultAttributes];
self.drawFrame = TUITextViewStandardFrame();
@@ -182,7 +181,7 @@ - (void)setFont:(NSFont *)f
[self _updateDefaultAttributes];
}
-- (void)setTextColor:(TUIColor *)c
+- (void)setTextColor:(NSColor *)c
{
textColor = c;
[self _updateDefaultAttributes];
@@ -432,7 +431,7 @@ - (void)_checkSpelling
NSLog(@"Autocorrection result that's out of range: %@", result);
}
} else if(result.resultType == NSTextCheckingTypeSpelling) {
- [[renderer backingStore] addAttribute:(id)kCTUnderlineColorAttributeName value:(id)[TUIColor redColor].CGColor range:result.range];
+ [[renderer backingStore] addAttribute:NSUnderlineColorAttributeName value:[NSColor redColor] range:result.range];
[[renderer backingStore] addAttribute:(id)kCTUnderlineStyleAttributeName value:[NSNumber numberWithInteger:kCTUnderlineStyleThick | kCTUnderlinePatternDot] range:result.range];
}
}
View
3  lib/UIKit/TUIView.h
@@ -61,7 +61,6 @@ typedef enum {
TUIViewContentModeScaleAspectFill,
} TUIViewContentMode;
-@class TUIColor;
@class TUINSView;
@class TUINSWindow;
@class TUIView;
@@ -373,7 +372,7 @@ extern CGRect(^TUIViewCenteredLayout)(TUIView*);
/**
default is nil. Setting this with a color with <1.0 alpha will also set opaque=NO
*/
-@property (nonatomic,copy) TUIColor *backgroundColor;
+@property (nonatomic,copy) NSColor *backgroundColor;
/**
animatable. default is 1.0
View
11 lib/UIKit/TUIView.m
@@ -16,8 +16,8 @@
#import "TUIView.h"
#import <pthread.h>
+#import "NSColor+TUIExtensions.h"
#import "TUICGAdditions.h"
-#import "TUIColor.h"
#import "TUILayoutManager.h"
#import "TUINSView.h"
#import "TUINSWindow.h"
@@ -1083,16 +1083,17 @@ - (void)setHidden:(BOOL)h
self.layer.hidden = h;
}
-- (TUIColor *)backgroundColor
+- (NSColor *)backgroundColor
{
- return [TUIColor colorWithCGColor:self.layer.backgroundColor];
+ return [NSColor tui_colorWithCGColor:self.layer.backgroundColor];
}
-- (void)setBackgroundColor:(TUIColor *)color
+- (void)setBackgroundColor:(NSColor *)color
{
- self.layer.backgroundColor = color.CGColor;
+ self.layer.backgroundColor = color.tui_CGColor;
if(color.alphaComponent < 1.0)
self.opaque = NO;
+
[self setNeedsDisplay];
}
View
3  lib/UIKit/TUIViewController.m
@@ -15,7 +15,6 @@
*/
#import "TUIViewController.h"
-#import "TUIColor.h"
#import "TUIView.h"
@implementation TUIViewController
@@ -107,7 +106,7 @@ - (TUIResponder *)initialFirstResponder
- (TUIView *)setupStandardView
{
TUIView *v = [[TUIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
- v.backgroundColor = [TUIColor colorWithWhite:0.96 alpha:1.0];
+ v.backgroundColor = [NSColor colorWithCalibratedWhite:0.96 alpha:1.0];
self.view = v;
return v;
Please sign in to comment.
Something went wrong with that request. Please try again.