mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
More progress with GuiBox.
This commit is contained in:
parent
41f164e53b
commit
57461ba676
|
@ -1,5 +1,7 @@
|
|||
October 7
|
||||
-Fixed borders for GuiBox. Still need to flip the right border and bottom border.
|
||||
-Fixed borders for GuiBox. The right and bottom borders are flipped, too.
|
||||
-Added corners for GuiBox.
|
||||
-Added setFlipX() and setFlipY() to the GuiImage class.
|
||||
|
||||
October 5
|
||||
-GuiFastSelect is working, but ugly.
|
||||
|
|
|
@ -39,7 +39,10 @@ void GuiBox::setBackgroundImage(std::string path, bool tiled)
|
|||
|
||||
void GuiBox::setCornerImage(std::string path)
|
||||
{
|
||||
mCornerImage.setOrigin(0, 0);
|
||||
mCornerImage.setResize(getHorizontalBorderWidth(), getVerticalBorderWidth(), true);
|
||||
|
||||
mCornerImage.setImage(path);
|
||||
}
|
||||
|
||||
void GuiBox::onRender()
|
||||
|
@ -47,27 +50,53 @@ void GuiBox::onRender()
|
|||
//left border
|
||||
mHorizontalImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth());
|
||||
mHorizontalImage.setOffsetY(getOffsetY());
|
||||
mHorizontalImage.setFlipX(false);
|
||||
mHorizontalImage.render();
|
||||
//Renderer::drawRect(getOffsetX() - getHorizontalBorderWidth(), getOffsetY(), getHorizontalBorderWidth(), mHeight, 0xFF0000);
|
||||
|
||||
//right border
|
||||
mHorizontalImage.setOffsetX(getOffsetX() + mWidth);
|
||||
//same Y
|
||||
mHorizontalImage.setFlipX(true);
|
||||
mHorizontalImage.render();
|
||||
//Renderer::drawRect(getOffsetX() + mWidth, getOffsetY(), getHorizontalBorderWidth(), mHeight, 0xFF0000);
|
||||
|
||||
//top border
|
||||
mVerticalImage.setOffsetX(getOffsetX());
|
||||
mVerticalImage.setOffsetY(getOffsetY() - getVerticalBorderWidth());
|
||||
mVerticalImage.setFlipY(false);
|
||||
mVerticalImage.render();
|
||||
//Renderer::drawRect(getOffsetX(), getOffsetY() - getVerticalBorderWidth(), mWidth, getVerticalBorderWidth(), 0x00FF00);
|
||||
|
||||
//bottom border
|
||||
//same X
|
||||
mVerticalImage.setOffsetY(getOffsetY() + mHeight);
|
||||
mVerticalImage.setFlipY(true);
|
||||
mVerticalImage.render();
|
||||
//Renderer::drawRect(getOffsetX(), getOffsetY() + mHeight, mWidth, getVerticalBorderWidth(), 0x00FF00);
|
||||
|
||||
|
||||
//corner top left
|
||||
mCornerImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth());
|
||||
mCornerImage.setOffsetY(getOffsetY() - getVerticalBorderWidth());
|
||||
mCornerImage.setFlipX(false);
|
||||
mCornerImage.setFlipY(false);
|
||||
mCornerImage.render();
|
||||
|
||||
//top right
|
||||
mCornerImage.setOffsetX(getOffsetX() + mWidth);
|
||||
mCornerImage.setFlipX(true);
|
||||
mCornerImage.render();
|
||||
|
||||
//bottom right
|
||||
mCornerImage.setOffsetY(getOffsetY() + mHeight);
|
||||
mCornerImage.setFlipY(true);
|
||||
mCornerImage.render();
|
||||
|
||||
//bottom left
|
||||
mCornerImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth());
|
||||
mCornerImage.setFlipX(false);
|
||||
mCornerImage.render();
|
||||
}
|
||||
|
||||
void GuiBox::onInit()
|
||||
|
|
|
@ -27,8 +27,9 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
|
|||
addChild(mBox);
|
||||
|
||||
//set test mBox info
|
||||
//mBox->setHorizontalImage("test.jpg", false);
|
||||
//mBox->setVerticalImage("test.jpg", false);
|
||||
mBox->setHorizontalImage("left.jpg", false);
|
||||
mBox->setVerticalImage("top.jpg", false);
|
||||
mBox->setCornerImage("corner.jpg");
|
||||
|
||||
mParent->pause();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ GuiImage::GuiImage(int offsetX, int offsetY, std::string path, unsigned int resi
|
|||
|
||||
mResizeExact = resizeExact;
|
||||
|
||||
mFlipX = false;
|
||||
mFlipY = false;
|
||||
|
||||
if(!path.empty())
|
||||
setImage(path);
|
||||
}
|
||||
|
@ -243,6 +246,16 @@ void GuiImage::setResize(unsigned int width, unsigned int height, bool resizeExa
|
|||
resize();
|
||||
}
|
||||
|
||||
void GuiImage::setFlipX(bool flip)
|
||||
{
|
||||
mFlipX = flip;
|
||||
}
|
||||
|
||||
void GuiImage::setFlipY(bool flip)
|
||||
{
|
||||
mFlipY = flip;
|
||||
}
|
||||
|
||||
void GuiImage::onRender()
|
||||
{
|
||||
if(mTextureID)
|
||||
|
@ -293,6 +306,17 @@ void GuiImage::buildImageArray(int posX, int posY, GLfloat* points, GLfloat* tex
|
|||
texs[6] = 1; texs[7] = 1;
|
||||
texs[8] = 0; texs[9] = 0;
|
||||
texs[10] = 1; texs[11] = 0;
|
||||
|
||||
if(mFlipX)
|
||||
{
|
||||
for(int i = 0; i < 11; i += 2)
|
||||
texs[i] = !texs[i];
|
||||
}
|
||||
if(mFlipY)
|
||||
{
|
||||
for(int i = 1; i < 12; i += 2)
|
||||
texs[i] = !texs[i];
|
||||
}
|
||||
}
|
||||
|
||||
void GuiImage::drawImageArray(GLfloat* points, GLfloat* texs, unsigned int numArrays)
|
||||
|
|
|
@ -21,6 +21,9 @@ public:
|
|||
void setTiling(bool tile); //Enables or disables tiling. Must be called before loading an image or resizing will be weird.
|
||||
void setResize(unsigned int width, unsigned int height, bool resizeExact);
|
||||
|
||||
void setFlipX(bool flip);
|
||||
void setFlipY(bool flip);
|
||||
|
||||
unsigned int getWidth(); //Returns render width in pixels. May be different than actual texture width.
|
||||
unsigned int getHeight(); //Returns render height in pixels. May be different than actual texture height.
|
||||
|
||||
|
@ -33,7 +36,7 @@ public:
|
|||
private:
|
||||
unsigned int mResizeWidth, mResizeHeight;
|
||||
float mOriginX, mOriginY;
|
||||
bool mResizeExact, mTiled;
|
||||
bool mResizeExact, mTiled, mFlipX, mFlipY;
|
||||
|
||||
void loadImage(std::string path);
|
||||
void resize();
|
||||
|
|
Loading…
Reference in a new issue