mirror of
https://github.com/hyprwm/hyprcursor.git
synced 2024-12-22 02:09:48 +01:00
util: add --resize
This commit is contained in:
parent
effb7a4665
commit
06d1028025
3 changed files with 26 additions and 5 deletions
|
@ -15,4 +15,8 @@ Cursor themes can be in 3 states:
|
|||
|
||||
`--extract | -x [path]` -> extract an xcursor theme into a working state
|
||||
|
||||
both commands support `--output | -o` to specify an output directory. This directory will be fully overwritten, and by default is `./theme` and `./extracted` respectively.
|
||||
both commands support `--output | -o` to specify an output directory. This directory will be fully overwritten, and by default is `./theme` and `./extracted` respectively.
|
||||
|
||||
### Flags
|
||||
|
||||
`--resize [mode]` - for `extract`: specify a default resize algorithm for shapes. Default is `none`.
|
|
@ -12,6 +12,8 @@ enum eOperation {
|
|||
OPERATION_EXTRACT = 1,
|
||||
};
|
||||
|
||||
eResizeAlgo explicitResizeAlgo = RESIZE_INVALID;
|
||||
|
||||
struct XCursorConfigEntry {
|
||||
int size = 0, hotspotX = 0, hotspotY = 0, delay = 0;
|
||||
std::string image;
|
||||
|
@ -349,7 +351,7 @@ static std::optional<std::string> extractXTheme(const std::string& xpath, const
|
|||
}
|
||||
|
||||
// write a meta.hl
|
||||
std::string metaString = "resize_algorithm = none\n";
|
||||
std::string metaString = std::format("resize_algorithm = {}\n", explicitResizeAlgo == RESIZE_INVALID ? "none" : algoToString(explicitResizeAlgo));
|
||||
|
||||
// find hotspot from first entry
|
||||
metaString +=
|
||||
|
@ -431,6 +433,9 @@ int main(int argc, char** argv, char** envp) {
|
|||
if (arg == "-o" || arg == "--output") {
|
||||
out = argv[++i];
|
||||
continue;
|
||||
} else if (arg == "--resize") {
|
||||
explicitResizeAlgo = stringToAlgo(argv[++i]);
|
||||
continue;
|
||||
} else {
|
||||
std::cerr << "Unknown arg: " << arg << "\n";
|
||||
return 1;
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
#include <memory>
|
||||
|
||||
enum eResizeAlgo {
|
||||
RESIZE_NONE = 0,
|
||||
RESIZE_BILINEAR = 1,
|
||||
RESIZE_NEAREST = 2,
|
||||
RESIZE_INVALID = 0,
|
||||
RESIZE_NONE,
|
||||
RESIZE_BILINEAR,
|
||||
RESIZE_NEAREST,
|
||||
};
|
||||
|
||||
enum eShapeType {
|
||||
|
@ -23,6 +24,17 @@ inline eResizeAlgo stringToAlgo(const std::string& s) {
|
|||
return RESIZE_BILINEAR;
|
||||
}
|
||||
|
||||
inline std::string algoToString(const eResizeAlgo a) {
|
||||
switch (a) {
|
||||
case RESIZE_BILINEAR: return "bilinear";
|
||||
case RESIZE_NEAREST: return "nearest";
|
||||
case RESIZE_NONE: return "none";
|
||||
default: return "none";
|
||||
}
|
||||
|
||||
return "none";
|
||||
}
|
||||
|
||||
struct SCursorImage {
|
||||
std::string filename;
|
||||
int size = 0;
|
||||
|
|
Loading…
Reference in a new issue