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

Method handle

src/Interface/Slider.cpp:173–189  ·  view source on GitHub ↗

* Automatically updates the slider * 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

171 * @param state State that the action handlers belong to.
172 */
173void Slider::handle(Action *action, State *state)
174{
175 InteractiveSurface::handle(action, state);
176 //_button->handle(action, state);
177 if (_pressed && (action->getDetails()->type == SDL_MOUSEMOTION || action->getDetails()->type == SDL_MOUSEBUTTONDOWN))
178 {
179 int cursorX = action->getAbsoluteXMouse();
180 double buttonX = std::min(std::max(_minX, cursorX + _offsetX), _maxX);
181 double pos = (buttonX - _minX) / (_maxX - _minX);
182 int value = _min + (int)Round((_max - _min) * pos);
183 setValue(value);
184 if (_change)
185 {
186 (state->*_change)(action);
187 }
188 }
189}
190
191/**
192 * Moves the slider to the new position.

Callers

nothing calls this directly

Calls 3

RoundFunction · 0.85
getDetailsMethod · 0.80
getAbsoluteXMouseMethod · 0.80

Tested by

no test coverage detected