Use Button1 to open thumbnail
This commit is contained in:
parent
f08c24bbb3
commit
6adbb3831d
97
main.c
97
main.c
|
@ -268,11 +268,11 @@ void redraw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_keypress(XKeyEvent *kev) {
|
void on_keypress(XKeyEvent *kev) {
|
||||||
int sel, x, y;
|
int x, y;
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
char key;
|
char key;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
int changed;
|
int changed, sel;
|
||||||
|
|
||||||
if (!kev)
|
if (!kev)
|
||||||
return;
|
return;
|
||||||
|
@ -439,7 +439,7 @@ void on_keypress(XKeyEvent *kev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_buttonpress(XButtonEvent *bev) {
|
void on_buttonpress(XButtonEvent *bev) {
|
||||||
int changed;
|
int changed, sel;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
if (!bev)
|
if (!bev)
|
||||||
|
@ -448,46 +448,61 @@ void on_buttonpress(XButtonEvent *bev) {
|
||||||
mask = CLEANMASK(bev->state);
|
mask = CLEANMASK(bev->state);
|
||||||
changed = 0;
|
changed = 0;
|
||||||
|
|
||||||
switch (bev->button) {
|
if (mode == MODE_NORMAL) {
|
||||||
case Button1:
|
switch (bev->button) {
|
||||||
if (fileidx + 1 < filecnt) {
|
case Button1:
|
||||||
++fileidx;
|
if (fileidx + 1 < filecnt) {
|
||||||
changed = load_image();
|
++fileidx;
|
||||||
}
|
changed = load_image();
|
||||||
break;
|
}
|
||||||
case Button2:
|
break;
|
||||||
mox = bev->x;
|
case Button2:
|
||||||
moy = bev->y;
|
mox = bev->x;
|
||||||
win_set_cursor(&win, CURSOR_HAND);
|
moy = bev->y;
|
||||||
break;
|
win_set_cursor(&win, CURSOR_HAND);
|
||||||
case Button3:
|
break;
|
||||||
if (fileidx > 0) {
|
case Button3:
|
||||||
--fileidx;
|
if (fileidx > 0) {
|
||||||
changed = load_image();
|
--fileidx;
|
||||||
}
|
changed = load_image();
|
||||||
break;
|
}
|
||||||
case Button4:
|
break;
|
||||||
if (mask == ControlMask)
|
case Button4:
|
||||||
changed = img_zoom_in(&img);
|
if (mask == ControlMask)
|
||||||
else if (mask == ShiftMask)
|
changed = img_zoom_in(&img);
|
||||||
|
else if (mask == ShiftMask)
|
||||||
|
changed = img_pan(&img, &win, PAN_LEFT);
|
||||||
|
else
|
||||||
|
changed = img_pan(&img, &win, PAN_UP);
|
||||||
|
break;
|
||||||
|
case Button5:
|
||||||
|
if (mask == ControlMask)
|
||||||
|
changed = img_zoom_out(&img);
|
||||||
|
else if (mask == ShiftMask)
|
||||||
|
changed = img_pan(&img, &win, PAN_RIGHT);
|
||||||
|
else
|
||||||
|
changed = img_pan(&img, &win, PAN_DOWN);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
changed = img_pan(&img, &win, PAN_LEFT);
|
changed = img_pan(&img, &win, PAN_LEFT);
|
||||||
else
|
break;
|
||||||
changed = img_pan(&img, &win, PAN_UP);
|
case 7:
|
||||||
break;
|
|
||||||
case Button5:
|
|
||||||
if (mask == ControlMask)
|
|
||||||
changed = img_zoom_out(&img);
|
|
||||||
else if (mask == ShiftMask)
|
|
||||||
changed = img_pan(&img, &win, PAN_RIGHT);
|
changed = img_pan(&img, &win, PAN_RIGHT);
|
||||||
else
|
break;
|
||||||
changed = img_pan(&img, &win, PAN_DOWN);
|
}
|
||||||
break;
|
} else {
|
||||||
case 6:
|
/* thumbnail mode */
|
||||||
changed = img_pan(&img, &win, PAN_LEFT);
|
switch (bev->button) {
|
||||||
break;
|
case Button1:
|
||||||
case 7:
|
if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
|
||||||
changed = img_pan(&img, &win, PAN_RIGHT);
|
fileidx = sel;
|
||||||
break;
|
load_image();
|
||||||
|
mode = MODE_NORMAL;
|
||||||
|
changed = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
|
|
16
thumbs.c
16
thumbs.c
|
@ -170,3 +170,19 @@ void tns_move_selection(tns_t *tns, win_t *win, movedir_t dir) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tns_translate(tns_t *tns, int x, int y) {
|
||||||
|
int n;
|
||||||
|
thumb_t *t;
|
||||||
|
|
||||||
|
if (!tns || x < 5 || y < 5)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((n = y / thumb_dim * tns-> cols + x / thumb_dim) < tns->cnt) {
|
||||||
|
t = &tns->thumbs[n];
|
||||||
|
if (x > t->x && x < t->x + t->w && y > t->y && y < t->y + t->h)
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue