mirror of
https://github.com/luanti-org/luanti.git
synced 2025-12-04 06:35:25 +01:00
IrrlichtMt: import scrollbar changes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user