aboutsummaryrefslogtreecommitdiff
path: root/src/gui/guiEditBoxWithScrollbar.cpp
diff options
context:
space:
mode:
authorstujones11 <stujones111@gmail.com>2019-05-24 16:42:05 +0100
committerrubenwardy <rw@rubenwardy.com>2019-05-24 16:42:05 +0100
commitb917ea4723fb0fe976486602a456c8dd41eab7ef (patch)
treeab459ae6aaeb19599d19a63b4508dcc60b632386 /src/gui/guiEditBoxWithScrollbar.cpp
parenta2848c9cdeba8d077c61ef20108cb208fd073ef8 (diff)
downloadminetest-b917ea4723fb0fe976486602a456c8dd41eab7ef.tar.gz
minetest-b917ea4723fb0fe976486602a456c8dd41eab7ef.tar.bz2
minetest-b917ea4723fb0fe976486602a456c8dd41eab7ef.zip
Add IGUIScrollbar implementation with variable bar sizes (#8507)
Diffstat (limited to 'src/gui/guiEditBoxWithScrollbar.cpp')
-rw-r--r--src/gui/guiEditBoxWithScrollbar.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/guiEditBoxWithScrollbar.cpp b/src/gui/guiEditBoxWithScrollbar.cpp
index 4a821c7b4..b7192b37b 100644
--- a/src/gui/guiEditBoxWithScrollbar.cpp
+++ b/src/gui/guiEditBoxWithScrollbar.cpp
@@ -13,7 +13,6 @@
#include "porting.h"
#include "Keycodes.h"
-
/*
todo:
optional scrollbars [done]
@@ -76,7 +75,8 @@ GUIEditBoxWithScrollBar::~GUIEditBoxWithScrollBar()
if (m_operator)
m_operator->drop();
- m_vscrollbar->remove();
+ if (m_vscrollbar)
+ m_vscrollbar->drop();
}
@@ -1400,7 +1400,9 @@ void GUIEditBoxWithScrollBar::createVScrollBar()
irr::core::rect<s32> scrollbarrect = m_frame_rect;
scrollbarrect.UpperLeftCorner.X += m_frame_rect.getWidth() - m_scrollbar_width;
- m_vscrollbar = Environment->addScrollBar(false, scrollbarrect, getParent(), getID());
+ m_vscrollbar = new guiScrollBar(Environment, getParent(), -1,
+ scrollbarrect, false, true);
+
m_vscrollbar->setVisible(false);
m_vscrollbar->setSmallStep(1);
m_vscrollbar->setLargeStep(1);
@@ -1422,6 +1424,7 @@ void GUIEditBoxWithScrollBar::updateVScrollBar()
if (scrollymax != m_vscrollbar->getMax()) {
// manage a newline or a deleted line
m_vscrollbar->setMax(scrollymax);
+ m_vscrollbar->setPageSize(s32(getTextDimension().Height));
calculateScrollPos();
} else {
// manage a newline or a deleted line
@@ -1436,6 +1439,7 @@ void GUIEditBoxWithScrollBar::updateVScrollBar()
s32 scrollymax = getTextDimension().Height - m_frame_rect.getHeight();
if (scrollymax != m_vscrollbar->getMax()) {
m_vscrollbar->setMax(scrollymax);
+ m_vscrollbar->setPageSize(s32(getTextDimension().Height));
}
if (!m_vscrollbar->isVisible()) {
@@ -1448,10 +1452,10 @@ void GUIEditBoxWithScrollBar::updateVScrollBar()
m_vscroll_pos = 0;
m_vscrollbar->setPos(0);
m_vscrollbar->setMax(1);
+ m_vscrollbar->setPageSize(s32(getTextDimension().Height));
}
}
-
}
//! set true if this editbox is writable