mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Added an 'imageCropPos' property to the grid element
This commit is contained in:
parent
248df769eb
commit
f240094191
|
@ -203,6 +203,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"unfocusedItemSaturation", FLOAT},
|
{"unfocusedItemSaturation", FLOAT},
|
||||||
{"unfocusedItemDimming", FLOAT},
|
{"unfocusedItemDimming", FLOAT},
|
||||||
{"imageFit", STRING},
|
{"imageFit", STRING},
|
||||||
|
{"imageCropPos", NORMALIZED_PAIR},
|
||||||
{"imageInterpolation", STRING},
|
{"imageInterpolation", STRING},
|
||||||
{"imageRelativeScale", FLOAT},
|
{"imageRelativeScale", FLOAT},
|
||||||
{"imageCornerRadius", FLOAT},
|
{"imageCornerRadius", FLOAT},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
// ES-DE
|
// ES-DE Frontend
|
||||||
// GridComponent.h
|
// GridComponent.h
|
||||||
//
|
//
|
||||||
// Grid, usable in both the system and gamelist views.
|
// Grid, usable in both the system and gamelist views.
|
||||||
|
@ -161,6 +161,7 @@ private:
|
||||||
bool mHasUnfocusedItemSaturation;
|
bool mHasUnfocusedItemSaturation;
|
||||||
float mUnfocusedItemDimming;
|
float mUnfocusedItemDimming;
|
||||||
ImageFit mImagefit;
|
ImageFit mImagefit;
|
||||||
|
glm::vec2 mImageCropPos;
|
||||||
bool mImageLinearInterpolation;
|
bool mImageLinearInterpolation;
|
||||||
float mImageRelativeScale;
|
float mImageRelativeScale;
|
||||||
float mImageCornerRadius;
|
float mImageCornerRadius;
|
||||||
|
@ -239,6 +240,7 @@ GridComponent<T>::GridComponent()
|
||||||
, mHasUnfocusedItemSaturation {false}
|
, mHasUnfocusedItemSaturation {false}
|
||||||
, mUnfocusedItemDimming {1.0f}
|
, mUnfocusedItemDimming {1.0f}
|
||||||
, mImagefit {ImageFit::CONTAIN}
|
, mImagefit {ImageFit::CONTAIN}
|
||||||
|
, mImageCropPos {0.5f, 0.5f}
|
||||||
, mImageLinearInterpolation {true}
|
, mImageLinearInterpolation {true}
|
||||||
, mImageRelativeScale {1.0f}
|
, mImageRelativeScale {1.0f}
|
||||||
, mImageCornerRadius {0.0f}
|
, mImageCornerRadius {0.0f}
|
||||||
|
@ -304,12 +306,16 @@ void GridComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeData>&
|
||||||
auto item = std::make_shared<ImageComponent>(false, dynamic);
|
auto item = std::make_shared<ImageComponent>(false, dynamic);
|
||||||
item->setLinearInterpolation(mImageLinearInterpolation);
|
item->setLinearInterpolation(mImageLinearInterpolation);
|
||||||
item->setMipmapping(true);
|
item->setMipmapping(true);
|
||||||
if (mImagefit == ImageFit::CONTAIN)
|
if (mImagefit == ImageFit::CONTAIN) {
|
||||||
item->setMaxSize(glm::round(mItemSize * mImageRelativeScale));
|
item->setMaxSize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
else if (mImagefit == ImageFit::FILL)
|
}
|
||||||
|
else if (mImagefit == ImageFit::FILL) {
|
||||||
item->setResize(glm::round(mItemSize * mImageRelativeScale));
|
item->setResize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
else if (mImagefit == ImageFit::COVER)
|
}
|
||||||
|
else if (mImagefit == ImageFit::COVER) {
|
||||||
|
item->setCropPos(mImageCropPos);
|
||||||
item->setCroppedSize(glm::round(mItemSize * mImageRelativeScale));
|
item->setCroppedSize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
|
}
|
||||||
item->setCornerRadius(mImageCornerRadius);
|
item->setCornerRadius(mImageCornerRadius);
|
||||||
item->setImage(entry.data.imagePath);
|
item->setImage(entry.data.imagePath);
|
||||||
if (mImageBrightness != 0.0)
|
if (mImageBrightness != 0.0)
|
||||||
|
@ -336,12 +342,16 @@ void GridComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeData>&
|
||||||
mDefaultImage = std::make_shared<ImageComponent>(false, dynamic);
|
mDefaultImage = std::make_shared<ImageComponent>(false, dynamic);
|
||||||
mDefaultImage->setLinearInterpolation(mImageLinearInterpolation);
|
mDefaultImage->setLinearInterpolation(mImageLinearInterpolation);
|
||||||
mDefaultImage->setMipmapping(true);
|
mDefaultImage->setMipmapping(true);
|
||||||
if (mImagefit == ImageFit::CONTAIN)
|
if (mImagefit == ImageFit::CONTAIN) {
|
||||||
mDefaultImage->setMaxSize(glm::round(mItemSize * mImageRelativeScale));
|
mDefaultImage->setMaxSize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
else if (mImagefit == ImageFit::FILL)
|
}
|
||||||
|
else if (mImagefit == ImageFit::FILL) {
|
||||||
mDefaultImage->setResize(glm::round(mItemSize * mImageRelativeScale));
|
mDefaultImage->setResize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
else if (mImagefit == ImageFit::COVER)
|
}
|
||||||
|
else if (mImagefit == ImageFit::COVER) {
|
||||||
|
mDefaultImage->setCropPos(mImageCropPos);
|
||||||
mDefaultImage->setCroppedSize(glm::round(mItemSize * mImageRelativeScale));
|
mDefaultImage->setCroppedSize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
|
}
|
||||||
mDefaultImage->setCornerRadius(mImageCornerRadius);
|
mDefaultImage->setCornerRadius(mImageCornerRadius);
|
||||||
mDefaultImage->setImage(entry.data.defaultImagePath);
|
mDefaultImage->setImage(entry.data.defaultImagePath);
|
||||||
if (mImageBrightness != 0.0)
|
if (mImageBrightness != 0.0)
|
||||||
|
@ -393,12 +403,16 @@ void GridComponent<T>::updateEntry(Entry& entry, const std::shared_ptr<ThemeData
|
||||||
auto item = std::make_shared<ImageComponent>(false, true);
|
auto item = std::make_shared<ImageComponent>(false, true);
|
||||||
item->setLinearInterpolation(mImageLinearInterpolation);
|
item->setLinearInterpolation(mImageLinearInterpolation);
|
||||||
item->setMipmapping(true);
|
item->setMipmapping(true);
|
||||||
if (mImagefit == ImageFit::CONTAIN)
|
if (mImagefit == ImageFit::CONTAIN) {
|
||||||
item->setMaxSize(glm::round(mItemSize * mImageRelativeScale));
|
item->setMaxSize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
else if (mImagefit == ImageFit::FILL)
|
}
|
||||||
|
else if (mImagefit == ImageFit::FILL) {
|
||||||
item->setResize(glm::round(mItemSize * mImageRelativeScale));
|
item->setResize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
else if (mImagefit == ImageFit::COVER)
|
}
|
||||||
|
else if (mImagefit == ImageFit::COVER) {
|
||||||
|
item->setCropPos(mImageCropPos);
|
||||||
item->setCroppedSize(glm::round(mItemSize * mImageRelativeScale));
|
item->setCroppedSize(glm::round(mItemSize * mImageRelativeScale));
|
||||||
|
}
|
||||||
item->setCornerRadius(mImageCornerRadius);
|
item->setCornerRadius(mImageCornerRadius);
|
||||||
item->setImage(entry.data.imagePath);
|
item->setImage(entry.data.imagePath);
|
||||||
if (mImageBrightness != 0.0)
|
if (mImageBrightness != 0.0)
|
||||||
|
@ -1042,6 +1056,8 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
else if (imageFit == "cover") {
|
else if (imageFit == "cover") {
|
||||||
mImagefit = ImageFit::COVER;
|
mImagefit = ImageFit::COVER;
|
||||||
|
if (elem->has("imageCropPos"))
|
||||||
|
mImageCropPos = glm::clamp(elem->get<glm::vec2>("imageCropPos"), 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mImagefit = ImageFit::CONTAIN;
|
mImagefit = ImageFit::CONTAIN;
|
||||||
|
|
Loading…
Reference in a new issue