Commit 1ec36fee authored by hybrid's avatar hybrid

Use API functions instead of direct member access.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2506 dfc29bdd-3216-0410-991c-e03cc46cb475
parent d6189fd1
......@@ -1237,15 +1237,15 @@ public:
virtual core::stringw getStringW()
{
char tmp[10];
video::SColor c = getColor();
sprintf(tmp, "%08x", c.color);
const video::SColor c = getColor();
sprintf(tmp, "%02x%02x%02x%02x", c.getAlpha(), c.getRed(), c.getBlue(), c.getGreen());
return core::stringw(tmp);
}
virtual void setString(const char* text)
{
video::SColor c;
sscanf(text, "%08x", &c.color);
u32 c;
sscanf(text, "%08x", &c);
setColor(c);
}
......
......@@ -99,7 +99,7 @@ CGUIColorSelectDialog::CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironme
if ( 0 == ColorRing.Texture )
{
buildColorRing(core::dimension2d<u32>(128, 128), 1,
Environment->getSkin()->getColor(EGDC_3D_SHADOW).color);
Environment->getSkin()->getColor(EGDC_3D_SHADOW));
}
core::rect<s32> r(20,20, 0,0);
......@@ -184,16 +184,13 @@ CGUIColorSelectDialog::~CGUIColorSelectDialog()
//! renders a antialiased, colored ring
void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const u32 borderColor )
void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const video::SColor& borderColor )
{
const core::dimension2d<u32> d(dim.Width * supersample, dim.Height * supersample);
video::CImage *RawTexture = new video::CImage(video::ECF_A8R8G8B8, d);
RawTexture->fill ( 0x00808080 );
u8 * data= (u8*) RawTexture->lock();
const u32 pitch = RawTexture->getPitch();
const s32 radiusOut = ( d.Width / 2 ) - 4;
const s32 fullR2 = radiusOut * radiusOut;
......@@ -203,14 +200,11 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim,
hsl.Saturation = 1.f;
core::position2d<s32> p;
u32 *dst;
for ( p.Y = -radiusOut; p.Y <= radiusOut; p.Y += 1 )
{
s32 y2 = p.Y * p.Y;
dst = (u32*) ( (u8* ) data + ( ( 4 + p.Y + radiusOut ) * pitch ) + (4 << 2 ) );
for ( p.X = -radiusOut; p.X <= radiusOut; p.X += 1, dst += 1 )
for (p.X = -radiusOut; p.X <= radiusOut; p.X += 1)
{
s32 r2 = y2 + ( p.X * p.X );
......@@ -273,20 +267,20 @@ void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim,
hsl.Luminance = 0.5f;
hsl.Saturation = 1.f;
hsl.toRGB(rgb);
*dst = rgb.color;
}
if ( rTest >= 0.5f && rTest <= 0.55f )
{
u32 alpha = (s32) ( (rTest - 0.5f ) * ( 255.f / 0.05f ) );
*dst = (*dst & 0x00ffffff) | (alpha << 24);
}
if ( rTest >= 0.95f )
{
u32 alpha = (s32) ( (rTest - 0.95f ) * ( 255.f / 0.05f ) );
alpha = 255 - alpha;
*dst = (*dst & 0x00ffffff) | (alpha << 24);
if ( rTest <= 0.55f )
{
const u32 alpha = (u32) ( (rTest - 0.5f ) * ( 255.f / 0.05f ) );
rgb.setAlpha(alpha);
}
else if ( rTest >= 0.95f )
{
const u32 alpha = (u32) ( (rTest - 0.95f ) * ( 255.f / 0.05f ) );
rgb.setAlpha(255-alpha);
}
else
rgb.setAlpha(255);
RawTexture->setPixel(4+p.X+radiusOut, 4+p.Y+radiusOut, rgb);
}
}
}
......
......@@ -67,7 +67,7 @@ namespace gui
};
SColorCircle ColorRing;
void buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const u32 borderColor );
void buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const video::SColor& borderColor );
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment