MCPcopy Create free account
hub / github.com/SpartanJ/eepp / drawMinimap

Method drawMinimap

src/eepp/ui/uicodeeditor.cpp:4993–5373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4991};
4992
4993void UICodeEditor::drawMinimap( const Vector2f& start, const DocumentLineRange&,
4994 const DocumentViewLineRange& visibleLineRange ) {
4995 Float charHeight = PixelDensity::getPixelDensity() * mMinimapConfig.scale;
4996 Float charSpacing =
4997 eemax( 1.f, eefloor( 0.8 * PixelDensity::getPixelDensity() * mMinimapConfig.scale ) );
4998 Float lineSpacing = getMinimapLineSpacing();
4999 Rectf rect( getMinimapRect( start ) );
5000 Int64 visibleLinesCount = ( static_cast<Int64>( visibleLineRange.second ) -
5001 static_cast<Int64>( visibleLineRange.first ) );
5002 Int64 visibleLinesStart = static_cast<Int64>( visibleLineRange.first );
5003 Float scrollerHeight = visibleLinesCount * lineSpacing;
5004 Int64 lineCount = getTotalVisibleLines();
5005 Float visibleY = rect.Top + visibleLinesStart * lineSpacing;
5006 Int64 maxMinmapLines = eefloor( rect.getHeight() / lineSpacing );
5007 Int64 minimapStartLine = 0;
5008
5009 if ( isMinimapFileTooLarge() && visibleLinesCount ) {
5010 Float scrollPos = static_cast<Float>( visibleLinesStart - 1 ) /
5011 (Float)( lineCount - visibleLinesCount - 1 );
5012 scrollPos = eeclamp( scrollPos, 0.f, 1.f );
5013 Float scrollPosPixels = scrollPos * ( rect.getHeight() - scrollerHeight );
5014 visibleY = rect.Top + scrollPosPixels;
5015 Float t = ( lineCount - visibleLinesStart ) / visibleLinesCount;
5016 if ( t <= 1 )
5017 visibleY += scrollerHeight * ( 1.f - t );
5018 minimapStartLine = visibleLinesStart - eefloor( scrollPosPixels / lineSpacing );
5019 minimapStartLine = eemax( 0ll, eemin( minimapStartLine, lineCount - maxMinmapLines ) );
5020 }
5021
5022 // Disable multi-sample to avoid rectangle-smoothing
5023 bool disableMultisample = !mMinimapConfig.allowSmoothing && GLi->isMultisample();
5024 ScopedOp op(
5025 [disableMultisample] {
5026 if ( disableMultisample )
5027 GLi->multisample( false );
5028 },
5029 [disableMultisample] {
5030 if ( disableMultisample )
5031 GLi->multisample( true );
5032 } );
5033
5034 GlobalBatchRenderer* BR = GlobalBatchRenderer::instance();
5035 BR->setTexture( nullptr );
5036 BR->setBlendMode( BlendMode::Alpha() );
5037 BR->quadsBegin();
5038
5039 if ( mMinimapConfig.drawBackground ) {
5040 BR->quadsSetColor( Color( mMinimapBackgroundColor ).blendAlpha( mAlpha ) );
5041 BR->batchQuad( rect );
5042 }
5043
5044 BR->quadsSetColor( Color( mMinimapVisibleAreaColor ).blendAlpha( mAlpha ) );
5045 BR->batchQuad( { { rect.Left, visibleY }, Sizef( rect.getWidth(), scrollerHeight ) } );
5046 if ( mMinimapHover || mMinimapDragging ) {
5047 BR->quadsSetColor( Color( mMinimapHoverColor ).blendAlpha( mAlpha ) );
5048 BR->batchQuad( { { rect.Left, visibleY }, Sizef( rect.getWidth(), scrollerHeight ) } );
5049 }
5050

Callers

nothing calls this directly

Calls 15

eemaxFunction · 0.85
eeclampFunction · 0.85
eeminFunction · 0.85
AlphaFunction · 0.85
isMultisampleMethod · 0.80
multisampleMethod · 0.80
quadsBeginMethod · 0.80
quadsSetColorMethod · 0.80
batchQuadMethod · 0.80
isWrapEnabledMethod · 0.80
columnMethod · 0.80
substrMethod · 0.80

Tested by

no test coverage detected