Skip to content

Commit f5b0f47

Browse files
committed
Fix selecting model with arrow not scrolling the list enough to see whole selected icon
1 parent 62ed632 commit f5b0f47

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

code/ui/ui_shared.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4582,16 +4582,22 @@ void Item_ListBox_Paint(itemDef_t *item) {
45824582
thumb = Item_ListBox_ThumbDrawPosition(item);//Item_ListBox_ThumbPosition(item);
45834583
DC->drawHandlePic(thumb, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarThumb);
45844584
//
4585-
listPtr->endPos = listPtr->startPos;
4585+
listPtr->endPos = listPtr->startPos - 1;
45864586
size = item->window.rect.w - 2;
45874587
// items
45884588
// size contains max available space
45894589
if (listPtr->elementStyle == LISTBOX_IMAGE) {
45904590
// fit = 0;
45914591
x = item->window.rect.x + 1;
45924592
y = item->window.rect.y + 1;
4593-
for (i = listPtr->startPos; i < count; i++, listPtr->endPos++) {
4594-
float width = MIN(size + 1, listPtr->elementWidth);
4593+
for (i = listPtr->startPos; i < count && size > 0; i++) {
4594+
float width = listPtr->elementWidth;
4595+
if (size < width) {
4596+
// partially drawn item is not selectable
4597+
width = size + 1;
4598+
} else {
4599+
listPtr->endPos++;
4600+
}
45954601
// always draw at least one
45964602
// which may overdraw the box if it is too small for the element
45974603
image = DC->feederItemImage(item->special, i);
@@ -4606,12 +4612,11 @@ void Item_ListBox_Paint(itemDef_t *item) {
46064612

46074613
size -= listPtr->elementWidth;
46084614
x += listPtr->elementWidth;
4609-
4610-
if (size <= 1) {
4611-
break;
4612-
}
46134615
}
46144616

4617+
if (listPtr->endPos < listPtr->startPos)
4618+
listPtr->endPos = listPtr->startPos;
4619+
46154620
listPtr->drawPadding = size;
46164621
} else {
46174622
//

0 commit comments

Comments
 (0)