1
1

mouse: make the clickable width of menu items more consistent

When there are fewer than four menu items, act as if there are four:
make their clickable width half the width of the screen.

Until now, when there were two menu items, their clickable width would
be the full width of the screen, which was overwide.  But when there
was just one menu item, its clickable width would suddenly be as small
as when the menu had the maximum number of items (12 for an 80-column
screen).  This was odd.

Also, slightly simplify another computation.
Этот коммит содержится в:
Benno Schulenberg 2019-10-01 12:29:02 +02:00
родитель a4933873c9
Коммит 78def852d1

Просмотреть файл

@ -1694,12 +1694,11 @@ int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts)
/* Determine how many shortcuts are being shown. */ /* Determine how many shortcuts are being shown. */
number = shown_entries_for(currmenu); number = shown_entries_for(currmenu);
/* Calculate the width of each non-rightmost shortcut item; /* Calculate the clickable width of each menu item. */
* the rightmost ones will "absorb" any remaining slack. */ if (number < 5)
if (number < 2) width = COLS / 2;
width = COLS / (MAIN_VISIBLE / 2);
else else
width = COLS / ((number / 2) + (number % 2)); width = COLS / ((number + 1) / 2);
/* Calculate the one-based index in the shortcut list. */ /* Calculate the one-based index in the shortcut list. */
index = (*mouse_x / width) * 2 + *mouse_y; index = (*mouse_x / width) * 2 + *mouse_y;