MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / lineNumberAreaPaintEvent

Method lineNumberAreaPaintEvent

Gui/ScriptTextEdit.cpp:398–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398void
399InputScriptTextEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
400{
401 QPainter painter(_lineNumber);
402 QColor fillColor;
403 QColor txtColor;
404 QColor selColor;
405 {
406 double r, g, b;
407 appPTR->getCurrentSettings()->getRaisedColor(&r, &g, &b);
408 fillColor.setRgbF( Image::clamp(r, 0., 1.), Image::clamp(g, 0., 1.), Image::clamp(b, 0., 1.) );
409 appPTR->getCurrentSettings()->getTextColor(&r, &g, &b);
410 txtColor.setRgbF( Image::clamp(r, 0., 1.), Image::clamp(g, 0., 1.), Image::clamp(b, 0., 1.) );
411 appPTR->getCurrentSettings()->getSelectionColor(&r, &g, &b);
412 selColor.setRgbF( Image::clamp(r, 0., 1.), Image::clamp(g, 0., 1.), Image::clamp(b, 0., 1.) );
413 }
414
415 painter.fillRect(event->rect(), fillColor);
416
417 QTextBlock block = firstVisibleBlock();
418 int blockNumber = block.blockNumber();
419 int top = (int) blockBoundingGeometry(block).translated( contentOffset() ).top();
420 int bottom = top + (int) blockBoundingRect(block).height();
421
422 while ( block.isValid() && top <= event->rect().bottom() ) {
423 if ( block.isVisible() && ( bottom >= event->rect().top() ) ) {
424 QString number = QString::number(blockNumber + 1);
425 if ( blockNumber == textCursor().block().blockNumber() ) {
426 painter.setPen(selColor);
427 } else {
428 painter.setPen(txtColor);
429 }
430
431 painter.drawText(0, top, _lineNumber->width(), fontMetrics().height(),
432 Qt::AlignRight, number);
433 }
434
435 block = block.next();
436 top = bottom;
437 bottom = top + (int) blockBoundingRect(block).height();
438 ++blockNumber;
439 }
440}
441
442void
443InputScriptTextEdit::dragEnterEvent(QDragEnterEvent* e)

Callers 1

LineNumberWidgetClass · 0.80

Calls 11

clampFunction · 0.85
getRaisedColorMethod · 0.80
getCurrentSettingsMethod · 0.80
getTextColorMethod · 0.80
getSelectionColorMethod · 0.80
topMethod · 0.45
heightMethod · 0.45
isValidMethod · 0.45
bottomMethod · 0.45
isVisibleMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected