Added:

- setResizeIndicatorOffset:
- resizeIndicatorOffset

to CPWindow.

[#21 state:resolved]

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2008-09-07 02:49:32 -07:00
1 parent a1920c55c3
commit 71a468f932
3 files changed
+50 -28

No files matched your search

+4 -10
View File
@@ -410,18 +410,12 @@ var CPWindowSaveImage = nil,
- (CGSize)resizeIndicatorOffset
{
return _resizeIndicatorOffset;
return [_windowView resizeIndicatorOffset];
}
- (void)setResizeIndicatorOffset:(CGSize)aSize
- (void)setResizeIndicatorOffset:(CGSize)anOffset
{
_resizeIndicatorOffset = CGSizeCreateCopy(aSize);
if (_showsResizeIndicator)
{
_resizeIndicator.style.top = (CGRectGetMaxY(_windowView._frame) - 13.0 + _resizeIndicatorOffset.height) + "px";
_resizeIndicator.style.left = (CGRectGetMaxX(_windowView._frame) - 13.0 + _resizeIndicatorOffset.width) + "px";
}
[_windowView setResizeIndicatorOffset:anOffset];
}
- (void)setContentView:(CPView)aView
@@ -433,7 +427,7 @@ var CPWindowSaveImage = nil,
[_contentView setFrame:[self contentRectForFrameRect:_frame]];
[_contentView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_windowView addSubview:_contentView];
[_windowView addSubview:_contentView positioned:CPWindowBelow relativeTo:nil];
}
- (CPView)contentView
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

+46 -18
View File
@@ -31,6 +31,7 @@ var _CPWindowViewResizeIndicatorImage = nil;
unsigned _styleMask;
CPImageView _resizeIndicator;
CGSize _resizeIndicatorOffset;
CPString _title;
}
@@ -59,14 +60,9 @@ var _CPWindowViewResizeIndicatorImage = nil;
if (self)
{
_resizeIndicator = [[CPImageView alloc] initWithFrame:CGRectMakeZero()];
_resizeIndicatorOffset = CGSizeMake(0.0, 0.0);
[_resizeIndicator setImage:_CPWindowViewResizeIndicatorImage];
[_resizeIndicator setFrameSize:CGSizeMakeCopy([_CPWindowViewResizeIndicatorImage size])];
[self addSubview:_resizeIndicator];
[self setShowsResizeIndicator:_styleMask & CPResizableWindowMask];
[self setShowsResizeIndicator:((_styleMask & CPBorderlessWindowMask) || (_styleMask & CPBorderlessBridgeWindowMask)) && (_styleMask & CPResizableWindowMask)];
}
return self;
@@ -90,15 +86,10 @@ var _CPWindowViewResizeIndicatorImage = nil;
{
var theWindow = [self window];
if (![_resizeIndicator isHidden])
if ((_styleMask & CPResizableWindowMask) && _resizeIndicator)
{
// FIXME: This should be better
var frame = CGRectMakeCopy([self frame]);
frame.origin.x = CGRectGetWidth(frame) - 20.0;
frame.origin.y = CGRectGetHeight(frame) - 24.0;
frame.size.width = 20.0 - 5.0,
frame.size.height = 24.0 - 8.0;
var frame = [_resizeIndicator frame];
if (CGRectContainsPoint(frame, [self convertPoint:[anEvent locationInWindow] fromView:nil]))
return [theWindow trackResizeWithEvent:anEvent];
@@ -113,12 +104,50 @@ var _CPWindowViewResizeIndicatorImage = nil;
- (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator
{
[_resizeIndicator setHidden:!shouldShowResizeIndicator];
if (shouldShowResizeIndicator)
{
var size = [_CPWindowViewResizeIndicatorImage size],
boundsSize = [self frame].size;
_resizeIndicator = [[CPImageView alloc] initWithFrame:CGRectMake(boundsSize.width - size.width - _resizeIndicatorOffset.width, boundsSize.height - size.height - _resizeIndicatorOffset.height, size.width, size.height)];
[_resizeIndicator setImage:_CPWindowViewResizeIndicatorImage];
[_resizeIndicator setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
[self addSubview:_resizeIndicator positioned:CPWindowAbove relativeTo:nil];
}
else
{
[_resizeIndicator removeFromSuperview];
_resizeIndicator = nil;
}
}
- (CPImage)showsResizeIndicator
{
return ![_resizeIndicator isHidden];
return _resizeIndicator != nil;
}
- (void)setResizeIndicatorOffset:(CGSize)anOffset
{
if (CGSizeEqualToSize(_resizeIndicatorOffset, anOffset))
return;
_resizeIndicatorOffset = anOffset;
if (!_resizeIndicator)
return;
var size = [_resizeIndicator frame].size,
boundsSize = [self frame].size;
[_resizeIndicator setFrameOrigin:CGPointMake(boundsSize.width - size.width - anOffset.width, boundsSize.height - size.height - anOffset.height)];
}
- (CGSize)resizeIndicatorOffset
{
return _resizeIndicatorOffset;
}
- (void)setTitle:(CPString)title
@@ -235,8 +264,7 @@ var _CPHUDWindowViewTopImage = nil,
[self addSubview:_closeButton];
}
[_resizeIndicator setFrameOrigin:CGPointMake(CGRectGetWidth(bounds) - 20.0, CGRectGetHeight(bounds) - 24.0)];
[_resizeIndicator setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
[self setResizeIndicatorOffset:CGSizeMake(8.0, 12.0)];
}
return self;