Merge branch 'master' into jgrpp

# Conflicts:
#	src/openttd.cpp
#	src/script/api/script_text.cpp
#	src/settings_type.h
This commit is contained in:
Jonathan G Rennison
2024-02-27 18:48:50 +00:00
19 changed files with 649 additions and 598 deletions

View File

@@ -862,6 +862,20 @@ public:
int GetScrolledRowFromWidget(int clickpos, const Window * const w, WidgetID widget, int padding = 0, int line_height = -1) const;
/**
* Get a pair of iterators for the range of visible elements in a container.
* @param container Container of elements represented by the scrollbar.
* @returns Pair of iterators of visible elements.
*/
template <typename Tcontainer>
auto GetVisibleRangeIterators(Tcontainer &container) const
{
assert(this->GetCount() == container.size()); // Scrollbar and container size must match.
auto first = std::next(std::begin(container), this->GetPosition());
auto last = std::next(first, std::min<size_t>(this->GetCapacity(), this->GetCount() - this->GetPosition()));
return std::make_pair(first, last);
}
/**
* Return an iterator pointing to the element of a scrolled widget that a user clicked in.
* @param container Container of elements represented by the scrollbar.