Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upstream-ML-scrol…
Browse files Browse the repository at this point in the history
…lbars

Conflicts:
	lib/UIKit/TUIScrollKnob.m
  • Loading branch information
avaidyam committed Oct 17, 2012
2 parents 310574e + 8827005 commit a733539
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 35 deletions.
1 change: 1 addition & 0 deletions lib/UIKit/TUIButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ - (void)drawRect:(CGRect)r
CGContextSetAlpha(ctx, 0.5);
CGRect titleFrame = self.bounds;
titleFrame.size.width -= (_titleEdgeInsets.left + _titleEdgeInsets.right);
titleFrame.size.height -= (_titleEdgeInsets.top + _titleEdgeInsets.bottom);
self.titleLabel.frame = titleFrame;
[self.titleLabel drawRect:self.titleLabel.bounds];
CGContextRestoreGState(ctx);
Expand Down
5 changes: 3 additions & 2 deletions lib/UIKit/TUICGAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,12 @@ void TUIGraphicsEndImageContext(void)

NSImage *TUIGraphicsDrawAsImage(CGSize size, void(^draw)(void))
{
TUIGraphicsBeginImageContext(size);
TUIGraphicsBeginImageContextWithOptions(size, NO, 0);
draw();
NSImage *image = TUIGraphicsGetImageFromCurrentImageContext();
TUIGraphicsEndImageContext();


image.size = size;
return image;
}

Expand Down
1 change: 1 addition & 0 deletions lib/UIKit/TUILabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ - (id)initWithFrame:(CGRect)frame
{
if((self = [super initWithFrame:frame])) {
renderer = [[TUITextRenderer alloc] init];
renderer.verticalAlignment = TUITextVerticalAlignmentMiddle;
[self setTextRenderers:[NSArray arrayWithObjects:renderer, nil]];

_lineBreakMode = TUILineBreakModeClip;
Expand Down
2 changes: 0 additions & 2 deletions lib/UIKit/TUINSWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ - (NSInteger)futureMakeFirstResponderRequestToken

- (BOOL)tui_makeFirstResponder:(NSResponder *)aResponder
{
if(![aResponder acceptsFirstResponder])
return NO;
++makeFirstResponderCount; // cool if it overflows
if([aResponder respondsToSelector:@selector(initialFirstResponder)])
aResponder = ((TUIResponder *)aResponder).initialFirstResponder;
Expand Down
4 changes: 3 additions & 1 deletion lib/UIKit/TUIScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,8 @@ - (void)_startThrow
_throw.t = t;

[self _startTimer:AnimationModeThrow];

BOOL pulling = self._pulling; // prefetch the pulling state before resetting it

if(_pull.xPulling) {
_pull.xPulling = NO;
Expand All @@ -1038,7 +1040,7 @@ - (void)_startThrow
_bounce.y = _pull.y;
}

if(self._pulling && _scrollViewFlags.didChangeContentInset){
if(pulling && _scrollViewFlags.didChangeContentInset){
_scrollViewFlags.didChangeContentInset = 0;
_bounce.x += _contentInset.left;
_bounce.y += _contentInset.top;
Expand Down
47 changes: 25 additions & 22 deletions lib/UIKit/TUITextEditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (id)init
markedRange = NSMakeRange(NSNotFound, 0);
inputContext = [[NSTextInputContext alloc] initWithClient:self];
inputContext.acceptsGlyphInfo = YES;
_secure = NO;
self.attributedString = backingStore;
}
Expand All @@ -50,19 +50,19 @@ - (void)setSecure:(BOOL)secured {
}

- (NSAttributedString*)drawingAttributedString {
if(_secure) {
NSString *placeholder = @"\u2022";
NSUInteger backingStoreLength = backingStore.length;
NSMutableString *string = [NSMutableString string];
for(int i = 0; i < backingStoreLength; i++) {
[string appendString:placeholder];
}
NSAttributedString *securePlaceHolder = [[NSAttributedString alloc] initWithString:string attributes:defaultAttributes];
return securePlaceHolder;
}
return [super drawingAttributedString];
if(_secure) {
NSString *placeholder = @"\u2022";
NSUInteger backingStoreLength = backingStore.length;
NSMutableString *string = [NSMutableString string];
for(int i = 0; i < backingStoreLength; i++) {
[string appendString:placeholder];
}
NSAttributedString *securePlaceHolder = [[NSAttributedString alloc] initWithString:string attributes:defaultAttributes];
return securePlaceHolder;
}
return [super drawingAttributedString];
}

- (NSTextInputContext *)inputContext
Expand Down Expand Up @@ -121,18 +121,18 @@ - (void)setText:(NSString *)aString

- (BOOL)respondsToSelector:(SEL)aSelector
{
if(aSelector == @selector(copy:) || aSelector == @selector(cut:))
return !_secure;
return [super respondsToSelector:aSelector];
if(aSelector == @selector(copy:) || aSelector == @selector(cut:))
return !_secure;
return [super respondsToSelector:aSelector];
}

- (void)copy:(id)sender
{
if(_secure) {
return;
}
[super copy:sender];
if(_secure) {
return;
}
[super copy:sender];
}

- (void)cut:(id)sender
Expand All @@ -146,6 +146,7 @@ - (void)paste:(id)sender
if (self.editable) {
[self insertText:[[NSPasteboard generalPasteboard] stringForType:NSPasteboardTypeString]];
}
[self _scrollToIndex:MAX(_selectionStart, _selectionEnd)];
}

- (void)patchMenuWithStandardEditingMenuItems:(NSMenu *)menu
Expand Down Expand Up @@ -218,6 +219,7 @@ - (void)deleteCharactersInRange:(NSRange)range // designated delete
selectedRange.length = 0;
self.selectedRange = selectedRange;
[self _textDidChange];
[self _scrollToIndex:MAX(_selectionStart, _selectionEnd)];
}


Expand Down Expand Up @@ -278,6 +280,7 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange // des
[self unmarkText];
self.selectedRange = selectedRange;
[self _textDidChange];
[self _scrollToIndex:MAX(_selectionStart, _selectionEnd)];
}

/* The receiver inserts aString replacing the content specified by replacementRange.
Expand Down
Loading

0 comments on commit a733539

Please sign in to comment.