diff options
author | Bert <ber.t@gmx.com> | 2011-02-16 18:16:00 +0100 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-02-16 18:16:00 +0100 |
commit | 8919204a2e666e12216240a792bfff7a391d4d43 (patch) | |
tree | 057989f1a75c90f7257cc08f118e0197c2e87cef /main.c | |
parent | 89ec18385b1d9e76463afd443b25c203a83c94cb (diff) | |
download | nsxiv-8919204a2e666e12216240a792bfff7a391d4d43.tar.zst |
Render thumbnails
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -27,6 +27,7 @@ #include <X11/Xutil.h> #include <X11/keysym.h> +#include "config.h" #include "image.h" #include "options.h" #include "util.h" @@ -38,6 +39,7 @@ typedef enum appmode_e { } appmode_t; void update_title(); +void render_thumbs(); int check_append(const char*); void read_dir_rec(const char*); void run(); @@ -53,6 +55,7 @@ int filecnt, fileidx; size_t filesize; thumb_t *thumbs; +int tvis, tcols, trows; #define TITLE_LEN 256 char win_title[TITLE_LEN]; @@ -137,6 +140,7 @@ int main(int argc, char **argv) { if (options->thumbnails == 2) { mode = MODE_THUMBS; + render_thumbs(); } else { mode = MODE_NORMAL; load_image(); @@ -175,6 +179,35 @@ void update_title() { win_set_title(&win, win_title); } +void render_thumbs() { + int i, cnt, x, y; + + tcols = win.w / (THUMB_SIZE + 10); + trows = win.h / (THUMB_SIZE + 10); + + x = win.w - tcols * (THUMB_SIZE + 10) + 5; + y = win.h - trows * (THUMB_SIZE + 10) + 5; + cnt = MIN(tcols * trows, filecnt); + + win_clear(&win); + + i = 0; + while (i < cnt) { + thumbs[i].x = x + (THUMB_SIZE - thumbs[i].w) / 2; + thumbs[i].y = y + (THUMB_SIZE - thumbs[i].h) / 2; + win_draw_pixmap(&win, thumbs[i].pm, thumbs[i].x, thumbs[i].y, thumbs[i].w, + thumbs[i].h); + if (++i % tcols == 0) { + x = win.w - tcols * (THUMB_SIZE + 10) + 5; + y += THUMB_SIZE + 10; + } else { + x += THUMB_SIZE + 10; + } + } + + win_draw(&win); +} + int check_append(const char *filename) { if (!filename) return 0; |