| 327 | } |
| 328 | |
| 329 | bool ScrollArea::sendEvent(InputEvent const& event) { |
| 330 | if (!m_visible) |
| 331 | return false; |
| 332 | |
| 333 | if (m_dragActive) { |
| 334 | if (event.is<MouseButtonUpEvent>()) { |
| 335 | blur(); |
| 336 | m_dragActive = false; |
| 337 | m_vBar->thumb()->setPressed(false); |
| 338 | m_hBar->thumb()->setPressed(false); |
| 339 | return true; |
| 340 | } else if (event.is<MouseMoveEvent>()) { |
| 341 | auto thumbDragPosition = *context()->mousePosition(event) - screenPosition() - m_dragOffset; |
| 342 | if (m_dragDirection == GuiDirection::Vertical) { |
| 343 | m_scrollOffset = m_vBar->offsetFromThumbPosition(thumbDragPosition); |
| 344 | } else { |
| 345 | m_scrollOffset = m_hBar->offsetFromThumbPosition(thumbDragPosition); |
| 346 | } |
| 347 | return true; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | auto mousePos = context()->mousePosition(event); |
| 352 | if (mousePos && !inMember(*mousePos)) |
| 353 | return false; |
| 354 | |
| 355 | if (event.is<MouseButtonDownEvent>()) { |
| 356 | if (m_vBar->thumb()->inMember(*mousePos)) { |
| 357 | focus(); |
| 358 | m_dragOffset = *mousePos - screenPosition() - m_vBar->thumb()->position(); |
| 359 | m_dragDirection = GuiDirection::Vertical; |
| 360 | m_dragActive = true; |
| 361 | m_vBar->thumb()->setPressed(true); |
| 362 | return true; |
| 363 | } else if (m_hBar->thumb()->inMember(*mousePos)) { |
| 364 | focus(); |
| 365 | m_dragOffset = *mousePos - screenPosition() - m_hBar->thumb()->position(); |
| 366 | m_dragDirection = GuiDirection::Horizontal; |
| 367 | m_dragActive = true; |
| 368 | m_hBar->thumb()->setPressed(true); |
| 369 | return true; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | if (Widget::sendEvent(event)) |
| 374 | return true; |
| 375 | |
| 376 | if (auto mouseWheel = event.ptr<MouseWheelEvent>()) { |
| 377 | if (mouseWheel->mouseWheel == MouseWheel::Up) |
| 378 | scrollAreaBy({0, m_buttonAdvance * 3}); |
| 379 | else |
| 380 | scrollAreaBy({0, -m_buttonAdvance * 3}); |
| 381 | return true; |
| 382 | } |
| 383 | |
| 384 | return true; |
| 385 | } |
| 386 |
nothing calls this directly
no test coverage detected