MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / paintScrollbar

Method paintScrollbar

app/src/UI/Widgets/Terminal.cpp:486–510  ·  view source on GitHub ↗

* @brief Draws the rounded scrollbar thumb when manual scrolling is active. */

Source from the content-addressed store, hash-verified

484 * @brief Draws the rounded scrollbar thumb when manual scrolling is active.
485 */
486void Widgets::Terminal::paintScrollbar(QPainter* painter)
487{
488 if (autoscroll() || lineCount() <= linesPerPage())
489 return;
490
491 const int availableHeight = height() - 2 * m_borderY;
492 const int scrollbarWidth = 6;
493 int scrollbarHeight = qMax(20.0, qPow(availableHeight, 2) / lineCount());
494 if (scrollbarHeight > availableHeight / 2)
495 scrollbarHeight = availableHeight / 2;
496
497 const bool rtl = Misc::Translator::instance().rtl();
498 const int x = rtl ? m_borderX : (width() - scrollbarWidth - m_borderX);
499 int y = (m_scrollOffsetY / static_cast<float>(lineCount() - linesPerPage()))
500 * (availableHeight - scrollbarHeight)
501 - m_borderY;
502 y = qMax(m_borderY, y);
503
504 QRect scrollbarRect(x, y, scrollbarWidth, scrollbarHeight);
505 QBrush scrollbarBrush(m_palette.color(QPalette::Window));
506 painter->setRenderHint(QPainter::Antialiasing);
507 painter->setBrush(scrollbarBrush);
508 painter->setPen(Qt::NoPen);
509 painter->drawRoundedRect(scrollbarRect, scrollbarWidth / 2, scrollbarWidth / 2);
510}
511
512//--------------------------------------------------------------------------------------------------
513// Character metrics

Callers

nothing calls this directly

Calls 1

rtlMethod · 0.80

Tested by

no test coverage detected