clang-format + clang-tidy improvements
This commit is contained in:
parent
890ae64652
commit
1faf2e091c
|
@ -4,19 +4,19 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#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 )
|
||||||
|
@ -40,8 +40,8 @@ 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 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,16 +49,46 @@ public:
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -71,16 +101,46 @@ public:
|
||||||
// [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;
|
||||||
}
|
}
|
||||||
|
@ -93,16 +153,46 @@ public:
|
||||||
// [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;
|
||||||
}
|
}
|
||||||
|
@ -144,10 +234,18 @@ public:
|
||||||
|
|
||||||
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 {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +254,13 @@ public:
|
||||||
q->setSkinHint( QskSpinBox::Layout | QskAspect::Metric | QskAspect::Position, pos );
|
q->setSkinHint( QskSpinBox::Layout | QskAspect::Metric | QskAspect::Position, pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool focusNow() const
|
||||||
|
{
|
||||||
|
const auto focusOnClick = ( q->focusPolicy() & Qt::ClickFocus ) == Qt::ClickFocus;
|
||||||
|
const auto focusOnTouchRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease();
|
||||||
|
return focusOnClick && !focusOnTouchRelease;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QskSpinBox* const q;
|
QskSpinBox* const q;
|
||||||
FocusIndeces m_focusIndex = FocusIndeces::None;
|
FocusIndeces m_focusIndex = FocusIndeces::None;
|
||||||
|
@ -177,26 +282,26 @@ 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() ) )
|
||||||
{
|
{
|
||||||
|
@ -235,11 +340,11 @@ 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() ) )
|
||||||
{
|
{
|
||||||
|
@ -262,7 +367,7 @@ 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() )
|
||||||
{
|
{
|
||||||
|
@ -278,11 +383,19 @@ void QskSpinBox::keyPressEvent(QKeyEvent *event)
|
||||||
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 )
|
||||||
|
@ -305,12 +418,11 @@ void QskSpinBox::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
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 )
|
||||||
{
|
{
|
||||||
|
@ -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
|
||||||
|
|
|
@ -5,20 +5,28 @@
|
||||||
|
|
||||||
#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:
|
public:
|
||||||
enum FocusIndeces : int { Decrement = 0, Textbox = 1, Increment = 2, None = 3 };
|
enum FocusIndeces : int
|
||||||
|
{
|
||||||
|
Decrement = 0,
|
||||||
|
Textbox = 1,
|
||||||
|
Increment = 2,
|
||||||
|
None = 3
|
||||||
|
};
|
||||||
Q_ENUM( FocusIndeces )
|
Q_ENUM( FocusIndeces )
|
||||||
|
|
||||||
Q_PROPERTY( FocusIndeces focusIndex READ focusIndex NOTIFY focusIndexChanged )
|
Q_PROPERTY( FocusIndeces focusIndex READ focusIndex NOTIFY focusIndexChanged )
|
||||||
QSK_SUBCONTROLS(IncrementPanel, DecrementPanel, IncrementText, DecrementText, TextPanel, Text, Layout)
|
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 );
|
||||||
|
|
|
@ -8,10 +8,22 @@
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
const auto INCREMENT_TEXT = QStringLiteral("+");
|
namespace
|
||||||
const auto DECREMENT_TEXT = QStringLiteral("-");
|
{
|
||||||
|
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 };
|
enum SampleIndeces
|
||||||
|
{
|
||||||
|
Dec = 0,
|
||||||
|
Txt = 1,
|
||||||
|
Inc = 2,
|
||||||
|
Count
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
QskSpinBoxSkinlet::QskSpinBoxSkinlet( QskSkin* )
|
QskSpinBoxSkinlet::QskSpinBoxSkinlet( QskSkin* )
|
||||||
{
|
{
|
||||||
|
@ -23,7 +35,8 @@ int QskSpinBoxSkinlet::sampleCount(const QskSkinnable *, QskAspect::Subcontrol)
|
||||||
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 )
|
||||||
{
|
{
|
||||||
|
@ -33,19 +46,22 @@ QRectF QskSpinBoxSkinlet::sampleRect(const QskSkinnable* const skinnable, const
|
||||||
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 ) ||
|
||||||
|
@ -60,7 +76,8 @@ QskAspect::States QskSpinBoxSkinlet::sampleStates(const QskSkinnable* const skin
|
||||||
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 );
|
||||||
|
@ -85,13 +102,16 @@ QSizeF QskSpinBoxSkinlet::sizeHint(const QskSkinnable* const skinnable, Qt::Size
|
||||||
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 =
|
||||||
|
qMax( 2.0 * qMax( strutInc.height(), strutDec.height() ), strutTxt.height() );
|
||||||
return { w + spacing, h + spacing };
|
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() );
|
||||||
|
@ -101,20 +121,29 @@ QSizeF QskSpinBoxSkinlet::sizeHint(const QskSkinnable* const skinnable, Qt::Size
|
||||||
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);
|
return subControlRect( skinnable, rect, S::DecrementPanel );
|
||||||
|
}
|
||||||
|
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* 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 );
|
||||||
|
|
||||||
std::array<QRectF, Count> rects =
|
std::array< QRectF, Count > rects = {
|
||||||
{
|
|
||||||
QRectF{ QPointF{}, spinbox->strutSizeHint( S::DecrementPanel ) },
|
QRectF{ QPointF{}, spinbox->strutSizeHint( S::DecrementPanel ) },
|
||||||
QRectF{ QPointF{}, spinbox->strutSizeHint( S::TextPanel ) },
|
QRectF{ QPointF{}, spinbox->strutSizeHint( S::TextPanel ) },
|
||||||
QRectF{ QPointF{}, spinbox->strutSizeHint( S::IncrementPanel ) },
|
QRectF{ QPointF{}, spinbox->strutSizeHint( S::IncrementPanel ) },
|
||||||
|
@ -122,68 +151,86 @@ QRectF QskSpinBoxSkinlet::subControlRect(const QskSkinnable* const skinnable, co
|
||||||
|
|
||||||
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,
|
||||||
|
center.y() - spacing * 0.5 - rects[ Inc ].height() } );
|
||||||
rects[ Dec ].moveTopLeft( { rects[ Txt ].right() + spacing, center.y() + spacing * 0.5 } );
|
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(
|
||||||
|
{ dx - rects[ Inc ].width(), center.y() - spacing * 0.5 - rects[ Inc ].height() } );
|
||||||
rects[ Dec ].moveTopLeft( { dx - rects[ Dec ].width(), center.y() + spacing * 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 } );
|
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 )
|
||||||
|
@ -202,24 +249,46 @@ QRectF QskSpinBoxSkinlet::subControlRect(const QskSkinnable* const skinnable, co
|
||||||
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 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 );
|
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 );
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue