| 248 | } |
| 249 | |
| 250 | void UICodeEditor::draw() { |
| 251 | if ( !mVisible || mAlpha == 0 ) |
| 252 | return; |
| 253 | |
| 254 | UIWidget::draw(); |
| 255 | |
| 256 | if ( mFont == NULL ) |
| 257 | return; |
| 258 | |
| 259 | if ( mDisplayLoaderIfDocumentLoading && mDoc->isLoading() ) { |
| 260 | UILoader* loader = getLoader(); |
| 261 | loader->setParent( this ); |
| 262 | loader->setVisible( true ); |
| 263 | loader->setEnabled( false ); |
| 264 | loader->setPixelsSize( getPixelsSize() ); |
| 265 | } else if ( mLoader != nullptr && !mDoc->isLoading() && mLoader->isVisible() ) { |
| 266 | mLoader->setVisible( false ); |
| 267 | } |
| 268 | |
| 269 | if ( mDoc->isLoading() || mSize.getWidth() == 0 ) |
| 270 | return; |
| 271 | |
| 272 | bool needsClipping = mPaddingPx != Rectf::Zero; |
| 273 | if ( isClipped() && needsClipping ) { |
| 274 | clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top, |
| 275 | editorWidth(), editorHeight() ); |
| 276 | } |
| 277 | |
| 278 | if ( mDirtyEditor ) |
| 279 | updateEditor(); |
| 280 | |
| 281 | if ( mDocView.isPendingReconstruction() ) |
| 282 | mDocView.invalidateCache(); |
| 283 | |
| 284 | Color col; |
| 285 | auto lineRange = getDocumentLineRange(); |
| 286 | auto visibleLineRange = getVisibleLineRange(); |
| 287 | Float charSize = getCharacterSize(); |
| 288 | Float lineHeight = getLineHeight(); |
| 289 | int lineNumberDigits = getLineNumberDigits(); |
| 290 | Float gutterWidth = getGutterWidth(); |
| 291 | Vector2f screenStart( getScreenStart() ); |
| 292 | Vector2f start( screenStart.x + gutterWidth, screenStart.y + getPluginsTopSpace() ); |
| 293 | Vector2f startScroll( start - mScroll ); |
| 294 | Primitives primitives; |
| 295 | TextPosition cursor( mDoc->getSelection().start() ); |
| 296 | |
| 297 | for ( auto& plugin : mPlugins ) |
| 298 | plugin->preDraw( this, startScroll, lineHeight, cursor ); |
| 299 | |
| 300 | if ( !mLocked && mHighlightCurrentLine ) { |
| 301 | for ( const auto& sel : mDoc->getSelections() ) { |
| 302 | if ( mDocView.isFolded( sel.start().line(), true ) ) |
| 303 | continue; |
| 304 | primitives.setColor( Color( mCurrentLineBackgroundColor ).blendAlpha( mAlpha ) ); |
| 305 | Float height = 1; |
| 306 | if ( mDocView.isWrappedLine( sel.start().line() ) ) |
| 307 | height = mDocView.getVisibleLineInfo( sel.start().line() ).visualLines.size(); |
no test coverage detected