| 194 | } |
| 195 | |
| 196 | void ScrollBar::drawChildren() { |
| 197 | if (m_parent) { |
| 198 | auto scrollArea = convert<ScrollArea>(m_parent); |
| 199 | |
| 200 | float ratio = sizeRatio(); |
| 201 | if (ratio < 1) |
| 202 | ratio = 1; |
| 203 | |
| 204 | int innerSize = (int)max(0.0f, ceil(trackSize() / ratio)); |
| 205 | int offsetBegin = (int)ceil((trackSize() - innerSize) * scrollRatio()); |
| 206 | innerSize += ScrollThumbOverhead; |
| 207 | |
| 208 | if (m_direction == GuiDirection::Vertical) { |
| 209 | if (scrollArea->horizontalScroll()) { |
| 210 | m_forward->setPosition(m_parent->size() - Vec2I(ScrollAreaBorder, ScrollButtonStackSize)); |
| 211 | m_backward->setPosition({m_parent->size()[0] - ScrollAreaBorder, ScrollAreaBorder}); |
| 212 | m_thumb->setPosition({m_parent->size()[0] - ScrollAreaBorder, ScrollAreaBorder + ScrollButtonStackSize + offsetBegin}); |
| 213 | } else { |
| 214 | m_forward->setPosition(m_parent->size() - Vec2I(ScrollAreaBorder, ScrollButtonStackSize)); |
| 215 | m_backward->setPosition({m_parent->size()[0] - ScrollAreaBorder, 0}); |
| 216 | m_thumb->setPosition({m_parent->size()[0] - ScrollAreaBorder, ScrollButtonStackSize + offsetBegin}); |
| 217 | } |
| 218 | m_thumb->setSize(Vec2I(m_thumb->baseSize()[0], innerSize)); |
| 219 | } else { |
| 220 | m_forward->setPosition({m_parent->size()[0] - ScrollButtonStackSize, 0}); |
| 221 | m_backward->setPosition({0, 0}); |
| 222 | m_thumb->setPosition({ScrollButtonStackSize + offsetBegin, 0}); |
| 223 | m_thumb->setSize(Vec2I(innerSize, m_thumb->baseSize()[1])); |
| 224 | } |
| 225 | |
| 226 | for (auto child : m_members) { |
| 227 | child->render(m_drawingArea); |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | Vec2I ScrollBar::offsetFromThumbPosition(Vec2I const& thumbPosition) const { |
| 233 | auto scrollArea = convert<ScrollArea>(m_parent); |
nothing calls this directly
no test coverage detected