Fix: shortcut key highlight remains when cursor leaves list

This commit is contained in:
Hielke Morsink 2022-05-28 22:55:42 +02:00 committed by GitHub
parent a45a788da9
commit 3ea70cdeaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View file

@ -29,6 +29,7 @@
- Fix: [#17221] Object ghosts and tooltips follow invisible cursor when moving the viewport by right-click dragging.
- Fix: [#17255] Cursor position is incorrect when adjusting terrain and water height.
- Fix: [#17261] Hand cursor position is incorrect when dragging items in the Inventions List window.
- Fix: [#17292] Rows in shortcut key list stay highlighted when cursor leaves list.
- Fix: [#17295] Pause status not cleared when loading a scenario made from a converted paused save.
0.4.0 (2022-04-25)

View file

@ -175,7 +175,7 @@ private:
std::vector<ShortcutTabDesc> _tabs;
std::vector<rct_widget> _widgets;
std::vector<ShortcutStringPair> _list;
std::optional<size_t> _highlightedItem;
int_fast16_t _highlightedItem;
size_t _currentTabIndex{};
uint32_t _tabAnimationIndex{};
@ -199,6 +199,13 @@ public:
void OnUpdate() override
{
// Remove highlight when the mouse is not hovering over the list
if (_highlightedItem != -1 && !WidgetIsHighlighted(this, WIDX_SCROLL))
{
_highlightedItem = -1;
InvalidateWidget(WIDX_SCROLL);
}
_tabAnimationIndex++;
InvalidateWidget(static_cast<rct_widgetindex>(WIDX_TAB_0 + _currentTabIndex));
}
@ -267,12 +274,16 @@ public:
void OnScrollMouseOver(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
{
auto index = static_cast<size_t>((screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT);
if (index < _list.size())
auto index = static_cast<int_fast16_t>((screenCoords.y - 1) / SCROLLABLE_ROW_HEIGHT);
if (static_cast<size_t>(index) < _list.size())
{
_highlightedItem = index;
Invalidate();
}
else
{
_highlightedItem = -1;
}
}
void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override
@ -319,7 +330,7 @@ public:
}
else
{
auto isHighlighted = _highlightedItem == i;
auto isHighlighted = _highlightedItem == static_cast<int_fast16_t>(i);
DrawItem(dpi, y, scrollWidth, _list[i], isHighlighted);
}
}