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
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_PLAIN_TEXT_RENDERER_H
|
|
|
|
#define QSK_PLAIN_TEXT_RENDERER_H
|
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
|
|
|
#include "QskNamespace.h"
|
|
|
|
#include "QskTextOptions.h"
|
|
|
|
|
|
|
|
#include <QFont>
|
|
|
|
#include <QFontMetricsF>
|
|
|
|
|
|
|
|
class QSGNode;
|
|
|
|
class QQuickItem;
|
|
|
|
class QColor;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskPlainTextRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QskPlainTextRenderer();
|
|
|
|
~QskPlainTextRenderer();
|
|
|
|
|
|
|
|
void setFont( const QFont& );
|
|
|
|
void setOptions( const QskTextOptions& );
|
|
|
|
void setAlignment( Qt::Alignment );
|
|
|
|
|
|
|
|
void updateNode(
|
|
|
|
const QQuickItem*, const QRectF&, const QString&, QSGNode* parentNode,
|
|
|
|
const QColor& textColor, Qsk::TextStyle, const QColor& styleColor );
|
|
|
|
|
|
|
|
void updateNode(
|
2017-10-17 17:34:00 +02:00
|
|
|
const QQuickItem*, const QSizeF& size, const QString&, QSGNode* parentNode,
|
2017-07-21 18:21:34 +02:00
|
|
|
const QColor& textColor, Qsk::TextStyle, const QColor& styleColor );
|
|
|
|
|
|
|
|
static void updateNodeColor( QSGNode* parentNode,
|
|
|
|
const QColor& textColor, Qsk::TextStyle, const QColor& styleColor );
|
|
|
|
|
2017-10-20 15:29:50 +02:00
|
|
|
QSizeF textSize( const QString& ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
QRectF textRect( const QSizeF&, const QString& ) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int flags() const;
|
|
|
|
|
|
|
|
QFont m_font;
|
|
|
|
QFontMetricsF m_fontMetrics;
|
|
|
|
QskTextOptions m_options;
|
|
|
|
Qt::Alignment m_alignment;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline void QskPlainTextRenderer::updateNode(
|
|
|
|
const QQuickItem* item, const QSizeF& size, const QString& text, QSGNode* parentNode,
|
|
|
|
const QColor& textColor, Qsk::TextStyle style, const QColor& styleColor )
|
|
|
|
{
|
|
|
|
updateNode( item, QRectF( QPointF(), size ),
|
|
|
|
text, parentNode, textColor, style, styleColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|