mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Added carousel theme support for offsetting items to achieve a diagonal layout.
This commit is contained in:
parent
7b2dda0807
commit
7b47d2e4d6
|
@ -158,6 +158,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"imageBrightness", FLOAT},
|
||||
{"imageSaturation", FLOAT},
|
||||
{"itemTransitions", STRING},
|
||||
{"itemDiagonalOffset", FLOAT},
|
||||
{"itemHorizontalAlignment", STRING},
|
||||
{"itemVerticalAlignment", STRING},
|
||||
{"wheelHorizontalAlignment", STRING},
|
||||
|
|
|
@ -167,6 +167,7 @@ private:
|
|||
bool mHasImageSelectedColor;
|
||||
float mImageBrightness;
|
||||
float mImageSaturation;
|
||||
float mItemDiagonalOffset;
|
||||
bool mInstantItemTransitions;
|
||||
Alignment mItemHorizontalAlignment;
|
||||
Alignment mItemVerticalAlignment;
|
||||
|
@ -233,6 +234,7 @@ CarouselComponent<T>::CarouselComponent()
|
|||
, mHasImageSelectedColor {false}
|
||||
, mImageBrightness {0.0f}
|
||||
, mImageSaturation {1.0f}
|
||||
, mItemDiagonalOffset {0.0f}
|
||||
, mInstantItemTransitions {false}
|
||||
, mItemHorizontalAlignment {ALIGN_CENTER}
|
||||
, mItemVerticalAlignment {ALIGN_CENTER}
|
||||
|
@ -1109,6 +1111,16 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
|
|||
metadataOpacity = 0.7f;
|
||||
}
|
||||
|
||||
const glm::vec3 origPos {comp->getPosition()};
|
||||
if (mItemDiagonalOffset != 0.0f) {
|
||||
if (mType == CarouselType::HORIZONTAL)
|
||||
comp->setPosition(
|
||||
origPos.x, origPos.y - (mItemDiagonalOffset * renderItem.distance), origPos.z);
|
||||
else
|
||||
comp->setPosition(origPos.x - (mItemDiagonalOffset * renderItem.distance),
|
||||
origPos.y, origPos.z);
|
||||
}
|
||||
|
||||
comp->setScale(renderItem.scale);
|
||||
comp->setOpacity(renderItem.opacity * metadataOpacity);
|
||||
if (renderItem.index == mCursor && (mHasImageSelectedColor || mHasTextSelectedColor)) {
|
||||
|
@ -1143,6 +1155,9 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
|
|||
comp->render(renderItem.trans);
|
||||
}
|
||||
|
||||
if (mItemDiagonalOffset != 0.0f)
|
||||
comp->setPosition(origPos);
|
||||
|
||||
// TODO: Rewrite to use "real" reflections instead of this hack.
|
||||
// Don't attempt to add reflections for text entries.
|
||||
if (mReflections && (mEntries.at(renderItem.index).data.imagePath != "" ||
|
||||
|
@ -1415,6 +1430,16 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
if (elem->has("imageSaturation"))
|
||||
mImageSaturation = glm::clamp(elem->get<float>("imageSaturation"), 0.0f, 1.0f);
|
||||
|
||||
if (elem->has("itemDiagonalOffset") &&
|
||||
(mType == CarouselType::HORIZONTAL || mType == CarouselType::VERTICAL)) {
|
||||
const float diagonalOffset {
|
||||
glm::clamp(elem->get<float>("itemDiagonalOffset"), -0.5f, 0.5f)};
|
||||
if (mType == CarouselType::HORIZONTAL)
|
||||
mItemDiagonalOffset = diagonalOffset * Renderer::getScreenHeight();
|
||||
else
|
||||
mItemDiagonalOffset = diagonalOffset * Renderer::getScreenWidth();
|
||||
}
|
||||
|
||||
if (elem->has("imageInterpolation")) {
|
||||
const std::string& imageInterpolation {elem->get<std::string>("imageInterpolation")};
|
||||
if (imageInterpolation == "linear") {
|
||||
|
|
Loading…
Reference in a new issue