0x004C8E2E regs.bp: deltaY possible extraction of common functionality in verticalDragFollow, horizontalDragFollow, verticalFollow, horizontalFollow
| 126 | // regs.bp: deltaY |
| 127 | // possible extraction of common functionality in verticalDragFollow, horizontalDragFollow, verticalFollow, horizontalFollow |
| 128 | void verticalDragFollow(Ui::Window& window, Ui::Widget* const widget, const WidgetIndex_t dragWidgetIndex, const size_t dragScrollIndex, const int16_t deltaY) |
| 129 | { |
| 130 | ScrollArea& scrollArea = window.scrollAreas[dragScrollIndex]; |
| 131 | if (!scrollArea.hasFlags(ScrollFlags::vscrollbarVisible)) |
| 132 | { |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | uint16_t trackHeight = widget->height() - 2 - kThumbSize - kThumbSize; |
| 137 | if (scrollArea.hasFlags(ScrollFlags::hscrollbarVisible)) |
| 138 | { |
| 139 | trackHeight -= kScrollbarSize; |
| 140 | } |
| 141 | |
| 142 | if (trackHeight == 0) |
| 143 | { |
| 144 | return; |
| 145 | } |
| 146 | auto contentDeltaY = deltaY * scrollArea.contentHeight / trackHeight; |
| 147 | |
| 148 | int16_t newOffset = scrollArea.contentOffsetY + contentDeltaY; |
| 149 | |
| 150 | int frameHeight = widget->height() - 2; |
| 151 | if (scrollArea.hasFlags(ScrollFlags::hscrollbarVisible)) |
| 152 | { |
| 153 | frameHeight -= kScrollbarSize; |
| 154 | } |
| 155 | |
| 156 | int16_t maxOffset = scrollArea.contentHeight - frameHeight; |
| 157 | maxOffset = std::max<int16_t>(maxOffset, 0); |
| 158 | |
| 159 | scrollArea.contentOffsetY = std::clamp<int16_t>(newOffset, 0, maxOffset); |
| 160 | |
| 161 | ScrollView::updateThumbs(window, dragWidgetIndex); |
| 162 | WindowManager::invalidateWidget(window.type, window.number, dragWidgetIndex); |
| 163 | } |
| 164 | |
| 165 | // 0x004C8EF0 |
| 166 | // Note: Original function returns a scrollAreaOffset not an index |
no test coverage detected