* Tests/gui/NSView/NSView_autoresize_and_rounding.m: Add tests

for centerScanRect: with flipped view.
        * Source/NSView.m (-centerScanRect:): Change to get the failed
        tests to pass.
        * Source/GSThemeTools.m (-drawRoundBezel:withColor:): Make round
        bezel look a bit nicer.
        * Source/NSButtonCell.m (-drawImage:withFrame:inView:): Use
        centerScanRect: instead of similar code.
        * Source/NSCell.m: Use imageRectForBounds: and
        titleRectForBounds: in drawInteriorWithFrame:inView:.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38929 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2015-08-25 21:33:04 +00:00
parent 80f7c762a3
commit 1f3a02d1e7
6 changed files with 98 additions and 64 deletions

View file

@ -1015,47 +1015,23 @@ typedef struct _GSButtonCellFlags
toFitInSize: cellFrame.size
scalingType: _imageScaling];
/* Pixel-align size */
if (controlView)
{
NSSize sizeInBase = [controlView convertSizeToBase: size];
sizeInBase.width = GSRoundTowardsInfinity(sizeInBase.width);
sizeInBase.height = GSRoundTowardsInfinity(sizeInBase.height);
size = [controlView convertSizeFromBase: sizeInBase];
}
/* Calculate an offset from the cellFrame origin */
offset = NSMakePoint((NSWidth(cellFrame) - size.width) / 2.0,
(NSHeight(cellFrame) - size.height) / 2.0);
/* Pixel-align the offset */
if (controlView)
{
NSPoint inBase = [controlView convertPointToBase: offset];
// By convention we will round down and to the right.
// With the standard button design this looks good
// because the bottom and right edges of the button look 'heavier'
// so if the image's center must be offset from the button's geometric
// center, it looks beter if it's closer to the 'heavier' part
inBase.x = GSRoundTowardsInfinity(inBase.x);
inBase.y = [controlView isFlipped] ?
GSRoundTowardsInfinity(inBase.y) :
GSRoundTowardsNegativeInfinity(inBase.y);
offset = [controlView convertPointFromBase: inBase];
}
/* Draw the image */
(NSHeight(cellFrame) - size.height) / 2.0);
rect = NSMakeRect(cellFrame.origin.x + offset.x,
cellFrame.origin.y + offset.y,
size.width,
size.height);
/* Pixel-align */
if (nil != controlView)
{
rect = [controlView centerScanRect: rect];
}
/* Draw the image */
fraction = (![self isEnabled] &&
[self imageDimsWhenDisabled]) ? 0.5 : 1.0;