MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / scrollToLatestData

Function scrollToLatestData

src/OpenLoco/src/Ui/Windows/CompanyWindow.cpp:2116–2135  ·  view source on GitHub ↗

0x004C8DBF For the finances the most recent data on the scroll view is the data most off to the right of the scroll. This function moves to the last page of data as far to the right of the scroll.

Source from the content-addressed store, hash-verified

2114 // most off to the right of the scroll. This function moves to the last
2115 // page of data as far to the right of the scroll.
2116 static void scrollToLatestData(Window& self)
2117 {
2118 self.initScrollWidgets();
2119 self.scrollAreas[0].contentOffsetX = 0x7FFF;
2120 self.scrollAreas[0].contentWidth = 0;
2121 self.updateScrollWidgets();
2122
2123 const Ui::Widget& widget = self.widgets[widx::scrollview];
2124
2125 const auto x = std::max<int16_t>(0, self.scrollAreas[0].contentOffsetX);
2126 auto widgetWidth = widget.width() - 2;
2127 if (self.scrollAreas[0].hasFlags(ScrollFlags::vscrollbarVisible))
2128 {
2129 widgetWidth -= ScrollView::kScrollbarSize;
2130 }
2131 // This gets the offset of the last full page (widgetWidth) of the scroll view
2132 const auto newOffset = std::max(0, self.scrollAreas[0].contentWidth - widgetWidth);
2133 self.scrollAreas[0].contentOffsetX = std::min<int16_t>(x, newOffset);
2134 ScrollView::updateThumbs(self, widx::scrollview);
2135 }
2136
2137 // 0x00433868
2138 static void onDropdown(Window& self, WidgetIndex_t widgetIndex, [[maybe_unused]] const WidgetId id, int16_t itemIndex)

Callers 3

onDropdownFunction · 0.85
openFinancesFunction · 0.85
switchTabFunction · 0.85

Calls 5

updateThumbsFunction · 0.85
initScrollWidgetsMethod · 0.80
updateScrollWidgetsMethod · 0.80
widthMethod · 0.45
hasFlagsMethod · 0.45

Tested by

no test coverage detected