| 53 | } |
| 54 | |
| 55 | void 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 | |
| 82 | Uint32 InputMethod::addTextEditingCb( TextEditingCb cb ) { |
| 83 | mEditingCbs[++mLastCb] = std::move( cb ); |
no test coverage detected