Rename radio to button
This commit is contained in:
parent
8c0a54e54a
commit
92ba2385db
@ -472,7 +472,7 @@ void Editor::setupRadioBox()
|
|||||||
using A = QskAspect;
|
using A = QskAspect;
|
||||||
|
|
||||||
setStrutSize( Q::Text, {100, 20 });
|
setStrutSize( Q::Text, {100, 20 });
|
||||||
setStrutSize( Q::Radio, {20, 20 });
|
setStrutSize( Q::Button, {20, 20 });
|
||||||
setStrutSize( Q::Symbol, {10, 10 });
|
setStrutSize( Q::Symbol, {10, 10 });
|
||||||
setStrutSize( Q::Ripple | Q::Focused, { 40, 40 });
|
setStrutSize( Q::Ripple | Q::Focused, { 40, 40 });
|
||||||
|
|
||||||
@ -480,10 +480,10 @@ void Editor::setupRadioBox()
|
|||||||
|
|
||||||
setColor( Q::Text, m_pal.onBackground );
|
setColor( Q::Text, m_pal.onBackground );
|
||||||
|
|
||||||
setBoxShape(Q::Radio, 20);
|
setBoxShape(Q::Button, 20);
|
||||||
setBoxBorderMetrics( Q::Radio, 2_dp );
|
setBoxBorderMetrics( Q::Button, 2_dp );
|
||||||
setBoxBorderColors( Q::Radio, m_pal.onBackground );
|
setBoxBorderColors( Q::Button, m_pal.onBackground );
|
||||||
setBoxBorderColors( Q::Radio | Q::Selected, m_pal.primary );
|
setBoxBorderColors( Q::Button | Q::Selected, m_pal.primary );
|
||||||
|
|
||||||
setBoxShape(Q::Ripple, 40);
|
setBoxShape(Q::Ripple, 40);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
|
||||||
QSK_SUBCONTROL( QskRadioBox, Panel )
|
QSK_SUBCONTROL( QskRadioBox, Panel )
|
||||||
QSK_SUBCONTROL( QskRadioBox, Radio )
|
QSK_SUBCONTROL( QskRadioBox, Button )
|
||||||
QSK_SUBCONTROL( QskRadioBox, Symbol )
|
QSK_SUBCONTROL( QskRadioBox, Symbol )
|
||||||
QSK_SUBCONTROL( QskRadioBox, Text )
|
QSK_SUBCONTROL( QskRadioBox, Text )
|
||||||
QSK_SUBCONTROL( QskRadioBox, Ripple )
|
QSK_SUBCONTROL( QskRadioBox, Ripple )
|
||||||
|
@ -22,7 +22,7 @@ class QSK_EXPORT QskRadioBox : public QskControl
|
|||||||
using Inherited = QskControl;
|
using Inherited = QskControl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Panel, Radio, Symbol, Text, Ripple )
|
QSK_SUBCONTROLS( Panel, Button, Symbol, Text, Ripple )
|
||||||
QSK_STATES( Selected, Pressed, Focused )
|
QSK_STATES( Selected, Pressed, Focused )
|
||||||
|
|
||||||
QskRadioBox( QQuickItem* parent = nullptr );
|
QskRadioBox( QQuickItem* parent = nullptr );
|
||||||
|
@ -16,7 +16,7 @@ namespace {
|
|||||||
|
|
||||||
QskRadioBoxSkinlet::QskRadioBoxSkinlet( QskSkin* )
|
QskRadioBoxSkinlet::QskRadioBoxSkinlet( QskSkin* )
|
||||||
{
|
{
|
||||||
setNodeRoles( { PanelRole, RadioRole, SymbolRole, TextRole, RippleRole } );
|
setNodeRoles( { PanelRole, ButtonRole, SymbolRole, TextRole, RippleRole } );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskRadioBoxSkinlet::~QskRadioBoxSkinlet()
|
QskRadioBoxSkinlet::~QskRadioBoxSkinlet()
|
||||||
@ -35,7 +35,7 @@ QRectF QskRadioBoxSkinlet::subControlRect( const QskSkinnable* skinnable,
|
|||||||
result.setSize( radio->strutSizeHint( subcontrol ) );
|
result.setSize( radio->strutSizeHint( subcontrol ) );
|
||||||
result.moveTop( (lh + spacing) * radio->focusedIndex()
|
result.moveTop( (lh + spacing) * radio->focusedIndex()
|
||||||
- (result.size().height() - lh ) / 2);
|
- (result.size().height() - lh ) / 2);
|
||||||
result.moveLeft(( radio->strutSizeHint( Q::Radio ).width()
|
result.moveLeft(( radio->strutSizeHint( Q::Button ).width()
|
||||||
- result.width()) /2);
|
- result.width()) /2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ QSizeF QskRadioBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
|||||||
|
|
||||||
const auto font = skinnable->effectiveFont( Q::Text );
|
const auto font = skinnable->effectiveFont( Q::Text );
|
||||||
const auto textMargins = skinnable->marginHint( Q::Text );
|
const auto textMargins = skinnable->marginHint( Q::Text );
|
||||||
const auto buttonMargins = skinnable->marginHint( Q::Radio );
|
const auto buttonMargins = skinnable->marginHint( Q::Button );
|
||||||
const auto symbolMargins = skinnable->marginHint( Q::Symbol );
|
const auto symbolMargins = skinnable->marginHint( Q::Symbol );
|
||||||
|
|
||||||
qreal maxTextWidth = 0;
|
qreal maxTextWidth = 0;
|
||||||
@ -58,7 +58,7 @@ QSizeF QskRadioBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
|||||||
maxTextWidth = std::max( maxTextWidth, qskHorizontalAdvance( font, item ) );
|
maxTextWidth = std::max( maxTextWidth, qskHorizontalAdvance( font, item ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto radioWidth = radio->strutSizeHint(Q::Radio).width();
|
auto radioWidth = radio->strutSizeHint(Q::Button).width();
|
||||||
auto symbolWidth = radio->strutSizeHint(Q::Symbol).width();
|
auto symbolWidth = radio->strutSizeHint(Q::Symbol).width();
|
||||||
|
|
||||||
maxTextWidth += textMargins.left() + textMargins.right();
|
maxTextWidth += textMargins.left() + textMargins.right();
|
||||||
@ -74,31 +74,31 @@ QSizeF QskRadioBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
|||||||
QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
||||||
quint8 nodeRole, QSGNode* node) const
|
quint8 nodeRole, QSGNode* node) const
|
||||||
{
|
{
|
||||||
auto radioButtons = static_cast<const QskRadioBox*>( skinnable );
|
auto radio = static_cast<const QskRadioBox*>( skinnable );
|
||||||
|
|
||||||
switch( nodeRole )
|
switch( nodeRole )
|
||||||
{
|
{
|
||||||
case PanelRole:
|
case PanelRole:
|
||||||
return updateBoxNode( skinnable, node, Q::Panel );
|
return updateBoxNode( skinnable, node, Q::Panel );
|
||||||
|
|
||||||
case RadioRole:
|
case ButtonRole:
|
||||||
return updateSeriesNode( radioButtons, Q::Radio, node );
|
return updateSeriesNode( radio, Q::Button, node );
|
||||||
|
|
||||||
case SymbolRole:
|
case SymbolRole:
|
||||||
return updateSeriesNode( radioButtons, Q::Symbol, node );
|
return updateSeriesNode( radio, Q::Symbol, node );
|
||||||
|
|
||||||
case TextRole:
|
case TextRole:
|
||||||
return updateSeriesNode( radioButtons, Q::Text, node );
|
return updateSeriesNode( radio, Q::Text, node );
|
||||||
|
|
||||||
case RippleRole:
|
case RippleRole:
|
||||||
return updateBoxNode( radioButtons, node, Q::Ripple );
|
return updateBoxNode( radio, node, Q::Ripple );
|
||||||
};
|
};
|
||||||
|
|
||||||
return Inherited::updateSubNode( skinnable, nodeRole, node );
|
return Inherited::updateSubNode( skinnable, nodeRole, node );
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QskRadioBoxSkinlet::lineHeight(const QskRadioBox* target) const {
|
qreal QskRadioBoxSkinlet::lineHeight(const QskRadioBox* target) const {
|
||||||
auto strutHight = qMax( target->strutSizeHint( Q::Radio ).height(),
|
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 );
|
const auto textMargins = target->marginHint( Q::Text );
|
||||||
auto fontHeight = target->effectiveFontHeight( Q::Text );
|
auto fontHeight = target->effectiveFontHeight( Q::Text );
|
||||||
@ -114,7 +114,7 @@ int QskRadioBoxSkinlet::sampleCount( const QskSkinnable* skinnable,
|
|||||||
return radio->items().count();
|
return radio->items().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskRadioBoxSkinlet::radioRect( const QskRadioBox* radio,
|
QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
||||||
const QskAspect::Subcontrol target,
|
const QskAspect::Subcontrol target,
|
||||||
const QRectF& rect, int index ) const {
|
const QRectF& rect, int index ) const {
|
||||||
auto result = rect;
|
auto result = rect;
|
||||||
@ -127,7 +127,7 @@ QRectF QskRadioBoxSkinlet::radioRect( const QskRadioBox* radio,
|
|||||||
if( radio->layoutMirroring() ) {
|
if( radio->layoutMirroring() ) {
|
||||||
result.moveRight( rect.width() );
|
result.moveRight( rect.width() );
|
||||||
} else {
|
} else {
|
||||||
result.moveLeft((radio->strutSizeHint( Q::Radio ).width()
|
result.moveLeft((radio->strutSizeHint( Q::Button ).width()
|
||||||
- result.width()) / 2);
|
- result.width()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +149,8 @@ QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
|||||||
+ textMargins.top());
|
+ textMargins.top());
|
||||||
|
|
||||||
if(!radio->layoutMirroring()) {
|
if(!radio->layoutMirroring()) {
|
||||||
auto symbolWidth = radioRect( radio, Q::Symbol, rect, index ).width();
|
auto symbolWidth = buttonRect( radio, Q::Symbol, rect, index ).width();
|
||||||
auto radioWidth = radioRect( radio, Q::Radio, rect, index ).width();
|
auto radioWidth = buttonRect( radio, Q::Button, rect, index ).width();
|
||||||
result.moveLeft( qMax(symbolWidth, radioWidth) + textMargins.left());
|
result.moveLeft( qMax(symbolWidth, radioWidth) + textMargins.left());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
|||||||
return textRect( radio, rect, index );
|
return textRect( radio, rect, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
return radioRect( radio, subcontrol, rect, index);
|
return buttonRect( radio, subcontrol, rect, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnable,
|
QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnable,
|
||||||
@ -195,7 +195,7 @@ QSGNode* QskRadioBoxSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
|||||||
Qt::AlignLeft,
|
Qt::AlignLeft,
|
||||||
radioButtons->items()[index],
|
radioButtons->items()[index],
|
||||||
subcontrol);
|
subcontrol);
|
||||||
} else if (subcontrol == Q::Radio) {
|
} else if (subcontrol == Q::Button) {
|
||||||
return QskSkinlet::updateBoxNode(radioButtons,
|
return QskSkinlet::updateBoxNode(radioButtons,
|
||||||
node,
|
node,
|
||||||
rect,
|
rect,
|
||||||
|
@ -15,7 +15,7 @@ class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet
|
|||||||
enum NodeRole
|
enum NodeRole
|
||||||
{
|
{
|
||||||
PanelRole,
|
PanelRole,
|
||||||
RadioRole,
|
ButtonRole,
|
||||||
SymbolRole,
|
SymbolRole,
|
||||||
TextRole,
|
TextRole,
|
||||||
RippleRole,
|
RippleRole,
|
||||||
@ -38,7 +38,7 @@ class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet
|
|||||||
const QRectF&, QskAspect::Subcontrol, int index ) const override;
|
const QRectF&, QskAspect::Subcontrol, int index ) const override;
|
||||||
|
|
||||||
QRectF textRect( const QskRadioBox*, const QRectF&, int ) const;
|
QRectF textRect( const QskRadioBox*, const QRectF&, int ) const;
|
||||||
QRectF radioRect( const QskRadioBox*, const QskAspect::Subcontrol target, const QRectF&, int ) const;
|
QRectF buttonRect( const QskRadioBox*, const QskAspect::Subcontrol target, const QRectF&, int ) const;
|
||||||
|
|
||||||
QskAspect::States sampleStates( const QskSkinnable*,
|
QskAspect::States sampleStates( const QskSkinnable*,
|
||||||
QskAspect::Subcontrol, int index ) const override;
|
QskAspect::Subcontrol, int index ) const override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user