Refactoring of GSDrawTiles to let it draw itself, and added a new init method

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28838 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicolas Roard 2009-10-18 14:21:57 +00:00
parent 161d6e03e7
commit 2c3f0453ee
5 changed files with 581 additions and 464 deletions

View file

@ -1,3 +1,14 @@
2009-10-18 Nicolas Roard <nicolas@roard.com>
* Source/GSTheme.m,
* Source/GSThemeTools.m,
* Source/GSThemePrivate.h,
* Headers/Additions/GNUstepGUI/GSTheme.h: Refactoring of
GSDrawTiles, splitting fillRect:withTiles:background:fillStyle:
in smaller methods, letting GSDrawTiles be in charge of its own
drawing. Also added a 'nine patch' init method, to create
a GSDrawTiles from a specially crafted image (see comments).
2009-10-17 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSApplication.m (-_windowWillClose:): When using MS

View file

@ -179,7 +179,10 @@ typedef enum {
GSThemeFillStyleScale, /** CM image is scaled to fit */
GSThemeFillStyleRepeat, /** CM image is tiled from bottom left */
GSThemeFillStyleCenter, /** CM image is tiled from the center */
GSThemeFillStyleMatrix /** a matrix of nine separated images */
GSThemeFillStyleMatrix, /** a matrix of nine separated images */
GSThemeFillStyleScaleAll /** All 'stretchable' images (i.e. not
the four corners) are scaled to fill
their area, instead of being repeated */
} GSThemeFillStyle;

View file

@ -843,6 +843,8 @@ typedef struct {
tiles = [[GSDrawTiles alloc] initWithImage: image
horizontal: x
vertical: y];
//TODO(rio) tiles = [[GSDrawTiles alloc] initWithNinePatchImage: image];
RELEASE(image);
}
}

View file

@ -55,9 +55,16 @@ typedef enum {
@public
NSImage *images[9]; /** The tile images */
NSRect rects[9]; /** The rectangles to use when drawing */
float scaleFactor;
}
- (id) copyWithZone: (NSZone*)zone;
/* Initialise with a single image, using 'annotations' to determinate
* where the tiles are in the image, in the form of black pixels in a 1-pixel surrounding border.
* It is similar to http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
*/
- (id) initWithNinePatchImage: (NSImage*)image;
/* Initialise with a single image assuming division into nine equally
* sized sections.
*/
@ -68,10 +75,35 @@ typedef enum {
*/
- (id) initWithImage: (NSImage*)image horizontal: (float)x vertical: (float)y;
/* Scale the imge to the specified value.
/*
* Verify the individual tiles size
* If incorrect, we nullify the corresponding image
* otherwise, we retain it.
*/
- (void) validateTilesSizeWithImage: (NSImage*)image;
/* Scale the image to the specified value.
*/
- (void) scaleTo: (float)multiple;
- (NSRect) fillRect: (NSRect)rect
background: (NSColor*) color
fillStyle: (GSThemeFillStyle)style;
- (NSSize) computeTotalTilesSize;
- (void) drawCornersRect: (NSRect)rect;
- (void) repeatFillRect: (NSRect)rect;
- (NSRect) noneStyleFillRect: (NSRect)rect;
- (NSRect) centerStyleFillRect: (NSRect)rect;
- (NSRect) repeatStyleFillRect: (NSRect)rect;
- (NSRect) scaleStyleFillRect: (NSRect)rect;
/* Draw GSThemeFillStyleMatrix
*/
- (NSRect) matrixStyleFillRect: (NSRect)rect;
- (void) repeatFillRect: (NSRect)rect;
@end
/** This is the panel used to select and inspect themes.

File diff suppressed because it is too large Load diff