mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
support for color gradients in drawRect and ImageComponent
This commit is contained in:
parent
79cc5a7e8b
commit
fc58af98fd
|
@ -209,7 +209,7 @@ void SystemScreenSaver::renderScreenSaver()
|
|||
{
|
||||
// Render black background
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), (unsigned char)(255));
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
|
||||
// Only render the video if the state requires it
|
||||
if ((int)mState >= STATE_FADE_IN_VIDEO)
|
||||
|
@ -222,7 +222,7 @@ void SystemScreenSaver::renderScreenSaver()
|
|||
{
|
||||
// Render black background
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), (unsigned char)(255));
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
|
||||
// Only render the video if the state requires it
|
||||
if ((int)mState >= STATE_FADE_IN_VIDEO)
|
||||
|
@ -248,8 +248,8 @@ void SystemScreenSaver::renderScreenSaver()
|
|||
else if (mState != STATE_INACTIVE)
|
||||
{
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
unsigned char opacity = screensaver_behavior == "dim" ? 0xA0 : 0xFF;
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | opacity);
|
||||
unsigned char color = screensaver_behavior == "dim" ? 0x000000A0 : 0x000000FF;
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), color, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ void AsyncReqComponent::render(const Transform4x4f& /*parentTrans*/)
|
|||
Renderer::setMatrix(trans);
|
||||
|
||||
Vector3f point(Math::cosf(mTime * 0.01f) * 12, Math::sinf(mTime * 0.01f) * 12, 0);
|
||||
Renderer::drawRect((int)point.x(), (int)point.y(), 8, 8, 0x0000FFFF);
|
||||
Renderer::drawRect((int)point.x(), (int)point.y(), 8, 8, 0x0000FFFF, 0x0000FFFF);
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> AsyncReqComponent::getHelpPrompts()
|
||||
|
|
|
@ -359,9 +359,9 @@ void ScraperSearchComponent::render(const Transform4x4f& parentTrans)
|
|||
if(mBlockAccept)
|
||||
{
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), 0x00000011);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), 0x00000011, 0x00000011);
|
||||
//Renderer::drawRect((int)mResultList->getPosition().x(), (int)mResultList->getPosition().y(),
|
||||
// (int)mResultList->getSize().x(), (int)mResultList->getSize().y(), 0x00000011);
|
||||
// (int)mResultList->getSize().x(), (int)mResultList->getSize().y(), 0x0000011, 0x00000011);
|
||||
|
||||
mBusyAnim.render(trans);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ public:
|
|||
inline void setSelectorHeight(float selectorScale) { mSelectorHeight = selectorScale; }
|
||||
inline void setSelectorOffsetY(float selectorOffsetY) { mSelectorOffsetY = selectorOffsetY; }
|
||||
inline void setSelectorColor(unsigned int color) { mSelectorColor = color; }
|
||||
inline void setSelectorColorEnd(unsigned int color) { mSelectorColorEnd = color; }
|
||||
inline void setSelectorColorGradientHorizontal(bool horizontal) { mSelectorColorGradientHorizontal = horizontal; }
|
||||
inline void setSelectedColor(unsigned int color) { mSelectedColor = color; }
|
||||
inline void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
|
||||
inline void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
|
||||
|
@ -97,6 +99,8 @@ private:
|
|||
float mSelectorHeight;
|
||||
float mSelectorOffsetY;
|
||||
unsigned int mSelectorColor;
|
||||
unsigned int mSelectorColorEnd;
|
||||
bool mSelectorColorGradientHorizontal = true;
|
||||
unsigned int mSelectedColor;
|
||||
std::string mScrollSound;
|
||||
static const unsigned int COLOR_ID_COUNT = 2;
|
||||
|
@ -122,6 +126,8 @@ TextListComponent<T>::TextListComponent(Window* window) :
|
|||
mSelectorHeight = mFont->getSize() * 1.5f;
|
||||
mSelectorOffsetY = 0;
|
||||
mSelectorColor = 0x000000FF;
|
||||
mSelectorColorEnd = 0x000000FF;
|
||||
mSelectorColorGradientHorizontal = true;
|
||||
mSelectedColor = 0;
|
||||
mColors[0] = 0x0000FFFF;
|
||||
mColors[1] = 0x00FF00FF;
|
||||
|
@ -167,7 +173,8 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)
|
|||
mSelectorImage.render(trans);
|
||||
} else {
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, (mCursor - startEntry)*entrySize + mSelectorOffsetY, mSize.x(), mSelectorHeight, mSelectorColor);
|
||||
Renderer::drawRect(0.f, (mCursor - startEntry)*entrySize + mSelectorOffsetY, mSize.x(),
|
||||
mSelectorHeight, mSelectorColor, mSelectorColorEnd, mSelectorColorGradientHorizontal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +370,14 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme, c
|
|||
if(properties & COLOR)
|
||||
{
|
||||
if(elem->has("selectorColor"))
|
||||
{
|
||||
setSelectorColor(elem->get<unsigned int>("selectorColor"));
|
||||
setSelectorColorEnd(elem->get<unsigned int>("selectorColor"));
|
||||
}
|
||||
if (elem->has("selectorColorEnd"))
|
||||
setSelectorColorEnd(elem->get<unsigned int>("selectorColorEnd"));
|
||||
if (elem->has("selectorGradientType"))
|
||||
setSelectorColorGradientHorizontal(!(elem->get<std::string>("selectorGradientType").compare("horizontal")));
|
||||
if(elem->has("selectedColor"))
|
||||
setSelectedColor(elem->get<unsigned int>("selectedColor"));
|
||||
if(elem->has("primaryColor"))
|
||||
|
@ -426,6 +440,7 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme, c
|
|||
mSelectorImage.setImage(path, tile);
|
||||
mSelectorImage.setSize(mSize.x(), mSelectorHeight);
|
||||
mSelectorImage.setColorShift(mSelectorColor);
|
||||
mSelectorImage.setColorShiftEnd(mSelectorColorEnd);
|
||||
} else {
|
||||
mSelectorImage.setImage("");
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
|
|||
Renderer::pushClipRect(Vector2i((int)clipPos.x(), (int)clipPos.y()), Vector2i((int)mCarousel.size.x(), (int)mCarousel.size.y()));
|
||||
|
||||
Renderer::setMatrix(carouselTrans);
|
||||
Renderer::drawRect(0.0, 0.0, mCarousel.size.x(), mCarousel.size.y(), mCarousel.color);
|
||||
Renderer::drawRect(0.0, 0.0, mCarousel.size.x(), mCarousel.size.y(), mCarousel.color, mCarousel.colorEnd, mCarousel.colorGradientHorizontal);
|
||||
|
||||
// draw logos
|
||||
Vector2f logoSpacing(0.0, 0.0); // NB: logoSpacing will include the size of the logo itself as well!
|
||||
|
@ -584,8 +584,9 @@ void SystemView::renderFade(const Transform4x4f& trans)
|
|||
// fade extras if necessary
|
||||
if (mExtrasFadeOpacity)
|
||||
{
|
||||
unsigned int fadeColor = 0x00000000 | (unsigned char)(mExtrasFadeOpacity * 255);
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000000 | (unsigned char)(mExtrasFadeOpacity * 255));
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), fadeColor, fadeColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -602,6 +603,8 @@ void SystemView::getDefaultElements(void)
|
|||
mCarousel.origin.x() = 0.0f;
|
||||
mCarousel.origin.y() = 0.0f;
|
||||
mCarousel.color = 0xFFFFFFD8;
|
||||
mCarousel.colorEnd = 0xFFFFFFD8;
|
||||
mCarousel.colorGradientHorizontal = true;
|
||||
mCarousel.logoScale = 1.2f;
|
||||
mCarousel.logoRotation = 7.5;
|
||||
mCarousel.logoRotationOrigin.x() = -5;
|
||||
|
@ -642,7 +645,14 @@ void SystemView::getCarouselFromTheme(const ThemeData::ThemeElement* elem)
|
|||
if (elem->has("origin"))
|
||||
mCarousel.origin = elem->get<Vector2f>("origin");
|
||||
if (elem->has("color"))
|
||||
{
|
||||
mCarousel.color = elem->get<unsigned int>("color");
|
||||
mCarousel.colorEnd = mCarousel.color;
|
||||
}
|
||||
if (elem->has("colorEnd"))
|
||||
mCarousel.colorEnd = elem->get<unsigned int>("colorEnd");
|
||||
if (elem->has("gradientType"))
|
||||
mCarousel.colorGradientHorizontal = !(elem->get<std::string>("gradientType").compare("horizontal"));
|
||||
if (elem->has("logoScale"))
|
||||
mCarousel.logoScale = elem->get<float>("logoScale");
|
||||
if (elem->has("logoSize"))
|
||||
|
|
|
@ -36,6 +36,8 @@ struct SystemViewCarousel
|
|||
Vector2f logoRotationOrigin;
|
||||
Alignment logoAlignment;
|
||||
unsigned int color;
|
||||
unsigned int colorEnd;
|
||||
bool colorGradientHorizontal;
|
||||
int maxLogoCount; // number of logos shown on the carousel
|
||||
Vector2f logoSize;
|
||||
float zIndex;
|
||||
|
|
|
@ -422,8 +422,9 @@ void ViewController::render(const Transform4x4f& parentTrans)
|
|||
// fade out
|
||||
if(mFadeOpacity)
|
||||
{
|
||||
unsigned int fadeColor = 0x00000000 | (unsigned char)(mFadeOpacity * 255);
|
||||
Renderer::setMatrix(parentTrans);
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x00000000 | (unsigned char)(mFadeOpacity * 255));
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), fadeColor, fadeColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
|
|||
{ "default", PATH },
|
||||
{ "tile", BOOLEAN },
|
||||
{ "color", COLOR },
|
||||
{ "colorEnd", COLOR },
|
||||
{ "gradientType", STRING },
|
||||
{ "visible", BOOLEAN },
|
||||
{ "zIndex", FLOAT } } },
|
||||
{ "imagegrid", {
|
||||
|
@ -66,6 +68,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
|
|||
{ "selectorHeight", FLOAT },
|
||||
{ "selectorOffsetY", FLOAT },
|
||||
{ "selectorColor", COLOR },
|
||||
{ "selectorColorEnd", COLOR },
|
||||
{ "selectorGradientType", STRING },
|
||||
{ "selectorImagePath", PATH },
|
||||
{ "selectorImageTile", BOOLEAN },
|
||||
{ "selectedColor", COLOR },
|
||||
|
@ -148,6 +152,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
|
|||
{ "pos", NORMALIZED_PAIR },
|
||||
{ "origin", NORMALIZED_PAIR },
|
||||
{ "color", COLOR },
|
||||
{ "colorEnd", COLOR },
|
||||
{ "gradientType", STRING },
|
||||
{ "logoScale", FLOAT },
|
||||
{ "logoRotation", FLOAT },
|
||||
{ "logoRotationOrigin", NORMALIZED_PAIR },
|
||||
|
|
|
@ -301,7 +301,7 @@ void Window::renderLoadingScreen(std::string text)
|
|||
{
|
||||
Transform4x4f trans = Transform4x4f::Identity();
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF);
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
|
||||
ImageComponent splash(this, true);
|
||||
splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f);
|
||||
|
|
|
@ -202,12 +202,12 @@ void ComponentList::render(const Transform4x4f& parentTrans)
|
|||
// (1 - dst) + 0x77
|
||||
|
||||
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
|
||||
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0xFFFFFFFF, Renderer::Blend::ONE_MINUS_DST_COLOR, Renderer::Blend::ZERO);
|
||||
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0x777777FF, Renderer::Blend::ONE, Renderer::Blend::ONE);
|
||||
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0xFFFFFFFF, 0xFFFFFFFF, false, Renderer::Blend::ONE_MINUS_DST_COLOR, Renderer::Blend::ZERO);
|
||||
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0x777777FF, 0x777777FF, false, Renderer::Blend::ONE, Renderer::Blend::ONE);
|
||||
|
||||
// hack to draw 2px dark on left/right of the bar
|
||||
Renderer::drawRect(0.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
|
||||
Renderer::drawRect(mSize.x() - 2.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
|
||||
Renderer::drawRect(0.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF, 0x878787FF);
|
||||
Renderer::drawRect(mSize.x() - 2.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF, 0x878787FF);
|
||||
|
||||
for(auto it = drawAfterCursor.cbegin(); it != drawAfterCursor.cend(); it++)
|
||||
(*it)->render(trans);
|
||||
|
@ -221,10 +221,10 @@ void ComponentList::render(const Transform4x4f& parentTrans)
|
|||
float y = 0;
|
||||
for(unsigned int i = 0; i < mEntries.size(); i++)
|
||||
{
|
||||
Renderer::drawRect(0.0f, y, mSize.x(), 1.0f, 0xC6C7C6FF);
|
||||
Renderer::drawRect(0.0f, y, mSize.x(), 1.0f, 0xC6C7C6FF, 0xC6C7C6FF);
|
||||
y += getRowHeight(mEntries.at(i).data);
|
||||
}
|
||||
Renderer::drawRect(0.0f, y, mSize.x(), 1.0f, 0xC6C7C6FF);
|
||||
Renderer::drawRect(0.0f, y, mSize.x(), 1.0f, 0xC6C7C6FF, 0xC6C7C6FF);
|
||||
|
||||
Renderer::popClipRect();
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
|
|||
if(mEditIndex >= 0 && (unsigned int)mEditIndex < mCursorBoxes.size())
|
||||
{
|
||||
Renderer::drawRect((int)mCursorBoxes[mEditIndex][0], (int)mCursorBoxes[mEditIndex][1],
|
||||
(int)mCursorBoxes[mEditIndex][2], (int)mCursorBoxes[mEditIndex][3], 0x00000022);
|
||||
(int)mCursorBoxes[mEditIndex][2], (int)mCursorBoxes[mEditIndex][3], 0x00000022, 0x00000022);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ Vector2f ImageComponent::getSize() const
|
|||
|
||||
ImageComponent::ImageComponent(Window* window, bool forceLoad, bool dynamic) : GuiComponent(window),
|
||||
mTargetIsMax(false), mTargetIsMin(false), mFlipX(false), mFlipY(false), mTargetSize(0, 0), mColorShift(0xFFFFFFFF),
|
||||
mForceLoad(forceLoad), mDynamic(dynamic), mFadeOpacity(0), mFading(false), mRotateByTargetSize(false),
|
||||
mTopLeftCrop(0.0f, 0.0f), mBottomRightCrop(1.0f, 1.0f)
|
||||
mColorShiftEnd(0xFFFFFFFF), mColorGradientHorizontal(true), mForceLoad(forceLoad), mDynamic(dynamic),
|
||||
mFadeOpacity(0), mFading(false), mRotateByTargetSize(false), mTopLeftCrop(0.0f, 0.0f), mBottomRightCrop(1.0f, 1.0f)
|
||||
{
|
||||
updateColors();
|
||||
}
|
||||
|
@ -253,6 +253,21 @@ void ImageComponent::setColorShift(unsigned int color)
|
|||
updateColors();
|
||||
}
|
||||
|
||||
void ImageComponent::setColorShiftEnd(unsigned int color)
|
||||
{
|
||||
mColorShiftEnd = color;
|
||||
// Grab the opacity from the color shift because we may need to apply it if
|
||||
// fading textures in
|
||||
mOpacity = color & 0xff;
|
||||
updateColors();
|
||||
}
|
||||
|
||||
void ImageComponent::setColorGradientHorizontal(bool horizontal)
|
||||
{
|
||||
mColorGradientHorizontal = horizontal;
|
||||
updateColors();
|
||||
}
|
||||
|
||||
void ImageComponent::setOpacity(unsigned char opacity)
|
||||
{
|
||||
mOpacity = opacity;
|
||||
|
@ -273,10 +288,11 @@ void ImageComponent::updateVertices()
|
|||
const float px = mTexture->isTiled() ? mSize.x() / getTextureSize().x() : 1.0f;
|
||||
const float py = mTexture->isTiled() ? mSize.y() / getTextureSize().y() : 1.0f;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const unsigned int colorEnd = Renderer::convertColor(mColorShiftEnd);
|
||||
|
||||
mVertices[0] = { { topLeft.x(), topLeft.y() }, { mTopLeftCrop.x(), py - mTopLeftCrop.y() }, color };
|
||||
mVertices[1] = { { topLeft.x(), bottomRight.y() }, { mTopLeftCrop.x(), 1.0f - mBottomRightCrop.y() }, color };
|
||||
mVertices[2] = { { bottomRight.x(), topLeft.y() }, { mBottomRightCrop.x() * px, py - mTopLeftCrop.y() }, color };
|
||||
mVertices[1] = { { topLeft.x(), bottomRight.y() }, { mTopLeftCrop.x(), 1.0f - mBottomRightCrop.y() }, mColorGradientHorizontal ? colorEnd : color };
|
||||
mVertices[2] = { { bottomRight.x(), topLeft.y() }, { mBottomRightCrop.x() * px, py - mTopLeftCrop.y() }, mColorGradientHorizontal ? color : colorEnd };
|
||||
mVertices[3] = { { bottomRight.x(), bottomRight.y() }, { mBottomRightCrop.x() * px, 1.0f - mBottomRightCrop.y() }, color };
|
||||
|
||||
if(mFlipX)
|
||||
|
@ -294,9 +310,12 @@ void ImageComponent::updateVertices()
|
|||
void ImageComponent::updateColors()
|
||||
{
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const unsigned int colorEnd = Renderer::convertColor(mColorShiftEnd);
|
||||
|
||||
for(int i = 0; i < 4; ++i)
|
||||
mVertices[i].col = color;
|
||||
mVertices[0].col = color;
|
||||
mVertices[1].col = mColorGradientHorizontal ? colorEnd : color;
|
||||
mVertices[2].col = mColorGradientHorizontal ? color : colorEnd;
|
||||
mVertices[3].col = colorEnd;
|
||||
}
|
||||
|
||||
void ImageComponent::render(const Transform4x4f& parentTrans)
|
||||
|
@ -311,8 +330,8 @@ void ImageComponent::render(const Transform4x4f& parentTrans)
|
|||
{
|
||||
if(Settings::getInstance()->getBool("DebugImage")) {
|
||||
Vector2f targetSizePos = (mTargetSize - mSize) * mOrigin * -1;
|
||||
Renderer::drawRect(targetSizePos.x(), targetSizePos.y(), mTargetSize.x(), mTargetSize.y(), 0xFF000033);
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000033);
|
||||
Renderer::drawRect(targetSizePos.x(), targetSizePos.y(), mTargetSize.x(), mTargetSize.y(), 0xFF000033, 0xFF000033);
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000033, 0x00000033);
|
||||
}
|
||||
if(mTexture->isInitialized())
|
||||
{
|
||||
|
@ -420,8 +439,20 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
|
|||
setImage(elem->get<std::string>("path"), tile);
|
||||
}
|
||||
|
||||
if(properties & COLOR && elem->has("color"))
|
||||
if(properties & COLOR)
|
||||
{
|
||||
if(elem->has("color"))
|
||||
{
|
||||
setColorShift(elem->get<unsigned int>("color"));
|
||||
setColorShiftEnd(elem->get<unsigned int>("color"));
|
||||
}
|
||||
|
||||
if (elem->has("colorEnd"))
|
||||
setColorShiftEnd(elem->get<unsigned int>("colorEnd"));
|
||||
|
||||
if (elem->has("gradientType"))
|
||||
setColorGradientHorizontal(!(elem->get<std::string>("gradientType").compare("horizontal")));
|
||||
}
|
||||
|
||||
if(properties & ThemeFlags::ROTATION) {
|
||||
if(elem->has("rotation"))
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
|
||||
// Multiply all pixels in the image by this color when rendering.
|
||||
void setColorShift(unsigned int color);
|
||||
void setColorShiftEnd(unsigned int color);
|
||||
void setColorGradientHorizontal(bool horizontal);
|
||||
|
||||
void setFlipX(bool flip); // Mirror on the X axis.
|
||||
void setFlipY(bool flip); // Mirror on the Y axis.
|
||||
|
@ -89,6 +91,8 @@ private:
|
|||
void fadeIn(bool textureLoaded);
|
||||
|
||||
unsigned int mColorShift;
|
||||
unsigned int mColorShiftEnd;
|
||||
bool mColorGradientHorizontal;
|
||||
|
||||
std::string mDefaultPath;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void SliderComponent::render(const Transform4x4f& parentTrans)
|
|||
|
||||
//render line
|
||||
const float lineWidth = 2;
|
||||
Renderer::drawRect(mKnob.getSize().x() / 2, mSize.y() / 2 - lineWidth / 2, width, lineWidth, 0x777777FF);
|
||||
Renderer::drawRect(mKnob.getSize().x() / 2, mSize.y() / 2 - lineWidth / 2, width, lineWidth, 0x777777FF, 0x777777FF);
|
||||
|
||||
//render knob
|
||||
mKnob.render(trans);
|
||||
|
|
|
@ -102,7 +102,7 @@ void TextComponent::render(const Transform4x4f& parentTrans)
|
|||
if (mRenderBackground)
|
||||
{
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), mBgColor);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), mBgColor, mBgColor);
|
||||
}
|
||||
|
||||
if(mTextCache)
|
||||
|
@ -127,7 +127,7 @@ void TextComponent::render(const Transform4x4f& parentTrans)
|
|||
{
|
||||
// draw the "textbox" area, what we are aligned within
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), 0xFF000033);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), 0xFF000033, 0xFF000033);
|
||||
}
|
||||
|
||||
trans.translate(off);
|
||||
|
@ -140,13 +140,13 @@ void TextComponent::render(const Transform4x4f& parentTrans)
|
|||
switch(mHorizontalAlignment)
|
||||
{
|
||||
case ALIGN_LEFT:
|
||||
Renderer::drawRect(0.0f, 0.0f, mTextCache->metrics.size.x(), mTextCache->metrics.size.y(), 0x00000033);
|
||||
Renderer::drawRect(0.0f, 0.0f, mTextCache->metrics.size.x(), mTextCache->metrics.size.y(), 0x00000033, 0x00000033);
|
||||
break;
|
||||
case ALIGN_CENTER:
|
||||
Renderer::drawRect((mSize.x() - mTextCache->metrics.size.x()) / 2.0f, 0.0f, mTextCache->metrics.size.x(), mTextCache->metrics.size.y(), 0x00000033);
|
||||
Renderer::drawRect((mSize.x() - mTextCache->metrics.size.x()) / 2.0f, 0.0f, mTextCache->metrics.size.x(), mTextCache->metrics.size.y(), 0x00000033, 0x00000033);
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
Renderer::drawRect(mSize.x() - mTextCache->metrics.size.x(), 0.0f, mTextCache->metrics.size.x(), mTextCache->metrics.size.y(), 0x00000033);
|
||||
Renderer::drawRect(mSize.x() - mTextCache->metrics.size.x(), 0.0f, mTextCache->metrics.size.x(), mTextCache->metrics.size.y(), 0x00000033, 0x00000033);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ void TextEditComponent::render(const Transform4x4f& parentTrans)
|
|||
}
|
||||
|
||||
float cursorHeight = mFont->getHeight() * 0.8f;
|
||||
Renderer::drawRect(cursorPos.x(), cursorPos.y() + (mFont->getHeight() - cursorHeight) / 2, 2.0f, cursorHeight, 0x000000FF);
|
||||
Renderer::drawRect(cursorPos.x(), cursorPos.y() + (mFont->getHeight() - cursorHeight) / 2, 2.0f, cursorHeight, 0x000000FF, 0x000000FF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,21 +236,22 @@ namespace Renderer
|
|||
|
||||
} // popClipRect
|
||||
|
||||
void drawRect(const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor, const Blend::Factor _dstBlendFactor)
|
||||
void drawRect(const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient, const Blend::Factor _srcBlendFactor, const Blend::Factor _dstBlendFactor)
|
||||
{
|
||||
drawRect((int)Math::round(_x), (int)Math::round(_y), (int)Math::round(_w), (int)Math::round(_h), _color, _srcBlendFactor, _dstBlendFactor);
|
||||
drawRect((int)Math::round(_x), (int)Math::round(_y), (int)Math::round(_w), (int)Math::round(_h), _color, _colorEnd, horizontalGradient, _srcBlendFactor, _dstBlendFactor);
|
||||
|
||||
} // drawRect
|
||||
|
||||
void drawRect(const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor, const Blend::Factor _dstBlendFactor)
|
||||
void drawRect(const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient, const Blend::Factor _srcBlendFactor, const Blend::Factor _dstBlendFactor)
|
||||
{
|
||||
const unsigned int color = convertColor(_color);
|
||||
const unsigned int colorEnd = convertColor(_colorEnd);
|
||||
Vertex vertices[4];
|
||||
|
||||
vertices[0] = { { (float)(_x ), (float)(_y ) }, { 0.0f, 0.0f }, color };
|
||||
vertices[1] = { { (float)(_x ), (float)(_y + _h) }, { 0.0f, 0.0f }, color };
|
||||
vertices[2] = { { (float)(_x + _w), (float)(_y ) }, { 0.0f, 0.0f }, color };
|
||||
vertices[3] = { { (float)(_x + _w), (float)(_y + _h) }, { 0.0f, 0.0f }, color };
|
||||
vertices[1] = { { (float)(_x ), (float)(_y + _h) }, { 0.0f, 0.0f }, horizontalGradient ? colorEnd : color };
|
||||
vertices[2] = { { (float)(_x + _w), (float)(_y ) }, { 0.0f, 0.0f }, horizontalGradient ? color : colorEnd };
|
||||
vertices[3] = { { (float)(_x + _w), (float)(_y + _h) }, { 0.0f, 0.0f }, colorEnd };
|
||||
|
||||
bindTexture(0);
|
||||
drawTriangleStrips(vertices, 4, _srcBlendFactor, _dstBlendFactor);
|
||||
|
|
|
@ -66,8 +66,8 @@ namespace Renderer
|
|||
void deinit ();
|
||||
void pushClipRect (const Vector2i& _pos, const Vector2i& _size);
|
||||
void popClipRect ();
|
||||
void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||
void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||
void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient = false, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||
void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient = false, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
SDL_Window* getSDLWindow ();
|
||||
int getWindowWidth ();
|
||||
|
|
Loading…
Reference in a new issue