summaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-03 16:14:49 +0100
committerBert <ber.t@gmx.com>2011-02-03 16:14:49 +0100
commitc6556f8cc7a90909b2dd71747ab605954a3f7892 (patch)
treea5cf1a0b10f0db53b145fa507bc70dcd4180c9bf /image.c
parentbad9a70a48ff38f0d1e22fdedfcaa2241882a0bf (diff)
downloadnsxiv-c6556f8cc7a90909b2dd71747ab605954a3f7892.tar.zst
New key mappings: 0/w, zoom to 100%/to fit window
Diffstat (limited to 'image.c')
-rw-r--r--image.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/image.c b/image.c
index c7e9e3a..e83e479 100644
--- a/image.c
+++ b/image.c
@@ -88,9 +88,9 @@ int img_load(img_t *img, const char *filename) {
imlib_context_set_anti_alias(img->aa);
+ img->scalemode = options->scalemode;
img->re = 0;
img->checkpan = 0;
- img->zoomed = 0;
img->w = imlib_image_get_width();
img->h = imlib_image_get_height();
@@ -127,9 +127,9 @@ void img_render(img_t *img, win_t *win) {
if (!img || !win || !imlib_context_get_image())
return;
- if (!img->zoomed && options->scalemode != SCALE_ZOOM) {
- img_fit(img, win);
- if (options->scalemode == SCALE_DOWN && img->zoom > 1.0)
+ if (img->scalemode != SCALE_ZOOM) {
+ img_fit(img, win, 0);
+ if (img->scalemode == SCALE_DOWN && img->zoom > 1.0)
img->zoom = 1.0;
}
@@ -176,7 +176,7 @@ void img_render(img_t *img, win_t *win) {
win_draw(win);
}
-int img_fit(img_t *img, win_t *win) {
+int img_fit(img_t *img, win_t *win, unsigned char set) {
float oz, zw, zh;
if (!img || !win)
@@ -190,6 +190,9 @@ int img_fit(img_t *img, win_t *win) {
img->zoom = MAX(img->zoom, zoom_min);
img->zoom = MIN(img->zoom, zoom_max);
+ if (set)
+ img->scalemode = SCALE_FIT;
+
return oz != img->zoom;
}
@@ -214,13 +217,13 @@ int img_zoom(img_t *img, float z) {
z = MAX(z, zoom_min);
z = MIN(z, zoom_max);
+ img->scalemode = SCALE_ZOOM;
if (z != img->zoom) {
img->x -= (img->w * z - img->w * img->zoom) / 2;
img->y -= (img->h * z - img->h * img->zoom) / 2;
img->zoom = z;
img->checkpan = 1;
- img->zoomed = 1;
return 1;
} else {
return 0;