Skip to content

Commit

Permalink
Fixed backlog entries with long names not being selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
PringlesGang committed Sep 21, 2024
1 parent 389dafe commit ac31bd0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/ui/backlogmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ void BacklogMenu::Hide() {
}
}

inline bool inVerticalHoverBounds(const Widget& entry) {
return (HoverBounds.Y <= entry.Bounds.Y &&
entry.Bounds.Y + entry.Bounds.Height <=
HoverBounds.Y + HoverBounds.Height);
}

void BacklogMenu::Update(float dt) {
UpdateInput();

Expand Down Expand Up @@ -125,13 +131,12 @@ void BacklogMenu::Update(float dt) {

// Handle entry moving out of hover bounds
if (CurrentlyFocusedElement &&
!HoverBounds.Contains(CurrentlyFocusedElement->Bounds)) {
!inVerticalHoverBounds(*CurrentlyFocusedElement)) {
FocusDirection dir = (CurrentlyFocusedElement->Bounds.Y < HoverBounds.Y)
? FDIR_DOWN
: FDIR_UP;
Widget* newFocusedElement = CurrentlyFocusedElement->GetFocus(dir);
while (newFocusedElement &&
!HoverBounds.Contains(newFocusedElement->Bounds))
while (newFocusedElement && !inVerticalHoverBounds(*newFocusedElement))
newFocusedElement = newFocusedElement->GetFocus(dir);

CurrentlyFocusedElement->Hovered = false;
Expand Down
6 changes: 4 additions & 2 deletions src/ui/widgets/backlogentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ void BacklogEntry::UpdateInput() {
RectF entryHoverBounds =
RectF(HoverBounds.X, Bounds.Y, HoverBounds.Width, Bounds.Height);

Hovered = entryHoverBounds.ContainsPoint(Input::CurMousePos) &&
HoverBounds.Contains(Bounds);
Hovered =
entryHoverBounds.ContainsPoint(Input::CurMousePos) &&
HoverBounds.Y <= Bounds.Y &&
(Bounds.Y + Bounds.Height) <= (HoverBounds.Y + HoverBounds.Height);
}
if (HasFocus &&
((Hovered &&
Expand Down

0 comments on commit ac31bd0

Please sign in to comment.