Skip to content

Commit

Permalink
fix hovered state of group listeners
Browse files Browse the repository at this point in the history
fixes #7838

Diffs=
4fb978a92 fix hovered state of group listeners (#7839)

Co-authored-by: hernan <[email protected]>
  • Loading branch information
bodymovin and bodymovin committed Aug 14, 2024
1 parent 2615d26 commit a7a0a01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e75b8fa633a4f8eb102e669ac1308b1d1151fed1
4fb978a9230fc006b5e575364f062907e7dd2afe
13 changes: 13 additions & 0 deletions src/animation/state_machine_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ class ListenerGroup
void consume() { m_isConsumed = true; }
//
void hover() { m_isHovered = true; }
void unhover() { m_isHovered = false; }
void reset()
{
m_isConsumed = false;
Expand Down Expand Up @@ -547,6 +548,18 @@ class HitShape : public HitComponent
{
continue;
}
// Because each group is tested individually for its hover state, a group
// could be marked "incorrectly" as hovered at this point.
// But once we iterate each element in the drawing order, that group can
// be occluded by an opaque target on top of it.
// So although it is hovered in isolation, it shouldn't be considered as
// hovered in the full context.
// In this case, we unhover the group so it is not marked as previously
// hovered.
if (!canHit && listenerGroup->isHovered())
{
listenerGroup->unhover();
}

bool isGroupHovered = canHit ? listenerGroup->isHovered() : false;
bool hoverChange = listenerGroup->prevHovered() != isGroupHovered;
Expand Down

0 comments on commit a7a0a01

Please sign in to comment.