summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-09-29 09:02:29 +0200
committerBert Münnich <ber.t@posteo.de>2014-09-29 09:02:29 +0200
commit39671a149c180945a1be46c74776b3df0ef5c084 (patch)
tree98e5bcafac9b7cc054006d03ffe35c34669a7663
parent8fa7247f69e1d8528572c43d3815a62e6bcdb75f (diff)
downloadnsxiv-39671a149c180945a1be46c74776b3df0ef5c084.tar.zst
Moved thumbnail sizes array to config.def.h
-rw-r--r--config.def.h6
-rw-r--r--thumbs.c14
2 files changed, 13 insertions, 7 deletions
diff --git a/config.def.h b/config.def.h
index 6facb8e..cb230c8 100644
--- a/config.def.h
+++ b/config.def.h
@@ -51,6 +51,12 @@ static const bool ANTI_ALIAS = true;
static const bool ALPHA_LAYER = false;
#endif
+#ifdef _THUMBS_CONFIG
+
+/* thumbnail sizes in pixels (width == height): */
+static const int thumb_sizes[] = { 32, 64, 96, 128, 160 };
+
+#endif
#ifdef _MAPPINGS_CONFIG
/* keyboard mappings for image and thumbnail mode: */
diff --git a/thumbs.c b/thumbs.c
index 3916160..55c6d4f 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -17,6 +17,7 @@
*/
#define _POSIX_C_SOURCE 200112L
+#define _THUMBS_CONFIG
#include <stdio.h>
#include <stdlib.h>
@@ -36,7 +37,6 @@ void exif_auto_orientate(const fileinfo_t*);
#endif
static char *cache_dir;
-static const int thumb_size[] = { 32, 64, 96, 128, 160 };
char* tns_cache_filepath(const char *filepath)
{
@@ -330,11 +330,11 @@ bool tns_load(tns_t *tns, int n, bool force)
imlib_context_set_image(im);
exif_auto_orientate(file);
#endif
- im = tns_scale_down(im, thumb_size[ARRLEN(thumb_size)-1]);
+ im = tns_scale_down(im, thumb_sizes[ARRLEN(thumb_sizes)-1]);
tns_cache_write(im, file->path, true);
}
- t->im = tns_scale_down(im, thumb_size[tns->zl]);
+ t->im = tns_scale_down(im, thumb_sizes[tns->zl]);
imlib_context_set_image(t->im);
t->w = imlib_image_get_width();
t->h = imlib_image_get_height();
@@ -434,8 +434,8 @@ void tns_render(tns_t *tns)
for (i = tns->first; i < tns->end; i++) {
t = &tns->thumbs[i];
if (t->im != NULL) {
- t->x = x + (thumb_size[tns->zl] - t->w) / 2;
- t->y = y + (thumb_size[tns->zl] - t->h) / 2;
+ t->x = x + (thumb_sizes[tns->zl] - t->w) / 2;
+ t->y = y + (thumb_sizes[tns->zl] - t->h) / 2;
imlib_context_set_image(t->im);
imlib_render_image_on_drawable_at_size(t->x, t->y, t->w, t->h);
if (tns->files[i].marked)
@@ -572,9 +572,9 @@ bool tns_zoom(tns_t *tns, int d)
oldzl = tns->zl;
tns->zl += -(d < 0) + (d > 0);
tns->zl = MAX(tns->zl, 0);
- tns->zl = MIN(tns->zl, ARRLEN(thumb_size)-1);
+ tns->zl = MIN(tns->zl, ARRLEN(thumb_sizes)-1);
- tns->dim = thumb_size[tns->zl] + 10;
+ tns->dim = thumb_sizes[tns->zl] + 10;
if (tns->zl != oldzl) {
for (i = 0; i < tns->cnt; i++)