mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Fix hypertext[] sometimes calculating incorrect scrollbar height (#13943)
This commit is contained in:
parent
1363059416
commit
96197025b9
@ -1132,8 +1132,16 @@ void GUIHyperText::draw()
|
||||
m_display_text_rect = AbsoluteRect;
|
||||
m_drawer.place(m_display_text_rect);
|
||||
|
||||
// Show scrollbar if text overflow
|
||||
// Show a scrollbar if the text overflows vertically
|
||||
if (m_drawer.getHeight() > m_display_text_rect.getHeight()) {
|
||||
// Showing a scrollbar will reduce the width of the viewport, causing
|
||||
// more text to be wrapped and thus increasing the height of the text.
|
||||
// Therefore, we have to re-layout the text *before* setting the height
|
||||
// of the scrollbar.
|
||||
core::rect<s32> smaller_rect = m_display_text_rect;
|
||||
smaller_rect.LowerRightCorner.X -= m_scrollbar_width;
|
||||
m_drawer.place(smaller_rect);
|
||||
|
||||
m_vscrollbar->setSmallStep(m_display_text_rect.getHeight() * 0.1f);
|
||||
m_vscrollbar->setLargeStep(m_display_text_rect.getHeight() * 0.5f);
|
||||
m_vscrollbar->setMax(m_drawer.getHeight() - m_display_text_rect.getHeight());
|
||||
@ -1141,11 +1149,6 @@ void GUIHyperText::draw()
|
||||
m_vscrollbar->setVisible(true);
|
||||
|
||||
m_vscrollbar->setPageSize(s32(m_drawer.getHeight()));
|
||||
|
||||
core::rect<s32> smaller_rect = m_display_text_rect;
|
||||
|
||||
smaller_rect.LowerRightCorner.X -= m_scrollbar_width;
|
||||
m_drawer.place(smaller_rect);
|
||||
} else {
|
||||
m_vscrollbar->setMax(0);
|
||||
m_vscrollbar->setPos(0);
|
||||
|
Loading…
Reference in New Issue
Block a user