mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 18:50:48 +00:00
* Source/GSThemeTools.m: Correct implementation of contentRectForRect
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29424 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8906ec7b22
commit
1ed115d842
2 changed files with 11 additions and 63 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2010-01-27 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
|
* Source/GSThemeTools.m: Correct implementation of contentRectForRect:
|
||||||
|
|
||||||
2010-01-27 Eric Wasylishen <ewasylishen@gmail.com>
|
2010-01-27 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/GSThemeTools.m:
|
* Source/GSThemeTools.m:
|
||||||
|
|
|
@ -1079,69 +1079,13 @@ withRepeatedImage: (NSImage*)image
|
||||||
|
|
||||||
- (NSRect) contentRectForRect: (NSRect)rect
|
- (NSRect) contentRectForRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
NSRect contentRectParts[9];
|
NSSize total = [self computeTotalTilesSize];
|
||||||
NSRect scaledContentRect;
|
NSRect inFill = NSMakeRect(
|
||||||
int i;
|
rect.origin.x + contentRect.origin.x,
|
||||||
float centerHScale, centerVScale;
|
rect.origin.y + contentRect.origin.y,
|
||||||
|
rect.size.width - (total.width - contentRect.size.width),
|
||||||
// Divide the content rect into 9 parts
|
rect.size.height - (total.height - contentRect.size.height));
|
||||||
for (i = 0; i < 9; i++)
|
return inFill;
|
||||||
{
|
|
||||||
contentRectParts[i] = NSIntersectionRect(contentRect, rects[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rects[TileCM].size.width > 0)
|
|
||||||
{
|
|
||||||
centerHScale = (rect.size.width - rects[TileCL].size.width -
|
|
||||||
rects[TileCR].size.width) / rects[TileCM].size.width;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
centerHScale = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rects[TileCM].size.height > 0)
|
|
||||||
{
|
|
||||||
centerVScale = (rect.size.height - rects[TileCL].size.height -
|
|
||||||
rects[TileCR].size.height) / rects[TileCM].size.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
centerVScale = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
contentRectParts[TileTM].size.width *= centerHScale;
|
|
||||||
contentRectParts[TileCM].size.width *= centerHScale;
|
|
||||||
contentRectParts[TileBM].size.width *= centerHScale;
|
|
||||||
|
|
||||||
contentRectParts[TileCL].size.height *= centerVScale;
|
|
||||||
contentRectParts[TileCM].size.height *= centerVScale;
|
|
||||||
contentRectParts[TileCR].size.height *= centerVScale;
|
|
||||||
|
|
||||||
// Recalculate the origins of the top row and right column of the
|
|
||||||
// contentRectParts
|
|
||||||
|
|
||||||
contentRectParts[TileTL].origin.y = contentRectParts[TileCL].origin.y +
|
|
||||||
contentRectParts[TileCL].size.height;
|
|
||||||
|
|
||||||
contentRectParts[TileTM].origin.y = contentRectParts[TileTL].origin.y;
|
|
||||||
|
|
||||||
contentRectParts[TileTR].origin.y = contentRectParts[TileTL].origin.y;
|
|
||||||
contentRectParts[TileTR].origin.x = contentRectParts[TileTM].origin.x +
|
|
||||||
contentRectParts[TileTM].size.width;
|
|
||||||
|
|
||||||
contentRectParts[TileCR].origin.x = contentRectParts[TileTR].origin.x;
|
|
||||||
|
|
||||||
contentRectParts[TileBR].origin.x = contentRectParts[TileTR].origin.x;
|
|
||||||
|
|
||||||
// Return the union of the scaled contentRectParts
|
|
||||||
// NOTE: NSUnionRect ignores rects with width and height of 0
|
|
||||||
scaledContentRect = NSZeroRect;
|
|
||||||
for (i = 0; i < 9; i++)
|
|
||||||
{
|
|
||||||
scaledContentRect = NSUnionRect(scaledContentRect, contentRectParts[i]);
|
|
||||||
}
|
|
||||||
return scaledContentRect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) noneStyleFillRect: (NSRect)rect
|
- (NSRect) noneStyleFillRect: (NSRect)rect
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue