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

Method draw

src/eepp/window/inputmethod.cpp:55–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void InputMethod::draw( const Vector2f& screenPos, const Float& lineHeight,
56 const FontStyleConfig& fontStyle, const Color& lineColor,
57 const Color& backgroundColor, bool drawText ) {
58 Float width = Text::getTextWidth( mState.text, fontStyle );
59 Primitives p;
60
61 if ( backgroundColor != Color::Transparent ) {
62 p.setColor( backgroundColor );
63 p.drawRectangle( { screenPos, { width, lineHeight } } );
64 }
65
66 if ( lineColor != Color::Transparent ) {
67 Float lh = PixelDensity::dpToPx( 2 );
68 p.setColor( lineColor );
69 p.drawRectangle(
70 Rectf( { screenPos.x, screenPos.y + lineHeight - lh * 0.5f }, { width, lh } ) );
71
72 Float lineOffsetX =
73 Text::getTextWidth( mState.text.view().substr( 0, mState.start ), fontStyle );
74 p.drawRectangle( Rectf( { screenPos.x + lineOffsetX, screenPos.y },
75 { PixelDensity::dpToPx( 1.f ), lineHeight } ) );
76 }
77
78 if ( drawText )
79 Text::draw( mState.text, screenPos, fontStyle );
80}
81
82Uint32 InputMethod::addTextEditingCb( TextEditingCb cb ) {
83 mEditingCbs[++mLastCb] = std::move( cb );

Callers 3

takeScreenshotMethod · 0.45
getFrontBufferImageMethod · 0.45
displayMethod · 0.45

Calls 5

getTextWidthFunction · 0.85
substrMethod · 0.80
viewMethod · 0.80
setColorMethod · 0.45
drawRectangleMethod · 0.45

Tested by

no test coverage detected