1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00

IrrlichtMt: import scrollbar changes

This commit is contained in:
SmallJoker 2025-09-09 20:04:40 +02:00 committed by SmallJoker
parent 70fbef112c
commit ecabcb5c58
4 changed files with 64 additions and 0 deletions

View file

@ -7,6 +7,7 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IGUIFont.h"
#include "IGUIScrollBar.h"
#include "IVideoDriver.h"
#include "rect.h"
#include "os.h"
@ -1512,4 +1513,52 @@ void CGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type)
}
}
void CGUIEditBox::updateVScrollBar()
{
if (!VScrollBar) {
return;
}
// OnScrollBarChanged(...)
if (VScrollBar->getPos() != VScrollPos) {
s32 deltaScrollY = VScrollBar->getPos() - VScrollPos;
CurrentTextRect.UpperLeftCorner.Y -= deltaScrollY;
CurrentTextRect.LowerRightCorner.Y -= deltaScrollY;
s32 scrollymax = getTextDimension().Height - FrameRect.getHeight();
if (scrollymax != VScrollBar->getMax()) {
// manage a newline or a deleted line
VScrollBar->setMax(scrollymax);
VScrollBar->setPageSize(s32(getTextDimension().Height));
calculateScrollPos();
} else {
// manage a newline or a deleted line
VScrollPos = VScrollBar->getPos();
}
}
// check if a vertical scrollbar is needed ?
if (getTextDimension().Height > (u32)FrameRect.getHeight()) {
FrameRect.LowerRightCorner.X -= VScrollBarWidth;
s32 scrollymax = getTextDimension().Height - FrameRect.getHeight();
if (scrollymax != VScrollBar->getMax()) {
VScrollBar->setMax(scrollymax);
VScrollBar->setPageSize(s32(getTextDimension().Height));
}
if (!VScrollBar->isVisible()) {
VScrollBar->setVisible(true);
}
} else {
if (VScrollBar->isVisible()) {
VScrollBar->setVisible(false);
VScrollPos = 0;
VScrollBar->setPos(0);
VScrollBar->setMax(1);
VScrollBar->setPageSize(s32(getTextDimension().Height));
}
}
}
} // end namespace gui

View file

@ -59,6 +59,9 @@ public:
//! sets the position of the scrollbar
void setPos(s32 pos) override;
//! sets the content height to scroll
void setPageSize(s32 size) override { }
//! updates the rectangle
void updateAbsolutePosition() override;