|
@@ -31,6 +31,18 @@
|
|
|
namespace Urho3D
|
|
namespace Urho3D
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+static const char* blendModes[] =
|
|
|
|
|
+{
|
|
|
|
|
+ "Replace",
|
|
|
|
|
+ "Add",
|
|
|
|
|
+ "Multiply",
|
|
|
|
|
+ "Alpha",
|
|
|
|
|
+ "AddAlpha",
|
|
|
|
|
+ "PreMultiply",
|
|
|
|
|
+ "InvDestAlpha",
|
|
|
|
|
+ 0
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
OBJECTTYPESTATIC(BorderImage);
|
|
OBJECTTYPESTATIC(BorderImage);
|
|
|
|
|
|
|
|
BorderImage::BorderImage(Context* context) :
|
|
BorderImage::BorderImage(Context* context) :
|
|
@@ -38,7 +50,8 @@ BorderImage::BorderImage(Context* context) :
|
|
|
imageRect_(IntRect::ZERO),
|
|
imageRect_(IntRect::ZERO),
|
|
|
border_(IntRect::ZERO),
|
|
border_(IntRect::ZERO),
|
|
|
hoverOffset_(IntVector2::ZERO),
|
|
hoverOffset_(IntVector2::ZERO),
|
|
|
- tiled_(false)
|
|
|
|
|
|
|
+ tiled_(false),
|
|
|
|
|
+ blendMode_(0)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -55,6 +68,7 @@ void BorderImage::RegisterObject(Context* context)
|
|
|
REF_ACCESSOR_ATTRIBUTE(BorderImage, VAR_INTRECT, "Border", GetBorder, SetBorder, IntRect, IntRect::ZERO, AM_FILE);
|
|
REF_ACCESSOR_ATTRIBUTE(BorderImage, VAR_INTRECT, "Border", GetBorder, SetBorder, IntRect, IntRect::ZERO, AM_FILE);
|
|
|
REF_ACCESSOR_ATTRIBUTE(BorderImage, VAR_INTVECTOR2, "Hover Image Offset", GetHoverOffset, SetHoverOffset, IntVector2, IntVector2::ZERO, AM_FILE);
|
|
REF_ACCESSOR_ATTRIBUTE(BorderImage, VAR_INTVECTOR2, "Hover Image Offset", GetHoverOffset, SetHoverOffset, IntVector2, IntVector2::ZERO, AM_FILE);
|
|
|
ACCESSOR_ATTRIBUTE(BorderImage, VAR_BOOL, "Tiled", IsTiled, SetTiled, bool, true, AM_FILE);
|
|
ACCESSOR_ATTRIBUTE(BorderImage, VAR_BOOL, "Tiled", IsTiled, SetTiled, bool, true, AM_FILE);
|
|
|
|
|
+ ENUM_ACCESSOR_ATTRIBUTE(BorderImage, "Blend Mode", GetBlendMode, SetBlendMode, unsigned, blendModes, 0, AM_FILE);
|
|
|
COPY_BASE_ATTRIBUTES(BorderImage, UIElement);
|
|
COPY_BASE_ATTRIBUTES(BorderImage, UIElement);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -116,6 +130,11 @@ void BorderImage::SetTiled(bool enable)
|
|
|
tiled_ = enable;
|
|
tiled_ = enable;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void BorderImage::SetBlendMode(unsigned mode)
|
|
|
|
|
+{
|
|
|
|
|
+ blendMode_ = mode;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void BorderImage::GetBatches(PODVector<UIBatch>& batches, PODVector<UIQuad>& quads, const IntRect& currentScissor, const IntVector2& offset)
|
|
void BorderImage::GetBatches(PODVector<UIBatch>& batches, PODVector<UIQuad>& quads, const IntRect& currentScissor, const IntVector2& offset)
|
|
|
{
|
|
{
|
|
|
bool allOpaque = true;
|
|
bool allOpaque = true;
|
|
@@ -123,7 +142,7 @@ void BorderImage::GetBatches(PODVector<UIBatch>& batches, PODVector<UIQuad>& qua
|
|
|
color_[C_BOTTOMLEFT].a_ < 1.0f || color_[C_BOTTOMRIGHT].a_ < 1.0f)
|
|
color_[C_BOTTOMLEFT].a_ < 1.0f || color_[C_BOTTOMRIGHT].a_ < 1.0f)
|
|
|
allOpaque = false;
|
|
allOpaque = false;
|
|
|
|
|
|
|
|
- UIBatch batch(allOpaque ? BLEND_REPLACE : BLEND_ALPHA, currentScissor, texture_, &quads);
|
|
|
|
|
|
|
+ UIBatch batch(blendMode_ == BLEND_REPLACE && !allOpaque ? BLEND_ALPHA : static_cast<BlendMode>(blendMode_), currentScissor, texture_, &quads);
|
|
|
|
|
|
|
|
// Calculate size of the inner rect, and texture dimensions of the inner rect
|
|
// Calculate size of the inner rect, and texture dimensions of the inner rect
|
|
|
const IntVector2& size = GetSize();
|
|
const IntVector2& size = GetSize();
|