mirror of
https://github.com/hyprwm/hyprcursor.git
synced 2024-12-22 18:29:48 +01:00
core: add helper for resize algo
This commit is contained in:
parent
10516e0451
commit
fcfa979979
3 changed files with 13 additions and 4 deletions
|
@ -136,7 +136,7 @@ static std::optional<std::string> createCursorThemeFromPath(const std::string& p
|
||||||
SHAPE.directory = dir.path().stem().string();
|
SHAPE.directory = dir.path().stem().string();
|
||||||
SHAPE.hotspotX = std::any_cast<float>(meta->getConfigValue("hotspot_x"));
|
SHAPE.hotspotX = std::any_cast<float>(meta->getConfigValue("hotspot_x"));
|
||||||
SHAPE.hotspotY = std::any_cast<float>(meta->getConfigValue("hotspot_y"));
|
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";
|
std::cout << "Shape " << SHAPE.directory << ": \n\toverrides: " << SHAPE.overrides.size() << "\n\tsizes: " << SHAPE.images.size() << "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,7 +383,7 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
|
||||||
SHAPE.directory = cursor.path().stem().string();
|
SHAPE.directory = cursor.path().stem().string();
|
||||||
SHAPE.hotspotX = std::any_cast<float>(meta->getConfigValue("hotspot_x"));
|
SHAPE.hotspotX = std::any_cast<float>(meta->getConfigValue("hotspot_x"));
|
||||||
SHAPE.hotspotY = std::any_cast<float>(meta->getConfigValue("hotspot_y"));
|
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);
|
zip_discard(zip);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,19 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
enum eResizeAlgo {
|
enum eResizeAlgo {
|
||||||
RESIZE_BILINEAR = 0,
|
RESIZE_NONE = 0,
|
||||||
RESIZE_NEAREST = 1,
|
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 {
|
struct SCursorImage {
|
||||||
std::string filename;
|
std::string filename;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
Loading…
Reference in a new issue