]> git.lizzy.rs Git - minetest.git/blobdiff - src/gui/intlGUIEditBox.cpp
Move `setlocale` from Lua to C++.
[minetest.git] / src / gui / intlGUIEditBox.cpp
index 279e7a48a205e1a022855b965de3ea5f2354b7db..8b0f10721551393654d602df818ec84b236fc510 100644 (file)
@@ -1087,7 +1087,7 @@ bool intlGUIEditBox::processMouse(const SEvent& event)
                }
                break;
        case EMIE_MOUSE_WHEEL:
-               if (m_vscrollbar) {
+               if (m_vscrollbar && m_vscrollbar->isVisible()) {
                        s32 pos = m_vscrollbar->getPos();
                        s32 step = m_vscrollbar->getSmallStep();
                        m_vscrollbar->setPos(pos - event.MouseInput.Wheel * step);
@@ -1430,14 +1430,14 @@ void intlGUIEditBox::calculateScrollPos()
                // todo: adjust scrollbar
        }
 
-       // vertical scroll position
-       if (FrameRect.LowerRightCorner.Y < CurrentTextRect.LowerRightCorner.Y + VScrollPos)
-               VScrollPos = CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y + VScrollPos;
+       if (!WordWrap && !MultiLine)
+               return;
 
-       else if (FrameRect.UpperLeftCorner.Y > CurrentTextRect.UpperLeftCorner.Y + VScrollPos)
-               VScrollPos = CurrentTextRect.UpperLeftCorner.Y - FrameRect.UpperLeftCorner.Y + VScrollPos;
-       else
-               VScrollPos = 0;
+       // vertical scroll position
+       if (FrameRect.LowerRightCorner.Y < CurrentTextRect.LowerRightCorner.Y)
+               VScrollPos += CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y; // scrolling downwards
+       else if (FrameRect.UpperLeftCorner.Y > CurrentTextRect.UpperLeftCorner.Y)
+               VScrollPos += CurrentTextRect.UpperLeftCorner.Y - FrameRect.UpperLeftCorner.Y; // scrolling upwards
 
        // todo: adjust scrollbar
        if (m_vscrollbar)