nsxiv26a624a
Added options for anti-alias & alpha layer coloring to config.def.h
Also removed now obsolete -p command line option; fixes issue #98
+23 −15
8 files changed
- M README.md +0 −1
- M commands.c +3 −1
- M config.def.h +13 −0
- M image.c +3 −2
- M options.c +2 −6
- M options.h +0 −1
- M sxiv.1 +0 −3
- M thumbs.c +2 −1
| @@ -80,7 +80,6 @@ of small previews is displayed, making it easy to choose an image to open. | |||
| 80 | 80 | -n NUM Start at picture NUM | |
| 81 | 81 | -N NAME Set X window resource name to NAME | |
| 82 | 82 | -o Write list of marked files to stdout when quitting | |
| 83 | − | -p Pixelize, i.e. turn off image anti-aliasing | |
| 84 | 83 | -q Be quiet, disable warnings | |
| 85 | 84 | -r Search given directories recursively for images | |
| 86 | 85 | -s Scale all images to fit into window | |
| @@ -74,8 +74,10 @@ bool it_quit(arg_t a) | |||
| 74 | 74 | bool it_switch_mode(arg_t a) | |
| 75 | 75 | { | |
| 76 | 76 | if (mode == MODE_IMAGE) { | |
| 77 | − | if (tns.thumbs == NULL) | |
| 77 | + | if (tns.thumbs == NULL) { | |
| 78 | 78 | tns_init(&tns, filecnt, &win); | |
| 79 | + | tns.alpha = img.alpha; | |
| 80 | + | } | |
| 79 | 81 | img_close(&img, false); | |
| 80 | 82 | reset_timeout(reset_cursor); | |
| 81 | 83 | tns.sel = fileidx; | |
| @@ -52,6 +52,19 @@ enum { | |||
| 52 | 52 | /* default dimension of thumbnails (width == height): */ | |
| 53 | 53 | enum { THUMB_SIZE = 60 }; | |
| 54 | 54 | ||
| 55 | + | #endif | |
| 56 | + | #ifdef _RENDER_CONFIG | |
| 57 | + | ||
| 58 | + | /* if false, pixelate images at zoom level != 100%, | |
| 59 | + | * toggled with 'a' key binding | |
| 60 | + | */ | |
| 61 | + | static const bool RENDER_ANTI_ALIAS = true; | |
| 62 | + | ||
| 63 | + | /* if true, use white background for alpha layer, | |
| 64 | + | * toggled with 'A' key binding | |
| 65 | + | */ | |
| 66 | + | static const bool RENDER_WHITE_ALPHA = false; | |
| 67 | + | ||
| 55 | 68 | #endif | |
| 56 | 69 | #ifdef _MAPPINGS_CONFIG | |
| 57 | 70 | ||
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | #define _POSIX_C_SOURCE 200112L | |
| 20 | 20 | #define _IMAGE_CONFIG | |
| 21 | + | #define _RENDER_CONFIG | |
| 21 | 22 | ||
| 22 | 23 | #include <stdlib.h> | |
| 23 | 24 | #include <string.h> | |
| @@ -62,8 +63,8 @@ void img_init(img_t *img, win_t *win) | |||
| 62 | 63 | img->zoom = MIN(img->zoom, zoom_max); | |
| 63 | 64 | img->checkpan = false; | |
| 64 | 65 | img->dirty = false; | |
| 65 | − | img->aa = options->aa; | |
| 66 | − | img->alpha = true; | |
| 66 | + | img->aa = RENDER_ANTI_ALIAS; | |
| 67 | + | img->alpha = !RENDER_WHITE_ALPHA; | |
| 67 | 68 | img->multi.cap = img->multi.cnt = 0; | |
| 68 | 69 | img->multi.animate = false; | |
| 69 | 70 | } | |
| @@ -33,7 +33,7 @@ const options_t *options = (const options_t*) &_options; | |||
| 33 | 33 | ||
| 34 | 34 | void print_usage(void) | |
| 35 | 35 | { | |
| 36 | − | printf("usage: sxiv [-bcdFfhiopqrstvZ] [-g GEOMETRY] [-n NUM] " | |
| 36 | + | printf("usage: sxiv [-bcdFfhioqrstvZ] [-g GEOMETRY] [-n NUM] " | |
| 37 | 37 | "[-N name] [-z ZOOM] FILES...\n"); | |
| 38 | 38 | } | |
| 39 | 39 | ||
| @@ -53,7 +53,6 @@ void parse_options(int argc, char **argv) | |||
| 53 | 53 | ||
| 54 | 54 | _options.scalemode = SCALE_MODE; | |
| 55 | 55 | _options.zoom = 1.0; | |
| 56 | − | _options.aa = true; | |
| 57 | 56 | ||
| 58 | 57 | _options.fixed_win = false; | |
| 59 | 58 | _options.fullscreen = false; | |
| @@ -65,7 +64,7 @@ void parse_options(int argc, char **argv) | |||
| 65 | 64 | _options.thumb_mode = false; | |
| 66 | 65 | _options.clean_cache = false; | |
| 67 | 66 | ||
| 68 | − | while ((opt = getopt(argc, argv, "bcdFfg:hin:N:opqrstvZz:")) != -1) { | |
| 67 | + | while ((opt = getopt(argc, argv, "bcdFfg:hin:N:oqrstvZz:")) != -1) { | |
| 69 | 68 | switch (opt) { | |
| 70 | 69 | case '?': | |
| 71 | 70 | print_usage(); | |
| @@ -109,9 +108,6 @@ void parse_options(int argc, char **argv) | |||
| 109 | 108 | case 'o': | |
| 110 | 109 | _options.to_stdout = true; | |
| 111 | 110 | break; | |
| 112 | − | case 'p': | |
| 113 | − | _options.aa = false; | |
| 114 | − | break; | |
| 115 | 111 | case 'q': | |
| 116 | 112 | _options.quiet = true; | |
| 117 | 113 | break; | |
| @@ -34,7 +34,6 @@ typedef struct { | |||
| 34 | 34 | /* image: */ | |
| 35 | 35 | scalemode_t scalemode; | |
| 36 | 36 | float zoom; | |
| 37 | − | bool aa; | |
| 38 | 37 | ||
| 39 | 38 | /* window: */ | |
| 40 | 39 | bool fixed_win; | |
| @@ -67,9 +67,6 @@ with | |||
| 67 | 67 | .I \-i | |
| 68 | 68 | sxiv can be used as a visual filter/pipe. | |
| 69 | 69 | .TP | |
| 70 | − | .B \-p | |
| 71 | − | Pixelize images, i.e. turn off anti-aliasing. | |
| 72 | − | .TP | |
| 73 | 70 | .B \-q | |
| 74 | 71 | Be quiet, disable warnings to standard error stream. | |
| 75 | 72 | .TP | |
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | #define _POSIX_C_SOURCE 200112L | |
| 20 | 20 | #define _THUMBS_CONFIG | |
| 21 | + | #define _RENDER_CONFIG | |
| 21 | 22 | ||
| 22 | 23 | #include <stdlib.h> | |
| 23 | 24 | #include <string.h> | |
| @@ -177,7 +178,7 @@ void tns_init(tns_t *tns, int cnt, win_t *win) | |||
| 177 | 178 | tns->cap = cnt; | |
| 178 | 179 | tns->cnt = tns->first = tns->sel = 0; | |
| 179 | 180 | tns->win = win; | |
| 180 | − | tns->alpha = true; | |
| 181 | + | tns->alpha = !RENDER_WHITE_ALPHA; | |
| 181 | 182 | tns->dirty = false; | |
| 182 | 183 | ||
| 183 | 184 | if ((homedir = getenv("HOME")) != NULL) { | |