NinePatch fix.

--HG--
branch : dev-css-refactor
This commit is contained in:
Martín Lucas Golini
2019-11-30 18:43:14 -03:00
parent 1f92011748
commit 02fe48f331

View File

@@ -112,15 +112,25 @@ TextureRegion * NinePatch::getTextureRegion( const int& side ) {
}
void NinePatch::createFromTexture(const Uint32 & TexId, int left, int top, int right, int bottom) {
mDrawable[ Left ] = TextureRegion::New( TexId, Rect( 0, top, left, mSize.getHeight() - bottom ) );
mDrawable[ Right ] = TextureRegion::New( TexId, Rect( mSize.getWidth() - right, top, mSize.getWidth(), mSize.getHeight() - bottom ) );
mDrawable[ Down ] = TextureRegion::New( TexId, Rect( left, mSize.getHeight() - bottom, mSize.getWidth() - right, mSize.getHeight() ) );
mDrawable[ Up ] = TextureRegion::New( TexId, Rect( left, 0, mSize.getWidth() - right, top ) );
mDrawable[ UpLeft ] = TextureRegion::New( TexId, Rect( 0, 0, left, top ) );
mDrawable[ UpRight] = TextureRegion::New( TexId, Rect( mSize.getWidth() - right, 0, mSize.getWidth(), top ) );
mDrawable[ DownLeft] = TextureRegion::New( TexId, Rect( 0, mSize.getHeight() - bottom, left, mSize.getHeight() ) );
mDrawable[ DownRight ] = TextureRegion::New( TexId, Rect( mSize.getWidth() - right, mSize.getHeight() - bottom, mSize.getWidth(), mSize.getHeight() ) );
mDrawable[ Center ] = TextureRegion::New( TexId, Rect( left, top, mSize.getWidth() - right, mSize.getHeight() - bottom ) );
Rect r;
r = Rect( 0, top, left, mSize.getHeight() - bottom );
mDrawable[ Left ] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( mSize.getWidth() - right, top, mSize.getWidth(), mSize.getHeight() - bottom );
mDrawable[ Right ] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( left, mSize.getHeight() - bottom, mSize.getWidth() - right, mSize.getHeight() );
mDrawable[ Down ] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( left, 0, mSize.getWidth() - right, top );
mDrawable[ Up ] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( 0, 0, left, top );
mDrawable[ UpLeft ] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( mSize.getWidth() - right, 0, mSize.getWidth(), top );
mDrawable[ UpRight] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( 0, mSize.getHeight() - bottom, left, mSize.getHeight() );
mDrawable[ DownLeft] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( mSize.getWidth() - right, mSize.getHeight() - bottom, mSize.getWidth(), mSize.getHeight() );
mDrawable[ DownRight ] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
r = Rect( left, top, mSize.getWidth() - right, mSize.getHeight() - bottom );
mDrawable[ Center ] = TextureRegion::New( TexId, r, r.getSize().asFloat() );
mRect = Rect( left, top, right, bottom );