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

Method scrollToVisibleIndex

src/eepp/ui/uicodeeditor.cpp:2453–2475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2451}
2452
2453void UICodeEditor::scrollToVisibleIndex( Int64 visibleIndex, bool centered,
2454 bool forceExactPosition ) {
2455 Rectf scrollArea = getVisibleScrollArea();
2456 Float lineHeight = getLineHeight();
2457 Int64 minDistance = mHScrollBar->isVisible() ? 3 : 2;
2458 scrollArea.Top += lineHeight;
2459 scrollArea.Bottom = eemax( scrollArea.Top, scrollArea.Bottom - minDistance * lineHeight );
2460
2461 Vector2f offsetEnd{ 0.f, static_cast<Float>( mDocView.getLineYOffset(
2462 static_cast<VisibleIndex>( visibleIndex ), lineHeight ) ) };
2463
2464 // Vertical Scroll
2465 Float halfScreenSize = eefloor( getViewportDimensions().getHeight() * 0.5f );
2466 if ( centered || forceExactPosition ) {
2467 setScrollY(
2468 eeclamp( offsetEnd.y - ( centered ? halfScreenSize : 0 ), 0.f, getMaxScroll().y ) );
2469 } else if ( offsetEnd.y < scrollArea.Top ) {
2470 setScrollY( eeclamp( offsetEnd.y - lineHeight, 0.f, getMaxScroll().y ) );
2471 } else if ( offsetEnd.y > scrollArea.Bottom - lineHeight ) {
2472 setScrollY(
2473 eeclamp( offsetEnd.y - scrollArea.getHeight() - lineHeight, 0.f, getMaxScroll().y ) );
2474 }
2475}
2476
2477void UICodeEditor::scrollTo( TextRange position, bool centered, bool forceExactPosition,
2478 bool scrollX ) {

Callers 1

onKeyDownMethod · 0.80

Calls 5

eemaxFunction · 0.85
eeclampFunction · 0.85
getLineYOffsetMethod · 0.80
isVisibleMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected