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 );
|
||||
|
||||
setSpacing(Q::Panel, 10_dp);
|
||||
setSpacing( Q::Panel, 10_dp );
|
||||
|
||||
setStrutSize( Q::Button, { 20_dp, 20_dp });
|
||||
setStrutSize( Q::Symbol, { 10_dp, 10_dp });
|
||||
setStrutSize( Q::Ripple, { 40_dp, 40_dp });
|
||||
setStrutSize( Q::Button, { 20_dp, 20_dp } );
|
||||
setStrutSize( Q::Symbol, { 10_dp, 10_dp } );
|
||||
setStrutSize( Q::Ripple, { 40_dp, 40_dp } );
|
||||
|
||||
setAlignment( Q::Symbol, Qt::AlignCenter );
|
||||
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::Ripple, 40_dp);
|
||||
setBoxShape( Q::Button, 20_dp );
|
||||
setBoxShape( Q::Ripple, 40_dp );
|
||||
setBoxBorderMetrics( Q::Button, 2_dp );
|
||||
setBoxBorderColors( Q::Button, m_pal.onBackground );
|
||||
setColor( Q::Text, m_pal.onBackground );
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace
|
|||
void setupPopup();
|
||||
void setupProgressBar();
|
||||
void setupPushButton();
|
||||
void setupRadioBox();
|
||||
void setupRadioBox();
|
||||
void setupScrollView();
|
||||
void setupSegmentedBar();
|
||||
void setupSeparator();
|
||||
|
@ -616,11 +616,11 @@ void Editor::setupRadioBox()
|
|||
|
||||
setSpacing(Q::Panel, qskDpiScaled( 10 ) );
|
||||
|
||||
setStrutSize( Q::Button, { qskDpiScaled( 20 ), qskDpiScaled( 20 ) });
|
||||
setStrutSize( Q::Symbol, { qskDpiScaled( 9 ), qskDpiScaled( 9 ) });
|
||||
setStrutSize( Q::Button, { qskDpiScaled( 20 ), qskDpiScaled( 20 ) } );
|
||||
setStrutSize( Q::Symbol, { qskDpiScaled( 9 ), qskDpiScaled( 9 ) }) ;
|
||||
|
||||
setBoxShape(Q::Button, qskDpiScaled( 20 ) );
|
||||
setBoxShape(Q::Ripple, qskDpiScaled( 40 ) );
|
||||
setBoxShape( Q::Button, qskDpiScaled( 20 ) );
|
||||
setBoxShape( Q::Ripple, qskDpiScaled( 40 ) );
|
||||
setBoxBorderMetrics( Q::Button, qskDpiScaled( 1 ) );
|
||||
|
||||
setBoxBorderColors( Q::Button, m_pal.darker125 );
|
||||
|
|
|
@ -9,9 +9,9 @@ QSK_SUBCONTROL( QskRadioBox, Symbol )
|
|||
QSK_SUBCONTROL( QskRadioBox, Text )
|
||||
QSK_SUBCONTROL( QskRadioBox, Ripple )
|
||||
|
||||
QSK_STATE( QskRadioBox, Selected, QskAspect::FirstUserState << 1)
|
||||
QSK_STATE( QskRadioBox, Pressed, QskAspect::FirstUserState << 2)
|
||||
QSK_STATE( QskRadioBox, Focused, QskAspect::FirstUserState << 3)
|
||||
QSK_STATE( QskRadioBox, Selected, QskAspect::FirstUserState << 1 )
|
||||
QSK_STATE( QskRadioBox, Pressed, QskAspect::FirstUserState << 2 )
|
||||
QSK_STATE( QskRadioBox, Focused, QskAspect::FirstUserState << 3 )
|
||||
|
||||
class QskRadioBox::PrivateData {
|
||||
public:
|
||||
|
@ -23,34 +23,30 @@ public:
|
|||
|
||||
QskRadioBox::QskRadioBox( QQuickItem* parent ) :
|
||||
Inherited( parent ),
|
||||
m_data( new PrivateData{} )
|
||||
{
|
||||
m_data( new PrivateData{} ) {
|
||||
setFocusPolicy( Qt::NoFocus );
|
||||
setAcceptedMouseButtons( Qt::LeftButton );
|
||||
|
||||
connect(this, &QskRadioBox::itemsChanged, this,
|
||||
[this]( const QStringList& items ) {
|
||||
if( items.count() > 0 ) {
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
} else {
|
||||
setFocusPolicy( Qt::NoFocus );
|
||||
}
|
||||
});
|
||||
[this]( const QStringList& items ) {
|
||||
if( items.count() > 0 ) {
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
} else {
|
||||
setFocusPolicy( Qt::NoFocus );
|
||||
}
|
||||
});
|
||||
|
||||
setFocusedIndex( -1 );
|
||||
}
|
||||
|
||||
QskRadioBox::QskRadioBox( const QStringList& list, QQuickItem* parent ) :
|
||||
QskRadioBox( parent )
|
||||
{
|
||||
QskRadioBox( parent ) {
|
||||
setItems( list );
|
||||
}
|
||||
|
||||
QskRadioBox::QskRadioBox( const QStringList& items,
|
||||
int selectedIndex,
|
||||
QQuickItem* parent ) :
|
||||
QskRadioBox( items, parent )
|
||||
{
|
||||
int selectedIndex, QQuickItem* parent ) :
|
||||
QskRadioBox( items, parent ) {
|
||||
if( selectedIndex >= 0 && selectedIndex < items.count() )
|
||||
{
|
||||
m_data->selectedIndex = selectedIndex;
|
||||
|
@ -59,7 +55,6 @@ QskRadioBox::QskRadioBox( const QStringList& items,
|
|||
|
||||
QRectF QskRadioBox::focusIndicatorRect() const {
|
||||
if( m_data->focusedIndex > -1) {
|
||||
|
||||
auto textRect = effectiveSkinlet()->sampleRect( this,
|
||||
contentsRect(), QskRadioBox::Text, m_data->focusedIndex );
|
||||
|
||||
|
@ -71,10 +66,10 @@ QRectF QskRadioBox::focusIndicatorRect() const {
|
|||
}
|
||||
|
||||
auto result = QRectF(
|
||||
qMin( textRect.x(), buttonRect.x() ),
|
||||
qMin( textRect.y(), buttonRect.y() ),
|
||||
buttonRect.width() + textRect.width(),
|
||||
qMax( buttonRect.height(), textRect.height() ));
|
||||
qMin( textRect.x(), buttonRect.x() ),
|
||||
qMin( textRect.y(), buttonRect.y() ),
|
||||
buttonRect.width() + textRect.width(),
|
||||
qMax( buttonRect.height(), textRect.height() ));
|
||||
|
||||
if( layoutMirroring() ) {
|
||||
result.setWidth(
|
||||
|
@ -106,7 +101,7 @@ int QskRadioBox::pressedIndex() const {
|
|||
|
||||
void QskRadioBox::setSelectedIndex( int index ) {
|
||||
if( index == m_data->selectedIndex
|
||||
|| index >= m_data->items.count() ) {
|
||||
|| index >= m_data->items.count() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -139,14 +134,15 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
|||
{
|
||||
case Qt::Key_Up:
|
||||
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 );
|
||||
event->setAccepted( true );
|
||||
update();
|
||||
return;
|
||||
case Qt::Key_Down:
|
||||
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 );
|
||||
event->setAccepted( true );
|
||||
update();
|
||||
|
@ -165,18 +161,17 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
|||
if( nextTabIndex >= items().size()
|
||||
|| nextTabIndex < 0 ) {
|
||||
Inherited::keyPressEvent( event );
|
||||
setFocusedIndex( -1);
|
||||
setFocusedIndex( -1 );
|
||||
update();
|
||||
} else {
|
||||
event->setAccepted( true );
|
||||
setFocusedIndex( (float) nextTabIndex );
|
||||
setFocusedIndex( ( float ) nextTabIndex );
|
||||
|
||||
const auto aspect = Ripple | QskAspect::Metric | QskAspect::Position;
|
||||
auto hint = animationHint(aspect | skinStates());
|
||||
if( hint.isValid()) {
|
||||
startTransition( aspect,
|
||||
hint,
|
||||
(float) currentTabIndex, (float) nextTabIndex );
|
||||
startTransition( aspect, hint,
|
||||
( float ) currentTabIndex, ( float ) nextTabIndex );
|
||||
}
|
||||
|
||||
update();
|
||||
|
@ -191,7 +186,7 @@ void QskRadioBox::keyReleaseEvent( QKeyEvent* e )
|
|||
|
||||
void QskRadioBox::mousePressEvent( QMouseEvent* e )
|
||||
{
|
||||
auto indexAtPosition = indexAt(e->localPos());
|
||||
auto indexAtPosition = indexAt( e->localPos() );
|
||||
|
||||
m_data->pressedIndex = indexAtPosition;
|
||||
m_data->selectedIndex = -1;
|
||||
|
@ -217,7 +212,7 @@ void QskRadioBox::focusInEvent( QFocusEvent* e ) {
|
|||
if( e->reason() == Qt::TabFocusReason ) {
|
||||
setFocusedIndex(0 );
|
||||
} else if( e->reason() == Qt::BacktabFocusReason ) {
|
||||
setFocusedIndex(items().size() - 1 );
|
||||
setFocusedIndex( items().size() - 1 );
|
||||
}
|
||||
|
||||
update();
|
||||
|
@ -235,8 +230,9 @@ int QskRadioBox::indexAt( const QPointF& target ) const {
|
|||
auto itemHeight = contentsRect().height() / items().size();
|
||||
auto index = target.y() / itemHeight;
|
||||
|
||||
if( index < 0 || index >= items().size() )
|
||||
if( index < 0 || index >= items().size() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ class QSK_EXPORT QskRadioBox : public QskControl
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( int selectedIndex
|
||||
READ selectedIndex
|
||||
WRITE setSelectedIndex
|
||||
NOTIFY selectedIndexChanged FINAL )
|
||||
READ selectedIndex
|
||||
WRITE setSelectedIndex
|
||||
NOTIFY selectedIndexChanged FINAL )
|
||||
|
||||
Q_PROPERTY( QStringList items
|
||||
READ items
|
||||
WRITE setItems
|
||||
NOTIFY itemsChanged FINAL )
|
||||
READ items
|
||||
WRITE setItems
|
||||
NOTIFY itemsChanged FINAL )
|
||||
|
||||
using Inherited = QskControl;
|
||||
|
||||
|
@ -30,7 +30,7 @@ class QSK_EXPORT QskRadioBox : public QskControl
|
|||
QskRadioBox( const QStringList&, int, QQuickItem* parent = nullptr );
|
||||
|
||||
QRectF focusIndicatorRect() const override;
|
||||
|
||||
|
||||
const QStringList& items() const;
|
||||
int selectedIndex() const;
|
||||
int pressedIndex() const;
|
||||
|
@ -43,7 +43,7 @@ class QSK_EXPORT QskRadioBox : public QskControl
|
|||
void selectedIndexChanged( int );
|
||||
void itemsChanged( const QStringList& );
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void keyPressEvent( QKeyEvent* ) override;
|
||||
void keyReleaseEvent( QKeyEvent* ) override;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
if( radio->selectedIndex() == index ) {
|
||||
|
@ -42,49 +42,48 @@ QskAspect::States statesForIndex(const QskRadioBox* radio, int index) {
|
|||
}
|
||||
|
||||
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 ) {
|
||||
return rippleRect(radio, contentsRect);
|
||||
return rippleRect( radio, contentsRect );
|
||||
}
|
||||
|
||||
return contentsRect;
|
||||
}
|
||||
|
||||
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 buttonMargins = skinnable->marginHint( Q::Button );
|
||||
const auto symbolMargins = skinnable->marginHint( Q::Symbol );
|
||||
|
||||
qreal maxTextWidth = 0;
|
||||
for(auto& item : radio->items() ) {
|
||||
for( auto& item : radio->items() ) {
|
||||
maxTextWidth = std::max( maxTextWidth, qskHorizontalAdvance( font, item ) );
|
||||
}
|
||||
|
||||
auto buttonWidth = radio->strutSizeHint(Q::Button).width();
|
||||
auto symbolWidth = radio->strutSizeHint(Q::Symbol).width();
|
||||
auto buttonWidth = radio->strutSizeHint( Q::Button ).width();
|
||||
auto symbolWidth = radio->strutSizeHint( Q::Symbol ).width();
|
||||
|
||||
maxTextWidth += textMargins.left() + textMargins.right();
|
||||
buttonWidth += buttonMargins.left() + buttonMargins.right();
|
||||
symbolWidth += symbolMargins.left() + symbolMargins.right();
|
||||
|
||||
auto spacing = radio->spacingHint(Q::Panel);
|
||||
return QSizeF( maxTextWidth + qMax(buttonWidth, symbolWidth),
|
||||
( lineHeight( radio ) + spacing ) * radio->items().size()
|
||||
- spacing );
|
||||
auto spacing = radio->spacingHint( Q::Panel );
|
||||
return QSizeF( maxTextWidth + qMax( buttonWidth, symbolWidth ),
|
||||
( lineHeight( radio ) + spacing ) * radio->items().size() - spacing );
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
|
@ -103,7 +102,8 @@ QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
|||
case RippleRole:
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
|||
|
||||
qreal QskRadioBoxSkinlet::lineHeight(const QskRadioBox* target) const {
|
||||
auto strutHight = qMax( target->strutSizeHint( Q::Button ).height(),
|
||||
target->strutSizeHint( Q::Text ).height() );
|
||||
target->strutSizeHint( Q::Text ).height() );
|
||||
const auto textMargins = target->marginHint( Q::Text );
|
||||
auto fontHeight = target->effectiveFontHeight( Q::Text );
|
||||
fontHeight += textMargins.top() + textMargins.bottom();
|
||||
|
@ -122,8 +122,7 @@ qreal QskRadioBoxSkinlet::lineHeight(const QskRadioBox* target) const {
|
|||
return qMax( strutHight, fontHeight );
|
||||
}
|
||||
|
||||
int QskRadioBoxSkinlet::sampleCount( const QskSkinnable* skinnable,
|
||||
QskAspect::Subcontrol ) const {
|
||||
int QskRadioBoxSkinlet::sampleCount( const QskSkinnable* skinnable, QskAspect::Subcontrol ) const {
|
||||
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||
return radio->items().count();
|
||||
}
|
||||
|
@ -140,8 +139,7 @@ QSizeF QskRadioBoxSkinlet::buttonSymbolSize( const QskRadioBox* radio ) const {
|
|||
qMax( buttonStrut.height(), symbolStrut.height() ) );
|
||||
}
|
||||
|
||||
QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio,
|
||||
const QRectF& rect ) const {
|
||||
QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio, const QRectF& rect ) const {
|
||||
auto ripplePosition = radio->positionHint( Q::Ripple );
|
||||
|
||||
if( ripplePosition < 0 ) {
|
||||
|
@ -157,16 +155,15 @@ QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio,
|
|||
}
|
||||
|
||||
QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
||||
const QskAspect::Subcontrol target,
|
||||
const QRectF& rect, double index ) const {
|
||||
const QskAspect::Subcontrol target, const QRectF& rect, double index ) const {
|
||||
if( index < 0 ) {
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
auto margins = radio->marginHint( target );
|
||||
|
@ -177,23 +174,23 @@ QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
|||
|
||||
// Vertical positioning
|
||||
auto alignHeight = maxSize.height() - withMargins.height();
|
||||
if( alignment.testFlag( Qt::AlignVCenter )) {
|
||||
result.moveTop( result.top() + alignHeight / 2);
|
||||
if( alignment.testFlag( Qt::AlignVCenter ) ) {
|
||||
result.moveTop( result.top() + alignHeight / 2 );
|
||||
} else if( alignment.testFlag( Qt::AlignBottom ) ) {
|
||||
result.moveTop( result.top() + alignHeight );
|
||||
}
|
||||
result.moveTop( result.top() + margins.top());
|
||||
result.moveTop( result.top() + margins.top() );
|
||||
|
||||
// Horizontal positioning
|
||||
auto alignWidth = 0;
|
||||
if( alignment.testFlag( Qt::AlignHCenter ) ) {
|
||||
alignWidth = (maxSize.width() - withMargins.width()) / 2;
|
||||
alignWidth = ( maxSize.width() - withMargins.width() ) / 2;
|
||||
} else if ( alignment.testFlag( Qt::AlignRight )) {
|
||||
alignWidth = maxSize.width() - withMargins.width();
|
||||
}
|
||||
|
||||
if( radio->layoutMirroring() ) {
|
||||
result.moveRight( rect.width() - (alignWidth + margins.right() ));
|
||||
result.moveRight( rect.width() - ( alignWidth + margins.right() ) );
|
||||
} else {
|
||||
result.moveLeft( margins.left() + alignWidth );
|
||||
}
|
||||
|
@ -202,22 +199,22 @@ QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
|||
}
|
||||
|
||||
QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
||||
const QRectF& rect, int index ) const {
|
||||
auto text = radio->items()[index];
|
||||
const QRectF& rect, int index ) const {
|
||||
auto text = radio->items()[ index ];
|
||||
|
||||
if(text.isEmpty()) {
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
QRectF result = rect;
|
||||
auto spacing = radio->spacingHint(Q::Panel);
|
||||
auto spacing = radio->spacingHint( Q::Panel );
|
||||
auto lh = lineHeight( radio );
|
||||
const auto textMargins = radio->marginHint( Q::Text );
|
||||
const auto font = radio->effectiveFont( Q::Text );
|
||||
|
||||
result.moveTop( index * ( lh + spacing )
|
||||
+ lh - radio->effectiveFontHeight(Q::Text)
|
||||
+ textMargins.top());
|
||||
+ lh - radio->effectiveFontHeight( Q::Text )
|
||||
+ textMargins.top());
|
||||
|
||||
result.setHeight( lh );
|
||||
result.setWidth( qskHorizontalAdvance( font, text ) );
|
||||
|
@ -228,7 +225,7 @@ QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
|||
|
||||
if( radio->layoutMirroring() ) {
|
||||
result.moveLeft( rect.width() - textMargins.right()
|
||||
- result.width() - buttonWidth);
|
||||
- result.width() - buttonWidth);
|
||||
} else {
|
||||
result.moveLeft( buttonWidth + textMargins.left() );
|
||||
}
|
||||
|
@ -237,8 +234,8 @@ QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
|||
}
|
||||
|
||||
QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
||||
const QRectF& rect, QskAspect::Subcontrol subcontrol,
|
||||
int index ) const {
|
||||
const QRectF& rect, QskAspect::Subcontrol subcontrol, int index ) const {
|
||||
|
||||
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||
|
||||
if( subcontrol == Q::Text ) {
|
||||
|
@ -250,7 +247,8 @@ QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
|||
|
||||
QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnable,
|
||||
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 );
|
||||
|
||||
return states | statesForIndex( radio, index );
|
||||
|
@ -258,23 +256,17 @@ QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnabl
|
|||
|
||||
QSGNode* QskRadioBoxSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
||||
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(),
|
||||
subcontrol, index );
|
||||
|
||||
if( subcontrol == Q::Text ) {
|
||||
return QskSkinlet::updateTextNode( radio,
|
||||
node,
|
||||
rect,
|
||||
Qt::AlignLeft,
|
||||
radio->items()[index],
|
||||
subcontrol);
|
||||
} else if (subcontrol == Q::Button) {
|
||||
return QskSkinlet::updateBoxNode( radio,
|
||||
node,
|
||||
rect,
|
||||
subcontrol );
|
||||
return QskSkinlet::updateTextNode( radio, node, rect, Qt::AlignLeft,
|
||||
radio->items()[ index ], subcontrol );
|
||||
} else if ( subcontrol == Q::Button ) {
|
||||
return QskSkinlet::updateBoxNode( radio, node, rect, subcontrol );
|
||||
} else if( subcontrol == Q::Symbol ) {
|
||||
auto symbol = QskStandardSymbol::NoSymbol;
|
||||
auto color = radio->color( subcontrol ).rgb();
|
||||
|
@ -292,7 +284,7 @@ QSGNode* QskRadioBoxSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
|||
*/
|
||||
QskColorFilter filter;
|
||||
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() );
|
||||
|
||||
QskGraphic::fromGraphic( graphic, filter );
|
||||
|
|
|
@ -7,20 +7,20 @@ class QskRadioBox;
|
|||
|
||||
class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet
|
||||
{
|
||||
Q_GADGET
|
||||
Q_GADGET
|
||||
|
||||
using Inherited = QskSkinlet;
|
||||
|
||||
public:
|
||||
enum NodeRole
|
||||
public:
|
||||
enum NodeRole
|
||||
{
|
||||
PanelRole,
|
||||
ButtonRole,
|
||||
SymbolRole,
|
||||
TextRole,
|
||||
RippleRole,
|
||||
PanelRole,
|
||||
ButtonRole,
|
||||
SymbolRole,
|
||||
TextRole,
|
||||
RippleRole,
|
||||
|
||||
RoleCount
|
||||
RoleCount
|
||||
};
|
||||
|
||||
Q_INVOKABLE QskRadioBoxSkinlet( QskSkin* = nullptr );
|
||||
|
@ -39,13 +39,14 @@ class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet
|
|||
|
||||
QSizeF buttonSymbolSize( const QskRadioBox* radio ) 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;
|
||||
|
||||
|
||||
QskAspect::States sampleStates( const QskSkinnable*,
|
||||
QskAspect::Subcontrol, int index ) const override;
|
||||
|
||||
|
||||
protected:
|
||||
QSGNode* updateSubNode( const QskSkinnable*,
|
||||
quint8 nodeRole, QSGNode* ) const override;
|
||||
|
|
Loading…
Reference in New Issue