make width of navigation area configurable (#155)
this allows users to configure navigation width from config.h. it also allows disabling the navigation function entirely by using a 0 width. one extra functionality this adds is being able to define an absolute width (in pixels) instead of just percentage via `NAV_IS_REL`. Co-authored-by: NRK <nrk@disroot.org>
This commit is contained in:
parent
abf316a066
commit
36f42081d0
|
@ -29,7 +29,7 @@ void load_image(int);
|
||||||
bool mark_image(int, bool);
|
bool mark_image(int, bool);
|
||||||
void close_info(void);
|
void close_info(void);
|
||||||
void open_info(void);
|
void open_info(void);
|
||||||
int ptr_third_x(void);
|
int nav_button(void);
|
||||||
void redraw(void);
|
void redraw(void);
|
||||||
void reset_cursor(void);
|
void reset_cursor(void);
|
||||||
void animate(void);
|
void animate(void);
|
||||||
|
@ -286,7 +286,7 @@ bool ci_navigate(arg_t n)
|
||||||
|
|
||||||
bool ci_cursor_navigate(arg_t _)
|
bool ci_cursor_navigate(arg_t _)
|
||||||
{
|
{
|
||||||
return ci_navigate(ptr_third_x() - 1);
|
return ci_navigate(nav_button() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ci_alternate(arg_t _)
|
bool ci_alternate(arg_t _)
|
||||||
|
|
|
@ -173,6 +173,11 @@ static const button_t buttons[] = {
|
||||||
{ 0, 5, g_zoom, -1 },
|
{ 0, 5, g_zoom, -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* true means NAV_WIDTH is relative (33%), false means absolute (33 pixels) */
|
||||||
|
static const bool NAV_IS_REL = true;
|
||||||
|
/* width of navigation area, 0 disables cursor navigation, */
|
||||||
|
static const unsigned int NAV_WIDTH = 33;
|
||||||
|
|
||||||
/* mouse cursor on left, middle and right part of the window */
|
/* mouse cursor on left, middle and right part of the window */
|
||||||
static const cursor_t imgcursor[3] = {
|
static const cursor_t imgcursor[3] = {
|
||||||
CURSOR_LEFT, CURSOR_ARROW, CURSOR_RIGHT
|
CURSOR_LEFT, CURSOR_ARROW, CURSOR_RIGHT
|
||||||
|
|
19
main.c
19
main.c
|
@ -392,12 +392,23 @@ void update_info(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptr_third_x(void)
|
int nav_button(void)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y, nw;
|
||||||
|
|
||||||
|
if (NAV_WIDTH == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
win_cursor_pos(&win, &x, &y);
|
win_cursor_pos(&win, &x, &y);
|
||||||
return MAX(0, MIN(2, (x / (win.w * 0.33))));
|
nw = NAV_IS_REL ? win.w * NAV_WIDTH / 100 : NAV_WIDTH;
|
||||||
|
nw = MIN(nw, (win.w + 1) / 2);
|
||||||
|
|
||||||
|
if (x < nw)
|
||||||
|
return 0;
|
||||||
|
else if (x < win.w-nw)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void redraw(void)
|
void redraw(void)
|
||||||
|
@ -431,7 +442,7 @@ void reset_cursor(void)
|
||||||
for (i = 0; i < ARRLEN(timeouts); i++) {
|
for (i = 0; i < ARRLEN(timeouts); i++) {
|
||||||
if (timeouts[i].handler == reset_cursor) {
|
if (timeouts[i].handler == reset_cursor) {
|
||||||
if (timeouts[i].active) {
|
if (timeouts[i].active) {
|
||||||
c = ptr_third_x();
|
c = nav_button();
|
||||||
c = MAX(fileidx > 0 ? 0 : 1, c);
|
c = MAX(fileidx > 0 ? 0 : 1, c);
|
||||||
c = MIN(fileidx + 1 < filecnt ? 2 : 1, c);
|
c = MIN(fileidx + 1 < filecnt ? 2 : 1, c);
|
||||||
cursor = imgcursor[c];
|
cursor = imgcursor[c];
|
||||||
|
|
Loading…
Reference in a new issue