Krolyxon
Commit 39671a1

Branches

Refs →

nsxiv39671a1

Moved thumbnail sizes array to config.def.h

Author
Bert Münnich
Date
2014-09-29 09:02 +0200
Parent
8fa7247
Commit
39671a149c180945a1be46c74776b3df0ef5c084

+13 −7

2 files changed

  1. M config.def.h +6 −0
  2. M thumbs.c +7 −7
M config.def.h View
@@ -50,6 +50,12 @@ static const bool ANTI_ALIAS = true;
5050 */
5151 static const bool ALPHA_LAYER = false;
5252
53+#endif
54+#ifdef _THUMBS_CONFIG
55+
56+/* thumbnail sizes in pixels (width == height): */
57+static const int thumb_sizes[] = { 32, 64, 96, 128, 160 };
58+
5359 #endif
5460 #ifdef _MAPPINGS_CONFIG
5561
M thumbs.c View
@@ -17,6 +17,7 @@
1717 */
1818
1919 #define _POSIX_C_SOURCE 200112L
20+#define _THUMBS_CONFIG
2021
2122 #include <stdio.h>
2223 #include <stdlib.h>
@@ -36,7 +37,6 @@ void exif_auto_orientate(const fileinfo_t*);
3637 #endif
3738
3839 static char *cache_dir;
39−static const int thumb_size[] = { 32, 64, 96, 128, 160 };
4040
4141 char* tns_cache_filepath(const char *filepath)
4242 {
@@ -330,11 +330,11 @@ bool tns_load(tns_t *tns, int n, bool force)
330330 imlib_context_set_image(im);
331331 exif_auto_orientate(file);
332332 #endif
333− im = tns_scale_down(im, thumb_size[ARRLEN(thumb_size)-1]);
333+ im = tns_scale_down(im, thumb_sizes[ARRLEN(thumb_sizes)-1]);
334334 tns_cache_write(im, file->path, true);
335335 }
336336
337− t->im = tns_scale_down(im, thumb_size[tns->zl]);
337+ t->im = tns_scale_down(im, thumb_sizes[tns->zl]);
338338 imlib_context_set_image(t->im);
339339 t->w = imlib_image_get_width();
340340 t->h = imlib_image_get_height();
@@ -434,8 +434,8 @@ void tns_render(tns_t *tns)
434434 for (i = tns->first; i < tns->end; i++) {
435435 t = &tns->thumbs[i];
436436 if (t->im != NULL) {
437− t->x = x + (thumb_size[tns->zl] - t->w) / 2;
438− t->y = y + (thumb_size[tns->zl] - t->h) / 2;
437+ t->x = x + (thumb_sizes[tns->zl] - t->w) / 2;
438+ t->y = y + (thumb_sizes[tns->zl] - t->h) / 2;
439439 imlib_context_set_image(t->im);
440440 imlib_render_image_on_drawable_at_size(t->x, t->y, t->w, t->h);
441441 if (tns->files[i].marked)
@@ -572,9 +572,9 @@ bool tns_zoom(tns_t *tns, int d)
572572 oldzl = tns->zl;
573573 tns->zl += -(d < 0) + (d > 0);
574574 tns->zl = MAX(tns->zl, 0);
575− tns->zl = MIN(tns->zl, ARRLEN(thumb_size)-1);
575+ tns->zl = MIN(tns->zl, ARRLEN(thumb_sizes)-1);
576576
577− tns->dim = thumb_size[tns->zl] + 10;
577+ tns->dim = thumb_sizes[tns->zl] + 10;
578578
579579 if (tns->zl != oldzl) {
580580 for (i = 0; i < tns->cnt; i++)