mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 08:30:59 +00:00
* Source/GSThemeDrawing.m: Use new -[GSDrawTiles themeMargins]
to get the margins for draw tiles. * Source/GSThemePrivate.h: * Source/GSThemeTools.m: Get the 9-patch content rect support working from end-to-end. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37191 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c63df23ba8
commit
fb723f8241
4 changed files with 57 additions and 16 deletions
|
@ -1,3 +1,11 @@
|
|||
2013-10-03 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/GSThemeDrawing.m: Use new -[GSDrawTiles themeMargins]
|
||||
to get the margins for draw tiles.
|
||||
* Source/GSThemePrivate.h:
|
||||
* Source/GSThemeTools.m: Get the 9-patch content rect support
|
||||
working from end-to-end.
|
||||
|
||||
2013-10-03 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
|
|
|
@ -288,12 +288,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Move this code to a method in GSDrawTiles?
|
||||
// FIXME: Not correct, need to get the content area of the draw tiles
|
||||
margins.left = tiles->rects[TileCL].size.width;
|
||||
margins.top = tiles->rects[TileTM].size.height;
|
||||
margins.right = tiles->rects[TileCR].size.width;
|
||||
margins.bottom = tiles->rects[TileBM].size.height;
|
||||
margins = [tiles themeMargins];
|
||||
return margins;
|
||||
}
|
||||
}
|
||||
|
@ -370,8 +365,9 @@
|
|||
{
|
||||
// FIXME: We assume the button's top and right padding are the same as
|
||||
// its bottom and left.
|
||||
return NSMakeSize(tiles->contentRect.origin.x,
|
||||
tiles->contentRect.origin.y);
|
||||
|
||||
GSThemeMargins margins = [tiles themeMargins];
|
||||
return NSMakeSize(margins.left, margins.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,9 @@ typedef enum {
|
|||
NSRect contentRect; /** Rectangle in which content should be
|
||||
* drawn, normally rects[TileCM], but can
|
||||
* be customized in the nine-patch format */
|
||||
NSRect originalRectCM; /** Caches rects[TileCM] as it was before
|
||||
* -validateTilesSizeWithImage clears the
|
||||
* origin. Used by -themeMargins */
|
||||
float scaleFactor;
|
||||
GSThemeFillStyle style; /** The default style for filling a rect */
|
||||
}
|
||||
|
@ -139,6 +142,8 @@ typedef enum {
|
|||
*/
|
||||
- (NSSize) size;
|
||||
|
||||
- (GSThemeMargins) themeMargins;
|
||||
|
||||
@end
|
||||
|
||||
/** This is the panel used to select and inspect themes.
|
||||
|
|
|
@ -897,7 +897,7 @@ withRepeatedImage: (NSImage*)image
|
|||
}
|
||||
else
|
||||
{
|
||||
contentRect.origin.y = s.height - y2 - 1;
|
||||
contentRect.origin.y = y1;
|
||||
contentRect.size.height = 1 + y2 - y1;
|
||||
}
|
||||
|
||||
|
@ -923,6 +923,8 @@ withRepeatedImage: (NSImage*)image
|
|||
{
|
||||
int i;
|
||||
|
||||
originalRectCM = rects[TileCM];
|
||||
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
if (rects[i].origin.x < 0.0 || rects[i].origin.y < 0.0
|
||||
|
@ -935,6 +937,8 @@ withRepeatedImage: (NSImage*)image
|
|||
{
|
||||
images[i]
|
||||
= [[self extractImageFrom: image withRect: rects[i]] retain];
|
||||
// FIXME: This makes no sense to me, why not leave the
|
||||
// rect origins at their original values?
|
||||
rects[i].origin.x = 0;
|
||||
rects[i].origin.y = 0;
|
||||
}
|
||||
|
@ -1078,15 +1082,43 @@ withRepeatedImage: (NSImage*)image
|
|||
return tsz;
|
||||
}
|
||||
|
||||
- (GSThemeMargins) themeMargins
|
||||
{
|
||||
NSRect cm = originalRectCM;
|
||||
GSThemeMargins margins;
|
||||
|
||||
margins.left = rects[TileCL].size.width;
|
||||
margins.right = rects[TileCR].size.width;
|
||||
margins.top = rects[TileTM].size.height;
|
||||
margins.bottom = rects[TileBM].size.height;
|
||||
|
||||
// Adjust for contentRect != cm
|
||||
|
||||
margins.left += (contentRect.origin.x - cm.origin.x);
|
||||
margins.bottom += (contentRect.origin.y - cm.origin.y);
|
||||
|
||||
margins.right += (NSMaxX(cm) - NSMaxX(contentRect));
|
||||
margins.top += (NSMaxY(cm) - NSMaxY(contentRect));
|
||||
|
||||
return margins;
|
||||
}
|
||||
|
||||
- (NSRect) contentRectForRect: (NSRect)rect
|
||||
{
|
||||
NSSize total = [self computeTotalTilesSize];
|
||||
NSRect inFill = NSMakeRect(
|
||||
rect.origin.x + contentRect.origin.x,
|
||||
rect.origin.y + contentRect.origin.y,
|
||||
rect.size.width - (total.width - contentRect.size.width),
|
||||
rect.size.height - (total.height - contentRect.size.height));
|
||||
return inFill;
|
||||
NSRect cm = originalRectCM;
|
||||
NSRect result = NSMakeRect(rect.origin.x + rects[TileCL].size.width,
|
||||
rect.origin.y + rects[TileBM].size.height,
|
||||
rect.size.width - (rects[TileCL].size.width + rects[TileCR].size.width),
|
||||
rect.size.height - (rects[TileTM].size.height + rects[TileBM].size.height));
|
||||
|
||||
|
||||
result.origin.x += (contentRect.origin.x - cm.origin.x);
|
||||
result.size.width += (contentRect.size.width - cm.size.width);
|
||||
|
||||
result.origin.y += (contentRect.origin.y - cm.origin.y);
|
||||
result.size.height += (contentRect.size.height - cm.size.height);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSRect) noneStyleFillRect: (NSRect)rect
|
||||
|
|
Loading…
Reference in a new issue