mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 13:20:42 +00:00
* Headers/AppKit/NSView.h:
* Source/NSView.m (-resizeWithOldSuperviewSize): Pixel-align view frame when autoresizing. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33483 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9c681fa416
commit
67cd120733
3 changed files with 50 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2011-07-07 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSView.h:
|
||||||
|
* Source/NSView.m (-resizeWithOldSuperviewSize): Pixel-align
|
||||||
|
view frame when autoresizing.
|
||||||
|
|
||||||
2011-07-03 Fred Kiefer <FredKiefer@gmx.de>
|
2011-07-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSView.m (-resizeWithOldSuperviewSize): Reimplement to
|
* Source/NSView.m (-resizeWithOldSuperviewSize): Reimplement to
|
||||||
|
|
|
@ -151,6 +151,7 @@ PACKAGE_SCOPE
|
||||||
|
|
||||||
unsigned int _autoresizingMask;
|
unsigned int _autoresizingMask;
|
||||||
NSFocusRingType _focusRingType;
|
NSFocusRingType _focusRingType;
|
||||||
|
NSRect _autoresizingFrameError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1163,6 +1163,12 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _setFrameAndClearAutoresizingError: (NSRect)frameRect
|
||||||
|
{
|
||||||
|
_frame = frameRect;
|
||||||
|
_autoresizingFrameError = NSZeroRect;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setFrame: (NSRect)frameRect
|
- (void) setFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
BOOL changedOrigin = NO;
|
BOOL changedOrigin = NO;
|
||||||
|
@ -1191,7 +1197,7 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
|
||||||
|
|
||||||
if (changedSize == YES || changedOrigin == YES)
|
if (changedSize == YES || changedOrigin == YES)
|
||||||
{
|
{
|
||||||
_frame = frameRect;
|
[self _setFrameAndClearAutoresizingError: frameRect];
|
||||||
|
|
||||||
if (changedSize == YES)
|
if (changedSize == YES)
|
||||||
{
|
{
|
||||||
|
@ -1230,12 +1236,14 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
|
||||||
{
|
{
|
||||||
if (NSEqualPoints(_frame.origin, newOrigin) == NO)
|
if (NSEqualPoints(_frame.origin, newOrigin) == NO)
|
||||||
{
|
{
|
||||||
_frame.origin = newOrigin;
|
NSRect newFrame = _frame;
|
||||||
|
newFrame.origin = newOrigin;
|
||||||
|
|
||||||
if (_coordinates_valid)
|
if (_coordinates_valid)
|
||||||
{
|
{
|
||||||
(*invalidateImp)(self, invalidateSel);
|
(*invalidateImp)(self, invalidateSel);
|
||||||
}
|
}
|
||||||
|
[self _setFrameAndClearAutoresizingError: newFrame];
|
||||||
[self resetCursorRects];
|
[self resetCursorRects];
|
||||||
if (_post_frame_changes)
|
if (_post_frame_changes)
|
||||||
{
|
{
|
||||||
|
@ -1247,6 +1255,7 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
|
||||||
|
|
||||||
- (void) setFrameSize: (NSSize)newSize
|
- (void) setFrameSize: (NSSize)newSize
|
||||||
{
|
{
|
||||||
|
NSRect newFrame = _frame;
|
||||||
if (newSize.width < 0)
|
if (newSize.width < 0)
|
||||||
{
|
{
|
||||||
NSWarnMLog(@"given negative width", 0);
|
NSWarnMLog(@"given negative width", 0);
|
||||||
|
@ -1268,7 +1277,8 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
|
||||||
CGFloat sx = _bounds.size.width / _frame.size.width;
|
CGFloat sx = _bounds.size.width / _frame.size.width;
|
||||||
CGFloat sy = _bounds.size.height / _frame.size.height;
|
CGFloat sy = _bounds.size.height / _frame.size.height;
|
||||||
|
|
||||||
_frame.size = newSize;
|
newFrame.size = newSize;
|
||||||
|
[self _setFrameAndClearAutoresizingError: newFrame];
|
||||||
_bounds.size.width = _frame.size.width * sx;
|
_bounds.size.width = _frame.size.width * sx;
|
||||||
_bounds.size.height = _frame.size.height * sy;
|
_bounds.size.height = _frame.size.height * sy;
|
||||||
}
|
}
|
||||||
|
@ -1277,7 +1287,9 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
|
||||||
NSAffineTransform *matrix;
|
NSAffineTransform *matrix;
|
||||||
NSRect frame;
|
NSRect frame;
|
||||||
|
|
||||||
_frame.size = newSize;
|
newFrame.size = newSize;
|
||||||
|
[self _setFrameAndClearAutoresizingError: newFrame];
|
||||||
|
|
||||||
frame = _frame;
|
frame = _frame;
|
||||||
frame.origin = NSMakePoint(0, 0);
|
frame.origin = NSMakePoint(0, 0);
|
||||||
matrix = [_boundsMatrix copy];
|
matrix = [_boundsMatrix copy];
|
||||||
|
@ -1288,7 +1300,8 @@ static NSSize _computeScale(NSSize fs, NSSize bs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_frame.size = _bounds.size = newSize;
|
newFrame.size = _bounds.size = newSize;
|
||||||
|
[self _setFrameAndClearAutoresizingError: newFrame];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_coordinates_valid)
|
if (_coordinates_valid)
|
||||||
|
@ -1941,6 +1954,14 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
|
||||||
if (_autoresizingMask == NSViewNotSizable)
|
if (_autoresizingMask == NSViewNotSizable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!NSEqualRects(NSZeroRect, _autoresizingFrameError))
|
||||||
|
{
|
||||||
|
newFrame.origin.x -= _autoresizingFrameError.origin.x;
|
||||||
|
newFrame.origin.y -= _autoresizingFrameError.origin.y;
|
||||||
|
newFrame.size.width -= _autoresizingFrameError.size.width;
|
||||||
|
newFrame.size.height -= _autoresizingFrameError.size.height;
|
||||||
|
}
|
||||||
|
|
||||||
superViewFrameSize = NSMakeSize(0,0);
|
superViewFrameSize = NSMakeSize(0,0);
|
||||||
if (_super_view)
|
if (_super_view)
|
||||||
superViewFrameSize = [_super_view frame].size;
|
superViewFrameSize = [_super_view frame].size;
|
||||||
|
@ -2019,7 +2040,23 @@ convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matrix1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[self setFrame: newFrame];
|
|
||||||
|
NSRect newFrameRounded = newFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform rounding to pixel-align the frame if we are not rotated
|
||||||
|
*/
|
||||||
|
if (![self isRotatedFromBase] && [self superview] != nil)
|
||||||
|
{
|
||||||
|
newFrameRounded = [[self superview] centerScanRect: newFrameRounded];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self setFrame: newFrameRounded];
|
||||||
|
|
||||||
|
_autoresizingFrameError.origin.x = (newFrameRounded.origin.x - newFrame.origin.x);
|
||||||
|
_autoresizingFrameError.origin.y = (newFrameRounded.origin.y - newFrame.origin.y);
|
||||||
|
_autoresizingFrameError.size.width = (newFrameRounded.size.width - newFrame.size.width);
|
||||||
|
_autoresizingFrameError.size.height = (newFrameRounded.size.height - newFrame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect
|
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue