layout code fixed

This commit is contained in:
Uwe Rathmann 2018-01-05 09:36:55 +01:00
parent 277d8dd8d6
commit 2df8d81174

View File

@ -42,6 +42,28 @@ namespace
#endif #endif
} }
inline void setGeometry( const QRectF& rect )
{
auto d = QQuickTextPrivate::get( this );
d->heightValid = true;
d->widthValid = true;
if ( ( d->x != rect.x() ) || ( d->y != rect.y() ) )
{
d->x = rect.x();
d->y = rect.y();
d->dirty( QQuickItemPrivate::Position );
}
if ( ( d->width != rect.width() ) || ( d->height != rect.height() ) )
{
d->height = rect.height();
d->width = rect.width();
d->dirty( QQuickItemPrivate::Size );
}
}
inline void setAlignment( Qt::Alignment alignment ) inline void setAlignment( Qt::Alignment alignment )
{ {
setHAlign( ( QQuickText::HAlignment ) ( int( alignment ) & 0x0f ) ); setHAlign( ( QQuickText::HAlignment ) ( int( alignment ) & 0x0f ) );
@ -57,8 +79,16 @@ namespace
setWrapMode( static_cast< QQuickText::WrapMode >( options.wrapMode() ) ); setWrapMode( static_cast< QQuickText::WrapMode >( options.wrapMode() ) );
} }
void begin() { classBegin(); } void begin()
void end() { componentComplete(); } {
classBegin();
QQuickTextPrivate::get( this )->updateOnComponentComplete = true;
}
void end()
{
componentComplete();
}
QRectF layedOutTextRect() const QRectF layedOutTextRect() const
{ {
@ -150,28 +180,14 @@ void QskRichTextRenderer::updateNode( const QString& text,
textItem.begin(); textItem.begin();
textItem.setGeometry( rect );
textItem.setBottomPadding( 0 ); textItem.setBottomPadding( 0 );
textItem.setTopPadding( 0 ); textItem.setTopPadding( 0 );
textItem.setFont( font ); textItem.setFont( font );
textItem.setOptions( options ); textItem.setOptions( options );
textItem.setAlignment( alignment ); textItem.setAlignment( alignment );
#if 0
// the position of textItem seems to have no effect
// on the position of the node. We do it by translation later.
textItem.setX( rect.x() );
textItem.setY( rect.y() );
#endif
if ( rect.width() != item->width() ||
rect.height() != item->height() )
{
textItem.setWidth( rect.width() );
textItem.setHeight( rect.height() );
textItem.doLayout();
}
textItem.setColor( colors.textColor ); textItem.setColor( colors.textColor );
textItem.setStyle( static_cast< QQuickText::TextStyle >( style ) ); textItem.setStyle( static_cast< QQuickText::TextStyle >( style ) );
textItem.setStyleColor( colors.styleColor ); textItem.setStyleColor( colors.styleColor );
@ -196,7 +212,7 @@ void QskRichTextRenderer::updateNode( const QString& text,
if ( static_cast< int >( rect.height() - h ) % 2 ) if ( static_cast< int >( rect.height() - h ) % 2 )
{ {
if ( static_cast<int>( h ) % 2 ) if ( static_cast< int >( h ) % 2 )
d->extra.value().bottomPadding = 1; d->extra.value().bottomPadding = 1;
else else
d->extra.value().topPadding = 1; d->extra.value().topPadding = 1;