mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Added two new flipHorizontal and flipVertical properties to image element.
This commit is contained in:
parent
28719da52e
commit
5ba73ebf1f
|
@ -290,6 +290,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"rotation", FLOAT},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
|
{"flipHorizontal", BOOLEAN},
|
||||||
|
{"flipVertical", BOOLEAN},
|
||||||
{"path", PATH},
|
{"path", PATH},
|
||||||
{"default", PATH},
|
{"default", PATH},
|
||||||
{"imageType", STRING},
|
{"imageType", STRING},
|
||||||
|
|
|
@ -513,6 +513,12 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
setImage(path, tile);
|
setImage(path, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->has("flipHorizontal"))
|
||||||
|
setFlipX(elem->get<bool>("flipHorizontal"));
|
||||||
|
|
||||||
|
if (elem->has("flipVertical"))
|
||||||
|
setFlipY(elem->get<bool>("flipVertical"));
|
||||||
|
|
||||||
bool updateAlignment {false};
|
bool updateAlignment {false};
|
||||||
|
|
||||||
if (elem->has("tileHorizontalAlignment")) {
|
if (elem->has("tileHorizontalAlignment")) {
|
||||||
|
@ -729,21 +735,33 @@ void ImageComponent::updateVertices()
|
||||||
const float pxA {mSize.x / mTileWidth};
|
const float pxA {mSize.x / mTileWidth};
|
||||||
const float pyA {mSize.y / mTileHeight};
|
const float pyA {mSize.y / mTileHeight};
|
||||||
|
|
||||||
if (mTileHorizontalAlignment == Alignment::ALIGN_RIGHT) {
|
if (mTileHorizontalAlignment == (mFlipX ? Alignment::ALIGN_LEFT : Alignment::ALIGN_RIGHT)) {
|
||||||
float offsetX {pxA - std::floor(pxA)};
|
float offsetX {pxA - std::floor(pxA)};
|
||||||
if (offsetX != 0.0f) {
|
if (offsetX != 0.0f) {
|
||||||
const float moveX {(mTileWidth * offsetX) / mSize.x};
|
const float moveX {(mTileWidth * offsetX) / mSize.x};
|
||||||
topLeftAlign.x -= moveX * pxA;
|
if (mFlipX) {
|
||||||
bottomRightAlign.x -= moveX;
|
topLeftAlign.x += moveX * pxA;
|
||||||
|
bottomRightAlign.x += moveX;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
topLeftAlign.x -= moveX * pxA;
|
||||||
|
bottomRightAlign.x -= moveX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTileVerticalAlignment == Alignment::ALIGN_TOP) {
|
if (mTileVerticalAlignment == (mFlipY ? Alignment::ALIGN_BOTTOM : Alignment::ALIGN_TOP)) {
|
||||||
float offsetY {pyA - std::floor(pyA)};
|
float offsetY {pyA - std::floor(pyA)};
|
||||||
if (offsetY != 0.0f) {
|
if (offsetY != 0.0f) {
|
||||||
const float moveY {(mTileHeight * offsetY) / mSize.y};
|
const float moveY {(mTileHeight * offsetY) / mSize.y};
|
||||||
topLeftAlign.y += moveY * pyA;
|
if (mFlipY) {
|
||||||
bottomRightAlign.y += moveY * pyA;
|
topLeftAlign.y -= moveY * pyA;
|
||||||
|
bottomRightAlign.y -= moveY * pyA;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
topLeftAlign.y += moveY * pyA;
|
||||||
|
bottomRightAlign.y += moveY * pyA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue