MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / handle

Method handle

src/Interface/ScrollBar.cpp:155–166  ·  view source on GitHub ↗

* Automatically updates the scrollbar * when the mouse moves. * @param action Pointer to an action. * @param state State that the action handlers belong to. */

Source from the content-addressed store, hash-verified

153 * @param state State that the action handlers belong to.
154 */
155void ScrollBar::handle(Action *action, State *state)
156{
157 InteractiveSurface::handle(action, state);
158 if (_pressed && (action->getDetails()->type == SDL_MOUSEMOTION || action->getDetails()->type == SDL_MOUSEBUTTONDOWN))
159 {
160 int cursorY = action->getAbsoluteYMouse() - getY();
161 int y = std::min(std::max(cursorY + _offset, 0), getHeight() - _thumbRect.h + 1);
162 double scale = (double)_list->getRows() / getHeight();
163 int scroll = (int)Round(y * scale);
164 _list->scrollTo(scroll);
165 }
166}
167
168/**
169 * Blits the scrollbar contents.

Callers

nothing calls this directly

Calls 5

RoundFunction · 0.85
getDetailsMethod · 0.80
getAbsoluteYMouseMethod · 0.80
getRowsMethod · 0.80
scrollToMethod · 0.80

Tested by

no test coverage detected