From e7b85c60546341dd842efe4dc06718854be9376c Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 6 Jun 2024 14:58:08 -0400 Subject: Allow scrolling while sticky hovering --- src/subway_map.cpp | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/subway_map.cpp b/src/subway_map.cpp index dde817b..b32c362 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -405,35 +405,47 @@ void SubwayMap::OnMouseLeave(wxMouseEvent &event) { } void SubwayMap::OnMouseClick(wxMouseEvent &event) { - if (sticky_hover_) { - sticky_hover_ = false; + bool finished = false; - if (actual_hover_ != hovered_item_) { - hovered_item_ = actual_hover_; - - Refresh(); - } - } else if (hovered_item_) { - const SubwayItem &subway_item = GD_GetSubwayItem(*hovered_item_); + if (actual_hover_) { + const SubwayItem &subway_item = GD_GetSubwayItem(*actual_hover_); if ((subway_item.door && !GetDoorRequirements(*subway_item.door).empty()) || networks_.IsItemInNetwork(*hovered_item_)) { - sticky_hover_ = true; + if (actual_hover_ != hovered_item_) { + hovered_item_ = actual_hover_; + + if (!hovered_item_) { + sticky_hover_ = false; + } + + Refresh(); + } else { + sticky_hover_ = !sticky_hover_; + } + + finished = true; } - } else if (scroll_mode_) { - scroll_mode_ = false; + } - SetScrollSpeed(0, 0); + if (!finished) { + if (scroll_mode_) { + scroll_mode_ = false; - SetCursor(wxCURSOR_ARROW); - } else if (event.GetPosition().x < GetSize().GetWidth() / 6 || - event.GetPosition().x > 5 * GetSize().GetWidth() / 6 || - event.GetPosition().y < GetSize().GetHeight() / 6 || - event.GetPosition().y > 5 * GetSize().GetHeight() / 6) { - scroll_mode_ = true; + SetScrollSpeed(0, 0); - EvaluateScroll(event.GetPosition()); + SetCursor(wxCURSOR_ARROW); + } else if (event.GetPosition().x < GetSize().GetWidth() / 6 || + event.GetPosition().x > 5 * GetSize().GetWidth() / 6 || + event.GetPosition().y < GetSize().GetHeight() / 6 || + event.GetPosition().y > 5 * GetSize().GetHeight() / 6) { + scroll_mode_ = true; - SetCursor(wxCURSOR_CROSS); + EvaluateScroll(event.GetPosition()); + + SetCursor(wxCURSOR_CROSS); + } else { + sticky_hover_ = false; + } } } -- cgit 1.4.1