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

Method paintEvent

Gui/ScaleSliderQWidget.cpp:437–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437void
438ScaleSliderQWidget::paintEvent(QPaintEvent* /*e*/)
439{
440 if (_imp->mustInitializeSliderPosition) {
441 if (_imp->minimum < _imp->maximum) {
442 centerOn(_imp->minimum, _imp->maximum);
443 }
444 _imp->mustInitializeSliderPosition = false;
445 seekScalePosition(_imp->value);
446 _imp->initialized = true;
447 }
448
449 ///fill the background with the appropriate style color
450 QStyleOption opt;
451 opt.init(this);
452 QPainter p(this);
453 p.setOpacity(1);
454 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
455
456 double txtR, txtG, txtB;
457 if (_imp->altered) {
458 appPTR->getCurrentSettings()->getAltTextColor(&txtR, &txtG, &txtB);
459 } else {
460 appPTR->getCurrentSettings()->getTextColor(&txtR, &txtG, &txtB);
461 }
462
463 QColor textColor;
464 textColor.setRgbF( Image::clamp<qreal>(txtR, 0., 1.),
465 Image::clamp<qreal>(txtG, 0., 1.),
466 Image::clamp<qreal>(txtB, 0., 1.) );
467
468 QColor scaleColor;
469 scaleColor.setRgbF(textColor.redF() / 2., textColor.greenF() / 2., textColor.blueF() / 2.);
470
471 QFontMetrics fontM(_imp->font, 0);
472
473 if (!_imp->useLineColor) {
474 p.setPen(scaleColor);
475 } else {
476 p.setPen(_imp->lineColor);
477 }
478
479 QPointF btmLeft = _imp->zoomCtx.toZoomCoordinates(0, height() - 1);
480 QPointF topRight = _imp->zoomCtx.toZoomCoordinates(width() - 1, 0);
481
482 if ( btmLeft.x() == topRight.x() ) {
483 return;
484 }
485
486 /*drawing X axis*/
487 double lineYpos = height() - 1 - fontM.height() - TO_DPIY(TICK_HEIGHT) / 2;
488 p.drawLine(0, lineYpos, width() - 1, lineYpos);
489
490 double tickBottom = _imp->zoomCtx.toZoomCoordinates( 0, height() - 1 - fontM.height() ).y();
491 double tickTop = _imp->zoomCtx.toZoomCoordinates( 0, height() - 1 - fontM.height() - TO_DPIY(TICK_HEIGHT) ).y();
492 const double smallestTickSizePixel = std::min(60., width() / 4.); // tick size (in pixels) for alpha = 0.
493 const double largestTickSizePixel = 120.; // tick size (in pixels) for alpha = 1.
494 const double rangePixel = width();

Callers

nothing calls this directly

Calls 15

ticks_sizeFunction · 0.85
ticks_boundsFunction · 0.85
ticks_fillFunction · 0.85
ticks_alphaFunction · 0.85
maxFunction · 0.85
getAltTextColorMethod · 0.80
getCurrentSettingsMethod · 0.80
getTextColorMethod · 0.80
setFontMethod · 0.80
getSliderColorMethod · 0.80
getSelectionColorMethod · 0.80
QPointFClass · 0.70

Tested by

no test coverage detected