void Scroller::onScroll(Widget& widget, vec2 offset) { if (m_orientation == HORIZONTAL) setValue(m_value + float(offset.x) * valueStep(), true); else setValue(m_value + float(offset.y) * valueStep(), true); }
void Scroller::onMouseButton(Widget& widget, vec2 point, MouseButton button, Action action, uint mods) { if (action != PRESSED) return; const vec2 local = transformToLocal(point); const float size = handleSize(); const float offset = handleOffset(); if (m_orientation == HORIZONTAL) { if (local.x < offset) setValue(m_value - valueStep(), true); else if (local.x >= offset + size) setValue(m_value + valueStep(), true); } else { if (local.y > height() - offset) setValue(m_value - valueStep(), true); else if (local.y <= height() - offset - size) setValue(m_value + valueStep(), true); } }
void Scroller::onKey(Key key, Action action, uint mods) { if ((action == PRESSED || action == REPEATED) && mods == 0) { switch (key) { case KEY_DOWN: case KEY_RIGHT: { setValue(m_value + valueStep(), true); break; } case KEY_UP: case KEY_LEFT: { setValue(m_value - valueStep(), true); break; } case KEY_HOME: { setValue(m_minValue, true); break; } case KEY_END: { setValue(m_maxValue, true); break; } default: break; } } Widget::onKey(key, action, mods); }
void Scroller::onKey(Widget& widget, Key key, Action action, uint mods) { if (action != PRESSED) { switch (key) { case KEY_DOWN: case KEY_RIGHT: { setValue(m_value + valueStep(), true); break; } case KEY_UP: case KEY_LEFT: { setValue(m_value - valueStep(), true); break; } case KEY_HOME: { setValue(m_minValue, true); break; } case KEY_END: { setValue(m_maxValue, true); break; } default: break; } } }