* Automatically updates the scrollbar * when the mouse moves. * @param action Pointer to an action. * @param state State that the action handlers belong to. */
| 153 | * @param state State that the action handlers belong to. |
| 154 | */ |
| 155 | void 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. |
nothing calls this directly
no test coverage detected