Skip to content

Commit

Permalink
Console Scrollbar: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chmodsayshello committed Jan 2, 2025
1 parent dd228df commit bdecc10
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/gui/guiChatConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@ void GUIChatConsole::draw()
m_screensize = screensize;
m_desired_height = m_desired_height_fraction * m_screensize.Y;
reformatConsole();
} else if (!m_scrollbar->getAbsolutePosition().isPointInside(core::vector2di(screensize.X, m_height)))
} else if (!m_scrollbar->getAbsolutePosition().isPointInside(core::vector2di(screensize.X, m_height))) {
// the height of the chat window is no longer the height of the scrollbar
// happens while opening/closing the window
updateScrollbar(true);
}

// Animation
u64 now = porting::getTimeMs();
Expand Down Expand Up @@ -333,6 +334,13 @@ void GUIChatConsole::drawText()
return;

ChatBuffer& buf = m_chat_backend->getConsoleBuffer();

core::recti rect;
if (m_scrollbar->isVisible())
rect = core::rect<s32> (0, 0, m_screensize.X - getScrollbarSize(Environment), m_height);
else
rect = AbsoluteClippingRect;

for (u32 row = 0; row < buf.getRows(); ++row)
{
const ChatFormattedLine& line = buf.getFormattedLine(row);
Expand All @@ -349,14 +357,6 @@ void GUIChatConsole::drawText()
core::rect<s32> destrect(
x, y, x + m_fontsize.X * fragment.text.size(), y + m_fontsize.Y);


core::recti rect;
if (m_scrollbar->isVisible())
rect = core::rect<s32> (0, 0, m_screensize.X - getScrollbarSize(Environment), m_height);
else
rect = AbsoluteClippingRect;


if (m_font->getType() == irr::gui::EGFT_CUSTOM) {
// Draw colored text if possible
gui::CGUITTFont *tmp = static_cast<gui::CGUITTFont*>(m_font);
Expand Down Expand Up @@ -818,11 +818,12 @@ void GUIChatConsole::updatePrimarySelection()

void GUIChatConsole::updateScrollbar(bool update_size)
{
m_scrollbar->setMin(m_chat_backend->getConsoleBuffer().getTopScrollPos());
m_scrollbar->setMax(m_chat_backend->getConsoleBuffer().getBottomScrollPos());
m_scrollbar->setPos(m_chat_backend->getConsoleBuffer().getScrollPosition());
ChatBuffer &buf = m_chat_backend->getConsoleBuffer();
m_scrollbar->setMin(buf.getTopScrollPos());
m_scrollbar->setMax(buf.getBottomScrollPos());
m_scrollbar->setPos(buf.getScrollPosition());
m_scrollbar->setPageSize(m_fontsize.Y * buf.getLineCount());
m_scrollbar->setVisible(m_scrollbar->getMin() != m_scrollbar->getMax());
m_scrollbar->setPageSize(m_fontsize.Y * m_chat_backend->getConsoleBuffer().getLineCount());

if (update_size) {
const core::rect<s32> rect (m_screensize.X - getScrollbarSize(Environment), 0, m_screensize.X, m_height);
Expand Down

0 comments on commit bdecc10

Please sign in to comment.