Added an 'interpolation' property to the badge element

This commit is contained in:
Leon Styhre 2023-09-30 11:36:10 +02:00
parent c988170641
commit fcc46148e9
3 changed files with 21 additions and 0 deletions

View file

@ -383,6 +383,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"folderLinkIconColor", COLOR}, {"folderLinkIconColor", COLOR},
{"folderLinkIconColorEnd", COLOR}, {"folderLinkIconColorEnd", COLOR},
{"folderLinkIconGradientType", STRING}, {"folderLinkIconGradientType", STRING},
{"interpolation", STRING},
{"opacity", FLOAT}, {"opacity", FLOAT},
{"visible", BOOLEAN}, {"visible", BOOLEAN},
{"zIndex", FLOAT}}}, {"zIndex", FLOAT}}},

View file

@ -76,6 +76,7 @@ BadgeComponent::BadgeComponent()
, mFlexboxComponent {mFlexboxItems} , mFlexboxComponent {mFlexboxItems}
, mBadgeTypes {{SLOT_COLLECTION, SLOT_FOLDER, SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, , mBadgeTypes {{SLOT_COLLECTION, SLOT_FOLDER, SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME,
SLOT_BROKEN, SLOT_CONTROLLER, SLOT_ALTEMULATOR, SLOT_MANUAL}} SLOT_BROKEN, SLOT_CONTROLLER, SLOT_ALTEMULATOR, SLOT_MANUAL}}
, mLinearInterpolation {false}
{ {
mBadgeIcons[SLOT_COLLECTION] = ":/graphics/badge_collection.svg"; mBadgeIcons[SLOT_COLLECTION] = ":/graphics/badge_collection.svg";
mBadgeIcons[SLOT_FOLDER] = ":/graphics/badge_folder.svg"; mBadgeIcons[SLOT_FOLDER] = ":/graphics/badge_folder.svg";
@ -300,6 +301,21 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
} }
} }
if (elem->has("interpolation")) {
const std::string& interpolation {elem->get<std::string>("interpolation")};
if (interpolation == "linear") {
mLinearInterpolation = true;
}
else if (interpolation == "nearest") {
mLinearInterpolation = false;
}
else {
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, property "
"\"interpolation\" for element \""
<< element.substr(7) << "\" defined as \"" << interpolation << "\"";
}
}
unsigned int badgeIconColorShift {0xFFFFFFFF}; unsigned int badgeIconColorShift {0xFFFFFFFF};
unsigned int badgeIconColorShiftEnd {0xFFFFFFFF}; unsigned int badgeIconColorShiftEnd {0xFFFFFFFF};
bool badgeIconColorGradientHorizontal {true}; bool badgeIconColorGradientHorizontal {true};
@ -417,9 +433,11 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
item.label = slot; item.label = slot;
ImageComponent badgeImage {false, false}; ImageComponent badgeImage {false, false};
badgeImage.setLinearInterpolation(mLinearInterpolation);
badgeImage.setImage(mBadgeIcons[slot]); badgeImage.setImage(mBadgeIcons[slot]);
item.baseImage = badgeImage; item.baseImage = badgeImage;
item.overlayImage = ImageComponent {false, false}; item.overlayImage = ImageComponent {false, false};
item.overlayImage.setLinearInterpolation(mLinearInterpolation);
item.baseImage.setColorShift(badgeIconColorShift); item.baseImage.setColorShift(badgeIconColorShift);
item.baseImage.setColorShiftEnd(badgeIconColorShiftEnd); item.baseImage.setColorShiftEnd(badgeIconColorShiftEnd);

View file

@ -62,6 +62,8 @@ private:
std::vector<std::string> mBadgeTypes; std::vector<std::string> mBadgeTypes;
std::map<std::string, std::string> mBadgeIcons; std::map<std::string, std::string> mBadgeIcons;
bool mLinearInterpolation;
}; };
#endif // ES_CORE_COMPONENTS_BADGE_COMPONENT_H #endif // ES_CORE_COMPONENTS_BADGE_COMPONENT_H