mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-01 15:50:27 +02:00
Reformat the code, using:
find -type f | # list all regular files grep -E '\.(h|cpp|mm)$' | # filter for source files grep -v '/mt_' | # filter out generated files grep -v '/vendor/' | # and vendored GL grep -v '/test/image_loader_test.cpp' | # and this file (has giant literals arrays) xargs -n 1 -P $(nproc) clang-format -i # reformat everything Co-authored-by: numzero <numzer0@yandex.ru>
This commit is contained in:
@ -13,18 +13,16 @@ namespace irr
|
||||
namespace gui
|
||||
{
|
||||
|
||||
|
||||
//! constructor
|
||||
CGUIImage::CGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
|
||||
: IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255,255,255,255),
|
||||
UseAlphaChannel(false), ScaleImage(false), DrawBounds(0.f, 0.f, 1.f, 1.f), DrawBackground(true)
|
||||
CGUIImage::CGUIImage(IGUIEnvironment *environment, IGUIElement *parent, s32 id, core::rect<s32> rectangle) :
|
||||
IGUIImage(environment, parent, id, rectangle), Texture(0), Color(255, 255, 255, 255),
|
||||
UseAlphaChannel(false), ScaleImage(false), DrawBounds(0.f, 0.f, 1.f, 1.f), DrawBackground(true)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CGUIImage");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! destructor
|
||||
CGUIImage::~CGUIImage()
|
||||
{
|
||||
@ -32,9 +30,8 @@ CGUIImage::~CGUIImage()
|
||||
Texture->drop();
|
||||
}
|
||||
|
||||
|
||||
//! sets an image
|
||||
void CGUIImage::setImage(video::ITexture* image)
|
||||
void CGUIImage::setImage(video::ITexture *image)
|
||||
{
|
||||
if (image == Texture)
|
||||
return;
|
||||
@ -49,7 +46,7 @@ void CGUIImage::setImage(video::ITexture* image)
|
||||
}
|
||||
|
||||
//! Gets the image texture
|
||||
video::ITexture* CGUIImage::getImage() const
|
||||
video::ITexture *CGUIImage::getImage() const
|
||||
{
|
||||
return Texture;
|
||||
}
|
||||
@ -72,39 +69,32 @@ void CGUIImage::draw()
|
||||
if (!IsVisible)
|
||||
return;
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
IGUISkin *skin = Environment->getSkin();
|
||||
video::IVideoDriver *driver = Environment->getVideoDriver();
|
||||
|
||||
if (Texture)
|
||||
{
|
||||
if (Texture) {
|
||||
core::rect<s32> sourceRect(SourceRect);
|
||||
if (sourceRect.getWidth() == 0 || sourceRect.getHeight() == 0)
|
||||
{
|
||||
if (sourceRect.getWidth() == 0 || sourceRect.getHeight() == 0) {
|
||||
sourceRect = core::rect<s32>(core::dimension2di(Texture->getOriginalSize()));
|
||||
}
|
||||
|
||||
if (ScaleImage)
|
||||
{
|
||||
const video::SColor Colors[] = {Color,Color,Color,Color};
|
||||
if (ScaleImage) {
|
||||
const video::SColor Colors[] = {Color, Color, Color, Color};
|
||||
|
||||
core::rect<s32> clippingRect(AbsoluteClippingRect);
|
||||
checkBounds(clippingRect);
|
||||
|
||||
driver->draw2DImage(Texture, AbsoluteRect, sourceRect,
|
||||
&clippingRect, Colors, UseAlphaChannel);
|
||||
}
|
||||
else
|
||||
{
|
||||
&clippingRect, Colors, UseAlphaChannel);
|
||||
} else {
|
||||
core::rect<s32> clippingRect(AbsoluteRect.UpperLeftCorner, sourceRect.getSize());
|
||||
checkBounds(clippingRect);
|
||||
clippingRect.clipAgainst(AbsoluteClippingRect);
|
||||
|
||||
driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, sourceRect,
|
||||
&clippingRect, Color, UseAlphaChannel);
|
||||
&clippingRect, Color, UseAlphaChannel);
|
||||
}
|
||||
}
|
||||
else if ( DrawBackground )
|
||||
{
|
||||
} else if (DrawBackground) {
|
||||
core::rect<s32> clippingRect(AbsoluteClippingRect);
|
||||
checkBounds(clippingRect);
|
||||
|
||||
@ -114,21 +104,18 @@ void CGUIImage::draw()
|
||||
IGUIElement::draw();
|
||||
}
|
||||
|
||||
|
||||
//! sets if the image should use its alpha channel to draw itself
|
||||
void CGUIImage::setUseAlphaChannel(bool use)
|
||||
{
|
||||
UseAlphaChannel = use;
|
||||
}
|
||||
|
||||
|
||||
//! sets if the image should use its alpha channel to draw itself
|
||||
void CGUIImage::setScaleImage(bool scale)
|
||||
{
|
||||
ScaleImage = scale;
|
||||
}
|
||||
|
||||
|
||||
//! Returns true if the image is scaled to fit, false if not
|
||||
bool CGUIImage::isImageScaled() const
|
||||
{
|
||||
@ -142,7 +129,7 @@ bool CGUIImage::isAlphaChannelUsed() const
|
||||
}
|
||||
|
||||
//! Sets the source rectangle of the image. By default the full image is used.
|
||||
void CGUIImage::setSourceRect(const core::rect<s32>& sourceRect)
|
||||
void CGUIImage::setSourceRect(const core::rect<s32> &sourceRect)
|
||||
{
|
||||
SourceRect = sourceRect;
|
||||
}
|
||||
@ -154,16 +141,16 @@ core::rect<s32> CGUIImage::getSourceRect() const
|
||||
}
|
||||
|
||||
//! Restrict target drawing-area.
|
||||
void CGUIImage::setDrawBounds(const core::rect<f32>& drawBoundUVs)
|
||||
void CGUIImage::setDrawBounds(const core::rect<f32> &drawBoundUVs)
|
||||
{
|
||||
DrawBounds = drawBoundUVs;
|
||||
DrawBounds.UpperLeftCorner.X = core::clamp(DrawBounds.UpperLeftCorner.X, 0.f, 1.f);
|
||||
DrawBounds.UpperLeftCorner.Y = core::clamp(DrawBounds.UpperLeftCorner.Y, 0.f, 1.f);
|
||||
DrawBounds.LowerRightCorner.X = core::clamp(DrawBounds.LowerRightCorner.X, 0.f, 1.f);
|
||||
DrawBounds.LowerRightCorner.X = core::clamp(DrawBounds.LowerRightCorner.X, 0.f, 1.f);
|
||||
if ( DrawBounds.UpperLeftCorner.X > DrawBounds.LowerRightCorner.X )
|
||||
if (DrawBounds.UpperLeftCorner.X > DrawBounds.LowerRightCorner.X)
|
||||
DrawBounds.UpperLeftCorner.X = DrawBounds.LowerRightCorner.X;
|
||||
if ( DrawBounds.UpperLeftCorner.Y > DrawBounds.LowerRightCorner.Y )
|
||||
if (DrawBounds.UpperLeftCorner.Y > DrawBounds.LowerRightCorner.Y)
|
||||
DrawBounds.UpperLeftCorner.Y = DrawBounds.LowerRightCorner.Y;
|
||||
}
|
||||
|
||||
@ -173,6 +160,5 @@ core::rect<f32> CGUIImage::getDrawBounds() const
|
||||
return DrawBounds;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
Reference in New Issue
Block a user