From b917ea4723fb0fe976486602a456c8dd41eab7ef Mon Sep 17 00:00:00 2001 From: stujones11 Date: Fri, 24 May 2019 16:42:05 +0100 Subject: Add IGUIScrollbar implementation with variable bar sizes (#8507) --- src/gui/guiEditBoxWithScrollbar.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/gui/guiEditBoxWithScrollbar.cpp') 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 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 -- cgit v1.2.3