ソースを参照

Added <,> mappings to rotate image

master
Bert 13年前
コミット
64a5366508
6個のファイルの変更52行の追加2行の削除
  1. +1
    -1
      Makefile
  2. +1
    -0
      README.md
  3. +32
    -1
      image.c
  4. +3
    -0
      image.h
  5. +8
    -0
      main.c
  6. +7
    -0
      sxiv.1

+ 1
- 1
Makefile ファイルの表示

@@ -1,6 +1,6 @@
all: sxiv

VERSION=0.2
VERSION=git-20110126

CC?=gcc
PREFIX?=/usr/local


+ 1
- 0
README.md ファイルの表示

@@ -42,5 +42,6 @@ Use the following keys to control sxiv:
+,= Zoom in
- Zoom out
h,j,k,l Scroll left/down/up/right
<,> Rotate image (counter-)clockwise by 90 degrees
f Toggle fullscreen mode (requires an EWMH/NetWM compliant
window manager)

+ 32
- 1
image.c ファイルの表示

@@ -104,7 +104,7 @@ void img_render(img_t *img, win_t *win) {
if (!img || !win || !imlib_context_get_image())
return;

if ((!img->re || !img->zoomed) && SCALE_MODE != SCALE_ZOOM) {
if (!img->zoomed && SCALE_MODE != SCALE_ZOOM) {
/* set zoom level to fit image into window */
zw = (float) win->w / (float) img->w;
zh = (float) win->h / (float) img->h;
@@ -241,3 +241,34 @@ int img_pan(img_t *img, win_t *win, pandir_t dir) {

return ox != img->x || oy != img->y;
}

int img_rotate(img_t *img, win_t *win, int d) {
int ox, oy, tmp;

if (!img || !win)
return 0;

ox = d == 1 ? img->x : win->w - img->x - img->w * img->zoom;
oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom;

imlib_image_orientate(d);

img->x = oy + (win->w - win->h) / 2;
img->y = ox + (win->h - win->w) / 2;

tmp = img->w;
img->w = img->h;
img->h = tmp;

img->checkpan = 1;

return 1;
}

int img_rotate_left(img_t *img, win_t *win) {
return img_rotate(img, win, 3);
}

int img_rotate_right(img_t *img, win_t *win) {
return img_rotate(img, win, 1);
}

+ 3
- 0
image.h ファイルの表示

@@ -56,4 +56,7 @@ int img_zoom_out(img_t*);

int img_pan(img_t*, win_t*, pandir_t);

int img_rotate_left(img_t*, win_t*);
int img_rotate_right(img_t*, win_t*);

#endif /* IMAGE_H */

+ 8
- 0
main.c ファイルの表示

@@ -219,6 +219,14 @@ void on_keypress(XEvent *ev) {
changed = img_pan(&img, &win, PAN_RIGHT);
break;

/* rotation */
case '<':
changed = img_rotate_left(&img, &win);
break;
case '>':
changed = img_rotate_right(&img, &win);
break;

/* Control window */
case 'f':
win_toggle_fullscreen(&win);


+ 7
- 0
sxiv.1 ファイルの表示

@@ -65,6 +65,13 @@ Pan up.
.TP
.B l
Pan right.
.SS Rotation
.TP
.B <
Rotate image counter-clockwise by 90 degrees.
.TP
.B >
Rotate image clockwise by 90 degrees.
.SS Control window
.TP
.B f


読み込み中…
キャンセル
保存