File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -391,10 +391,12 @@ namespace MWGui
391391
392392 void DialogueWindow::onMouseWheel (MyGUI::Widget* /* sender*/ , int rel)
393393 {
394- if (!mScrollBar ->getVisible ())
394+ if (!mScrollBar ->getVisible () || mScrollBar -> getScrollRange () == 0 )
395395 return ;
396- mScrollBar ->setScrollPosition (std::clamp<size_t >(
397- static_cast <size_t >(mScrollBar ->getScrollPosition () - rel * 0.3 ), 0 , mScrollBar ->getScrollRange () - 1 ));
396+ const int step = static_cast <int >(0 .3f * rel);
397+ const int newPos = static_cast <int >(mScrollBar ->getScrollPosition ()) - step;
398+ const int maxPos = static_cast <int >(mScrollBar ->getScrollRange ()) - 1 ;
399+ mScrollBar ->setScrollPosition (static_cast <size_t >(std::clamp (newPos, 0 , maxPos)));
398400 onScrollbarMoved (mScrollBar , mScrollBar ->getScrollPosition ());
399401 }
400402
You can’t perform that action at this time.
0 commit comments