core: add helper for resize algo

This commit is contained in:
Vaxry 2024-03-07 14:16:22 +00:00
parent 10516e0451
commit fcfa979979
3 changed files with 13 additions and 4 deletions

View file

@ -136,7 +136,7 @@ static std::optional<std::string> createCursorThemeFromPath(const std::string& p
SHAPE.directory = dir.path().stem().string();
SHAPE.hotspotX = std::any_cast<float>(meta->getConfigValue("hotspot_x"));
SHAPE.hotspotY = std::any_cast<float>(meta->getConfigValue("hotspot_y"));
SHAPE.resizeAlgo = std::string{std::any_cast<Hyprlang::STRING>(meta->getConfigValue("resize_algorithm"))} == "nearest" ? RESIZE_NEAREST : RESIZE_BILINEAR;
SHAPE.resizeAlgo = stringToAlgo(std::any_cast<Hyprlang::STRING>(meta->getConfigValue("resize_algorithm")));
std::cout << "Shape " << SHAPE.directory << ": \n\toverrides: " << SHAPE.overrides.size() << "\n\tsizes: " << SHAPE.images.size() << "\n";
}

View file

@ -383,7 +383,7 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
SHAPE.directory = cursor.path().stem().string();
SHAPE.hotspotX = std::any_cast<float>(meta->getConfigValue("hotspot_x"));
SHAPE.hotspotY = std::any_cast<float>(meta->getConfigValue("hotspot_y"));
SHAPE.resizeAlgo = std::string{std::any_cast<Hyprlang::STRING>(meta->getConfigValue("resize_algorithm"))} == "nearest" ? RESIZE_NEAREST : RESIZE_BILINEAR;
SHAPE.resizeAlgo = stringToAlgo(std::any_cast<Hyprlang::STRING>(meta->getConfigValue("resize_algorithm")));
zip_discard(zip);
}

View file

@ -3,10 +3,19 @@
#include <vector>
enum eResizeAlgo {
RESIZE_BILINEAR = 0,
RESIZE_NEAREST = 1,
RESIZE_NONE = 0,
RESIZE_BILINEAR = 1,
RESIZE_NEAREST = 2,
};
inline eResizeAlgo stringToAlgo(const std::string& s) {
if (s == "none")
return RESIZE_NONE;
if (s == "nearest")
return RESIZE_NEAREST;
return RESIZE_BILINEAR;
}
struct SCursorImage {
std::string filename;
int size = 0;