Code cleanup
This commit is contained in:
parent
4310ee3c34
commit
c3a4472587
|
@ -473,19 +473,19 @@ void Editor::setupRadioBox()
|
||||||
|
|
||||||
setAnimation( Q::Ripple | A::Metric | A::Position, qskDuration );
|
setAnimation( Q::Ripple | A::Metric | A::Position, qskDuration );
|
||||||
|
|
||||||
setSpacing(Q::Panel, 10_dp);
|
setSpacing( Q::Panel, 10_dp );
|
||||||
|
|
||||||
setStrutSize( Q::Button, { 20_dp, 20_dp });
|
setStrutSize( Q::Button, { 20_dp, 20_dp } );
|
||||||
setStrutSize( Q::Symbol, { 10_dp, 10_dp });
|
setStrutSize( Q::Symbol, { 10_dp, 10_dp } );
|
||||||
setStrutSize( Q::Ripple, { 40_dp, 40_dp });
|
setStrutSize( Q::Ripple, { 40_dp, 40_dp } );
|
||||||
|
|
||||||
setAlignment( Q::Symbol, Qt::AlignCenter );
|
setAlignment( Q::Symbol, Qt::AlignCenter );
|
||||||
setAlignment( Q::Text, Qt::AlignBottom );
|
setAlignment( Q::Text, Qt::AlignBottom );
|
||||||
|
|
||||||
setMargin( Q::Text, QskMargins( 10_dp, 0, 10_dp, 0));
|
setMargin( Q::Text, QskMargins( 10_dp, 0, 10_dp, 0 ) );
|
||||||
|
|
||||||
setBoxShape(Q::Button, 20_dp);
|
setBoxShape( Q::Button, 20_dp );
|
||||||
setBoxShape(Q::Ripple, 40_dp);
|
setBoxShape( Q::Ripple, 40_dp );
|
||||||
setBoxBorderMetrics( Q::Button, 2_dp );
|
setBoxBorderMetrics( Q::Button, 2_dp );
|
||||||
setBoxBorderColors( Q::Button, m_pal.onBackground );
|
setBoxBorderColors( Q::Button, m_pal.onBackground );
|
||||||
setColor( Q::Text, m_pal.onBackground );
|
setColor( Q::Text, m_pal.onBackground );
|
||||||
|
|
|
@ -616,11 +616,11 @@ void Editor::setupRadioBox()
|
||||||
|
|
||||||
setSpacing(Q::Panel, qskDpiScaled( 10 ) );
|
setSpacing(Q::Panel, qskDpiScaled( 10 ) );
|
||||||
|
|
||||||
setStrutSize( Q::Button, { qskDpiScaled( 20 ), qskDpiScaled( 20 ) });
|
setStrutSize( Q::Button, { qskDpiScaled( 20 ), qskDpiScaled( 20 ) } );
|
||||||
setStrutSize( Q::Symbol, { qskDpiScaled( 9 ), qskDpiScaled( 9 ) });
|
setStrutSize( Q::Symbol, { qskDpiScaled( 9 ), qskDpiScaled( 9 ) }) ;
|
||||||
|
|
||||||
setBoxShape(Q::Button, qskDpiScaled( 20 ) );
|
setBoxShape( Q::Button, qskDpiScaled( 20 ) );
|
||||||
setBoxShape(Q::Ripple, qskDpiScaled( 40 ) );
|
setBoxShape( Q::Ripple, qskDpiScaled( 40 ) );
|
||||||
setBoxBorderMetrics( Q::Button, qskDpiScaled( 1 ) );
|
setBoxBorderMetrics( Q::Button, qskDpiScaled( 1 ) );
|
||||||
|
|
||||||
setBoxBorderColors( Q::Button, m_pal.darker125 );
|
setBoxBorderColors( Q::Button, m_pal.darker125 );
|
||||||
|
|
|
@ -9,9 +9,9 @@ QSK_SUBCONTROL( QskRadioBox, Symbol )
|
||||||
QSK_SUBCONTROL( QskRadioBox, Text )
|
QSK_SUBCONTROL( QskRadioBox, Text )
|
||||||
QSK_SUBCONTROL( QskRadioBox, Ripple )
|
QSK_SUBCONTROL( QskRadioBox, Ripple )
|
||||||
|
|
||||||
QSK_STATE( QskRadioBox, Selected, QskAspect::FirstUserState << 1)
|
QSK_STATE( QskRadioBox, Selected, QskAspect::FirstUserState << 1 )
|
||||||
QSK_STATE( QskRadioBox, Pressed, QskAspect::FirstUserState << 2)
|
QSK_STATE( QskRadioBox, Pressed, QskAspect::FirstUserState << 2 )
|
||||||
QSK_STATE( QskRadioBox, Focused, QskAspect::FirstUserState << 3)
|
QSK_STATE( QskRadioBox, Focused, QskAspect::FirstUserState << 3 )
|
||||||
|
|
||||||
class QskRadioBox::PrivateData {
|
class QskRadioBox::PrivateData {
|
||||||
public:
|
public:
|
||||||
|
@ -23,8 +23,7 @@ public:
|
||||||
|
|
||||||
QskRadioBox::QskRadioBox( QQuickItem* parent ) :
|
QskRadioBox::QskRadioBox( QQuickItem* parent ) :
|
||||||
Inherited( parent ),
|
Inherited( parent ),
|
||||||
m_data( new PrivateData{} )
|
m_data( new PrivateData{} ) {
|
||||||
{
|
|
||||||
setFocusPolicy( Qt::NoFocus );
|
setFocusPolicy( Qt::NoFocus );
|
||||||
setAcceptedMouseButtons( Qt::LeftButton );
|
setAcceptedMouseButtons( Qt::LeftButton );
|
||||||
|
|
||||||
|
@ -41,16 +40,13 @@ QskRadioBox::QskRadioBox( QQuickItem* parent ) :
|
||||||
}
|
}
|
||||||
|
|
||||||
QskRadioBox::QskRadioBox( const QStringList& list, QQuickItem* parent ) :
|
QskRadioBox::QskRadioBox( const QStringList& list, QQuickItem* parent ) :
|
||||||
QskRadioBox( parent )
|
QskRadioBox( parent ) {
|
||||||
{
|
|
||||||
setItems( list );
|
setItems( list );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskRadioBox::QskRadioBox( const QStringList& items,
|
QskRadioBox::QskRadioBox( const QStringList& items,
|
||||||
int selectedIndex,
|
int selectedIndex, QQuickItem* parent ) :
|
||||||
QQuickItem* parent ) :
|
QskRadioBox( items, parent ) {
|
||||||
QskRadioBox( items, parent )
|
|
||||||
{
|
|
||||||
if( selectedIndex >= 0 && selectedIndex < items.count() )
|
if( selectedIndex >= 0 && selectedIndex < items.count() )
|
||||||
{
|
{
|
||||||
m_data->selectedIndex = selectedIndex;
|
m_data->selectedIndex = selectedIndex;
|
||||||
|
@ -59,7 +55,6 @@ QskRadioBox::QskRadioBox( const QStringList& items,
|
||||||
|
|
||||||
QRectF QskRadioBox::focusIndicatorRect() const {
|
QRectF QskRadioBox::focusIndicatorRect() const {
|
||||||
if( m_data->focusedIndex > -1) {
|
if( m_data->focusedIndex > -1) {
|
||||||
|
|
||||||
auto textRect = effectiveSkinlet()->sampleRect( this,
|
auto textRect = effectiveSkinlet()->sampleRect( this,
|
||||||
contentsRect(), QskRadioBox::Text, m_data->focusedIndex );
|
contentsRect(), QskRadioBox::Text, m_data->focusedIndex );
|
||||||
|
|
||||||
|
@ -139,14 +134,15 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
||||||
{
|
{
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
m_data->selectedIndex = qMax(m_data->selectedIndex - 1, 0);
|
m_data->selectedIndex = qMax( m_data->selectedIndex - 1, 0 );
|
||||||
setFocusedIndex( m_data->selectedIndex );
|
setFocusedIndex( m_data->selectedIndex );
|
||||||
event->setAccepted( true );
|
event->setAccepted( true );
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
m_data->selectedIndex = qMin(m_data->selectedIndex + 1, items().size() - 1);
|
m_data->selectedIndex = qMin( m_data->selectedIndex + 1,
|
||||||
|
items().size() - 1 );
|
||||||
setFocusedIndex( m_data->selectedIndex );
|
setFocusedIndex( m_data->selectedIndex );
|
||||||
event->setAccepted( true );
|
event->setAccepted( true );
|
||||||
update();
|
update();
|
||||||
|
@ -165,18 +161,17 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
||||||
if( nextTabIndex >= items().size()
|
if( nextTabIndex >= items().size()
|
||||||
|| nextTabIndex < 0 ) {
|
|| nextTabIndex < 0 ) {
|
||||||
Inherited::keyPressEvent( event );
|
Inherited::keyPressEvent( event );
|
||||||
setFocusedIndex( -1);
|
setFocusedIndex( -1 );
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
event->setAccepted( true );
|
event->setAccepted( true );
|
||||||
setFocusedIndex( (float) nextTabIndex );
|
setFocusedIndex( ( float ) nextTabIndex );
|
||||||
|
|
||||||
const auto aspect = Ripple | QskAspect::Metric | QskAspect::Position;
|
const auto aspect = Ripple | QskAspect::Metric | QskAspect::Position;
|
||||||
auto hint = animationHint(aspect | skinStates());
|
auto hint = animationHint(aspect | skinStates());
|
||||||
if( hint.isValid()) {
|
if( hint.isValid()) {
|
||||||
startTransition( aspect,
|
startTransition( aspect, hint,
|
||||||
hint,
|
( float ) currentTabIndex, ( float ) nextTabIndex );
|
||||||
(float) currentTabIndex, (float) nextTabIndex );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -191,7 +186,7 @@ void QskRadioBox::keyReleaseEvent( QKeyEvent* e )
|
||||||
|
|
||||||
void QskRadioBox::mousePressEvent( QMouseEvent* e )
|
void QskRadioBox::mousePressEvent( QMouseEvent* e )
|
||||||
{
|
{
|
||||||
auto indexAtPosition = indexAt(e->localPos());
|
auto indexAtPosition = indexAt( e->localPos() );
|
||||||
|
|
||||||
m_data->pressedIndex = indexAtPosition;
|
m_data->pressedIndex = indexAtPosition;
|
||||||
m_data->selectedIndex = -1;
|
m_data->selectedIndex = -1;
|
||||||
|
@ -217,7 +212,7 @@ void QskRadioBox::focusInEvent( QFocusEvent* e ) {
|
||||||
if( e->reason() == Qt::TabFocusReason ) {
|
if( e->reason() == Qt::TabFocusReason ) {
|
||||||
setFocusedIndex(0 );
|
setFocusedIndex(0 );
|
||||||
} else if( e->reason() == Qt::BacktabFocusReason ) {
|
} else if( e->reason() == Qt::BacktabFocusReason ) {
|
||||||
setFocusedIndex(items().size() - 1 );
|
setFocusedIndex( items().size() - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -235,8 +230,9 @@ int QskRadioBox::indexAt( const QPointF& target ) const {
|
||||||
auto itemHeight = contentsRect().height() / items().size();
|
auto itemHeight = contentsRect().height() / items().size();
|
||||||
auto index = target.y() / itemHeight;
|
auto index = target.y() / itemHeight;
|
||||||
|
|
||||||
if( index < 0 || index >= items().size() )
|
if( index < 0 || index >= items().size() ) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ QskRadioBoxSkinlet::~QskRadioBoxSkinlet()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QskAspect::States statesForIndex(const QskRadioBox* radio, int index) {
|
QskAspect::States statesForIndex( const QskRadioBox* radio, int index ) {
|
||||||
auto states = radio->skinStates();
|
auto states = radio->skinStates();
|
||||||
|
|
||||||
if( radio->selectedIndex() == index ) {
|
if( radio->selectedIndex() == index ) {
|
||||||
|
@ -42,12 +42,12 @@ QskAspect::States statesForIndex(const QskRadioBox* radio, int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskRadioBoxSkinlet::subControlRect( const QskSkinnable* skinnable,
|
QRectF QskRadioBoxSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
const QRectF& contentsRect, QskAspect::Subcontrol subcontrol) const
|
const QRectF& contentsRect, QskAspect::Subcontrol subcontrol ) const
|
||||||
{
|
{
|
||||||
auto radio = static_cast<const QskRadioBox*>( skinnable );
|
auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||||
|
|
||||||
if( subcontrol == Q::Ripple ) {
|
if( subcontrol == Q::Ripple ) {
|
||||||
return rippleRect(radio, contentsRect);
|
return rippleRect( radio, contentsRect );
|
||||||
}
|
}
|
||||||
|
|
||||||
return contentsRect;
|
return contentsRect;
|
||||||
|
@ -56,7 +56,7 @@ QRectF QskRadioBoxSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||||
QSizeF QskRadioBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
QSizeF QskRadioBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
||||||
Qt::SizeHint, const QSizeF& ) const
|
Qt::SizeHint, const QSizeF& ) const
|
||||||
{
|
{
|
||||||
auto radio = static_cast<const QskRadioBox*>( skinnable );
|
auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||||
|
|
||||||
const auto font = skinnable->effectiveFont( Q::Text );
|
const auto font = skinnable->effectiveFont( Q::Text );
|
||||||
const auto textMargins = skinnable->marginHint( Q::Text );
|
const auto textMargins = skinnable->marginHint( Q::Text );
|
||||||
|
@ -64,27 +64,26 @@ QSizeF QskRadioBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
||||||
const auto symbolMargins = skinnable->marginHint( Q::Symbol );
|
const auto symbolMargins = skinnable->marginHint( Q::Symbol );
|
||||||
|
|
||||||
qreal maxTextWidth = 0;
|
qreal maxTextWidth = 0;
|
||||||
for(auto& item : radio->items() ) {
|
for( auto& item : radio->items() ) {
|
||||||
maxTextWidth = std::max( maxTextWidth, qskHorizontalAdvance( font, item ) );
|
maxTextWidth = std::max( maxTextWidth, qskHorizontalAdvance( font, item ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto buttonWidth = radio->strutSizeHint(Q::Button).width();
|
auto buttonWidth = radio->strutSizeHint( Q::Button ).width();
|
||||||
auto symbolWidth = radio->strutSizeHint(Q::Symbol).width();
|
auto symbolWidth = radio->strutSizeHint( Q::Symbol ).width();
|
||||||
|
|
||||||
maxTextWidth += textMargins.left() + textMargins.right();
|
maxTextWidth += textMargins.left() + textMargins.right();
|
||||||
buttonWidth += buttonMargins.left() + buttonMargins.right();
|
buttonWidth += buttonMargins.left() + buttonMargins.right();
|
||||||
symbolWidth += symbolMargins.left() + symbolMargins.right();
|
symbolWidth += symbolMargins.left() + symbolMargins.right();
|
||||||
|
|
||||||
auto spacing = radio->spacingHint(Q::Panel);
|
auto spacing = radio->spacingHint( Q::Panel );
|
||||||
return QSizeF( maxTextWidth + qMax(buttonWidth, symbolWidth),
|
return QSizeF( maxTextWidth + qMax( buttonWidth, symbolWidth ),
|
||||||
( lineHeight( radio ) + spacing ) * radio->items().size()
|
( lineHeight( radio ) + spacing ) * radio->items().size() - spacing );
|
||||||
- spacing );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
||||||
quint8 nodeRole, QSGNode* node) const
|
quint8 nodeRole, QSGNode* node ) const
|
||||||
{
|
{
|
||||||
auto radio = static_cast<const QskRadioBox*>( skinnable );
|
auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||||
|
|
||||||
switch( nodeRole )
|
switch( nodeRole )
|
||||||
{
|
{
|
||||||
|
@ -103,7 +102,8 @@ QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
||||||
case RippleRole:
|
case RippleRole:
|
||||||
{
|
{
|
||||||
QskSkinStateChanger changer( radio );
|
QskSkinStateChanger changer( radio );
|
||||||
changer.setStates( statesForIndex( radio, radio->positionHint( Q::Ripple ) ) );
|
auto ripplePosition = radio->positionHint( Q::Ripple );
|
||||||
|
changer.setStates( statesForIndex( radio, ripplePosition ) );
|
||||||
|
|
||||||
return updateBoxNode( radio, node, Q::Ripple );
|
return updateBoxNode( radio, node, Q::Ripple );
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,7 @@ qreal QskRadioBoxSkinlet::lineHeight(const QskRadioBox* target) const {
|
||||||
return qMax( strutHight, fontHeight );
|
return qMax( strutHight, fontHeight );
|
||||||
}
|
}
|
||||||
|
|
||||||
int QskRadioBoxSkinlet::sampleCount( const QskSkinnable* skinnable,
|
int QskRadioBoxSkinlet::sampleCount( const QskSkinnable* skinnable, QskAspect::Subcontrol ) const {
|
||||||
QskAspect::Subcontrol ) const {
|
|
||||||
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||||
return radio->items().count();
|
return radio->items().count();
|
||||||
}
|
}
|
||||||
|
@ -140,8 +139,7 @@ QSizeF QskRadioBoxSkinlet::buttonSymbolSize( const QskRadioBox* radio ) const {
|
||||||
qMax( buttonStrut.height(), symbolStrut.height() ) );
|
qMax( buttonStrut.height(), symbolStrut.height() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio,
|
QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio, const QRectF& rect ) const {
|
||||||
const QRectF& rect ) const {
|
|
||||||
auto ripplePosition = radio->positionHint( Q::Ripple );
|
auto ripplePosition = radio->positionHint( Q::Ripple );
|
||||||
|
|
||||||
if( ripplePosition < 0 ) {
|
if( ripplePosition < 0 ) {
|
||||||
|
@ -157,16 +155,15 @@ QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio,
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
||||||
const QskAspect::Subcontrol target,
|
const QskAspect::Subcontrol target, const QRectF& rect, double index ) const {
|
||||||
const QRectF& rect, double index ) const {
|
|
||||||
if( index < 0 ) {
|
if( index < 0 ) {
|
||||||
return QRectF();
|
return QRectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = rect;
|
auto result = rect;
|
||||||
result.setSize( radio->strutSizeHint( target ));
|
result.setSize( radio->strutSizeHint( target ) );
|
||||||
|
|
||||||
auto spacing = radio->spacingHint(Q::Panel);
|
auto spacing = radio->spacingHint( Q::Panel );
|
||||||
result.moveTop( ( lineHeight( radio ) + spacing ) * index );
|
result.moveTop( ( lineHeight( radio ) + spacing ) * index );
|
||||||
|
|
||||||
auto margins = radio->marginHint( target );
|
auto margins = radio->marginHint( target );
|
||||||
|
@ -177,23 +174,23 @@ QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
||||||
|
|
||||||
// Vertical positioning
|
// Vertical positioning
|
||||||
auto alignHeight = maxSize.height() - withMargins.height();
|
auto alignHeight = maxSize.height() - withMargins.height();
|
||||||
if( alignment.testFlag( Qt::AlignVCenter )) {
|
if( alignment.testFlag( Qt::AlignVCenter ) ) {
|
||||||
result.moveTop( result.top() + alignHeight / 2);
|
result.moveTop( result.top() + alignHeight / 2 );
|
||||||
} else if( alignment.testFlag( Qt::AlignBottom ) ) {
|
} else if( alignment.testFlag( Qt::AlignBottom ) ) {
|
||||||
result.moveTop( result.top() + alignHeight );
|
result.moveTop( result.top() + alignHeight );
|
||||||
}
|
}
|
||||||
result.moveTop( result.top() + margins.top());
|
result.moveTop( result.top() + margins.top() );
|
||||||
|
|
||||||
// Horizontal positioning
|
// Horizontal positioning
|
||||||
auto alignWidth = 0;
|
auto alignWidth = 0;
|
||||||
if( alignment.testFlag( Qt::AlignHCenter ) ) {
|
if( alignment.testFlag( Qt::AlignHCenter ) ) {
|
||||||
alignWidth = (maxSize.width() - withMargins.width()) / 2;
|
alignWidth = ( maxSize.width() - withMargins.width() ) / 2;
|
||||||
} else if ( alignment.testFlag( Qt::AlignRight )) {
|
} else if ( alignment.testFlag( Qt::AlignRight )) {
|
||||||
alignWidth = maxSize.width() - withMargins.width();
|
alignWidth = maxSize.width() - withMargins.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( radio->layoutMirroring() ) {
|
if( radio->layoutMirroring() ) {
|
||||||
result.moveRight( rect.width() - (alignWidth + margins.right() ));
|
result.moveRight( rect.width() - ( alignWidth + margins.right() ) );
|
||||||
} else {
|
} else {
|
||||||
result.moveLeft( margins.left() + alignWidth );
|
result.moveLeft( margins.left() + alignWidth );
|
||||||
}
|
}
|
||||||
|
@ -203,20 +200,20 @@ QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
||||||
|
|
||||||
QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
||||||
const QRectF& rect, int index ) const {
|
const QRectF& rect, int index ) const {
|
||||||
auto text = radio->items()[index];
|
auto text = radio->items()[ index ];
|
||||||
|
|
||||||
if(text.isEmpty()) {
|
if(text.isEmpty()) {
|
||||||
return QRectF();
|
return QRectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF result = rect;
|
QRectF result = rect;
|
||||||
auto spacing = radio->spacingHint(Q::Panel);
|
auto spacing = radio->spacingHint( Q::Panel );
|
||||||
auto lh = lineHeight( radio );
|
auto lh = lineHeight( radio );
|
||||||
const auto textMargins = radio->marginHint( Q::Text );
|
const auto textMargins = radio->marginHint( Q::Text );
|
||||||
const auto font = radio->effectiveFont( Q::Text );
|
const auto font = radio->effectiveFont( Q::Text );
|
||||||
|
|
||||||
result.moveTop( index * ( lh + spacing )
|
result.moveTop( index * ( lh + spacing )
|
||||||
+ lh - radio->effectiveFontHeight(Q::Text)
|
+ lh - radio->effectiveFontHeight( Q::Text )
|
||||||
+ textMargins.top());
|
+ textMargins.top());
|
||||||
|
|
||||||
result.setHeight( lh );
|
result.setHeight( lh );
|
||||||
|
@ -237,8 +234,8 @@ QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
||||||
const QRectF& rect, QskAspect::Subcontrol subcontrol,
|
const QRectF& rect, QskAspect::Subcontrol subcontrol, int index ) const {
|
||||||
int index ) const {
|
|
||||||
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||||
|
|
||||||
if( subcontrol == Q::Text ) {
|
if( subcontrol == Q::Text ) {
|
||||||
|
@ -250,7 +247,8 @@ QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
||||||
|
|
||||||
QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnable,
|
QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnable,
|
||||||
QskAspect::Subcontrol subControl, int index ) const {
|
QskAspect::Subcontrol subControl, int index ) const {
|
||||||
auto radio = static_cast<const QskRadioBox*>( skinnable );
|
|
||||||
|
auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||||
auto states = Inherited::sampleStates( skinnable, subControl, index );
|
auto states = Inherited::sampleStates( skinnable, subControl, index );
|
||||||
|
|
||||||
return states | statesForIndex( radio, index );
|
return states | statesForIndex( radio, index );
|
||||||
|
@ -258,23 +256,17 @@ QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnabl
|
||||||
|
|
||||||
QSGNode* QskRadioBoxSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
QSGNode* QskRadioBoxSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
||||||
QskAspect::Subcontrol subcontrol, int index, QSGNode* node ) const {
|
QskAspect::Subcontrol subcontrol, int index, QSGNode* node ) const {
|
||||||
auto radio = static_cast<const QskRadioBox*>( skinnable );
|
|
||||||
|
auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||||
|
|
||||||
auto rect = sampleRect( skinnable, radio->contentsRect(),
|
auto rect = sampleRect( skinnable, radio->contentsRect(),
|
||||||
subcontrol, index );
|
subcontrol, index );
|
||||||
|
|
||||||
if( subcontrol == Q::Text ) {
|
if( subcontrol == Q::Text ) {
|
||||||
return QskSkinlet::updateTextNode( radio,
|
return QskSkinlet::updateTextNode( radio, node, rect, Qt::AlignLeft,
|
||||||
node,
|
radio->items()[ index ], subcontrol );
|
||||||
rect,
|
} else if ( subcontrol == Q::Button ) {
|
||||||
Qt::AlignLeft,
|
return QskSkinlet::updateBoxNode( radio, node, rect, subcontrol );
|
||||||
radio->items()[index],
|
|
||||||
subcontrol);
|
|
||||||
} else if (subcontrol == Q::Button) {
|
|
||||||
return QskSkinlet::updateBoxNode( radio,
|
|
||||||
node,
|
|
||||||
rect,
|
|
||||||
subcontrol );
|
|
||||||
} else if( subcontrol == Q::Symbol ) {
|
} else if( subcontrol == Q::Symbol ) {
|
||||||
auto symbol = QskStandardSymbol::NoSymbol;
|
auto symbol = QskStandardSymbol::NoSymbol;
|
||||||
auto color = radio->color( subcontrol ).rgb();
|
auto color = radio->color( subcontrol ).rgb();
|
||||||
|
@ -292,7 +284,7 @@ QSGNode* QskRadioBoxSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
||||||
*/
|
*/
|
||||||
QskColorFilter filter;
|
QskColorFilter filter;
|
||||||
filter.addColorSubstitution( Qt::black, color );
|
filter.addColorSubstitution( Qt::black, color );
|
||||||
auto colorSub = radio->color( subcontrol | statesForIndex(radio, index) );
|
auto colorSub = radio->color( subcontrol | statesForIndex( radio, index ) );
|
||||||
filter.addColorSubstitution( Qt::black, colorSub.rgb() );
|
filter.addColorSubstitution( Qt::black, colorSub.rgb() );
|
||||||
|
|
||||||
QskGraphic::fromGraphic( graphic, filter );
|
QskGraphic::fromGraphic( graphic, filter );
|
||||||
|
|
|
@ -39,7 +39,8 @@ class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet
|
||||||
|
|
||||||
QSizeF buttonSymbolSize( const QskRadioBox* radio ) const;
|
QSizeF buttonSymbolSize( const QskRadioBox* radio ) const;
|
||||||
QRectF textRect( const QskRadioBox*, const QRectF&, int ) const;
|
QRectF textRect( const QskRadioBox*, const QRectF&, int ) const;
|
||||||
QRectF buttonRect( const QskRadioBox*, const QskAspect::Subcontrol target, const QRectF&, double ) const;
|
QRectF buttonRect( const QskRadioBox*, const QskAspect::Subcontrol target, const QRectF&,
|
||||||
|
double ) const;
|
||||||
QRectF rippleRect( const QskRadioBox*, const QRectF& ) const;
|
QRectF rippleRect( const QskRadioBox*, const QRectF& ) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue