QskSkinnable::effectiveFontHeight added

This commit is contained in:
Uwe Rathmann 2021-12-24 16:17:49 +01:00
parent ca2cdf7663
commit fa6fc7b4c1
3 changed files with 11 additions and 3 deletions

View File

@ -79,7 +79,7 @@ QRectF QskPushButtonSkinlet::textRect(
{
// in case of having text + graphic we put the text at the bottom
qreal h = QFontMetricsF( button->effectiveFont( QskPushButton::Text ) ).height();
qreal h = button->effectiveFontHeight( QskPushButton::Text );
if ( h < r.height() )
r.setTop( r.bottom() - h );
}
@ -153,8 +153,8 @@ QSGNode* QskPushButtonSkinlet::updateTextNode(
{
const auto rect = button->subControlRect( QskPushButton::Text ).toAlignedRect();
const QFontMetricsF fm( button->effectiveFont( QskPushButton::Text ) );
if ( !button->clip() && ( rect.height() < fm.height() ) )
const auto textHeight = button->effectiveFontHeight( QskPushButton::Text );
if ( !button->clip() && ( rect.height() < textHeight ) )
return nullptr;
const auto alignment = button->alignmentHint( QskPushButton::Text, Qt::AlignCenter );

View File

@ -25,6 +25,7 @@
#include "QskGradient.h"
#include <qfont.h>
#include <qfontmetrics.h>
#include <map>
#define DEBUG_MAP 0
@ -577,6 +578,12 @@ QFont QskSkinnable::effectiveFont( const QskAspect aspect ) const
return effectiveSkin()->font( fontRoleHint( aspect ) );
}
qreal QskSkinnable::effectiveFontHeight( const QskAspect aspect ) const
{
const QFontMetricsF fm( effectiveFont( aspect ) );
return fm.height();
}
bool QskSkinnable::setGraphicRoleHint( const QskAspect aspect, int role )
{
return qskSetFlag( this, aspect | QskAspect::GraphicRole, role );

View File

@ -77,6 +77,7 @@ class QSK_EXPORT QskSkinnable
const QskSkinlet* skinlet() const;
QFont effectiveFont( QskAspect ) const;
qreal effectiveFontHeight( QskAspect ) const;
QskColorFilter effectiveGraphicFilter( QskAspect ) const;