summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/main.c b/main.c
index 602cc60..f4afcf0 100644
--- a/main.c
+++ b/main.c
@@ -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;