QskSpinBox text alignment fixed
This commit is contained in:
parent
f614117d96
commit
82bd6f1420
|
@ -1497,13 +1497,22 @@ void Editor::setupSpinBoxMetrics()
|
||||||
{
|
{
|
||||||
using Q = QskSpinBox;
|
using Q = QskSpinBox;
|
||||||
|
|
||||||
|
/*
|
||||||
|
The F2 NumberBox has 2 modes for the Up/Down panels ( a.k.a Spinner ):
|
||||||
|
|
||||||
|
- compact ( -> QskSpinBox::UpDownControl )
|
||||||
|
- inline ( -> QskSpinBox::ButtonsRight )
|
||||||
|
|
||||||
|
TODO: in compact mode the panels/indicators are blown up, when being hovered
|
||||||
|
*/
|
||||||
setHint( Q::Panel | QskAspect::Style, Q::ButtonsRight );
|
setHint( Q::Panel | QskAspect::Style, Q::ButtonsRight );
|
||||||
|
|
||||||
setStrutSize( Q::Panel, { -1, 32_px } );
|
setStrutSize( Q::Panel, { -1, 32_px } );
|
||||||
setBoxBorderMetrics( Q::Panel, 1_px );
|
setBoxBorderMetrics( Q::Panel, 1_px );
|
||||||
setBoxShape( Q::Panel, 3_px );
|
setBoxShape( Q::Panel, 3_px );
|
||||||
setPadding( Q::Panel, { 11_px, 0, 11_px, 0 } );
|
setPadding( Q::Panel, { 11_px, 0, 11_px, 0 } );
|
||||||
|
|
||||||
setAlignment( Q::Text, Qt::AlignLeft );
|
setAlignment( Q::Text, Qt::AlignLeft | Qt::AlignVCenter );
|
||||||
setFontRole( Q::Text, Fluent2::Body );
|
setFontRole( Q::Text, Fluent2::Body );
|
||||||
|
|
||||||
setPadding( Q::TextPanel, { 11_px, 5_px, 0, 0 } );
|
setPadding( Q::TextPanel, { 11_px, 5_px, 0, 0 } );
|
||||||
|
|
|
@ -859,8 +859,6 @@ void Editor::setupSpinBox()
|
||||||
|
|
||||||
setPadding( Q::TextPanel, 5_dp );
|
setPadding( Q::TextPanel, 5_dp );
|
||||||
setBoxShape( Q::TextPanel, 2, 0, 2, 0 );
|
setBoxShape( Q::TextPanel, 2, 0, 2, 0 );
|
||||||
|
|
||||||
setColor( Q::Text, m_pal.active( P::Text ) );
|
|
||||||
setGradient( Q::TextPanel | Q::Disabled, m_pal.disabled( P::Base ) );
|
setGradient( Q::TextPanel | Q::Disabled, m_pal.disabled( P::Base ) );
|
||||||
|
|
||||||
setBoxBorderMetrics( Q::TextPanel, 1_dp );
|
setBoxBorderMetrics( Q::TextPanel, 1_dp );
|
||||||
|
@ -872,6 +870,9 @@ void Editor::setupSpinBox()
|
||||||
Combination( { Q::Increasing, Q::Decreasing, Q::Hovered } ) );
|
Combination( { Q::Increasing, Q::Decreasing, Q::Hovered } ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
setColor( Q::Text, m_pal.active( P::Text ) );
|
||||||
|
setAlignment( Q::Text, Qt::AlignCenter );
|
||||||
|
|
||||||
setBoxShape( Q::UpPanel, 0, 2_dp, 0, 0 );
|
setBoxShape( Q::UpPanel, 0, 2_dp, 0, 0 );
|
||||||
setBoxBorderMetrics( Q::UpPanel, 0_dp, 1_dp, 1_dp, 0_dp );
|
setBoxBorderMetrics( Q::UpPanel, 0_dp, 1_dp, 1_dp, 0_dp );
|
||||||
|
|
||||||
|
|
|
@ -887,7 +887,6 @@ void Editor::setupSpinBox()
|
||||||
setStrutSize( Q::UpPanel, 40_dp,40_dp );
|
setStrutSize( Q::UpPanel, 40_dp,40_dp );
|
||||||
setStrutSize( Q::DownPanel, 40_dp, 40_dp );
|
setStrutSize( Q::DownPanel, 40_dp, 40_dp );
|
||||||
|
|
||||||
setAlignment( Q::Panel, Qt::AlignHCenter );
|
|
||||||
setAlignment( Q::Text, Qt::AlignCenter );
|
setAlignment( Q::Text, Qt::AlignCenter );
|
||||||
|
|
||||||
for( const auto subControl : { Q::DownPanel, Q::UpPanel, Q::TextPanel } )
|
for( const auto subControl : { Q::DownPanel, Q::UpPanel, Q::TextPanel } )
|
||||||
|
|
|
@ -39,14 +39,9 @@ namespace
|
||||||
return QskAspect::NoSubcontrol;
|
return QskAspect::NoSubcontrol;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QskAspect aspectDecoration()
|
inline constexpr QskAspect aspectDecoration()
|
||||||
{
|
{
|
||||||
return QskSpinBox::Panel | QskAspect::NoType | QskAspect::Style;
|
return QskSpinBox::Panel | QskAspect::Style;
|
||||||
}
|
|
||||||
|
|
||||||
inline QskAspect aspectTextAlignment()
|
|
||||||
{
|
|
||||||
return QskSpinBox::TextPanel | QskAspect::NoType | QskAspect::Alignment;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,26 +171,6 @@ QskSpinBox::Decoration QskSpinBox::decoration() const
|
||||||
return flagHint< QskSpinBox::Decoration >( aspectDecoration(), ButtonsLeftAndRight );
|
return flagHint< QskSpinBox::Decoration >( aspectDecoration(), ButtonsLeftAndRight );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSpinBox::setTextAlignment( Qt::Alignment alignment )
|
|
||||||
{
|
|
||||||
alignment &= Qt::AlignHorizontal_Mask;
|
|
||||||
|
|
||||||
if ( setFlagHint( aspectTextAlignment(), alignment ) )
|
|
||||||
Q_EMIT textAlignmentChanged( alignment );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskSpinBox::resetTextAlignment()
|
|
||||||
{
|
|
||||||
if ( resetSkinHint( aspectTextAlignment() ) )
|
|
||||||
Q_EMIT textAlignmentChanged( textAlignment() );
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::Alignment QskSpinBox::textAlignment() const
|
|
||||||
{
|
|
||||||
return flagHint< Qt::Alignment >(
|
|
||||||
aspectTextAlignment(), Qt::AlignLeft ) & Qt::AlignHorizontal_Mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskSpinBox::setWrapping( bool on )
|
void QskSpinBox::setWrapping( bool on )
|
||||||
{
|
{
|
||||||
if ( on != m_data->wrapping )
|
if ( on != m_data->wrapping )
|
||||||
|
|
|
@ -22,9 +22,6 @@ class QSK_EXPORT QskSpinBox : public QskBoundedValueInput
|
||||||
Q_PROPERTY( int decimals READ decimals
|
Q_PROPERTY( int decimals READ decimals
|
||||||
WRITE setDecimals NOTIFY decimalsChanged )
|
WRITE setDecimals NOTIFY decimalsChanged )
|
||||||
|
|
||||||
Q_PROPERTY( Qt::Alignment textAlignment READ textAlignment
|
|
||||||
WRITE setTextAlignment RESET textAlignment NOTIFY textAlignmentChanged )
|
|
||||||
|
|
||||||
Q_PROPERTY( QString text READ text NOTIFY textChanged )
|
Q_PROPERTY( QString text READ text NOTIFY textChanged )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -53,11 +50,6 @@ class QSK_EXPORT QskSpinBox : public QskBoundedValueInput
|
||||||
void resetDecoration();
|
void resetDecoration();
|
||||||
Decoration decoration() const;
|
Decoration decoration() const;
|
||||||
|
|
||||||
// Qt::AlignLeft, Qt::AlignRight or Qt::AlignHCenter.
|
|
||||||
void setTextAlignment( Qt::Alignment );
|
|
||||||
void resetTextAlignment();
|
|
||||||
Qt::Alignment textAlignment() const;
|
|
||||||
|
|
||||||
void setWrapping( bool );
|
void setWrapping( bool );
|
||||||
bool isWrapping() const;
|
bool isWrapping() const;
|
||||||
|
|
||||||
|
@ -71,10 +63,7 @@ class QSK_EXPORT QskSpinBox : public QskBoundedValueInput
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void decorationChanged( Decoration );
|
void decorationChanged( Decoration );
|
||||||
void textAlignmentChanged( Qt::Alignment );
|
|
||||||
|
|
||||||
void wrappingChanged( bool );
|
void wrappingChanged( bool );
|
||||||
|
|
||||||
void decimalsChanged( int );
|
void decimalsChanged( int );
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
|
||||||
|
|
|
@ -117,11 +117,7 @@ QSGNode* QskSpinBoxSkinlet::updateSubNode(
|
||||||
case TextRole:
|
case TextRole:
|
||||||
{
|
{
|
||||||
auto spinBox = static_cast< const QskSpinBox* >( skinnable );
|
auto spinBox = static_cast< const QskSpinBox* >( skinnable );
|
||||||
|
return updateTextNode( spinBox, node, spinBox->text(), Q::Text );
|
||||||
const auto rect = subControlRect( spinBox, spinBox->contentsRect(), Q::Text );
|
|
||||||
|
|
||||||
return updateTextNode( spinBox, node, rect,
|
|
||||||
spinBox->textAlignment(), spinBox->text(), Q::Text );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue