Skip to content
Browse files

Refactoring to change uses of TUIColor to NSColor

  • Loading branch information...
1 parent a8dfa16 commit ce1fef35304fb984d47789c9b678fb1146d2a64c @jspahrsummers jspahrsummers committed Jul 27, 2012
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,21 +162,22 @@ - (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];
NSImage *shadowImage = [NSImage tui_imageWithSize:paddedImage.size drawing:^(CGContextRef ctx) {
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,15 +55,15 @@ - (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];
[self setNeedsDisplay];
[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,19 +122,19 @@ - (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];
}
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
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,20 +479,20 @@ - (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)
{
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,20 +20,18 @@
@class TUITextEditor;
@class NSFont;
-@class TUIColor;
@protocol TUITextViewDelegate;
-@interface TUITextView : TUIControl
-{
+@interface TUITextView : TUIControl {
id<TUITextViewDelegate> __unsafe_unretained delegate;
TUIViewDrawRect drawFrame;
NSString *placeholder;
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,21 +118,21 @@ - (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;
self.textRenderers = [NSArray arrayWithObject:renderer];
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"
@@ -1078,16 +1078,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;

0 comments on commit ce1fef3

Please sign in to comment.
Something went wrong with that request. Please try again.