qskinny/src/nodes/QskTextRenderer.cpp

52 lines
1.8 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskTextRenderer.h"
2017-10-23 07:46:46 +02:00
#include "QskPlainTextRenderer.h"
2018-08-03 08:15:28 +02:00
#include "QskRichTextRenderer.h"
2017-10-23 07:46:46 +02:00
#include "QskTextOptions.h"
2017-10-20 20:26:39 +02:00
2018-07-19 14:10:48 +02:00
#include <qrect.h>
2017-07-21 18:21:34 +02:00
/*
Since Qt 5.7 QQuickTextNode is exported as Q_QUICK_PRIVATE_EXPORT
and could be used. TODO ...
*/
2018-08-03 08:15:28 +02:00
QSizeF QskTextRenderer::textSize(
const QString& text, const QFont& font, const QskTextOptions& options )
2017-07-21 18:21:34 +02:00
{
2017-10-23 07:46:46 +02:00
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
return QskPlainTextRenderer::textSize( text, font, options );
else
return QskRichTextRenderer::textSize( text, font, options );
2017-07-21 18:21:34 +02:00
}
2018-08-03 08:15:28 +02:00
QSizeF QskTextRenderer::textSize(
const QString& text, const QFont& font, const QskTextOptions& options,
const QSizeF& size )
2017-07-21 18:21:34 +02:00
{
2017-10-23 07:46:46 +02:00
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
return QskPlainTextRenderer::textRect( text, font, options, size ).size();
else
return QskRichTextRenderer::textRect( text, font, options, size ).size();
2017-07-21 18:21:34 +02:00
}
2018-08-03 08:15:28 +02:00
void QskTextRenderer::updateNode(
const QString& text, const QFont& font, const QskTextOptions& options,
Qsk::TextStyle style, const QskTextColors& colors, Qt::Alignment alignment,
const QRectF& rect, const QQuickItem* item, QSGTransformNode* node )
2017-07-21 18:21:34 +02:00
{
2017-10-23 07:46:46 +02:00
if ( options.format() == QskTextOptions::PlainText )
2017-07-21 18:21:34 +02:00
{
2018-08-03 08:15:28 +02:00
QskPlainTextRenderer::updateNode(
text, font, options, style, colors, alignment, rect, item, node );
2017-10-23 07:46:46 +02:00
}
else
{
2018-08-03 08:15:28 +02:00
QskRichTextRenderer::updateNode(
text, font, options, style, colors, alignment, rect, item, node );
2017-07-21 18:21:34 +02:00
}
2017-10-20 20:26:39 +02:00
}