clang-format + clang-tidy improvements

This commit is contained in:
Vogel, Rick 2023-02-17 15:22:40 +01:00
parent 890ae64652
commit 1faf2e091c
4 changed files with 721 additions and 520 deletions

View File

@ -4,30 +4,30 @@
*****************************************************************************/ *****************************************************************************/
#include "QskSpinBox.h" #include "QskSpinBox.h"
#include <QskLinearBox.h> #include <QGuiApplication>
#include <QskGridBox.h>
#include <QskTextInput.h>
#include <QRegExpValidator> #include <QRegExpValidator>
#include <QskBoxShapeMetrics.h> #include <QStyleHints>
#include <QskBoxBorderColors.h> #include <QskBoxBorderColors.h>
#include <QskBoxBorderMetrics.h> #include <QskBoxBorderMetrics.h>
#include <QskSkinlet.h> #include <QskBoxShapeMetrics.h>
#include <QskEvent.h> #include <QskEvent.h>
#include <QtMath> #include <QskGridBox.h>
#include <QGuiApplication>
#include <QStyleHints>
#include <QskIntervalF.h> #include <QskIntervalF.h>
#include <QskLinearBox.h>
#include <QskSkinlet.h>
#include <QskTextInput.h>
#include <QtMath>
#include <array> #include <array>
QSK_SUBCONTROL(QskSpinBox, IncrementPanel) QSK_SUBCONTROL( QskSpinBox, IncrementPanel )
QSK_SUBCONTROL(QskSpinBox, DecrementPanel) QSK_SUBCONTROL( QskSpinBox, DecrementPanel )
QSK_SUBCONTROL(QskSpinBox, IncrementText) QSK_SUBCONTROL( QskSpinBox, IncrementText )
QSK_SUBCONTROL(QskSpinBox, DecrementText) QSK_SUBCONTROL( QskSpinBox, DecrementText )
QSK_SUBCONTROL(QskSpinBox, Text) QSK_SUBCONTROL( QskSpinBox, Text )
QSK_SUBCONTROL(QskSpinBox, TextPanel) QSK_SUBCONTROL( QskSpinBox, TextPanel )
QSK_SUBCONTROL(QskSpinBox, Layout) QSK_SUBCONTROL( QskSpinBox, Layout )
QSK_SYSTEM_STATE(QskSpinBox, Pressed, ( QskAspect::QskAspect::FirstSystemState << 0)) QSK_SYSTEM_STATE( QskSpinBox, Pressed, ( QskAspect::QskAspect::FirstSystemState << 0 ) )
namespace aliased_enum namespace aliased_enum
{ {
@ -39,70 +39,160 @@ namespace aliased_enum
class QskSpinBox::PrivateData class QskSpinBox::PrivateData
{ {
public: public:
explicit PrivateData( QskSpinBox* const parent )
explicit PrivateData(QskSpinBox* const parent) : q(parent) : q( parent )
{ {
} }
FocusIndeces defaultFocusIndex() const FocusIndeces defaultFocusIndex() const
{ {
const auto layout = q->alignmentHint(QskSpinBox::Layout); const auto layout = q->alignmentHint( QskSpinBox::Layout );
if(layout == Qt::AlignLeft) return QskSpinBox::Textbox; if ( layout == Qt::AlignLeft )
if(layout == Qt::AlignRight) return QskSpinBox::Decrement; {
if(layout == Qt::AlignHCenter) return QskSpinBox::Decrement; return QskSpinBox::Textbox;
if(layout == Qt::AlignTop) return QskSpinBox::Textbox; }
if(layout == Qt::AlignBottom) return QskSpinBox::Increment; if ( layout == Qt::AlignRight )
if(layout == Qt::AlignVCenter) return QskSpinBox::Increment; {
if(layout == (Qt::AlignLeft | Qt::AlignVCenter)) return QskSpinBox::Textbox; return QskSpinBox::Decrement;
if(layout == (Qt::AlignRight | Qt::AlignVCenter)) return QskSpinBox::Increment; }
if(layout == (Qt::AlignTop | Qt::AlignHCenter)) return QskSpinBox::Textbox; if ( layout == Qt::AlignHCenter )
if(layout == (Qt::AlignBottom | Qt::AlignHCenter)) return QskSpinBox::Decrement; {
return QskSpinBox::Decrement;
}
if ( layout == Qt::AlignTop )
{
return QskSpinBox::Textbox;
}
if ( layout == Qt::AlignBottom )
{
return QskSpinBox::Increment;
}
if ( layout == Qt::AlignVCenter )
{
return QskSpinBox::Increment;
}
if ( layout == ( Qt::AlignLeft | Qt::AlignVCenter ) )
{
return QskSpinBox::Textbox;
}
if ( layout == ( Qt::AlignRight | Qt::AlignVCenter ) )
{
return QskSpinBox::Increment;
}
if ( layout == ( Qt::AlignTop | Qt::AlignHCenter ) )
{
return QskSpinBox::Textbox;
}
if ( layout == ( Qt::AlignBottom | Qt::AlignHCenter ) )
{
return QskSpinBox::Decrement;
}
return None; return None;
} }
FocusIndeces nextFocusIndex() const FocusIndeces nextFocusIndex() const
{ {
const auto layout = q->alignmentHint(QskSpinBox::Layout); const auto layout = q->alignmentHint( QskSpinBox::Layout );
using namespace aliased_enum; using namespace aliased_enum;
// [0][1][2][3] := index // [0][1][2][3] := index
// [D][T][I][N] := control // [D][T][I][N] := control
using LUT = std::array<QskSpinBox::FocusIndeces,4>; using LUT = std::array< QskSpinBox::FocusIndeces, 4 >;
if(layout == Qt::AlignLeft) return LUT{I,D,N,T}[m_focusIndex]; if ( layout == Qt::AlignLeft )
if(layout == Qt::AlignRight) return LUT{I,N,T,D}[m_focusIndex]; {
if(layout == Qt::AlignHCenter) return LUT{T,I,N,D}[m_focusIndex]; return LUT{ I, D, N, T }[ m_focusIndex ];
if(layout == Qt::AlignTop) return LUT{N,I,D,T}[m_focusIndex]; }
if(layout == Qt::AlignBottom) return LUT{T,N,D,I}[m_focusIndex]; if ( layout == Qt::AlignRight )
if(layout == Qt::AlignVCenter) return LUT{N,D,T,I}[m_focusIndex]; {
if(layout == (Qt::AlignLeft | Qt::AlignVCenter)) return LUT{N,I,D,T}[m_focusIndex]; return LUT{ I, N, T, D }[ m_focusIndex ];
if(layout == (Qt::AlignRight | Qt::AlignVCenter)) return LUT{T,N,D,I}[m_focusIndex]; }
if(layout == (Qt::AlignTop | Qt::AlignHCenter)) return LUT{I,D,N,T}[m_focusIndex]; if ( layout == Qt::AlignHCenter )
if(layout == (Qt::AlignBottom | Qt::AlignHCenter)) return LUT{I,N,T,D}[m_focusIndex]; {
return LUT{ T, I, N, D }[ m_focusIndex ];
}
if ( layout == Qt::AlignTop )
{
return LUT{ N, I, D, T }[ m_focusIndex ];
}
if ( layout == Qt::AlignBottom )
{
return LUT{ T, N, D, I }[ m_focusIndex ];
}
if ( layout == Qt::AlignVCenter )
{
return LUT{ N, D, T, I }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignLeft | Qt::AlignVCenter ) )
{
return LUT{ N, I, D, T }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignRight | Qt::AlignVCenter ) )
{
return LUT{ T, N, D, I }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignTop | Qt::AlignHCenter ) )
{
return LUT{ I, D, N, T }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignBottom | Qt::AlignHCenter ) )
{
return LUT{ I, N, T, D }[ m_focusIndex ];
}
return None; return None;
} }
FocusIndeces previousFocusIndex() const FocusIndeces previousFocusIndex() const
{ {
const auto layout = q->alignmentHint(QskSpinBox::Layout); const auto layout = q->alignmentHint( QskSpinBox::Layout );
using namespace aliased_enum; using namespace aliased_enum;
// [0][1][2][3] := index // [0][1][2][3] := index
// [D][T][I][N] := control // [D][T][I][N] := control
using LUT = std::array<FocusIndeces,4>; using LUT = std::array< FocusIndeces, 4 >;
if(layout == Qt::AlignLeft) return LUT{T,N,D,I}[m_focusIndex]; if ( layout == Qt::AlignLeft )
if(layout == Qt::AlignRight) return LUT{N,I,D,T}[m_focusIndex]; {
if(layout == Qt::AlignHCenter) return LUT{N,D,T,I}[m_focusIndex]; return LUT{ T, N, D, I }[ m_focusIndex ];
if(layout == Qt::AlignTop) return LUT{I,N,T,D}[m_focusIndex]; }
if(layout == Qt::AlignBottom) return LUT{I,D,N,T}[m_focusIndex]; if ( layout == Qt::AlignRight )
if(layout == Qt::AlignVCenter) return LUT{T,I,N,D}[m_focusIndex]; {
if(layout == (Qt::AlignLeft | Qt::AlignVCenter)) return LUT{I,N,T,D}[m_focusIndex]; return LUT{ N, I, D, T }[ m_focusIndex ];
if(layout == (Qt::AlignRight | Qt::AlignVCenter)) return LUT{I,D,N,T}[m_focusIndex]; }
if(layout == (Qt::AlignTop | Qt::AlignHCenter)) return LUT{T,N,D,I}[m_focusIndex]; if ( layout == Qt::AlignHCenter )
if(layout == (Qt::AlignBottom | Qt::AlignHCenter)) return LUT{N,I,D,T}[m_focusIndex]; {
return LUT{ N, D, T, I }[ m_focusIndex ];
}
if ( layout == Qt::AlignTop )
{
return LUT{ I, N, T, D }[ m_focusIndex ];
}
if ( layout == Qt::AlignBottom )
{
return LUT{ I, D, N, T }[ m_focusIndex ];
}
if ( layout == Qt::AlignVCenter )
{
return LUT{ T, I, N, D }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignLeft | Qt::AlignVCenter ) )
{
return LUT{ I, N, T, D }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignRight | Qt::AlignVCenter ) )
{
return LUT{ I, D, N, T }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignTop | Qt::AlignHCenter ) )
{
return LUT{ T, N, D, I }[ m_focusIndex ];
}
if ( layout == ( Qt::AlignBottom | Qt::AlignHCenter ) )
{
return LUT{ N, I, D, T }[ m_focusIndex ];
}
return None; return None;
} }
@ -115,61 +205,76 @@ public:
void focusNext() void focusNext()
{ {
const auto index = nextFocusIndex(); const auto index = nextFocusIndex();
setFocus(index); setFocus( index );
} }
void focusPrevious() void focusPrevious()
{ {
const auto index = previousFocusIndex(); const auto index = previousFocusIndex();
setFocus(index); setFocus( index );
} }
void focusDefault() void focusDefault()
{ {
const auto index = defaultFocusIndex(); const auto index = defaultFocusIndex();
setFocus(index); setFocus( index );
} }
void setFocus(const FocusIndeces index) void setFocus( const FocusIndeces index )
{ {
using namespace aliased_enum; using namespace aliased_enum;
Q_ASSERT(index == D || index == T || index == I || index == N); Q_ASSERT( index == D || index == T || index == I || index == N );
if(index == D || index == T || index == I || index == N) if ( index == D || index == T || index == I || index == N )
{ {
m_focusIndex = index; m_focusIndex = index;
Q_EMIT q->focusIndexChanged(m_focusIndex); Q_EMIT q->focusIndexChanged( m_focusIndex );
q->update(); q->update();
} }
} }
QRectF focusIndicatorRect() const QRectF focusIndicatorRect() const
{ {
using namespace aliased_enum; if ( m_focusIndex == QskSpinBox::Decrement )
if(m_focusIndex == D) return q->subControlRect(QskSpinBox::DecrementPanel); {
if(m_focusIndex == I) return q->subControlRect(QskSpinBox::IncrementPanel); return q->subControlRect( QskSpinBox::DecrementPanel );
if(m_focusIndex == T) return q->subControlRect(QskSpinBox::TextPanel); }
if ( m_focusIndex == QskSpinBox::Increment )
{
return q->subControlRect( QskSpinBox::IncrementPanel );
}
if ( m_focusIndex == QskSpinBox::Textbox )
{
return q->subControlRect( QskSpinBox::TextPanel );
}
return {}; return {};
} }
void saveMousePosition(const QPointF& pos) void saveMousePosition( const QPointF& pos )
{ {
q->setSkinHint(QskSpinBox::Layout | QskAspect::Metric | QskAspect::Position, pos ); q->setSkinHint( QskSpinBox::Layout | QskAspect::Metric | QskAspect::Position, pos );
} }
private: bool focusNow() const
{
const auto focusOnClick = ( q->focusPolicy() & Qt::ClickFocus ) == Qt::ClickFocus;
const auto focusOnTouchRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease();
return focusOnClick && !focusOnTouchRelease;
}
private:
QskSpinBox* const q; QskSpinBox* const q;
FocusIndeces m_focusIndex = FocusIndeces::None; FocusIndeces m_focusIndex = FocusIndeces::None;
}; };
using S = QskSpinBox; using S = QskSpinBox;
QskSpinBox::QskSpinBox(QQuickItem* const parent) QskSpinBox::QskSpinBox( QQuickItem* const parent )
: Inherited(parent) : Inherited( parent )
, m_data(std::make_unique<PrivateData>(this)) , m_data( std::make_unique< PrivateData >( this ) )
{ {
setBoundaries(0.0,1.0); setBoundaries( 0.0, 1.0 );
setAcceptHoverEvents(true); setAcceptHoverEvents( true );
setAcceptedMouseButtons(Qt::LeftButton); setAcceptedMouseButtons( Qt::LeftButton );
setFocusPolicy( Qt::StrongFocus ); setFocusPolicy( Qt::StrongFocus );
connect( this, &S::focusIndexChanged, this, &S::focusIndicatorRectChanged ); connect( this, &S::focusIndexChanged, this, &S::focusIndicatorRectChanged );
@ -177,56 +282,56 @@ QskSpinBox::QskSpinBox(QQuickItem* const parent)
QskSpinBox::~QskSpinBox() = default; QskSpinBox::~QskSpinBox() = default;
void QskSpinBox::hoverEnterEvent(QHoverEvent* event) void QskSpinBox::hoverEnterEvent( QHoverEvent* const event )
{ {
m_data->saveMousePosition( qskHoverPosition( event ) ); m_data->saveMousePosition( qskHoverPosition( event ) );
} }
void QskSpinBox::hoverLeaveEvent(QHoverEvent* event) void QskSpinBox::hoverLeaveEvent( QHoverEvent* /*const event */ )
{ {
m_data->saveMousePosition( {} ); m_data->saveMousePosition( {} );
} }
void QskSpinBox::hoverMoveEvent(QHoverEvent *event) void QskSpinBox::hoverMoveEvent( QHoverEvent* const event )
{ {
m_data->saveMousePosition( qskHoverPosition( event ) ); m_data->saveMousePosition( qskHoverPosition( event ) );
} }
void QskSpinBox::mouseReleaseEvent(QMouseEvent *event) void QskSpinBox::mouseReleaseEvent( QMouseEvent* const event )
{ {
m_data->saveMousePosition( qskMousePosition( event ) ); m_data->saveMousePosition( qskMousePosition( event ) );
const auto focus = ( focusPolicy() & Qt::ClickFocus ) == Qt::ClickFocus && !QGuiApplication::styleHints()->setFocusOnTouchRelease(); const auto focus = m_data->focusNow();
if(subControlRect(QskSpinBox::IncrementPanel).contains( event->pos() )) if ( subControlRect( QskSpinBox::IncrementPanel ).contains( event->pos() ) )
{ {
increment(+stepSize()); increment( +stepSize() );
if( focus ) if ( focus )
{ {
m_data->setFocus(Increment); m_data->setFocus( Increment );
} }
return; return;
} }
if(subControlRect(QskSpinBox::DecrementPanel).contains( event->pos() )) if ( subControlRect( QskSpinBox::DecrementPanel ).contains( event->pos() ) )
{ {
increment(-stepSize()); increment( -stepSize() );
if( focus ) if ( focus )
{ {
m_data->setFocus(Decrement); m_data->setFocus( Decrement );
} }
return; return;
} }
if(subControlRect(QskSpinBox::TextPanel).contains( event->pos() )) if ( subControlRect( QskSpinBox::TextPanel ).contains( event->pos() ) )
{ {
if( focus ) if ( focus )
{ {
m_data->setFocus(Textbox); m_data->setFocus( Textbox );
} }
return; return;
@ -235,26 +340,26 @@ void QskSpinBox::mouseReleaseEvent(QMouseEvent *event)
event->ignore(); event->ignore();
} }
void QskSpinBox::mousePressEvent(QMouseEvent *event) void QskSpinBox::mousePressEvent( QMouseEvent* const event )
{ {
m_data->saveMousePosition( -1 * qskMousePosition( event ) ); m_data->saveMousePosition( -1 * qskMousePosition( event ) );
const auto focus = ( focusPolicy() & Qt::ClickFocus ) == Qt::ClickFocus && !QGuiApplication::styleHints()->setFocusOnTouchRelease(); const auto focus = m_data->focusNow();
if(subControlRect(QskSpinBox::IncrementPanel).contains( event->pos() )) if ( subControlRect( QskSpinBox::IncrementPanel ).contains( event->pos() ) )
{ {
if( focus ) if ( focus )
{ {
m_data->setFocus(QskSpinBox::Increment); m_data->setFocus( QskSpinBox::Increment );
} }
return; return;
} }
if(subControlRect(QskSpinBox::DecrementPanel).contains( event->pos() )) if ( subControlRect( QskSpinBox::DecrementPanel ).contains( event->pos() ) )
{ {
if( focus ) if ( focus )
{ {
m_data->setFocus(QskSpinBox::Decrement); m_data->setFocus( QskSpinBox::Decrement );
} }
return; return;
} }
@ -262,57 +367,64 @@ void QskSpinBox::mousePressEvent(QMouseEvent *event)
event->ignore(); event->ignore();
} }
void QskSpinBox::keyPressEvent(QKeyEvent *event) void QskSpinBox::keyPressEvent( QKeyEvent* const event )
{ {
switch( event->key() ) switch ( event->key() )
{ {
case Qt::Key_Plus: case Qt::Key_Plus:
case Qt::Key_Up: case Qt::Key_Up:
case Qt::Key_Right: case Qt::Key_Right:
increment(+stepSize()); increment( +stepSize() );
return; return;
case Qt::Key_Minus: case Qt::Key_Minus:
case Qt::Key_Down: case Qt::Key_Down:
case Qt::Key_Left: case Qt::Key_Left:
increment(-stepSize()); increment( -stepSize() );
return; return;
case Qt::Key_Select: case Qt::Key_Select:
case Qt::Key_Space: case Qt::Key_Space:
if(focusIndex() == Increment) increment(+stepSize()); if ( focusIndex() == Increment )
if(focusIndex() == Decrement) increment(-stepSize()); {
increment( +stepSize() );
}
if ( focusIndex() == Decrement )
{
increment( -stepSize() );
}
return; return;
default: default:
{ break;
}
const int steps = qskFocusChainIncrement( event ); const int steps = qskFocusChainIncrement( event );
if(steps < 0) if ( steps < 0 )
{ {
for(int i = 0; i < qAbs(steps); ++i) for ( int i = 0; i < qAbs( steps ); ++i )
{ {
m_data->focusPrevious(); m_data->focusPrevious();
} }
} }
if(steps > 0) if ( steps > 0 )
{ {
for(int i = 0; i < steps; ++i) for ( int i = 0; i < steps; ++i )
{ {
m_data->focusNext(); m_data->focusNext();
} }
} }
if(steps != 0 && m_data->focusIndex() != None) if ( steps != 0 && m_data->focusIndex() != None )
{ {
return; return;
} }
}
}
Inherited::keyPressEvent( event ); Inherited::keyPressEvent( event );
} }
void QskSpinBox::keyReleaseEvent( QKeyEvent* event ) void QskSpinBox::keyReleaseEvent( QKeyEvent* const event )
{ {
if( event->key() == Qt::Key_Select || event->key() == Qt::Key_Space ) if ( event->key() == Qt::Key_Select || event->key() == Qt::Key_Space )
{ {
return; return;
} }
@ -320,32 +432,32 @@ void QskSpinBox::keyReleaseEvent( QKeyEvent* event )
Inherited::keyReleaseEvent( event ); Inherited::keyReleaseEvent( event );
} }
void QskSpinBox::focusInEvent(QFocusEvent *event) void QskSpinBox::focusInEvent( QFocusEvent* const event )
{ {
switch( event->reason() ) if ( event->reason() == Qt::TabFocusReason )
{ {
case Qt::TabFocusReason:
m_data->focusNext(); m_data->focusNext();
break; return;
}
case Qt::BacktabFocusReason: if ( event->reason() == Qt::BacktabFocusReason )
{
m_data->focusPrevious(); m_data->focusPrevious();
break; return;
}
default: if ( m_data->focusIndex() == QskSpinBox::None )
if(m_data->focusIndex() == QskSpinBox::None)
{ {
m_data->focusDefault(); m_data->focusDefault();
return; return;
} }
}
Inherited::focusInEvent( event ); Inherited::focusInEvent( event );
} }
QRectF QskSpinBox::focusIndicatorRect() const QRectF QskSpinBox::focusIndicatorRect() const
{ {
auto rect = m_data->focusIndicatorRect(); return m_data->focusIndicatorRect();
return rect;
} }
QskSpinBox::FocusIndeces QskSpinBox::focusIndex() const QskSpinBox::FocusIndeces QskSpinBox::focusIndex() const

View File

@ -5,43 +5,51 @@
#pragma once #pragma once
#include <QskBoundedValueInput.h>
#include <QskControl.h> #include <QskControl.h>
#include <QskPushButton.h> #include <QskPushButton.h>
#include <QskBoundedValueInput.h>
class QSK_EXPORT QskSpinBox : public QskBoundedValueInput class QSK_EXPORT QskSpinBox : public QskBoundedValueInput
{ {
Q_OBJECT Q_OBJECT
using Inherited = QskBoundedValueInput; using Inherited = QskBoundedValueInput;
public:
enum FocusIndeces : int { Decrement = 0, Textbox = 1, Increment = 2, None = 3 };
Q_ENUM(FocusIndeces)
Q_PROPERTY(FocusIndeces focusIndex READ focusIndex NOTIFY focusIndexChanged) public:
QSK_SUBCONTROLS(IncrementPanel, DecrementPanel, IncrementText, DecrementText, TextPanel, Text, Layout) enum FocusIndeces : int
{
Decrement = 0,
Textbox = 1,
Increment = 2,
None = 3
};
Q_ENUM( FocusIndeces )
Q_PROPERTY( FocusIndeces focusIndex READ focusIndex NOTIFY focusIndexChanged )
QSK_SUBCONTROLS(
IncrementPanel, DecrementPanel, IncrementText, DecrementText, TextPanel, Text, Layout )
QSK_STATES( Pressed ) QSK_STATES( Pressed )
explicit QskSpinBox( QQuickItem* parent = nullptr ); explicit QskSpinBox( QQuickItem* parent = nullptr );
~QskSpinBox() override; ~QskSpinBox() override;
FocusIndeces focusIndex() const; FocusIndeces focusIndex() const;
Q_SIGNALS: Q_SIGNALS:
void focusIndexChanged(int index); void focusIndexChanged( int index );
private: private:
void hoverEnterEvent( QHoverEvent* event) override; void hoverEnterEvent( QHoverEvent* event ) override;
void hoverLeaveEvent( QHoverEvent* event) override; void hoverLeaveEvent( QHoverEvent* event ) override;
void hoverMoveEvent( QHoverEvent* event) override; void hoverMoveEvent( QHoverEvent* event ) override;
void mouseReleaseEvent(QMouseEvent* event) override; void mouseReleaseEvent( QMouseEvent* event ) override;
void mousePressEvent(QMouseEvent* event) override; void mousePressEvent( QMouseEvent* event ) override;
void keyPressEvent( QKeyEvent* event ) override; void keyPressEvent( QKeyEvent* event ) override;
void keyReleaseEvent( QKeyEvent* event ) override; void keyReleaseEvent( QKeyEvent* event ) override;
void focusInEvent(QFocusEvent* event) override; void focusInEvent( QFocusEvent* event ) override;
QRectF focusIndicatorRect() const override; QRectF focusIndicatorRect() const override;
class PrivateData; class PrivateData;
std::unique_ptr<PrivateData> m_data; std::unique_ptr< PrivateData > m_data;
}; };

View File

@ -8,220 +8,289 @@
#include <QFontMetrics> #include <QFontMetrics>
#include <array> #include <array>
const auto INCREMENT_TEXT = QStringLiteral("+"); namespace
const auto DECREMENT_TEXT = QStringLiteral("-");
enum SampleIndeces { Dec = 0, Txt = 1, Inc = 2, Count };
QskSpinBoxSkinlet::QskSpinBoxSkinlet(QskSkin *)
{ {
setNodeRoles({IncPanel, IncText, DecPanel, DecText, TextPanel, TextText}); inline QPointF cursorPosSkinHint( const QskSpinBox& spinbox )
{
const auto aspect = QskSpinBox::Layout | QskAspect::Metric | QskAspect::Position;
return spinbox.effectiveSkinHint( aspect ).toPointF();
}
enum SampleIndeces
{
Dec = 0,
Txt = 1,
Inc = 2,
Count
};
} }
int QskSpinBoxSkinlet::sampleCount(const QskSkinnable *, QskAspect::Subcontrol) const QskSpinBoxSkinlet::QskSpinBoxSkinlet( QskSkin* )
{
setNodeRoles( { IncPanel, IncText, DecPanel, DecText, TextPanel, TextText } );
}
int QskSpinBoxSkinlet::sampleCount( const QskSkinnable*, QskAspect::Subcontrol ) const
{ {
return Count; return Count;
} }
QRectF QskSpinBoxSkinlet::sampleRect(const QskSkinnable* const skinnable, const QRectF& rect, QskAspect::Subcontrol subControl, int index) const QRectF QskSpinBoxSkinlet::sampleRect( const QskSkinnable* const skinnable, const QRectF& rect,
QskAspect::Subcontrol subControl, int index ) const
{ {
if(index == Dec || index == Inc || index == Txt) if ( index == Dec || index == Inc || index == Txt )
{ {
return subControlRect(skinnable, rect, subControl); return subControlRect( skinnable, rect, subControl );
} }
return Inherited::sampleRect( skinnable, rect, subControl, index ); return Inherited::sampleRect( skinnable, rect, subControl, index );
} }
QskAspect::States QskSpinBoxSkinlet::sampleStates(const QskSkinnable* const skinnable, QskAspect::Subcontrol subControl, int index) const QskAspect::States QskSpinBoxSkinlet::sampleStates(
const QskSkinnable* const skinnable, QskAspect::Subcontrol subControl, int index ) const
{ {
using S = QskSpinBox; using S = QskSpinBox;
auto states = Inherited::sampleStates( skinnable, subControl, index ); auto states = Inherited::sampleStates( skinnable, subControl, index );
if ( subControl == S::DecrementPanel || subControl == S::IncrementPanel || subControl == S::TextPanel) if ( subControl == S::DecrementPanel || subControl == S::IncrementPanel ||
subControl == S::TextPanel )
{ {
const auto* const spinbox = static_cast<const S*>(skinnable); const auto* const spinbox = static_cast< const S* >( skinnable );
const auto cursorPos = spinbox->effectiveSkinHint(S::Layout | QskAspect::Metric | QskAspect::Position).toPointF(); const auto cursorPos = cursorPosSkinHint( *spinbox );
const QPointF cursorPosAbs{qAbs(cursorPos.x()), qAbs(cursorPos.y())}; const QPointF cursorPosAbs{ qAbs( cursorPos.x() ), qAbs( cursorPos.y() ) };
const auto focusIndex = spinbox->focusIndex(); const auto focusIndex = spinbox->focusIndex();
const auto subControlRect = spinbox->subControlRect( subControl );
const auto contain = !cursorPosAbs.isNull() && spinbox->subControlRect(subControl).contains(cursorPosAbs); const auto contain = !cursorPosAbs.isNull() && subControlRect.contains( cursorPosAbs );
const auto pressed = contain && (cursorPos.x() < 0 || cursorPos.y() < 0); const auto pressed = contain && ( cursorPos.x() < 0 || cursorPos.y() < 0 );
const auto hovered = contain && !pressed; const auto hovered = contain && !pressed;
const auto focused = ( subControl == S::IncrementPanel && focusIndex == S::Increment) || const auto focused = ( subControl == S::IncrementPanel && focusIndex == S::Increment ) ||
( subControl == S::DecrementPanel && focusIndex == S::Decrement) || ( subControl == S::DecrementPanel && focusIndex == S::Decrement ) ||
( subControl == S::TextPanel && focusIndex == S::Textbox); ( subControl == S::TextPanel && focusIndex == S::Textbox );
states.setFlag(QskControl::Hovered, hovered); states.setFlag( QskControl::Hovered, hovered );
states.setFlag(QskSpinBox::Pressed, pressed); states.setFlag( QskSpinBox::Pressed, pressed );
states.setFlag(QskControl::Focused, focused); states.setFlag( QskControl::Focused, focused );
} }
return states; return states;
} }
QSizeF QskSpinBoxSkinlet::sizeHint(const QskSkinnable* const skinnable, Qt::SizeHint sizeHint, const QSizeF& size) const QSizeF QskSpinBoxSkinlet::sizeHint(
const QskSkinnable* const skinnable, Qt::SizeHint sizeHint, const QSizeF& size ) const
{ {
using S = QskSpinBox; using S = QskSpinBox;
const auto* const spinbox = static_cast<const S*>(skinnable); const auto* const spinbox = static_cast< const S* >( skinnable );
const auto layout = spinbox->alignmentHint(S::Layout); const auto layout = spinbox->alignmentHint( S::Layout );
const auto spacing = spinbox->spacingHint(S::Layout); const auto spacing = spinbox->spacingHint( S::Layout );
const auto strutInc = spinbox->strutSizeHint(S::IncrementPanel); const auto strutInc = spinbox->strutSizeHint( S::IncrementPanel );
const auto strutDec = spinbox->strutSizeHint(S::DecrementPanel); const auto strutDec = spinbox->strutSizeHint( S::DecrementPanel );
const auto strutTxt = spinbox->strutSizeHint(S::TextPanel); const auto strutTxt = spinbox->strutSizeHint( S::TextPanel );
if(sizeHint == Qt::MinimumSize || sizeHint == Qt::MaximumSize || Qt::PreferredSize) if ( sizeHint == Qt::MinimumSize || sizeHint == Qt::MaximumSize || Qt::PreferredSize )
{ {
if(layout == Qt::AlignTop || layout == Qt::AlignBottom || layout == Qt::AlignVCenter) if ( layout == Qt::AlignTop || layout == Qt::AlignBottom || layout == Qt::AlignVCenter )
{ {
const auto w = qMax(strutDec.width(), qMax( strutTxt.width() , strutInc.width())); const auto w = qMax( strutDec.width(), qMax( strutTxt.width(), strutInc.width() ) );
const auto h = strutDec.height() + strutTxt.height() + strutInc.height(); const auto h = strutDec.height() + strutTxt.height() + strutInc.height();
return {w,h + 2.0 * spacing}; return { w, h + 2.0 * spacing };
} }
if(layout == Qt::AlignLeft || layout == Qt::AlignRight || layout == Qt::AlignHCenter) if ( layout == Qt::AlignLeft || layout == Qt::AlignRight || layout == Qt::AlignHCenter )
{ {
const auto w = strutDec.width() + strutTxt.width() + strutInc.width(); const auto w = strutDec.width() + strutTxt.width() + strutInc.width();
const auto h = qMax(strutDec.height(), qMax( strutTxt.height() , strutInc.height())); const auto h = qMax( strutDec.height(), qMax( strutTxt.height(), strutInc.height() ) );
return {w + 2.0 * spacing,h}; return { w + 2.0 * spacing, h };
} }
if(layout == (Qt::AlignLeft | Qt::AlignVCenter) || layout == (Qt::AlignRight | Qt::AlignVCenter)) if ( layout == ( Qt::AlignLeft | Qt::AlignVCenter ) ||
layout == ( Qt::AlignRight | Qt::AlignVCenter ) )
{ {
const auto w = strutTxt.width() + qMax(strutInc.width(), strutDec.width()); const auto w = strutTxt.width() + qMax( strutInc.width(), strutDec.width() );
const auto h = qMax(2.0 * qMax(strutInc.height(), strutDec.height()), strutTxt.height()); const auto h =
return {w + spacing ,h + spacing}; qMax( 2.0 * qMax( strutInc.height(), strutDec.height() ), strutTxt.height() );
return { w + spacing, h + spacing };
} }
if(layout == (Qt::AlignTop | Qt::AlignHCenter) || layout == (Qt::AlignTop | Qt::AlignHCenter)) if ( layout == ( Qt::AlignTop | Qt::AlignHCenter ) ||
layout == ( Qt::AlignTop | Qt::AlignHCenter ) )
{ {
const auto w = qMax(strutTxt.width() , strutInc.width() + strutDec.width()); const auto w = qMax( strutTxt.width(), strutInc.width() + strutDec.width() );
const auto h = strutTxt.height() + qMax(strutInc.height() , strutDec.height()); const auto h = strutTxt.height() + qMax( strutInc.height(), strutDec.height() );
return {w + spacing, h + spacing}; return { w + spacing, h + spacing };
} }
} }
return Inherited::sizeHint(skinnable, sizeHint, size); return Inherited::sizeHint( skinnable, sizeHint, size );
} }
QRectF QskSpinBoxSkinlet::subControlRect(const QskSkinnable* const skinnable, const QRectF& rect, QskAspect::Subcontrol subControl) const QRectF QskSpinBoxSkinlet::subControlRect( const QskSkinnable* const skinnable, const QRectF& rect,
QskAspect::Subcontrol subControl ) const
{ {
using S = QskSpinBox; using S = QskSpinBox;
if(subControl == S::DecrementText) return subControlRect(skinnable, rect, S::DecrementPanel); if ( subControl == S::DecrementText )
if(subControl == S::IncrementText) return subControlRect(skinnable, rect, S::IncrementPanel);
if(subControl == S::Text) return subControlRect(skinnable, rect, S::TextPanel);
const auto* const spinbox = static_cast<const S*>(skinnable);
const auto layout = spinbox->alignmentHint(S::Layout);
const auto spacing = spinbox->spacingHint(S::Layout);
std::array<QRectF, Count> rects =
{ {
QRectF{ QPointF{}, spinbox->strutSizeHint(S::DecrementPanel)}, return subControlRect( skinnable, rect, S::DecrementPanel );
QRectF{ QPointF{}, spinbox->strutSizeHint(S::TextPanel)}, }
QRectF{ QPointF{}, spinbox->strutSizeHint(S::IncrementPanel)}, if ( subControl == S::IncrementText )
{
return subControlRect( skinnable, rect, S::IncrementPanel );
}
if ( subControl == S::Text )
{
return subControlRect( skinnable, rect, S::TextPanel );
}
const auto* const spinbox = static_cast< const S* >( skinnable );
const auto layout = spinbox->alignmentHint( S::Layout );
const auto spacing = spinbox->spacingHint( S::Layout );
std::array< QRectF, Count > rects = {
QRectF{ QPointF{}, spinbox->strutSizeHint( S::DecrementPanel ) },
QRectF{ QPointF{}, spinbox->strutSizeHint( S::TextPanel ) },
QRectF{ QPointF{}, spinbox->strutSizeHint( S::IncrementPanel ) },
}; };
const auto center = rect.center(); const auto center = rect.center();
// TODO center everything if ( layout == Qt::AlignLeft )
if(layout == Qt::AlignLeft)
{ {
rects[Txt].moveTopLeft({0.0 /************/, center.y() - rects[Txt].height() * 0.5}); rects[ Txt ].moveTopLeft( { 0.0, center.y() - rects[ Txt ].height() * 0.5 } );
rects[Dec].moveTopLeft({rects[Txt].right() + spacing, center.y() - rects[Dec].height() * 0.5}); rects[ Dec ].moveTopLeft(
rects[Inc].moveTopLeft({rects[Dec].right() + spacing, center.y() - rects[Inc].height() * 0.5}); { rects[ Txt ].right() + spacing, center.y() - rects[ Dec ].height() * 0.5 } );
rects[ Inc ].moveTopLeft(
{ rects[ Dec ].right() + spacing, center.y() - rects[ Inc ].height() * 0.5 } );
} }
else if(layout == Qt::AlignRight) else if ( layout == Qt::AlignRight )
{ {
rects[Dec].moveTopLeft({0.0 /************/, center.y() - rects[Dec].height() * 0.5}); rects[ Dec ].moveTopLeft( { 0.0, center.y() - rects[ Dec ].height() * 0.5 } );
rects[Inc].moveTopLeft({rects[Dec].right() + spacing, center.y() - rects[Inc].height() * 0.5}); rects[ Inc ].moveTopLeft(
rects[Txt].moveTopLeft({rects[Inc].right() + spacing, center.y() - rects[Txt].height() * 0.5}); { rects[ Dec ].right() + spacing, center.y() - rects[ Inc ].height() * 0.5 } );
rects[ Txt ].moveTopLeft(
{ rects[ Inc ].right() + spacing, center.y() - rects[ Txt ].height() * 0.5 } );
} }
else if(layout == Qt::AlignTop) else if ( layout == Qt::AlignTop )
{ {
rects[Txt].moveTopLeft({center.x() - rects[Txt].width() * 0.5, 0.0 }); rects[ Txt ].moveTopLeft( { center.x() - rects[ Txt ].width() * 0.5, 0.0 } );
rects[Inc].moveTopLeft({center.x() - rects[Inc].width() * 0.5, rects[Txt].bottom() + spacing}); rects[ Inc ].moveTopLeft(
rects[Dec].moveTopLeft({center.x() - rects[Dec].width() * 0.5, rects[Inc].bottom() + spacing}); { center.x() - rects[ Inc ].width() * 0.5, rects[ Txt ].bottom() + spacing } );
rects[ Dec ].moveTopLeft(
{ center.x() - rects[ Dec ].width() * 0.5, rects[ Inc ].bottom() + spacing } );
} }
else if(layout == Qt::AlignBottom) else if ( layout == Qt::AlignBottom )
{ {
rects[Inc].moveTopLeft({center.x() - rects[Inc].width() * 0.5, 0.0}); rects[ Inc ].moveTopLeft( { center.x() - rects[ Inc ].width() * 0.5, 0.0 } );
rects[Dec].moveTopLeft({center.x() - rects[Dec].width() * 0.5, rects[Inc].bottom() + spacing}); rects[ Dec ].moveTopLeft(
rects[Txt].moveTopLeft({center.x() - rects[Txt].width() * 0.5, rects[Dec].bottom() + spacing}); { center.x() - rects[ Dec ].width() * 0.5, rects[ Inc ].bottom() + spacing } );
rects[ Txt ].moveTopLeft(
{ center.x() - rects[ Txt ].width() * 0.5, rects[ Dec ].bottom() + spacing } );
} }
else if(layout == Qt::AlignHCenter) else if ( layout == Qt::AlignHCenter )
{ {
rects[Dec].moveTopLeft({0.0 /************/, center.y() - rects[Dec].height() * 0.5}); rects[ Dec ].moveTopLeft( { 0.0, center.y() - rects[ Dec ].height() * 0.5 } );
rects[Txt].moveTopLeft({rects[Dec].right() + spacing, center.y() - rects[Txt].height() * 0.5}); rects[ Txt ].moveTopLeft(
rects[Inc].moveTopLeft({rects[Txt].right() + spacing, center.y() - rects[Inc].height() * 0.5}); { rects[ Dec ].right() + spacing, center.y() - rects[ Txt ].height() * 0.5 } );
rects[ Inc ].moveTopLeft(
{ rects[ Txt ].right() + spacing, center.y() - rects[ Inc ].height() * 0.5 } );
} }
else if(layout == Qt::AlignVCenter) else if ( layout == Qt::AlignVCenter )
{ {
rects[Inc].moveTopLeft({center.x() - rects[Inc].width() * 0.5, 0.0}); rects[ Inc ].moveTopLeft( { center.x() - rects[ Inc ].width() * 0.5, 0.0 } );
rects[Txt].moveTopLeft({center.x() - rects[Txt].width() * 0.5, rects[Inc].bottom() + spacing}); rects[ Txt ].moveTopLeft(
rects[Dec].moveTopLeft({center.x() - rects[Dec].width() * 0.5, rects[Txt].bottom() + spacing}); { center.x() - rects[ Txt ].width() * 0.5, rects[ Inc ].bottom() + spacing } );
rects[ Dec ].moveTopLeft(
{ center.x() - rects[ Dec ].width() * 0.5, rects[ Txt ].bottom() + spacing } );
} }
else if(layout == (Qt::AlignLeft | Qt::AlignVCenter)) else if ( layout == ( Qt::AlignLeft | Qt::AlignVCenter ) )
{ {
rects[Txt].moveTopLeft({0.0 /************/, center.y() - rects[Txt].height() * 0.5 }); rects[ Txt ].moveTopLeft( { 0.0, center.y() - rects[ Txt ].height() * 0.5 } );
rects[Inc].moveTopLeft({rects[Txt].right() + spacing, center.y() - spacing * 0.5 - rects[Inc].height()}); rects[ Inc ].moveTopLeft( { rects[ Txt ].right() + spacing,
rects[Dec].moveTopLeft({rects[Txt].right() + spacing, center.y() + spacing * 0.5}); center.y() - spacing * 0.5 - rects[ Inc ].height() } );
rects[ Dec ].moveTopLeft( { rects[ Txt ].right() + spacing, center.y() + spacing * 0.5 } );
} }
else if(layout == (Qt::AlignRight | Qt::AlignVCenter)) else if ( layout == ( Qt::AlignRight | Qt::AlignVCenter ) )
{ {
const auto dx = qMax(rects[Inc].width(), rects[Dec].width()); const auto dx = qMax( rects[ Inc ].width(), rects[ Dec ].width() );
rects[Inc].moveTopLeft({dx - rects[Inc].width(), center.y() - spacing * 0.5 - rects[Inc].height()}); rects[ Inc ].moveTopLeft(
rects[Dec].moveTopLeft({dx - rects[Dec].width(), center.y() + spacing * 0.5}); { dx - rects[ Inc ].width(), center.y() - spacing * 0.5 - rects[ Inc ].height() } );
rects[Txt].moveTopLeft({dx + spacing, center.y() - rects[Txt].height() * 0.5 }); rects[ Dec ].moveTopLeft( { dx - rects[ Dec ].width(), center.y() + spacing * 0.5 } );
rects[ Txt ].moveTopLeft( { dx + spacing, center.y() - rects[ Txt ].height() * 0.5 } );
} }
else if(layout == (Qt::AlignTop | Qt::AlignHCenter)) else if ( layout == ( Qt::AlignTop | Qt::AlignHCenter ) )
{ {
rects[Txt].moveTopLeft({center.x() - rects[Txt].width() * 0.5, 0.0 }); rects[ Txt ].moveTopLeft( { center.x() - rects[ Txt ].width() * 0.5, 0.0 } );
rects[Dec].moveTopLeft({rects[Txt].center().x() - spacing * 0.5 - rects[Dec].width(), rects[Txt].bottom() + spacing }); rects[ Dec ].moveTopLeft(
rects[Inc].moveTopLeft({rects[Txt].center().x() + spacing * 0.5, rects[Txt].bottom() + spacing }); { rects[ Txt ].center().x() - spacing * 0.5 - rects[ Dec ].width(),
rects[ Txt ].bottom() + spacing } );
rects[ Inc ].moveTopLeft(
{ rects[ Txt ].center().x() + spacing * 0.5, rects[ Txt ].bottom() + spacing } );
} }
else if(layout == (Qt::AlignBottom | Qt::AlignHCenter)) else if ( layout == ( Qt::AlignBottom | Qt::AlignHCenter ) )
{ {
rects[Txt].moveTopLeft({center.x() - rects[Txt].width() * 0.5, center.y() - rects[Txt].height() * 0.5}); rects[ Txt ].moveTopLeft(
rects[Dec].moveTopLeft({center.x() - spacing * 0.5 - rects[Dec].width() , rects[Txt].top() - spacing - rects[Dec].height() }); { center.x() - rects[ Txt ].width() * 0.5, center.y() - rects[ Txt ].height() * 0.5 } );
rects[Inc].moveTopLeft({center.x() + spacing * 0.5, rects[Txt].top() - spacing - rects[Inc].height() }); rects[ Dec ].moveTopLeft( { center.x() - spacing * 0.5 - rects[ Dec ].width(),
rects[ Txt ].top() - spacing - rects[ Dec ].height() } );
rects[ Inc ].moveTopLeft(
{ center.x() + spacing * 0.5, rects[ Txt ].top() - spacing - rects[ Inc ].height() } );
} }
if(subControl == S::DecrementPanel) if ( subControl == S::DecrementPanel )
{ {
return rects[Dec]; return rects[ Dec ];
} }
if(subControl == S::TextPanel) if ( subControl == S::TextPanel )
{ {
return rects[Txt]; return rects[ Txt ];
} }
if(subControl == S::IncrementPanel) if ( subControl == S::IncrementPanel )
{ {
return rects[Inc]; return rects[ Inc ];
} }
return Inherited::subControlRect(skinnable, rect, subControl); return Inherited::subControlRect( skinnable, rect, subControl );
} }
QSGNode* QskSpinBoxSkinlet::updateSubNode(const QskSkinnable* const skinnable, const quint8 nodeRole, QSGNode* const node) const QSGNode* QskSpinBoxSkinlet::updateSubNode(
const QskSkinnable* const skinnable, const quint8 nodeRole, QSGNode* const node ) const
{ {
using S = QskSpinBox; using S = QskSpinBox;
if(nodeRole == IncPanel) { return updateSeriesNode( skinnable, S::IncrementPanel, node); } if ( nodeRole == IncPanel )
if(nodeRole == DecPanel) { return updateSeriesNode( skinnable, S::DecrementPanel, node ); } {
if(nodeRole == IncText) { return updateTextNode( skinnable, node, INCREMENT_TEXT, S::IncrementText); } return updateSeriesNode( skinnable, S::IncrementPanel, node );
if(nodeRole == DecText) { return updateTextNode( skinnable, node, DECREMENT_TEXT, S::DecrementText ); } }
if(nodeRole == TextPanel) { return updateSeriesNode( skinnable, S::TextPanel, node ); } if ( nodeRole == DecPanel )
if(nodeRole == TextText) { return updateTextNode( skinnable, node, QString::number(static_cast<const S*>(skinnable)->value()), S::Text ); } {
return Inherited::updateSubNode(skinnable, nodeRole, node); return updateSeriesNode( skinnable, S::DecrementPanel, node );
}
if ( nodeRole == IncText )
{
return updateTextNode( skinnable, node, QStringLiteral( "+" ), S::IncrementText );
}
if ( nodeRole == DecText )
{
return updateTextNode( skinnable, node, QStringLiteral( "-" ), S::DecrementText );
}
if ( nodeRole == TextPanel )
{
return updateSeriesNode( skinnable, S::TextPanel, node );
}
if ( nodeRole == TextText )
{
const auto* const spinbox = static_cast< const S* >( skinnable );
return updateTextNode( skinnable, node, QString::number( spinbox->value() ), S::Text );
}
return Inherited::updateSubNode( skinnable, nodeRole, node );
} }
QSGNode* QskSpinBoxSkinlet::updateSampleNode(const QskSkinnable* const skinnable, QskAspect::Subcontrol subControl, const int index, QSGNode* const node) const QSGNode* QskSpinBoxSkinlet::updateSampleNode( const QskSkinnable* const skinnable,
QskAspect::Subcontrol subControl, const int index, QSGNode* const node ) const
{ {
using S = QskSpinBox; using S = QskSpinBox;
const auto* const spinbox = static_cast<const S*>(skinnable); const auto* const spinbox = static_cast< const S* >( skinnable );
if ( subControl == S::DecrementPanel || subControl == S::IncrementPanel || subControl == S::TextPanel ) if ( subControl == S::DecrementPanel || subControl == S::IncrementPanel ||
subControl == S::TextPanel )
{ {
const auto rect = sampleRect(spinbox, spinbox->contentsRect(), subControl, index); const auto rect = sampleRect( spinbox, spinbox->contentsRect(), subControl, index );
return updateBoxNode( skinnable, node, rect, subControl ); return updateBoxNode( skinnable, node, rect, subControl );
} }

View File

@ -11,18 +11,30 @@ class QSK_EXPORT QskSpinBoxSkinlet : public QskSkinlet
{ {
Q_GADGET Q_GADGET
using Inherited = QskSkinlet; using Inherited = QskSkinlet;
public:
public:
enum NodeRole enum NodeRole
{ {
IncPanel, IncText, DecPanel, DecText, TextPanel, TextText, RoleCount IncPanel,
IncText,
DecPanel,
DecText,
TextPanel,
TextText,
RoleCount
}; };
Q_INVOKABLE QskSpinBoxSkinlet( QskSkin* = nullptr ); Q_INVOKABLE QskSpinBoxSkinlet( QskSkin* = nullptr );
protected:
protected:
int sampleCount( const QskSkinnable*, QskAspect::Subcontrol ) const override; int sampleCount( const QskSkinnable*, QskAspect::Subcontrol ) const override;
QRectF sampleRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol, int index ) const override; QRectF sampleRect(
QskAspect::States sampleStates(const QskSkinnable* skinnable, QskAspect::Subcontrol subControl, int index ) const override; const QskSkinnable*, const QRectF&, QskAspect::Subcontrol, int index ) const override;
QskAspect::States sampleStates(
const QskSkinnable* skinnable, QskAspect::Subcontrol subControl, int index ) const override;
QSizeF sizeHint( const QskSkinnable*, Qt::SizeHint, const QSizeF& ) const override; QSizeF sizeHint( const QskSkinnable*, Qt::SizeHint, const QSizeF& ) const override;
QRectF subControlRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const override; QRectF subControlRect(
const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const override;
QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override; QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* ) const override;
QSGNode* updateSampleNode( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl, int index, QSGNode* node ) const override; QSGNode* updateSampleNode( const QskSkinnable* skinnable, QskAspect::Subcontrol subControl,
int index, QSGNode* node ) const override;
}; };