more convenience methods to access skin hints
This commit is contained in:
parent
80004ed8e8
commit
c1e70a2d9e
@ -5,9 +5,11 @@
|
||||
|
||||
#include "ButtonBar.h"
|
||||
#include "SkinFactory.h"
|
||||
|
||||
#include <QskGraphic.h>
|
||||
#include <QskGraphicIO.h>
|
||||
#include <QskGraphicLabel.h>
|
||||
#include <QskMargins.h>
|
||||
|
||||
QSK_SUBCONTROL( ButtonBar, Indicator )
|
||||
|
||||
@ -40,7 +42,7 @@ ButtonBar::ButtonBar( QQuickItem* parentItem )
|
||||
c.setAlphaF( 0.5 );
|
||||
setBackgroundColor( c );
|
||||
|
||||
setMargins( QMarginsF( 20, 15, 20, 15 ) );
|
||||
setMargins( QskMargins( 20, 15 ) );
|
||||
setSpacing( 20 );
|
||||
|
||||
setSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding );
|
||||
|
@ -36,14 +36,12 @@ namespace
|
||||
public:
|
||||
Skin()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
declareSkinlet< Speedometer, SpeedometerSkinlet >();
|
||||
|
||||
setFont( QskSkin::DefaultFont, qskFont( 13 ) );
|
||||
setFont( QskSkin::LargeFont, qskFont( 20 ) );
|
||||
|
||||
setSkinHint( ButtonBar::Indicator | GraphicRole, SkinFactory::Indicator );
|
||||
setSkinHint( ButtonBar::Indicator | QskAspect::GraphicRole, SkinFactory::Indicator );
|
||||
}
|
||||
};
|
||||
|
||||
@ -80,7 +78,7 @@ namespace
|
||||
setColor( Q::Needle, color4 );
|
||||
|
||||
// margins between numbers and ticks:
|
||||
setMargins( Q::Labels, QskMargins( 3, 3, 3, 3 ) );
|
||||
setMargin( Q::Labels, 3 );
|
||||
setMetric( Q::Labels | MinimumWidth, 3 );
|
||||
setMetric( Q::Labels | Size, 25 ); // ticks size
|
||||
setColor( Q::Labels, color4 );
|
||||
@ -131,7 +129,7 @@ namespace
|
||||
setColor( Q::Needle, color2 );
|
||||
|
||||
// margins between numbers and ticks:
|
||||
setMargins( Q::Labels, QskMargins( 4, 4, 4, 4 ) );
|
||||
setMargin( Q::Labels, 4 );
|
||||
setMetric( Q::Labels | MinimumWidth, 2 );
|
||||
setMetric( Q::Labels | Size, 15 ); // ticks size
|
||||
setColor( Q::Labels, color4 );
|
||||
|
@ -113,9 +113,11 @@ QSGNode* SpeedometerSkinlet::updatePanelNode(
|
||||
return boxNode;
|
||||
}
|
||||
|
||||
QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, QSGNode* node ) const
|
||||
QSGNode* SpeedometerSkinlet::updateLabelsNode(
|
||||
const Speedometer* speedometer, QSGNode* node ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = Speedometer;
|
||||
|
||||
const int labelsCount = speedometer->labels().count();
|
||||
|
||||
@ -132,7 +134,7 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q
|
||||
ticksNode = new TicksNode();
|
||||
}
|
||||
|
||||
QColor color = speedometer->color( Speedometer::Labels );
|
||||
QColor color = speedometer->color( Q::Labels );
|
||||
ticksNode->setColor( color );
|
||||
|
||||
const auto startAngle = speedometer->minimum();
|
||||
@ -145,10 +147,10 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q
|
||||
auto vertexData = geometry->vertexDataAsPoint2D();
|
||||
memset( vertexData, 0, static_cast< size_t >( geometry->vertexCount() ) );
|
||||
|
||||
const auto panelMargins = speedometer->marginsHint( Speedometer::Panel | Margin );
|
||||
const auto panelMargins = speedometer->marginHint( Q::Panel );
|
||||
|
||||
auto panelRect = subControlRect(
|
||||
speedometer, speedometer->contentsRect(), Speedometer::Panel );
|
||||
speedometer, speedometer->contentsRect(), Q::Panel );
|
||||
panelRect = panelRect.marginsRemoved( panelMargins );
|
||||
|
||||
QPointF center = QPointF( panelRect.x() + panelRect.width() / 2,
|
||||
@ -156,12 +158,12 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q
|
||||
|
||||
auto radius = static_cast< float >( panelRect.width() / 2 );
|
||||
|
||||
const QMarginsF numbersMargins = speedometer->marginsHint( Speedometer::Labels );
|
||||
QFontMetricsF fontMetrics( speedometer->effectiveFont( Speedometer::Labels ) );
|
||||
const auto numbersMargins = speedometer->marginHint( Q::Labels );
|
||||
QFontMetricsF fontMetrics( speedometer->effectiveFont( Q::Labels ) );
|
||||
|
||||
auto angle = startAngle;
|
||||
qreal length = speedometer->metric( Speedometer::Labels | Size );
|
||||
QVector< QString > labels = speedometer->labels();
|
||||
qreal length = speedometer->metric( Q::Labels | Size );
|
||||
const auto labels = speedometer->labels();
|
||||
|
||||
// Create a series of tickmarks from minimum to maximum
|
||||
for ( int i = 0; i < labelsCount; ++i, angle += step )
|
||||
@ -207,7 +209,7 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q
|
||||
numbersNode = new QskTextNode();
|
||||
}
|
||||
|
||||
QFont font = speedometer->effectiveFont( Speedometer::Labels );
|
||||
const auto font = speedometer->effectiveFont( Q::Labels );
|
||||
numbersNode->setTextData( speedometer, text, numbersRect, font, QskTextOptions(),
|
||||
QskTextColors( color ), Qt::AlignCenter | Qt::AlignHCenter, Qsk::Normal );
|
||||
|
||||
@ -219,7 +221,7 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const Speedometer* speedometer, Q
|
||||
}
|
||||
}
|
||||
|
||||
auto lineWidth = speedometer->metric( Speedometer::Labels | MinimumWidth );
|
||||
auto lineWidth = speedometer->metric( Q::Labels | MinimumWidth );
|
||||
geometry->setLineWidth( lineWidth );
|
||||
geometry->markVertexDataDirty();
|
||||
|
||||
@ -232,6 +234,7 @@ QSGNode* SpeedometerSkinlet::updateNeedleNode(
|
||||
const Speedometer* speedometer, QSGNode* node ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = Speedometer;
|
||||
|
||||
auto needleNode = static_cast< TicksNode* >( node );
|
||||
if ( needleNode == nullptr )
|
||||
@ -249,31 +252,31 @@ QSGNode* SpeedometerSkinlet::updateNeedleNode(
|
||||
boxNode = static_cast< QskBoxNode* >( needleNode->childAtIndex( 0 ) );
|
||||
}
|
||||
|
||||
const auto margins = speedometer->marginsHint( Speedometer::Panel | Margin );
|
||||
const auto margins = speedometer->marginHint( Q::Panel );
|
||||
|
||||
auto panelRect = subControlRect(
|
||||
speedometer, speedometer->contentsRect(), Speedometer::Panel );
|
||||
speedometer, speedometer->contentsRect(), Q::Panel );
|
||||
|
||||
panelRect = panelRect.marginsRemoved( margins );
|
||||
|
||||
auto radius = speedometer->metric( Speedometer::NeedleHead | Size );
|
||||
auto radius = speedometer->metric( Q::NeedleHead | Size );
|
||||
QPointF center = QPointF( panelRect.x() + panelRect.width() / 2,
|
||||
panelRect.y() + panelRect.height() / 2 );
|
||||
|
||||
QskBoxShapeMetrics shapeMetrics( radius, radius, radius, radius );
|
||||
QskBoxBorderMetrics borderMetrics = speedometer->boxBorderMetricsHint( Speedometer::NeedleHead );
|
||||
QskBoxBorderColors borderColors = speedometer->boxBorderColorsHint( Speedometer::NeedleHead );
|
||||
QskGradient gradient = speedometer->gradientHint( Speedometer::NeedleHead );
|
||||
QskBoxBorderMetrics borderMetrics = speedometer->boxBorderMetricsHint( Q::NeedleHead );
|
||||
QskBoxBorderColors borderColors = speedometer->boxBorderColorsHint( Q::NeedleHead );
|
||||
QskGradient gradient = speedometer->gradientHint( Q::NeedleHead );
|
||||
QRectF centerNodeRect( center.x() - radius, center.y() - radius, 2 * radius, 2 * radius );
|
||||
boxNode->setBoxData( centerNodeRect, shapeMetrics, borderMetrics, borderColors, gradient );
|
||||
|
||||
QColor color = speedometer->color( Speedometer::Needle );
|
||||
QColor color = speedometer->color( Q::Needle );
|
||||
needleNode->setColor( color );
|
||||
|
||||
auto panelRadius = static_cast< float >( panelRect.width() / 2 );
|
||||
|
||||
auto needleWidth = speedometer->metric( Speedometer::Needle | MinimumWidth );
|
||||
auto needleMargin = speedometer->metric( Speedometer::Needle | Margin );
|
||||
auto needleWidth = speedometer->metric( Q::Needle | MinimumWidth );
|
||||
auto needleMargin = speedometer->metric( Q::Needle | Margin );
|
||||
|
||||
float xStart = center.x();
|
||||
float yStart = center.y();
|
||||
|
@ -18,29 +18,19 @@ QSK_SUBCONTROL( CustomSlider, Decoration )
|
||||
CustomSlider::CustomSlider( QQuickItem* parentItem )
|
||||
: QskSlider( parentItem )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
setMetric( QskSlider::Handle | Size, 80 );
|
||||
|
||||
#if 0
|
||||
const QskGradient fillGradient( QskGradient::Horizontal,
|
||||
QskRgb::Grey700, QskRgb::Grey500 );
|
||||
#else
|
||||
const QskGradient fillGradient( QskRgb::Grey700 );
|
||||
#endif
|
||||
|
||||
setBoxShapeHint( Fill, 0 );
|
||||
setGradientHint( Fill, fillGradient );
|
||||
setGradientHint( Fill, QskRgb::Grey700 );
|
||||
setColor( Scale, qRgb( 178, 178, 178 ) ); // for the ticks
|
||||
|
||||
setMetric( QskSlider::Handle | QskAspect::Size, 80 );
|
||||
setColor( QskSlider::Handle, QskRgb::Grey800 );
|
||||
|
||||
for ( auto state : { Pressed, Focused | Hovered, Hovered, Focused } )
|
||||
setColor( QskSlider::Handle | Color | state, QskRgb::Orange600 );
|
||||
setColor( QskSlider::Handle | state, QskRgb::Orange600 );
|
||||
|
||||
setAnimation( QskSlider::Handle | Color, 1000 );
|
||||
setAnimation( QskSlider::Handle | QskAspect::Color, 1000 );
|
||||
for ( auto state : { Focused | Hovered, Hovered, Focused } )
|
||||
setAnimation( QskSlider::Handle | Color | state, 300 );
|
||||
setAnimation( QskSlider::Handle | QskAspect::Color | state, 300 );
|
||||
|
||||
// using an individual skinlet, not known by the skin
|
||||
|
||||
|
@ -36,9 +36,9 @@ OtherSlider::OtherSlider( QQuickItem* parentItem )
|
||||
setGradientHint( aspect, Grey400 );
|
||||
|
||||
if ( placement == Horizontal )
|
||||
setMarginsHint( aspect | Padding, QMarginsF( paddingW, 0, paddingW, 0 ) );
|
||||
setPaddingHint( aspect, QskMargins( paddingW, 0 ) );
|
||||
else
|
||||
setMarginsHint( aspect | Padding, QMarginsF( 0, paddingW, 0, paddingW ) );
|
||||
setPaddingHint( aspect, QskMargins( 0, paddingW ) );
|
||||
}
|
||||
|
||||
// Groove
|
||||
@ -73,9 +73,9 @@ OtherSlider::OtherSlider( QQuickItem* parentItem )
|
||||
const qreal m = 0.5 * std::ceil( 0.5 * ( w - h ) ) + 1;
|
||||
|
||||
if ( placement == Horizontal )
|
||||
setMarginsHint( aspect | Margin, QMarginsF( -m, 0, -m, 0 ) );
|
||||
setMarginHint( aspect, QskMargins( -m, 0 ) );
|
||||
else
|
||||
setMarginsHint( aspect | Margin, QMarginsF( 0, -m, 0, -m ) );
|
||||
setMarginHint( aspect, QskMargins( 0, -m ) );
|
||||
|
||||
for ( auto state : { NoState, Pressed } )
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "OtherSlider.h"
|
||||
|
||||
#include <QskRgbValue.h>
|
||||
#include <QskMargins.h>
|
||||
|
||||
SliderPage::SliderPage( QQuickItem* parentItem )
|
||||
: Page( Qt::Vertical, parentItem )
|
||||
@ -79,7 +80,7 @@ void SliderPage::populate()
|
||||
{
|
||||
auto slider = new CustomSlider( this );
|
||||
|
||||
slider->setMargins( QMarginsF( 0, 15, 0, 15 ) );
|
||||
slider->setMargins( QskMargins( 0, 15 ) );
|
||||
slider->setSnap( true );
|
||||
slider->setMinimum( 0 );
|
||||
slider->setMaximum( 2000 );
|
||||
|
@ -20,13 +20,11 @@ class ListBox : public QskSimpleListBox
|
||||
public:
|
||||
ListBox()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
setMargins( QMarginsF( 15, 10, 10, 10 ) );
|
||||
setAlternatingRowColors( true );
|
||||
|
||||
// increasing the padding of each row: usually the job of the skin !
|
||||
setMarginsHint( Cell | Padding, QMargins( 10, 20, 10, 20 ) );
|
||||
setPaddingHint( Cell, QMargins( 10, 20, 10, 20 ) );
|
||||
|
||||
populate();
|
||||
|
||||
|
@ -53,7 +53,7 @@ class MySkin : public QskSkin
|
||||
|
||||
setBoxBorderMetrics( subControl, border );
|
||||
setBoxShape( subControl, radius );
|
||||
setMargins( subControl | QskAspect::Padding, padding );
|
||||
setPadding( subControl, padding );
|
||||
setGradient( subControl, Qt::transparent );
|
||||
|
||||
setBoxBorderColors( subControl, rgb );
|
||||
@ -70,7 +70,7 @@ class MySkin : public QskSkin
|
||||
setBoxShape( subControl, radius );
|
||||
setBoxBorderColors( subControl, borderColors );
|
||||
setGradient( subControl, fillColor );
|
||||
setMargins( subControl | QskAspect::Padding, 0.5 * radius );
|
||||
setPadding( subControl, 0.5 * radius );
|
||||
}
|
||||
|
||||
void initToggleButtonHints(
|
||||
@ -94,7 +94,7 @@ class MySkin : public QskSkin
|
||||
setColor( subControl | Q::Checked, color1 );
|
||||
setColor( subControl, color2 );
|
||||
|
||||
setSkinHint( subControl | Alignment, Qt::AlignCenter );
|
||||
setAlignment( subControl, Qt::AlignCenter );
|
||||
setAnimation( subControl | Color, animator() );
|
||||
}
|
||||
|
||||
@ -139,13 +139,13 @@ class MySkin : public QskSkin
|
||||
{
|
||||
setMetric( subControl | MinimumWidth, width );
|
||||
setMetric( subControl | MinimumHeight, height );
|
||||
//setMargins( subControl | Padding, +2 );
|
||||
//setPadding( subControl, +2 );
|
||||
|
||||
setBoxShape( subControl, radius );
|
||||
}
|
||||
|
||||
setMargins( Q::CheckedPanel | Padding, 10 );
|
||||
setMargins( Q::UncheckedPanel | Padding, 10 );
|
||||
setPadding( Q::CheckedPanel, 10 );
|
||||
setPadding( Q::UncheckedPanel, 10 );
|
||||
|
||||
for( auto state : { NoState, Q::Disabled } )
|
||||
{
|
||||
|
@ -42,8 +42,6 @@ class GraphicLabel : public QskGraphicLabel
|
||||
|
||||
void setDarknessMode( bool on )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const int oldRole = graphicRole();
|
||||
|
||||
QskGradient gradient;
|
||||
@ -65,10 +63,10 @@ class GraphicLabel : public QskGraphicLabel
|
||||
setBackground( gradient );
|
||||
|
||||
// finally setup a smooth transition manually
|
||||
startTransition( Control | Color, duration,
|
||||
startTransition( QskAspect::Control | QskAspect::Color, duration,
|
||||
QVariant::fromValue( oldGradient ), QVariant::fromValue( gradient ) );
|
||||
|
||||
startTransition( QskGraphicLabel::Graphic | GraphicRole,
|
||||
startTransition( QskGraphicLabel::Graphic | QskAspect::GraphicRole,
|
||||
duration, oldRole, graphicRole() );
|
||||
}
|
||||
};
|
||||
|
@ -186,14 +186,12 @@ class ScrollArea : public QskScrollArea
|
||||
ScrollArea( QQuickItem* parentItem = nullptr )
|
||||
: QskScrollArea( parentItem )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
// settings usually done in the skins
|
||||
setBoxBorderMetricsHint( Viewport, 2 );
|
||||
setBoxShapeHint( Viewport, 20 );
|
||||
|
||||
for ( auto subControl : { HorizontalScrollBar, VerticalScrollBar } )
|
||||
setMetric( subControl | Size, 20 );
|
||||
setMetric( subControl | QskAspect::Size, 20 );
|
||||
|
||||
setBoxBorderMetricsHint( VerticalScrollHandle, 1 );
|
||||
setBoxShapeHint( VerticalScrollHandle, 8 );
|
||||
|
@ -198,14 +198,12 @@ class LocaleListView final : public QskListView
|
||||
{
|
||||
if ( m_maxWidth == 0.0 )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const QFontMetricsF fm( effectiveFont( Text ) );
|
||||
|
||||
for ( const auto& entry : m_values )
|
||||
m_maxWidth = qMax( m_maxWidth, qskHorizontalAdvance( fm, entry.first ) );
|
||||
|
||||
const QMarginsF padding = marginsHint( Cell | Padding );
|
||||
const auto padding = paddingHint( Cell );
|
||||
m_maxWidth += padding.left() + padding.right();
|
||||
}
|
||||
|
||||
@ -214,10 +212,8 @@ class LocaleListView final : public QskListView
|
||||
|
||||
qreal rowHeight() const override
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const QFontMetricsF fm( effectiveFont( Text ) );
|
||||
const QMarginsF padding = marginsHint( Cell | Padding );
|
||||
const auto padding = paddingHint( Cell );
|
||||
|
||||
return fm.height() + padding.top() + padding.bottom();
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ void QskMaterialSkin::initCommonHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setMargins( Control | Padding, 4 );
|
||||
setPadding( Control, 4 );
|
||||
|
||||
setGradient( Control, pal.baseColor );
|
||||
setColor( Control | StyleColor, pal.textColor );
|
||||
@ -173,7 +173,6 @@ void QskMaterialSkin::initCommonHints()
|
||||
|
||||
void QskMaterialSkin::initBoxHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskBox;
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
@ -185,7 +184,6 @@ void QskMaterialSkin::initBoxHints()
|
||||
|
||||
void QskMaterialSkin::initPopupHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskPopup;
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
@ -205,10 +203,10 @@ void QskMaterialSkin::initTextLabelHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
setColor( Q::Text, pal.textColor );
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxBorderColors( Q::Panel, pal.darker125 );
|
||||
@ -220,8 +218,7 @@ void QskMaterialSkin::initTextInputHints()
|
||||
using namespace QskAspect;
|
||||
using Q = QskTextInput;
|
||||
|
||||
setSkinHint( Q::Text | Alignment,
|
||||
static_cast< int >( Qt::AlignLeft | Qt::AlignTop ) );
|
||||
setAlignment( Q::Text, Qt::AlignLeft | Qt::AlignTop );
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
@ -229,7 +226,7 @@ void QskMaterialSkin::initTextInputHints()
|
||||
setColor( Q::PanelSelected, pal.accentColor );
|
||||
setColor( Q::TextSelected, pal.contrastColor );
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxBorderColors( Q::Panel, pal.darker125 );
|
||||
@ -247,7 +244,7 @@ void QskMaterialSkin::initProgressBarHints()
|
||||
for ( auto subControl : { Q::Groove, Q::Bar } )
|
||||
{
|
||||
setMetric( subControl | Size, 5 );
|
||||
setMargins( subControl | Padding, 0 );
|
||||
setPadding( subControl, 0 );
|
||||
|
||||
setBoxShape( subControl, 0 );
|
||||
setBoxBorderMetrics( subControl, 0 );
|
||||
@ -265,7 +262,7 @@ void QskMaterialSkin::initFocusIndicatorHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxBorderColors( Q::Panel, pal.accentColor );
|
||||
@ -335,8 +332,8 @@ void QskMaterialSkin::initPushButtonHints()
|
||||
const QskMargins margin( 4, 3 );
|
||||
const QskMargins padding( 10, 6 );
|
||||
|
||||
setMargins( Q::Panel | Margin, margin );
|
||||
setMargins( Q::Panel | Padding, padding );
|
||||
setMargin( Q::Panel, margin );
|
||||
setPadding( Q::Panel, padding );
|
||||
|
||||
const QskBoxBorderColors borderColors( Grey400, Grey300, Grey400, Grey600 );
|
||||
|
||||
@ -353,7 +350,7 @@ void QskMaterialSkin::initPushButtonHints()
|
||||
setColor( Q::Text, pal.textColor );
|
||||
setColor( Q::Text | Q::Disabled, qskShadedColor( pal.textColor, 0.6 ) );
|
||||
setFontRole( Q::Text, ButtonFontRole );
|
||||
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
for ( auto state1 : { NoState, Q::Checkable, Q::Focused, Q::Focused | Q::Checkable } )
|
||||
{
|
||||
@ -395,8 +392,8 @@ void QskMaterialSkin::initDialogButtonHints()
|
||||
const QskMargins margin( 4, 3 );
|
||||
const QskMargins padding( 10, 6 );
|
||||
|
||||
setMargins( Q::Panel | Margin, margin );
|
||||
setMargins( Q::Panel | Padding, padding );
|
||||
setMargin( Q::Panel, margin );
|
||||
setPadding( Q::Panel, padding );
|
||||
|
||||
const QskBoxBorderColors borderColors( Grey400, Grey300, Grey400, Grey600 );
|
||||
|
||||
@ -411,7 +408,7 @@ void QskMaterialSkin::initDialogButtonHints()
|
||||
setColor( Q::Text, pal.textColor );
|
||||
setColor( Q::Text | Q::Disabled, qskShadedColor( pal.textColor, 0.6 ) );
|
||||
setFontRole( Q::Text, ButtonFontRole );
|
||||
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
for ( auto state1 : { NoState, Q::Checkable, Q::Focused, Q::Focused | Q::Checkable } )
|
||||
{
|
||||
@ -436,7 +433,6 @@ void QskMaterialSkin::initDialogButtonHints()
|
||||
|
||||
void QskMaterialSkin::initDialogButtonBoxHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskDialogButtonBox;
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
@ -463,15 +459,15 @@ void QskMaterialSkin::initSliderHints()
|
||||
setBoxBorderMetrics( Q::Panel, 0 );
|
||||
setGradient( Q::Panel, QskGradient() );
|
||||
|
||||
setMargins( Q::Panel | Horizontal | Padding, QskMargins( 0.5 * dim, 0 ) );
|
||||
setMargins( Q::Panel | Vertical | Padding, QskMargins( 0, 0.5 * dim ) );
|
||||
setPadding( Q::Panel | Horizontal, QskMargins( 0.5 * dim, 0 ) );
|
||||
setPadding( Q::Panel | Vertical, QskMargins( 0, 0.5 * dim ) );
|
||||
|
||||
// Groove, Fill
|
||||
|
||||
for ( auto subControl : { Q::Groove, Q::Fill } )
|
||||
{
|
||||
setMetric( subControl | Size, 5 );
|
||||
setMargins( subControl | Padding, 0 );
|
||||
setPadding( subControl, 0 );
|
||||
|
||||
setBoxShape( subControl, 0 );
|
||||
setBoxBorderMetrics( subControl, 0 );
|
||||
@ -577,7 +573,7 @@ void QskMaterialSkin::initTabButtonHints()
|
||||
|
||||
// text
|
||||
setFontRole( Q::Text, ButtonFontRole );
|
||||
setSkinHint( Q::Text | QskAspect::Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
setColor( Q::Text, pal.textColor );
|
||||
setColor( Q::Text | Q::Checkable | Q::Disabled, qskShadedColor( pal.textColor, 0.6 ) );
|
||||
@ -599,7 +595,6 @@ void QskMaterialSkin::initTabBarHints()
|
||||
|
||||
void QskMaterialSkin::initTabViewHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskTabView;
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
@ -614,7 +609,6 @@ void QskMaterialSkin::initTabViewHints()
|
||||
|
||||
void QskMaterialSkin::initInputPanelHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskInputPanelBox;
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
@ -633,7 +627,7 @@ void QskMaterialSkin::initVirtualKeyboardHints()
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
// key panel
|
||||
setMargins( Q::ButtonPanel | Margin, 2 );
|
||||
setMargin( Q::ButtonPanel, 2 );
|
||||
|
||||
setBoxShape( Q::ButtonPanel, 20.0, Qt::RelativeSize );
|
||||
setBoxBorderMetrics( Q::ButtonPanel, 2 );
|
||||
@ -671,7 +665,7 @@ void QskMaterialSkin::initScrollViewHints()
|
||||
for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } )
|
||||
{
|
||||
setMetric( subControl | Size, 12 );
|
||||
setMargins( subControl | Padding, 0 );
|
||||
setPadding( subControl, 0 );
|
||||
}
|
||||
|
||||
setMetric( Q::HorizontalScrollHandle | MinimumWidth, qskDpiScaled( 40.0 ) );
|
||||
@ -707,7 +701,7 @@ void QskMaterialSkin::initListViewHints()
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
// padding for each cell
|
||||
setMargins( Q::Cell | Padding, QskMargins( 4, 8 ) );
|
||||
setPadding( Q::Cell, QskMargins( 4, 8 ) );
|
||||
|
||||
setColor( Q::Cell, pal.baseColor );
|
||||
setColor( Q::Text, pal.textColor );
|
||||
@ -726,7 +720,7 @@ void QskMaterialSkin::initSubWindowHints()
|
||||
// Panel
|
||||
|
||||
setSkinHint( Q::Panel | Decoration, true );
|
||||
setMargins( Q::Panel | Padding, 10 );
|
||||
setPadding( Q::Panel, 10 );
|
||||
setBoxShape( Q::Panel, 0 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setGradient( Q::Panel, pal.baseColor );
|
||||
@ -743,9 +737,7 @@ void QskMaterialSkin::initSubWindowHints()
|
||||
|
||||
// TitleBarText
|
||||
setFontRole( Q::TitleBarText, QskSkin::SmallFont );
|
||||
|
||||
setSkinHint( Q::TitleBarText | Alignment,
|
||||
static_cast< int >( Qt::AlignLeft | Qt::AlignVCenter ) );
|
||||
setAlignment( Q::TitleBarText, Qt::AlignLeft | Qt::AlignVCenter );
|
||||
|
||||
for ( auto subControl : { Q::Panel, Q::TitleBar, Q::TitleBarText } )
|
||||
setAnimation( subControl | Color, qskDuration );
|
||||
|
@ -251,7 +251,7 @@ void QskSquiekSkin::initCommonHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setMargins( Control | Padding, 4 );
|
||||
setPadding( Control, 4 );
|
||||
|
||||
setGradient( Control, pal.lighter135 );
|
||||
setColor( Control | StyleColor, pal.themeForeground );
|
||||
@ -279,10 +279,10 @@ void QskSquiekSkin::initTextLabelHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
setColor( Q::Text, pal.themeForeground );
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
|
||||
@ -303,14 +303,13 @@ void QskSquiekSkin::initTextInputHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setSkinHint( Q::Text | Alignment,
|
||||
static_cast< int >( Qt::AlignLeft | Qt::AlignTop ) );
|
||||
setAlignment( Q::Text, Qt::AlignLeft | Qt::AlignTop );
|
||||
|
||||
setColor( Q::Text, pal.themeForeground );
|
||||
setColor( Q::PanelSelected, pal.highlighted );
|
||||
setColor( Q::TextSelected, pal.highlightedText );
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
|
||||
@ -352,7 +351,7 @@ void QskSquiekSkin::initProgressBarHints()
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setMetric( Q::Groove | Size, 8 );
|
||||
setMargins( Q::Groove | Padding, 0 );
|
||||
setPadding( Q::Groove, 0 );
|
||||
setGradient( Q::Groove, pal.darker200 );
|
||||
setBoxShape( Q::Groove, 4 );
|
||||
|
||||
@ -367,7 +366,7 @@ void QskSquiekSkin::initFocusIndicatorHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
setGradient( Q::Panel, Qt::transparent );
|
||||
@ -424,8 +423,8 @@ void QskSquiekSkin::initPushButtonHints()
|
||||
setMetric( Q::Panel | MinimumWidth, qskDpiScaled( 75.0 ) );
|
||||
setMetric( Q::Panel | MinimumHeight, qskDpiScaled( 23.0 ) );
|
||||
|
||||
setMargins( Q::Panel | Margin, 0 );
|
||||
setMargins( Q::Panel | Padding, 10 );
|
||||
setMargin( Q::Panel, 0 );
|
||||
setPadding( Q::Panel, 10 );
|
||||
setMetric( Q::Panel | Spacing, 4 );
|
||||
|
||||
for ( auto state : { NoState, Q::Checkable } )
|
||||
@ -448,7 +447,7 @@ void QskSquiekSkin::initPushButtonHints()
|
||||
|
||||
// Text
|
||||
setSkinHint( Q::Text | Q::Disabled | Style, Qsk::Sunken );
|
||||
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
setColor( Q::Text, pal.themeForeground );
|
||||
setColor( Q::Text | Q::Disabled, pal.darker200 );
|
||||
@ -465,7 +464,7 @@ void QskSquiekSkin::initDialogButtonHints()
|
||||
setMetric( Q::Panel | MinimumWidth, qskDpiScaled( 75.0 ) );
|
||||
setMetric( Q::Panel | MinimumHeight, qskDpiScaled( 23.0 ) );
|
||||
|
||||
setMargins( Q::Panel | Padding, 10 );
|
||||
setPadding( Q::Panel, 10 );
|
||||
setMetric( Q::Panel | Spacing, 4 );
|
||||
|
||||
setButton( Q::Panel, Raised );
|
||||
@ -476,7 +475,7 @@ void QskSquiekSkin::initDialogButtonHints()
|
||||
|
||||
// text
|
||||
setSkinHint( Q::Text | Q::Disabled | Style, Qsk::Sunken );
|
||||
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
setColor( Q::Text, pal.themeForeground );
|
||||
setColor( Q::Text | Q::Disabled, pal.darker200 );
|
||||
@ -484,7 +483,6 @@ void QskSquiekSkin::initDialogButtonHints()
|
||||
|
||||
void QskSquiekSkin::initDialogButtonBoxHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskDialogButtonBox;
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
@ -581,12 +579,12 @@ void QskSquiekSkin::initTabButtonHints()
|
||||
shape.setRadius( Qt::BottomLeftCorner, 0 );
|
||||
}
|
||||
|
||||
setMargins( aspect | Margin, margins0 );
|
||||
setMargin( aspect, margins0 );
|
||||
|
||||
for ( const auto state : { Q::Checked, Q::Checked | Q::Pressed } )
|
||||
setMargins( aspect | Margin | state, margins1 );
|
||||
setMargin( aspect | state, margins1 );
|
||||
|
||||
setMargins( aspect | Padding, padding );
|
||||
setPadding( aspect, padding );
|
||||
|
||||
setBoxBorderMetrics( aspect, border );
|
||||
setBoxShape( aspect, shape );
|
||||
@ -599,7 +597,7 @@ void QskSquiekSkin::initTabButtonHints()
|
||||
setAnimation( Q::Panel | Metric, animationHint );
|
||||
|
||||
// text
|
||||
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
setColor( Q::Text, pal.themeForeground );
|
||||
setColor( Q::Text | Q::Checkable | Q::Disabled, pal.darker200 );
|
||||
}
|
||||
@ -625,8 +623,8 @@ void QskSquiekSkin::initSliderHints()
|
||||
setGradient( aspect, QskGradient() );
|
||||
}
|
||||
|
||||
setMargins( Q::Panel | Horizontal | Padding, QskMargins( 0.5 * dim, 0 ) );
|
||||
setMargins( Q::Panel | Vertical | Padding, QskMargins( 0, 0.5 * dim ) );
|
||||
setPadding( Q::Panel | Horizontal, QskMargins( 0.5 * dim, 0 ) );
|
||||
setPadding( Q::Panel | Vertical, QskMargins( 0, 0.5 * dim ) );
|
||||
|
||||
// Groove, Fill
|
||||
|
||||
@ -637,7 +635,7 @@ void QskSquiekSkin::initSliderHints()
|
||||
const auto aspect = subControl | placement;
|
||||
|
||||
setMetric( aspect | Size, 0.3 * dim );
|
||||
setMargins( aspect | Padding, 0 );
|
||||
setPadding( aspect, 0 );
|
||||
|
||||
setBoxBorderMetrics( aspect, 0 );
|
||||
setBoxShape( aspect, 0.1 * dim );
|
||||
@ -671,15 +669,15 @@ void QskSquiekSkin::initTabBarHints()
|
||||
|
||||
setBoxBorderMetrics( Q::Panel, 0 );
|
||||
|
||||
setMargins( Q::Panel | Margin, 0 );
|
||||
setMargin( Q::Panel, 0 );
|
||||
|
||||
const qreal vb = 1.0; // borderWidth of the view
|
||||
const qreal pw = 1.0; // extra space for the negative padding of the buttons
|
||||
|
||||
setMargins( Q::Panel | Top | Padding, QskMargins( pw, 0.0, pw, vb ) );
|
||||
setMargins( Q::Panel | Bottom | Padding, QskMargins( pw, vb, pw, 0.0 ) );
|
||||
setMargins( Q::Panel | Left | Padding, QskMargins( 0.0, pw, vb, pw ) );
|
||||
setMargins( Q::Panel | Right | Padding, QskMargins( vb, pw, 0.0, pw ) );
|
||||
setPadding( Q::Panel | Top, QskMargins( pw, 0.0, pw, vb ) );
|
||||
setPadding( Q::Panel | Bottom, QskMargins( pw, vb, pw, 0.0 ) );
|
||||
setPadding( Q::Panel | Left, QskMargins( 0.0, pw, vb, pw ) );
|
||||
setPadding( Q::Panel | Right, QskMargins( vb, pw, 0.0, pw ) );
|
||||
|
||||
// when flicking
|
||||
setAnimation( Q::Panel | Metric, QskAnimationHint( 200, QEasingCurve::OutCubic ) );
|
||||
@ -690,8 +688,8 @@ void QskSquiekSkin::initTabViewHints()
|
||||
using namespace QskAspect;
|
||||
using Q = QskTabView;
|
||||
|
||||
setMargins( Q::Page | Padding, 0 );
|
||||
setMargins( Q::Page | Margin, 0 );
|
||||
setPadding( Q::Page, 0 );
|
||||
setMargin( Q::Page, 0 );
|
||||
setPanel( Q::Page, Plain );
|
||||
|
||||
const qreal radius = 8.0;
|
||||
@ -708,7 +706,7 @@ void QskSquiekSkin::initInputPanelHints()
|
||||
using namespace QskAspect;
|
||||
using Q = QskInputPanelBox;
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setPanel( Q::Panel, Raised );
|
||||
}
|
||||
|
||||
@ -719,7 +717,7 @@ void QskSquiekSkin::initInputPredictionBar()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setPanel( Q::Panel, Flat );
|
||||
|
||||
setButton( Q::ButtonPanel, Flat );
|
||||
@ -737,7 +735,7 @@ void QskSquiekSkin::initVirtualKeyboardHints()
|
||||
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setPadding( Q::Panel, 5 );
|
||||
setMetric( Q::Panel | Spacing, 5 );
|
||||
setPanel( Q::Panel, Raised );
|
||||
|
||||
@ -773,8 +771,8 @@ void QskSquiekSkin::initScrollViewHints()
|
||||
for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } )
|
||||
{
|
||||
setMetric( subControl | Size, qskDpiScaled( 12 ) );
|
||||
setMargins( subControl | Padding, 0 );
|
||||
setMargins( subControl | Margin, 0 );
|
||||
setPadding( subControl, 0 );
|
||||
setMargin( subControl, 0 );
|
||||
}
|
||||
|
||||
// scrollbar handles
|
||||
@ -811,7 +809,7 @@ void QskSquiekSkin::initListViewHints()
|
||||
const auto& pal = m_data->palette;
|
||||
|
||||
// padding for each cell
|
||||
setMargins( Q::Cell | Padding, QskMargins( 4, 8 ) );
|
||||
setPadding( Q::Cell, QskMargins( 4, 8 ) );
|
||||
|
||||
setColor( Q::Text, pal.themeForeground );
|
||||
setColor( Q::Cell, pal.contrasted );
|
||||
@ -832,7 +830,7 @@ void QskSquiekSkin::initSubWindowHints()
|
||||
// Panel
|
||||
|
||||
setSkinHint( Q::Panel | Decoration, true );
|
||||
setMargins( Q::Panel | Padding, 10 );
|
||||
setPadding( Q::Panel, 10 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxShape( Q::Panel, radius, radius, 0, 0, Qt::AbsoluteSize );
|
||||
|
||||
@ -856,8 +854,7 @@ void QskSquiekSkin::initSubWindowHints()
|
||||
setColor( Q::TitleBarText | Q::Focused, pal.highlightedText );
|
||||
setColor( Q::TitleBarText, pal.themeForeground );
|
||||
|
||||
setSkinHint( Q::TitleBarText | Alignment,
|
||||
static_cast< int >( Qt::AlignLeft | Qt::AlignVCenter ) );
|
||||
setAlignment( Q::TitleBarText, Qt::AlignLeft | Qt::AlignVCenter );
|
||||
|
||||
for ( auto subControl : { Q::Panel, Q::TitleBar, Q::TitleBarText } )
|
||||
setAnimation( subControl | Color, qskDuration );
|
||||
|
@ -168,6 +168,10 @@ namespace QskAspect
|
||||
bool isAnimator() const;
|
||||
void setAnimator( bool on );
|
||||
|
||||
bool isMetric() const;
|
||||
bool isColor() const;
|
||||
bool isFlag() const;
|
||||
|
||||
Subcontrol subControl() const;
|
||||
void setSubControl( Subcontrol );
|
||||
|
||||
@ -344,6 +348,21 @@ namespace QskAspect
|
||||
m_bits.type = type;
|
||||
}
|
||||
|
||||
inline bool Aspect::isMetric() const
|
||||
{
|
||||
return type() == Metric;
|
||||
}
|
||||
|
||||
inline bool Aspect::isColor() const
|
||||
{
|
||||
return type() == Color;
|
||||
}
|
||||
|
||||
inline bool Aspect::isFlag() const
|
||||
{
|
||||
return type() == Flag;
|
||||
}
|
||||
|
||||
inline State Aspect::state() const
|
||||
{
|
||||
return static_cast< State >( m_bits.states );
|
||||
|
@ -47,8 +47,6 @@ void QskBox::setPadding( qreal padding )
|
||||
|
||||
void QskBox::setPadding( const QMarginsF& padding )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const QMarginsF pd(
|
||||
qMax( qreal( padding.left() ), qreal( 0.0 ) ),
|
||||
qMax( qreal( padding.top() ), qreal( 0.0 ) ),
|
||||
@ -59,7 +57,7 @@ void QskBox::setPadding( const QMarginsF& padding )
|
||||
{
|
||||
const auto subControl = effectiveSubcontrol( QskBox::Panel );
|
||||
|
||||
setMarginsHint( subControl | Padding, pd );
|
||||
setPaddingHint( subControl, pd );
|
||||
resetImplicitSize();
|
||||
|
||||
if ( polishOnResize() || autoLayoutChildren() )
|
||||
@ -71,9 +69,8 @@ void QskBox::setPadding( const QMarginsF& padding )
|
||||
|
||||
void QskBox::resetPadding()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
if ( resetHint( QskBox::Panel | Metric | Padding ) )
|
||||
static auto aspectPadding = QskBox::Panel | QskAspect::Metric | QskAspect::Padding;
|
||||
if ( resetHint( aspectPadding ) )
|
||||
{
|
||||
resetImplicitSize();
|
||||
|
||||
@ -86,7 +83,7 @@ void QskBox::resetPadding()
|
||||
|
||||
QMarginsF QskBox::padding() const
|
||||
{
|
||||
return marginsHint( QskBox::Panel | QskAspect::Padding );
|
||||
return paddingHint( QskBox::Panel );
|
||||
}
|
||||
|
||||
QRectF QskBox::layoutRectForSize( const QSizeF& size ) const
|
||||
|
@ -144,8 +144,7 @@ void QskControl::setBackgroundColor( const QColor& color )
|
||||
|
||||
void QskControl::setBackground( const QskGradient& gradient )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
const auto aspect = Control | Color;
|
||||
const auto aspect = QskAspect::Control | QskAspect::Color;
|
||||
|
||||
if ( hintTable().gradient( aspect ) != gradient )
|
||||
{
|
||||
@ -159,9 +158,7 @@ void QskControl::setBackground( const QskGradient& gradient )
|
||||
|
||||
void QskControl::resetBackground()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
if ( resetHint( Control | Color ) )
|
||||
if ( resetHint( QskAspect::Control | QskAspect::Color ) )
|
||||
{
|
||||
update();
|
||||
Q_EMIT backgroundChanged();
|
||||
@ -170,8 +167,7 @@ void QskControl::resetBackground()
|
||||
|
||||
QskGradient QskControl::background() const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
return gradientHint( Control );
|
||||
return gradientHint( QskAspect::Control );
|
||||
}
|
||||
|
||||
void QskControl::setMargins( qreal margin )
|
||||
@ -181,8 +177,6 @@ void QskControl::setMargins( qreal margin )
|
||||
|
||||
void QskControl::setMargins( const QMarginsF& margins )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const QMarginsF m(
|
||||
qMax( qreal( margins.left() ), qreal( 0.0 ) ),
|
||||
qMax( qreal( margins.top() ), qreal( 0.0 ) ),
|
||||
@ -193,7 +187,7 @@ void QskControl::setMargins( const QMarginsF& margins )
|
||||
{
|
||||
const auto subControl = effectiveSubcontrol( QskAspect::Control );
|
||||
|
||||
setMarginsHint( subControl | Margin, m );
|
||||
setMarginHint( subControl, m );
|
||||
resetImplicitSize();
|
||||
|
||||
Q_D( const QskControl );
|
||||
@ -224,7 +218,7 @@ void QskControl::resetMargins()
|
||||
|
||||
QMarginsF QskControl::margins() const
|
||||
{
|
||||
return marginsHint( QskAspect::Control | QskAspect::Margin );
|
||||
return marginHint( QskAspect::Control );
|
||||
}
|
||||
|
||||
QRectF QskControl::contentsRect() const
|
||||
@ -1030,9 +1024,7 @@ QSizeF QskControl::layoutSizeHint(
|
||||
|
||||
QVector< QskAspect::Subcontrol > QskControl::subControls() const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
QVector< Subcontrol > subControls;
|
||||
QVector< QskAspect::Subcontrol > subControls;
|
||||
|
||||
for ( auto mo = metaObject(); mo != nullptr; mo = mo->superClass() )
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ void QskFocusIndicator::updateFocusFrame()
|
||||
|
||||
if ( !r.isEmpty() )
|
||||
{
|
||||
r = r.marginsAdded( marginsHint( Panel | QskAspect::Padding ) );
|
||||
r = r.marginsAdded( paddingHint( Panel ) );
|
||||
|
||||
if ( auto w = window() )
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ void QskHintAnimator::advance( qreal progress )
|
||||
{
|
||||
if ( m_updateFlags == QskAnimationHint::UpdateAuto )
|
||||
{
|
||||
if ( m_aspect.type() == QskAspect::Metric )
|
||||
if ( m_aspect.isMetric() )
|
||||
{
|
||||
m_control->resetImplicitSize();
|
||||
|
||||
|
@ -188,7 +188,7 @@ void QskListViewSkinlet::updateBackgroundNodes(
|
||||
void QskListViewSkinlet::updateForegroundNodes(
|
||||
const QskListView* listView, QskListViewNode* listViewNode ) const
|
||||
{
|
||||
QSGNode* parentNode = listViewNode->foregroundNode();
|
||||
auto parentNode = listViewNode->foregroundNode();
|
||||
|
||||
if ( listView->rowCount() <= 0 || listView->columnCount() <= 0 )
|
||||
{
|
||||
@ -197,10 +197,10 @@ void QskListViewSkinlet::updateForegroundNodes(
|
||||
return;
|
||||
}
|
||||
|
||||
const QMarginsF margins = listView->marginsHint( QskListView::Cell | QskAspect::Padding );
|
||||
const auto margins = listView->paddingHint( QskListView::Cell );
|
||||
|
||||
const QRectF cr = listView->viewContentsRect();
|
||||
const QPointF scrolledPos = listView->scrollPos();
|
||||
const auto cr = listView->viewContentsRect();
|
||||
const auto scrolledPos = listView->scrollPos();
|
||||
|
||||
const int rowMin = qFloor( scrolledPos.y() / listView->rowHeight() );
|
||||
|
||||
@ -291,7 +291,7 @@ void QskListViewSkinlet::updateVisibleForegroundNodes(
|
||||
int rowMin, int rowMax, int colMin, int colMax, const QMarginsF& margins,
|
||||
bool forward ) const
|
||||
{
|
||||
QSGNode* parentNode = listViewNode->foregroundNode();
|
||||
auto parentNode = listViewNode->foregroundNode();
|
||||
|
||||
const int rowCount = rowMax - rowMin + 1;
|
||||
const int colCount = colMax - colMin + 1;
|
||||
@ -443,8 +443,8 @@ QSGNode* QskListViewSkinlet::updateCellNode( const QskListView* listView,
|
||||
public API of QskListView TODO ...
|
||||
*/
|
||||
#endif
|
||||
const auto alignment = listView->flagHint< Qt::Alignment >(
|
||||
QskListView::Cell | QskAspect::Alignment, Qt::AlignVCenter | Qt::AlignLeft );
|
||||
const auto alignment = listView->alignmentHint(
|
||||
QskListView::Cell, Qt::AlignVCenter | Qt::AlignLeft );
|
||||
|
||||
const QVariant value = listView->valueAt( row, col );
|
||||
|
||||
|
@ -54,11 +54,10 @@ QSGNode* QskPageIndicatorSkinlet::updateSubNode(
|
||||
QRectF QskPageIndicatorSkinlet::bulletRect(
|
||||
const QskPageIndicator* indicator, const QRectF& rect, int index ) const
|
||||
{
|
||||
const qreal szNormal =
|
||||
indicator->metric( QskPageIndicator::Bullet | QskAspect::Size );
|
||||
using Q = QskPageIndicator;
|
||||
|
||||
const qreal szHighlighted =
|
||||
indicator->metric( QskPageIndicator::Highlighted | QskAspect::Size );
|
||||
const qreal szNormal = indicator->metric( Q::Bullet | QskAspect::Size );
|
||||
const qreal szHighlighted = indicator->metric( Q::Highlighted | QskAspect::Size );
|
||||
|
||||
// scale bullet size if we are in between a transition:
|
||||
qreal indexDiff = qAbs( indicator->currentIndex() - index );
|
||||
@ -68,7 +67,7 @@ QRectF QskPageIndicatorSkinlet::bulletRect(
|
||||
const qreal sz = ( indexDiff < 1 ) ?
|
||||
( 1 - indexDiff ) * szHighlighted + indexDiff * szNormal : szNormal;
|
||||
|
||||
const qreal spacing = indicator->metric( QskPageIndicator::Panel | QskAspect::Spacing );
|
||||
const qreal spacing = indicator->spacingHint( Q::Panel );
|
||||
const bool horizontal = ( indicator->orientation() == Qt::Horizontal );
|
||||
|
||||
qreal w, h;
|
||||
@ -123,8 +122,7 @@ QRectF QskPageIndicatorSkinlet::bulletRect(
|
||||
yAdjust *= indexDiff;
|
||||
const qreal y = ( horizontal ? r.top() : r.left() ) + yAdjust;
|
||||
|
||||
QRectF ret = horizontal ? QRectF( x, y, sz, sz ) : QRectF( y, x, sz, sz );
|
||||
return ret;
|
||||
return horizontal ? QRectF( x, y, sz, sz ) : QRectF( y, x, sz, sz );
|
||||
}
|
||||
|
||||
QSGNode* QskPageIndicatorSkinlet::updateBulletsNode(
|
||||
|
@ -299,7 +299,7 @@ bool QskPopup::isTransitionAccepted( QskAspect::Aspect aspect ) const
|
||||
if ( aspect == m_data->faderAspect )
|
||||
return true;
|
||||
|
||||
if ( aspect.type() == QskAspect::Color )
|
||||
if ( aspect.isColor() )
|
||||
{
|
||||
if ( aspect.subControl() == effectiveSubcontrol( QskPopup::Overlay ) )
|
||||
return true;
|
||||
|
@ -146,7 +146,7 @@ QRectF QskProgressBarSkinlet::barRect( const QskProgressBar* bar ) const
|
||||
|
||||
const auto borderMetrics = bar->boxBorderMetricsHint( subControl );
|
||||
|
||||
auto m = bar->marginsHint( subControl | QskAspect::Padding );
|
||||
auto m = bar->paddingHint( subControl );
|
||||
m += 0.5 * borderMetrics.toAbsolute( rect.size() ).widths();
|
||||
|
||||
rect = rect.marginsRemoved( m );
|
||||
|
@ -60,8 +60,8 @@ QskPushButton::~QskPushButton()
|
||||
|
||||
void QskPushButton::setCorner( const QskCorner& corner )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
const auto aspect = Panel | Shape;
|
||||
// effectiveSubcontrol TODO ...
|
||||
const auto aspect = Panel | QskAspect::Shape;
|
||||
|
||||
if ( corner.metrics() != boxShapeHint( aspect ) )
|
||||
{
|
||||
@ -74,10 +74,7 @@ void QskPushButton::setCorner( const QskCorner& corner )
|
||||
|
||||
QskCorner QskPushButton::corner() const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
const auto aspect = Panel | Shape;
|
||||
|
||||
const auto shape = boxShapeHint( aspect );
|
||||
const auto shape = boxShapeHint( Panel | QskAspect::Shape );
|
||||
|
||||
#if 1
|
||||
QskCorner corner;
|
||||
|
@ -93,15 +93,13 @@ QRectF QskPushButtonSkinlet::graphicRect(
|
||||
{
|
||||
// buttonShift -> TODO
|
||||
|
||||
QRectF r = button->innerBox( QskPushButton::Panel,
|
||||
auto r = button->innerBox( QskPushButton::Panel,
|
||||
subControlRect( button, contentsRect, QskPushButton::Panel ) );
|
||||
|
||||
if ( !button->text().isEmpty() )
|
||||
{
|
||||
const auto textRect = subControlRect( button, contentsRect, QskPushButton::Text );
|
||||
|
||||
qreal h = textRect.height() +
|
||||
button->metric( QskPushButton::Panel | QskAspect::Spacing );
|
||||
qreal h = textRect.height() + button->spacingHint( QskPushButton::Panel );
|
||||
|
||||
if ( h < r.height() )
|
||||
r.setBottom( r.bottom() - h );
|
||||
@ -161,8 +159,7 @@ QSGNode* QskPushButtonSkinlet::updateTextNode(
|
||||
if ( !button->clip() && ( rect.height() < fm.height() ) )
|
||||
return nullptr;
|
||||
|
||||
const auto alignment = button->flagHint< Qt::Alignment >(
|
||||
QskPushButton::Text | QskAspect::Alignment, Qt::AlignCenter );
|
||||
const auto alignment = button->alignmentHint( QskPushButton::Text, Qt::AlignCenter );
|
||||
|
||||
return QskSkinlet::updateTextNode( button, node, rect, alignment,
|
||||
button->text(), button->textOptions(), QskPushButton::Text );
|
||||
|
@ -42,12 +42,14 @@ static inline QSizeF qskPanelInnerSize( const QskScrollView* scrollView )
|
||||
static inline QSizeF qskScrolledItemSize( const QskScrollView* scrollView,
|
||||
const QQuickItem* item, const QSizeF& boundingSize )
|
||||
{
|
||||
using Q = QskScrollView;
|
||||
|
||||
QSizeF outerSize = boundingSize;
|
||||
|
||||
const qreal spacing = scrollView->metric( QskScrollView::Panel | QskAspect::Spacing );
|
||||
const qreal spacing = scrollView->spacingHint( Q::Panel );
|
||||
|
||||
const auto sbV = scrollView->metric( QskScrollView::VerticalScrollBar | QskAspect::Size );
|
||||
const auto sbH = scrollView->metric( QskScrollView::HorizontalScrollBar | QskAspect::Size );
|
||||
const auto sbV = scrollView->metric( Q::VerticalScrollBar | QskAspect::Size );
|
||||
const auto sbH = scrollView->metric( Q::HorizontalScrollBar | QskAspect::Size );
|
||||
|
||||
const auto policyH = scrollView->horizontalScrollBarPolicy();
|
||||
const auto policyV = scrollView->verticalScrollBarPolicy();
|
||||
|
@ -185,15 +185,17 @@ QSGNode* QskScrollViewSkinlet::contentsNode( const QskScrollView* scrollView )
|
||||
QRectF QskScrollViewSkinlet::viewportRect(
|
||||
const QskScrollView* scrollView, const QRectF& contentsRect ) const
|
||||
{
|
||||
const Qt::Orientations orientation = scrollView->scrollableOrientations();
|
||||
using Q = QskScrollView;
|
||||
|
||||
QRectF vr = subControlRect( scrollView, contentsRect, QskScrollView::Panel );
|
||||
const qreal spacing = scrollView->metric( QskScrollView::Panel | QskAspect::Spacing );
|
||||
const auto orientation = scrollView->scrollableOrientations();
|
||||
|
||||
auto vr = subControlRect( scrollView, contentsRect, Q::Panel );
|
||||
const qreal spacing = scrollView->spacingHint( Q::Panel );
|
||||
|
||||
if ( orientation & Qt::Vertical )
|
||||
{
|
||||
const QRectF r = subControlRect(
|
||||
scrollView, contentsRect, QskScrollView::VerticalScrollBar );
|
||||
const auto r = subControlRect(
|
||||
scrollView, contentsRect, Q::VerticalScrollBar );
|
||||
|
||||
if ( r.width() > 0.0 )
|
||||
vr.setWidth( vr.width() - r.width() - spacing );
|
||||
@ -201,8 +203,8 @@ QRectF QskScrollViewSkinlet::viewportRect(
|
||||
|
||||
if ( orientation & Qt::Horizontal )
|
||||
{
|
||||
const QRectF r = subControlRect(
|
||||
scrollView, contentsRect, QskScrollView::HorizontalScrollBar );
|
||||
const auto r = subControlRect(
|
||||
scrollView, contentsRect, Q::HorizontalScrollBar );
|
||||
|
||||
if ( r.height() >= 0.0 )
|
||||
vr.setHeight( vr.height() - r.height() - spacing );
|
||||
@ -221,6 +223,7 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||
const QRectF& contentsRect, Qt::Orientation orientation ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskScrollView;
|
||||
|
||||
const auto scrollOrientations = scrollView->scrollableOrientations();
|
||||
if ( !( orientation & scrollOrientations ) )
|
||||
@ -235,10 +238,10 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||
|
||||
if ( orientation == Qt::Vertical )
|
||||
{
|
||||
const auto subControlBar = QskScrollView::VerticalScrollBar;
|
||||
const auto subControlBar = Q::VerticalScrollBar;
|
||||
|
||||
const QRectF sbRect = subControlRect( scrollView, contentsRect, subControlBar );
|
||||
const QMarginsF padding = scrollView->marginsHint( subControlBar | Padding );
|
||||
const auto sbRect = subControlRect( scrollView, contentsRect, subControlBar );
|
||||
const auto padding = scrollView->paddingHint( subControlBar );
|
||||
|
||||
const qreal h = scrollView->scrollableSize().height();
|
||||
|
||||
@ -246,7 +249,7 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||
const qreal y2 = ( pos.y() + vRect.height() ) / h;
|
||||
|
||||
const qreal minHandleLength =
|
||||
scrollView->metric( QskScrollView::VerticalScrollHandle | MinimumHeight );
|
||||
scrollView->metric( Q::VerticalScrollHandle | MinimumHeight );
|
||||
|
||||
qreal top, bottom;
|
||||
qskAlignedHandle( y1, y2, sbRect.height(), minHandleLength, top, bottom );
|
||||
@ -258,10 +261,10 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto subControlBar = QskScrollView::HorizontalScrollBar;
|
||||
const auto subControlBar = Q::HorizontalScrollBar;
|
||||
|
||||
const QRectF sbRect = subControlRect( scrollView, contentsRect, subControlBar );
|
||||
const auto padding = scrollView->marginsHint( subControlBar | Padding );
|
||||
const auto sbRect = subControlRect( scrollView, contentsRect, subControlBar );
|
||||
const auto padding = scrollView->paddingHint( subControlBar );
|
||||
|
||||
const qreal w = scrollView->scrollableSize().width();
|
||||
|
||||
@ -269,7 +272,7 @@ QRectF QskScrollViewSkinlet::scrollHandleRect( const QskScrollView* scrollView,
|
||||
const qreal x2 = ( pos.x() + vRect.width() ) / w;
|
||||
|
||||
const qreal minHandleLength =
|
||||
scrollView->metric( QskScrollView::HorizontalScrollHandle | MinimumWidth );
|
||||
scrollView->metric( Q::HorizontalScrollHandle | MinimumWidth );
|
||||
|
||||
qreal left, right;
|
||||
qskAlignedHandle( x1, x2, sbRect.width(), minHandleLength, left, right );
|
||||
@ -287,40 +290,33 @@ QRectF QskScrollViewSkinlet::scrollBarRect( const QskScrollView* scrollView,
|
||||
const QRectF& contentsRect, Qt::Orientation orientation ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskScrollView;
|
||||
|
||||
const auto scrollOrientations = scrollView->scrollableOrientations();
|
||||
if ( !( orientation & scrollOrientations ) )
|
||||
return QRectF();
|
||||
|
||||
QRectF r = subControlRect( scrollView, contentsRect, QskScrollView::Panel );
|
||||
auto r = subControlRect( scrollView, contentsRect, Q::Panel );
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
{
|
||||
const qreal h = scrollView->metric(
|
||||
QskScrollView::HorizontalScrollBar | Size );
|
||||
|
||||
const qreal h = scrollView->metric( Q::HorizontalScrollBar | Size );
|
||||
r.setTop( r.bottom() - h );
|
||||
|
||||
if ( scrollOrientations & Qt::Vertical )
|
||||
{
|
||||
const qreal w = scrollView->metric(
|
||||
QskScrollView::VerticalScrollBar | Size );
|
||||
|
||||
const qreal w = scrollView->metric( Q::VerticalScrollBar | Size );
|
||||
r.setRight( r.right() - w );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const qreal w = scrollView->metric(
|
||||
QskScrollView::VerticalScrollBar | Size );
|
||||
|
||||
const qreal w = scrollView->metric( Q::VerticalScrollBar | Size );
|
||||
r.setLeft( r.right() - w );
|
||||
|
||||
if ( scrollOrientations & Qt::Horizontal )
|
||||
{
|
||||
const qreal h = scrollView->metric(
|
||||
QskScrollView::HorizontalScrollBar | Size );
|
||||
|
||||
const qreal h = scrollView->metric( Q::HorizontalScrollBar | Size );
|
||||
r.setBottom( r.bottom() - h );
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ QSK_SUBCONTROL( QskSeparator, Panel )
|
||||
|
||||
static inline QskAspect::Aspect qskAspectThickness()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
return QskSeparator::Panel | Metric | Size;
|
||||
return QskSeparator::Panel | QskAspect::Metric | QskAspect::Size;
|
||||
}
|
||||
|
||||
QskSeparator::QskSeparator( QQuickItem* parent )
|
||||
|
@ -279,13 +279,13 @@ qreal QskSimpleListBox::columnWidth( int col ) const
|
||||
if ( col >= columnCount() )
|
||||
return 0.0;
|
||||
|
||||
const auto padding = marginsHint( Cell | QskAspect::Padding );
|
||||
const auto padding = paddingHint( Cell );
|
||||
return m_data->maxTextWidth + padding.left() + padding.right();
|
||||
}
|
||||
|
||||
qreal QskSimpleListBox::rowHeight() const
|
||||
{
|
||||
const auto padding = marginsHint( Cell | QskAspect::Padding );
|
||||
const auto padding = paddingHint( Cell );
|
||||
const QFontMetricsF fm( effectiveFont( Text ) );
|
||||
|
||||
return fm.height() + padding.top() + padding.bottom();
|
||||
|
@ -156,11 +156,9 @@ QskSkin::QskSkin( QObject* parent )
|
||||
const QFont font = QGuiApplication::font();
|
||||
setupFonts( font.family(), font.weight(), font.italic() );
|
||||
|
||||
using namespace QskAspect;
|
||||
|
||||
setMargins( Control | Margin, 0 );
|
||||
setMargins( Control | Padding, 0 );
|
||||
setMetric( Control | Spacing, 0 );
|
||||
setMargin( QskAspect::Control, 0 );
|
||||
setPadding( QskAspect::Control, 0 );
|
||||
setSpacing( QskAspect::Control, 0 );
|
||||
}
|
||||
|
||||
QskSkin::~QskSkin()
|
||||
@ -197,14 +195,34 @@ qreal QskSkin::metric( QskAspect::Aspect aspect ) const
|
||||
return m_data->hintTable.metric( aspect );
|
||||
}
|
||||
|
||||
void QskSkin::setMargins( QskAspect::Aspect aspect, const QskMargins& margins )
|
||||
void QskSkin::setMargin( QskAspect::Aspect aspect, const QskMargins& margins )
|
||||
{
|
||||
m_data->hintTable.setMargins( aspect, margins );
|
||||
m_data->hintTable.setMargin( aspect, margins );
|
||||
}
|
||||
|
||||
QskMargins QskSkin::margins( QskAspect::Aspect aspect ) const
|
||||
QskMargins QskSkin::margin( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
return m_data->hintTable.margins( aspect );
|
||||
return m_data->hintTable.margin( aspect );
|
||||
}
|
||||
|
||||
void QskSkin::setPadding( QskAspect::Aspect aspect, const QskMargins& padding )
|
||||
{
|
||||
m_data->hintTable.setPadding( aspect, padding );
|
||||
}
|
||||
|
||||
QskMargins QskSkin::padding( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
return m_data->hintTable.padding( aspect );
|
||||
}
|
||||
|
||||
void QskSkin::setSpacing( QskAspect::Aspect aspect, qreal spacing )
|
||||
{
|
||||
m_data->hintTable.setSpacing( aspect, spacing );
|
||||
}
|
||||
|
||||
qreal QskSkin::spacing( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
return m_data->hintTable.spacing( aspect );
|
||||
}
|
||||
|
||||
void QskSkin::setGradient( QskAspect::Aspect aspect, const QskGradient& gradient )
|
||||
@ -290,6 +308,16 @@ QskAnimationHint QskSkin::animation( QskAspect::Aspect aspect ) const
|
||||
return m_data->hintTable.animation( aspect );
|
||||
}
|
||||
|
||||
void QskSkin::setAlignment( QskAspect::Aspect aspect, Qt::Alignment alignment )
|
||||
{
|
||||
m_data->hintTable.setAlignment( aspect, alignment );
|
||||
}
|
||||
|
||||
Qt::Alignment QskSkin::alignment( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
return m_data->hintTable.alignment( aspect );
|
||||
}
|
||||
|
||||
void QskSkin::setSkinHint( QskAspect::Aspect aspect, const QVariant& skinHint )
|
||||
{
|
||||
m_data->hintTable.setHint( aspect, skinHint );
|
||||
|
@ -70,8 +70,14 @@ class QSK_EXPORT QskSkin : public QObject
|
||||
void setMetric( QskAspect::Aspect, qreal metric );
|
||||
qreal metric( QskAspect::Aspect ) const;
|
||||
|
||||
void setMargins( QskAspect::Aspect, const QskMargins& );
|
||||
QskMargins margins( QskAspect::Aspect ) const;
|
||||
void setMargin( QskAspect::Aspect, const QskMargins& );
|
||||
QskMargins margin( QskAspect::Aspect ) const;
|
||||
|
||||
void setPadding( QskAspect::Aspect, const QskMargins& );
|
||||
QskMargins padding( QskAspect::Aspect ) const;
|
||||
|
||||
void setSpacing( QskAspect::Aspect, qreal );
|
||||
qreal spacing( QskAspect::Aspect ) const;
|
||||
|
||||
void setGradient( QskAspect::Aspect, const QskGradient& );
|
||||
QskGradient gradient( QskAspect::Aspect ) const;
|
||||
@ -95,6 +101,9 @@ class QSK_EXPORT QskSkin : public QObject
|
||||
void setAnimation( QskAspect::Aspect, QskAnimationHint );
|
||||
QskAnimationHint animation( QskAspect::Aspect ) const;
|
||||
|
||||
void setAlignment( QskAspect::Aspect, Qt::Alignment );
|
||||
Qt::Alignment alignment( QskAspect::Aspect ) const;
|
||||
|
||||
void setSkinHint( QskAspect::Aspect, const QVariant& hint );
|
||||
const QVariant& skinHint( QskAspect::Aspect ) const;
|
||||
|
||||
|
@ -39,8 +39,11 @@ class QSK_EXPORT QskSkinHintTable
|
||||
void setMetric( QskAspect::Aspect, qreal metric );
|
||||
qreal metric( QskAspect::Aspect ) const;
|
||||
|
||||
void setMargins( QskAspect::Aspect, const QskMargins& );
|
||||
QskMargins margins( QskAspect::Aspect ) const;
|
||||
void setMargin( QskAspect::Aspect, const QskMargins& );
|
||||
QskMargins margin( QskAspect::Aspect ) const;
|
||||
|
||||
void setPadding( QskAspect::Aspect, const QskMargins& );
|
||||
QskMargins padding( QskAspect::Aspect ) const;
|
||||
|
||||
void setGradient( QskAspect::Aspect, const QskGradient& );
|
||||
QskGradient gradient( QskAspect::Aspect ) const;
|
||||
@ -57,6 +60,12 @@ class QSK_EXPORT QskSkinHintTable
|
||||
void setInterval( QskAspect::Aspect, const QskIntervalF& );
|
||||
QskIntervalF interval( QskAspect::Aspect ) const;
|
||||
|
||||
void setSpacing( QskAspect::Aspect, qreal );
|
||||
qreal spacing( QskAspect::Aspect ) const;
|
||||
|
||||
void setAlignment( QskAspect::Aspect, Qt::Alignment );
|
||||
Qt::Alignment alignment( QskAspect::Aspect ) const;
|
||||
|
||||
void setAnimation( QskAspect::Aspect, QskAnimationHint animation );
|
||||
QskAnimationHint animation( QskAspect::Aspect ) const;
|
||||
|
||||
@ -166,15 +175,30 @@ inline qreal QskSkinHintTable::metric( QskAspect::Aspect aspect ) const
|
||||
return hint( aspect | QskAspect::Metric ).toReal();
|
||||
}
|
||||
|
||||
inline void QskSkinHintTable::setMargins(
|
||||
inline void QskSkinHintTable::setMargin(
|
||||
QskAspect::Aspect aspect, const QskMargins& margins )
|
||||
{
|
||||
setHint( aspect | QskAspect::Metric, QVariant::fromValue( margins ) );
|
||||
const auto aspectMargin = aspect | QskAspect::Metric | QskAspect::Margin;
|
||||
setHint( aspectMargin, QVariant::fromValue( margins ) );
|
||||
}
|
||||
|
||||
inline QskMargins QskSkinHintTable::margins( QskAspect::Aspect aspect ) const
|
||||
inline QskMargins QskSkinHintTable::margin( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
return hint( aspect | QskAspect::Metric ).value< QskMargins >();
|
||||
const auto aspectMargin = aspect | QskAspect::Metric | QskAspect::Margin;
|
||||
return hint( aspectMargin ).value< QskMargins >();
|
||||
}
|
||||
|
||||
inline void QskSkinHintTable::setPadding(
|
||||
QskAspect::Aspect aspect, const QskMargins& padding )
|
||||
{
|
||||
const auto aspectPadding = aspect | QskAspect::Metric | QskAspect::Padding;
|
||||
setHint( aspectPadding, QVariant::fromValue( padding ) );
|
||||
}
|
||||
|
||||
inline QskMargins QskSkinHintTable::padding( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
const auto aspectPadding = aspect | QskAspect::Metric | QskAspect::Padding;
|
||||
return hint( aspectPadding ).value< QskMargins >();
|
||||
}
|
||||
|
||||
inline void QskSkinHintTable::setGradient(
|
||||
@ -230,14 +254,22 @@ inline QskBoxBorderColors QskSkinHintTable::boxBorderColors( QskAspect::Aspect a
|
||||
inline void QskSkinHintTable::setInterval(
|
||||
QskAspect::Aspect aspect, const QskIntervalF& interval )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
setHint( aspect | Metric, QVariant::fromValue( interval ) );
|
||||
setHint( aspect | QskAspect::Metric, QVariant::fromValue( interval ) );
|
||||
}
|
||||
|
||||
inline QskIntervalF QskSkinHintTable::interval( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
return hint( aspect | Metric ).value< QskIntervalF >();
|
||||
return hint( aspect | QskAspect::Metric ).value< QskIntervalF >();
|
||||
}
|
||||
|
||||
inline void QskSkinHintTable::setSpacing( QskAspect::Aspect aspect, qreal spacing )
|
||||
{
|
||||
setMetric( aspect | QskAspect::Spacing, spacing );
|
||||
}
|
||||
|
||||
inline qreal QskSkinHintTable::spacing( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
return metric( aspect | QskAspect::Spacing );
|
||||
}
|
||||
|
||||
inline QskAnimationHint QskSkinHintTable::animation( QskAspect::Aspect aspect ) const
|
||||
@ -256,6 +288,17 @@ inline void QskSkinHintTable::setFontRole( QskAspect::Aspect aspect, int role )
|
||||
setHint( aspect | QskAspect::FontRole, role );
|
||||
}
|
||||
|
||||
inline void QskSkinHintTable::setAlignment(
|
||||
QskAspect::Aspect aspect, Qt::Alignment alignment )
|
||||
{
|
||||
setFlagHint( aspect | QskAspect::Alignment, alignment );
|
||||
}
|
||||
|
||||
inline Qt::Alignment QskSkinHintTable::alignment( QskAspect::Aspect aspect ) const
|
||||
{
|
||||
return hint( aspect | QskAspect::Alignment ).value< Qt::Alignment >();
|
||||
}
|
||||
|
||||
inline void QskSkinHintTable::setFlagHint( QskAspect::Aspect aspect, int flag )
|
||||
{
|
||||
setHint( aspect, QVariant( flag ) );
|
||||
|
@ -308,9 +308,7 @@ namespace
|
||||
|
||||
for ( const auto& candidate : candidates )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
if ( candidate.aspect.type() != Metric )
|
||||
if ( !candidate.aspect.isMetric() )
|
||||
{
|
||||
if ( !( control->flags() & QQuickItem::ItemHasContents ) )
|
||||
{
|
||||
@ -396,7 +394,7 @@ namespace
|
||||
info.control = control;
|
||||
|
||||
info.updateModes = UpdateInfo::Update;
|
||||
if ( aspect.type() == QskAspect::Metric )
|
||||
if ( aspect.isMetric() )
|
||||
info.updateModes |= UpdateInfo::Polish;
|
||||
|
||||
auto it = std::lower_bound(
|
||||
|
@ -89,8 +89,6 @@ static inline bool qskIsBoxVisible( const QskBoxBorderMetrics& borderMetrics,
|
||||
static inline QskTextColors qskTextColors(
|
||||
const QskSkinnable* skinnable, QskAspect::Subcontrol subControl )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
/*
|
||||
Would be more efficient to have QskTextColors hints instead of
|
||||
storing the colors as seperated hints. TODO ...
|
||||
@ -102,11 +100,11 @@ static inline QskTextColors qskTextColors(
|
||||
c.textColor = skinnable->color( subControl, &status );
|
||||
#if 1
|
||||
if ( !status.isValid() )
|
||||
c.textColor = skinnable->color( subControl | TextColor );
|
||||
c.textColor = skinnable->color( subControl | QskAspect::TextColor );
|
||||
#endif
|
||||
|
||||
c.styleColor = skinnable->color( subControl | StyleColor );
|
||||
c.linkColor = skinnable->color( subControl | LinkColor );
|
||||
c.styleColor = skinnable->color( subControl | QskAspect::StyleColor );
|
||||
c.linkColor = skinnable->color( subControl | QskAspect::LinkColor );
|
||||
|
||||
return c;
|
||||
}
|
||||
@ -289,9 +287,7 @@ QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
||||
QSGNode* node, const QRectF& rect, const QskGradient& fillGradient,
|
||||
QskAspect::Subcontrol subControl )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const auto margins = skinnable->marginsHint( subControl | Margin );
|
||||
const auto margins = skinnable->marginHint( subControl );
|
||||
|
||||
const auto boxRect = rect.marginsRemoved( margins );
|
||||
if ( boxRect.isEmpty() )
|
||||
@ -327,13 +323,11 @@ QSGNode* QskSkinlet::updateBoxClipNode( const QskSkinnable* skinnable,
|
||||
QSGNode* QskSkinlet::updateBoxClipNode( const QskSkinnable* skinnable,
|
||||
QSGNode* node, const QRectF& rect, QskAspect::Subcontrol subControl )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
auto clipNode = static_cast< QskBoxClipNode* >( node );
|
||||
if ( clipNode == nullptr )
|
||||
clipNode = new QskBoxClipNode();
|
||||
|
||||
const auto margins = skinnable->marginsHint( subControl | Margin );
|
||||
const auto margins = skinnable->marginHint( subControl );
|
||||
|
||||
const auto clipRect = rect.marginsRemoved( margins );
|
||||
if ( clipRect.isEmpty() )
|
||||
@ -409,8 +403,7 @@ QSGNode* QskSkinlet::updateTextNode(
|
||||
QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
const auto rect = qskSubControlRect( this, skinnable, subControl );
|
||||
const auto alignment = skinnable->flagHint< Qt::Alignment >(
|
||||
QskAspect::Alignment | subControl, Qt::AlignLeft );
|
||||
const auto alignment = skinnable->alignmentHint( subControl, Qt::AlignLeft );
|
||||
|
||||
return updateTextNode( skinnable, node,
|
||||
rect, alignment, text, textOptions, subControl );
|
||||
@ -422,10 +415,7 @@ QSGNode* QskSkinlet::updateGraphicNode(
|
||||
Qt::Orientations mirrored ) const
|
||||
{
|
||||
const auto rect = qskSubControlRect( this, skinnable, subcontrol );
|
||||
|
||||
const auto alignment = skinnable->flagHint< Qt::Alignment >(
|
||||
subcontrol | QskAspect::Alignment, Qt::AlignCenter );
|
||||
|
||||
const auto alignment = skinnable->alignmentHint( subcontrol, Qt::AlignCenter );
|
||||
const auto colorFilter = skinnable->effectiveGraphicFilter( subcontrol );
|
||||
|
||||
return updateGraphicNode( skinnable, node,
|
||||
|
@ -77,17 +77,15 @@ static inline bool qskCompareResolvedStates(
|
||||
|
||||
if ( s1 == 0 )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
if ( aspect1.placement() == NoPlacement )
|
||||
if ( aspect1.placement() == QskAspect::NoPlacement )
|
||||
return true;
|
||||
|
||||
// clear the placement bits and restart with the initial state
|
||||
aspect1 = a1;
|
||||
aspect1.setPlacement( NoPlacement );
|
||||
aspect1.setPlacement( QskAspect::NoPlacement );
|
||||
|
||||
aspect2 = a2;
|
||||
aspect2.setPlacement( NoPlacement );
|
||||
aspect2.setPlacement( QskAspect::NoPlacement );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -207,6 +205,12 @@ int QskSkinnable::flagHint( QskAspect::Aspect aspect ) const
|
||||
return effectiveHint( aspect ).toInt();
|
||||
}
|
||||
|
||||
void QskSkinnable::setAlignmentHint(
|
||||
QskAspect::Aspect aspect, Qt::Alignment alignment )
|
||||
{
|
||||
setFlagHint( aspect | QskAspect::Alignment, alignment );
|
||||
}
|
||||
|
||||
void QskSkinnable::setColor( QskAspect::Aspect aspect, const QColor& color )
|
||||
{
|
||||
m_data->hintTable.setColor( aspect, color );
|
||||
@ -237,20 +241,38 @@ qreal QskSkinnable::metric( QskAspect::Aspect aspect, QskSkinHintStatus* status
|
||||
return effectiveHint( aspect | QskAspect::Metric, status ).toReal();
|
||||
}
|
||||
|
||||
void QskSkinnable::setMarginsHint( QskAspect::Aspect aspect, qreal margins )
|
||||
void QskSkinnable::setMarginHint( QskAspect::Aspect aspect, qreal margins )
|
||||
{
|
||||
m_data->hintTable.setMargins( aspect, QskMargins( margins ) );
|
||||
m_data->hintTable.setMargin( aspect, QskMargins( margins ) );
|
||||
}
|
||||
|
||||
void QskSkinnable::setMarginsHint( QskAspect::Aspect aspect, const QMarginsF& margins )
|
||||
void QskSkinnable::setMarginHint( QskAspect::Aspect aspect, const QMarginsF& margins )
|
||||
{
|
||||
m_data->hintTable.setMargins( aspect, margins );
|
||||
m_data->hintTable.setMargin( aspect, margins );
|
||||
}
|
||||
|
||||
QMarginsF QskSkinnable::marginsHint(
|
||||
QMarginsF QskSkinnable::marginHint(
|
||||
QskAspect::Aspect aspect, QskSkinHintStatus* status ) const
|
||||
{
|
||||
return effectiveHint( aspect | QskAspect::Metric, status ).value< QskMargins >();
|
||||
const auto aspectMargin = aspect | QskAspect::Metric | QskAspect::Margin;
|
||||
return effectiveHint( aspectMargin, status ).value< QskMargins >();
|
||||
}
|
||||
|
||||
void QskSkinnable::setPaddingHint( QskAspect::Aspect aspect, qreal padding )
|
||||
{
|
||||
m_data->hintTable.setPadding( aspect, QskMargins( padding ) );
|
||||
}
|
||||
|
||||
void QskSkinnable::setPaddingHint( QskAspect::Aspect aspect, const QMarginsF& padding )
|
||||
{
|
||||
m_data->hintTable.setPadding( aspect, padding );
|
||||
}
|
||||
|
||||
QMarginsF QskSkinnable::paddingHint(
|
||||
QskAspect::Aspect aspect, QskSkinHintStatus* status ) const
|
||||
{
|
||||
const auto aspectPadding = aspect | QskAspect::Metric | QskAspect::Padding;
|
||||
return effectiveHint( aspectPadding, status ).value< QskMargins >();
|
||||
}
|
||||
|
||||
void QskSkinnable::setGradientHint(
|
||||
@ -316,6 +338,17 @@ QskIntervalF QskSkinnable::intervalHint(
|
||||
return effectiveHint( aspect | QskAspect::Metric, status ).value< QskIntervalF >();
|
||||
}
|
||||
|
||||
void QskSkinnable::setSpacingHint( QskAspect::Aspect aspect, qreal spacing )
|
||||
{
|
||||
m_data->hintTable.setSpacing( aspect, spacing );
|
||||
}
|
||||
|
||||
qreal QskSkinnable::spacingHint(
|
||||
QskAspect::Aspect aspect, QskSkinHintStatus* status ) const
|
||||
{
|
||||
return metric( aspect | QskAspect::Spacing, status );
|
||||
}
|
||||
|
||||
void QskSkinnable::setFontRole( QskAspect::Aspect aspect, int role )
|
||||
{
|
||||
m_data->hintTable.setFontRole( aspect, role );
|
||||
@ -352,7 +385,7 @@ QskColorFilter QskSkinnable::effectiveGraphicFilter(
|
||||
|
||||
QskSkinHintStatus status;
|
||||
|
||||
const QVariant hint = storedHint( aspect | skinState(), &status );
|
||||
const auto hint = storedHint( aspect | skinState(), &status );
|
||||
if ( status.isValid() )
|
||||
{
|
||||
// we need to know about how the aspect gets resolved
|
||||
@ -585,7 +618,7 @@ const QVariant& QskSkinnable::storedHint(
|
||||
const auto& localTable = m_data->hintTable;
|
||||
if ( localTable.hasHints() )
|
||||
{
|
||||
QskAspect::Aspect a = aspect;
|
||||
auto a = aspect;
|
||||
|
||||
if ( !localTable.hasStates() )
|
||||
{
|
||||
@ -609,7 +642,7 @@ const QVariant& QskSkinnable::storedHint(
|
||||
const auto& skinTable = skin->hintTable();
|
||||
if ( skinTable.hasHints() )
|
||||
{
|
||||
QskAspect::Aspect a = aspect;
|
||||
auto a = aspect;
|
||||
|
||||
const QVariant* value = skinTable.resolvedHint( a, &resolvedAspect );
|
||||
if ( value )
|
||||
@ -685,19 +718,18 @@ static inline QMarginsF qskEffectivePadding( const QskSkinnable* skinnable,
|
||||
QskAspect::Aspect aspect, const QSizeF& size, bool inner )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using namespace Qt;
|
||||
|
||||
const auto shape = skinnable->boxShapeHint( aspect | Shape ).toAbsolute( size );
|
||||
const auto borderMetrics = skinnable->boxBorderMetricsHint( aspect | Border );
|
||||
const auto shape = skinnable->boxShapeHint( aspect ).toAbsolute( size );
|
||||
const auto borderMetrics = skinnable->boxBorderMetricsHint( aspect );
|
||||
|
||||
const qreal left = qMax( shape.radius( TopLeftCorner ).width(),
|
||||
shape.radius( BottomLeftCorner ).width() );
|
||||
const qreal left = qMax( shape.radius( Qt::TopLeftCorner ).width(),
|
||||
shape.radius( Qt::BottomLeftCorner ).width() );
|
||||
|
||||
const qreal top = qMax( shape.radius( TopLeftCorner ).height(),
|
||||
shape.radius( TopRightCorner ).height() );
|
||||
const qreal top = qMax( shape.radius( Qt::TopLeftCorner ).height(),
|
||||
shape.radius( Qt::TopRightCorner ).height() );
|
||||
|
||||
const qreal right = qMax( shape.radius( TopRightCorner ).width(),
|
||||
shape.radius( BottomRightCorner ).width() );
|
||||
const qreal right = qMax( shape.radius( Qt::TopRightCorner ).width(),
|
||||
shape.radius( Qt::BottomRightCorner ).width() );
|
||||
|
||||
const qreal bottom = qMax( shape.radius( Qt::BottomLeftCorner ).height(),
|
||||
shape.radius( Qt::BottomRightCorner ).height() );
|
||||
@ -720,7 +752,7 @@ static inline QMarginsF qskEffectivePadding( const QskSkinnable* skinnable,
|
||||
// sin 45° ceiled : 0.70710678;
|
||||
padding *= 1.0 - 0.70710678;
|
||||
|
||||
const QMarginsF paddingHint = skinnable->marginsHint( aspect | Padding );
|
||||
const auto paddingHint = skinnable->paddingHint( aspect );
|
||||
|
||||
return QMarginsF(
|
||||
qMax( padding.left(), paddingHint.left() ),
|
||||
@ -878,15 +910,13 @@ void QskSkinnable::setSkinState( QskAspect::State newState, bool animated )
|
||||
const auto subControls = control->subControls();
|
||||
for ( const auto subControl : subControls )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
auto aspect = subControl | placement;
|
||||
|
||||
const auto& skinTable = skin->hintTable();
|
||||
|
||||
for ( int i = 0; i <= LastType; i++ )
|
||||
for ( int i = 0; i <= QskAspect::LastType; i++ )
|
||||
{
|
||||
const auto type = static_cast< Type >( i );
|
||||
const auto type = static_cast< QskAspect::Type >( i );
|
||||
|
||||
const auto hint = effectiveAnimation( type, subControl, newState );
|
||||
|
||||
@ -896,7 +926,8 @@ void QskSkinnable::setSkinState( QskAspect::State newState, bool animated )
|
||||
Starting an animator for all primitives,
|
||||
that differ between the states
|
||||
*/
|
||||
for ( uint primitive = 0; primitive <= LastPrimitive; primitive++ )
|
||||
for ( uint primitive = 0;
|
||||
primitive <= QskAspect::LastPrimitive; primitive++ )
|
||||
{
|
||||
aspect.setPrimitive( type, primitive );
|
||||
|
||||
|
@ -85,9 +85,13 @@ class QSK_EXPORT QskSkinnable
|
||||
void setMetric( QskAspect::Aspect, qreal metric );
|
||||
qreal metric( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
||||
void setMarginsHint( QskAspect::Aspect, qreal );
|
||||
void setMarginsHint( QskAspect::Aspect, const QMarginsF& );
|
||||
QMarginsF marginsHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
void setMarginHint( QskAspect::Aspect, qreal );
|
||||
void setMarginHint( QskAspect::Aspect, const QMarginsF& );
|
||||
QMarginsF marginHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
||||
void setPaddingHint( QskAspect::Aspect, qreal );
|
||||
void setPaddingHint( QskAspect::Aspect, const QMarginsF& );
|
||||
QMarginsF paddingHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
||||
void setGradientHint( QskAspect::Aspect, const QskGradient& );
|
||||
QskGradient gradientHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
@ -105,11 +109,17 @@ class QSK_EXPORT QskSkinnable
|
||||
void setIntervalHint( QskAspect::Aspect, const QskIntervalF& );
|
||||
QskIntervalF intervalHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
||||
void setSpacingHint( QskAspect::Aspect, qreal );
|
||||
qreal spacingHint( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
||||
void setFlagHint( QskAspect::Aspect, int flag );
|
||||
int flagHint( QskAspect::Aspect ) const;
|
||||
|
||||
template< typename T > T flagHint( QskAspect::Aspect, T = T() ) const;
|
||||
|
||||
void setAlignmentHint( QskAspect::Aspect, Qt::Alignment );
|
||||
Qt::Alignment alignmentHint( QskAspect::Aspect, Qt::Alignment = Qt::Alignment() ) const;
|
||||
|
||||
void setFontRole( QskAspect::Aspect, int role );
|
||||
int fontRole( QskAspect::Aspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
||||
@ -192,6 +202,12 @@ inline T QskSkinnable::flagHint( QskAspect::Aspect aspect, T defaultValue ) cons
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
inline Qt::Alignment QskSkinnable::alignmentHint(
|
||||
QskAspect::Aspect aspect, Qt::Alignment defaultAlignment ) const
|
||||
{
|
||||
return flagHint< Qt::Alignment >( aspect | QskAspect::Alignment, defaultAlignment );
|
||||
}
|
||||
|
||||
inline QskAspect::Placement QskSkinnable::effectivePlacement() const
|
||||
{
|
||||
return QskAspect::NoPlacement;
|
||||
|
@ -21,8 +21,8 @@ QSK_SYSTEM_STATE( QskSlider, Maximum, QskAspect::FirstSystemState << 4 )
|
||||
|
||||
static inline QskAspect::Aspect qskAspectPosition( const QskSlider* slider )
|
||||
{
|
||||
using namespace QskAspect;
|
||||
return slider->effectiveSubcontrol( QskSlider::Handle ) | Position | Metric;
|
||||
const auto subControl = slider->effectiveSubcontrol( QskSlider::Handle );
|
||||
return subControl | QskAspect::Position | QskAspect::Metric;
|
||||
}
|
||||
|
||||
class QskSlider::PrivateData
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include "QskBoxBorderMetrics.h"
|
||||
#include "QskFunctions.h"
|
||||
|
||||
static QMarginsF qskPadding(
|
||||
static inline QMarginsF qskPadding(
|
||||
const QskSlider* slider, QskAspect::Subcontrol subControl )
|
||||
{
|
||||
return slider->marginsHint( subControl | QskAspect::Padding ) +
|
||||
return slider->paddingHint( subControl ) +
|
||||
slider->boxBorderMetricsHint( subControl ).widths();
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ QRectF QskSliderSkinlet::panelRect(
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const QskAspect::Subcontrol subControl = QskSlider::Panel;
|
||||
const auto subControl = QskSlider::Panel;
|
||||
|
||||
qreal size = slider->metric( subControl | Size ); // 0: no hint
|
||||
|
||||
@ -117,8 +117,7 @@ QRectF QskSliderSkinlet::panelRect(
|
||||
|
||||
if ( size > 0 && size < r.height() )
|
||||
{
|
||||
const Qt::Alignment alignment =
|
||||
slider->flagHint< Qt::Alignment >( subControl | Alignment );
|
||||
const auto alignment = slider->alignmentHint( subControl );
|
||||
|
||||
if ( slider->orientation() == Qt::Horizontal )
|
||||
r = qskAlignedRectF( r, r.width(), size, alignment & Qt::AlignVertical_Mask );
|
||||
@ -132,29 +131,27 @@ QRectF QskSliderSkinlet::panelRect(
|
||||
QRectF QskSliderSkinlet::innerRect( const QskSlider* slider,
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
QRectF r = subControlRect( slider, contentsRect, QskSlider::Panel );
|
||||
r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) );
|
||||
|
||||
QskSkinHintStatus status;
|
||||
|
||||
qreal thickness = slider->metric( subControl | Size, &status );
|
||||
const qreal extent = slider->metric( subControl | QskAspect::Size, &status );
|
||||
|
||||
if ( slider->orientation() == Qt::Horizontal )
|
||||
{
|
||||
if ( status.isValid() && thickness < r.height() )
|
||||
if ( status.isValid() && ( extent < r.height() ) )
|
||||
{
|
||||
r.setTop( r.center().y() - 0.5 * thickness );
|
||||
r.setHeight( thickness );
|
||||
r.setTop( r.center().y() - 0.5 * extent );
|
||||
r.setHeight( extent );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( status.isValid() && thickness < r.width() )
|
||||
if ( status.isValid() && ( extent < r.width() ) )
|
||||
{
|
||||
r.setLeft( r.center().x() - 0.5 * thickness );
|
||||
r.setWidth( thickness );
|
||||
r.setLeft( r.center().x() - 0.5 * extent );
|
||||
r.setWidth( extent );
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,15 +173,13 @@ QRectF QskSliderSkinlet::scaleRect(
|
||||
QRectF QskSliderSkinlet::fillRect(
|
||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
QRectF r = subControlRect( slider, contentsRect, QskSlider::Panel );
|
||||
auto r = subControlRect( slider, contentsRect, QskSlider::Panel );
|
||||
r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) );
|
||||
|
||||
qreal pos = slider->metric( QskSlider::Handle | Position );
|
||||
qreal pos = slider->metric( QskSlider::Handle | QskAspect::Position );
|
||||
pos = qBound( 0.0, pos, 1.0 );
|
||||
|
||||
QRectF fillRect = innerRect( slider, contentsRect, QskSlider::Fill );
|
||||
auto fillRect = innerRect( slider, contentsRect, QskSlider::Fill );
|
||||
if ( slider->orientation() == Qt::Horizontal )
|
||||
{
|
||||
fillRect.setLeft( r.left() );
|
||||
@ -203,30 +198,31 @@ QRectF QskSliderSkinlet::handleRect(
|
||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskSlider;
|
||||
|
||||
QRectF r = subControlRect( slider, contentsRect, QskSlider::Panel );
|
||||
r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) );
|
||||
auto r = subControlRect( slider, contentsRect, Q::Panel );
|
||||
r = r.marginsRemoved( qskPadding( slider, Q::Panel ) );
|
||||
|
||||
const bool isHorizontal = slider->orientation() == Qt::Horizontal;
|
||||
|
||||
qreal thickness;
|
||||
qreal extent;
|
||||
|
||||
{
|
||||
QskSkinHintStatus status;
|
||||
|
||||
thickness = slider->metric( QskSlider::Handle | Size, &status );
|
||||
extent = slider->metric( Q::Handle | Size, &status );
|
||||
if ( !status.isValid() )
|
||||
thickness = isHorizontal ? r.height() : r.width();
|
||||
extent = isHorizontal ? r.height() : r.width();
|
||||
}
|
||||
|
||||
QRectF handleRect( 0, 0, thickness, thickness );
|
||||
if ( thickness > 0 )
|
||||
QRectF handleRect( 0, 0, extent, extent );
|
||||
if ( extent > 0 )
|
||||
{
|
||||
handleRect = handleRect.marginsRemoved(
|
||||
slider->marginsHint( QskSlider::Handle | QskAspect::Margin ) );
|
||||
slider->marginHint( Q::Handle) );
|
||||
}
|
||||
|
||||
qreal pos = slider->metric( QskSlider::Handle | Position );
|
||||
qreal pos = slider->metric( Q::Handle | Position );
|
||||
pos = qBound( 0.0, pos, 1.0 );
|
||||
|
||||
if ( slider->orientation() == Qt::Horizontal )
|
||||
|
@ -70,10 +70,8 @@ QSGNode* QskStatusIndicatorSkinlet::updateGraphicNode(
|
||||
{
|
||||
const auto subControl = QskStatusIndicator::Graphic;
|
||||
|
||||
const QRectF rect = subControlRect( indicator, indicator->contentsRect(), subControl );
|
||||
const Qt::Alignment alignment = indicator->flagHint< Qt::Alignment >(
|
||||
subControl | QskAspect::Alignment, Qt::AlignCenter );
|
||||
|
||||
const auto rect = subControlRect( indicator, indicator->contentsRect(), subControl );
|
||||
const auto alignment = indicator->alignmentHint( subControl, Qt::AlignCenter );
|
||||
const int status = indicator->status();
|
||||
|
||||
node = QskSkinlet::updateGraphicNode( indicator, node,
|
||||
|
@ -102,16 +102,16 @@ QRectF QskSubWindowSkinlet::titleBarRect(
|
||||
|
||||
qreal QskSubWindowSkinlet::titleBarHeight( const QskSubWindow* subWindow ) const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskSubWindow;
|
||||
|
||||
if ( !subWindow->isDecorated() )
|
||||
return 0;
|
||||
|
||||
const QMarginsF margins = subWindow->marginsHint( QskSubWindow::TitleBar | Padding );
|
||||
const QFontMetricsF fm( subWindow->effectiveFont( QskSubWindow::TitleBarText ) );
|
||||
const auto margins = subWindow->paddingHint( Q::TitleBar );
|
||||
const QFontMetricsF fm( subWindow->effectiveFont( Q::TitleBarText ) );
|
||||
|
||||
const qreal height = fm.height() + margins.top() + margins.bottom();
|
||||
const qreal minHeight = subWindow->metric( QskSubWindow::TitleBar | MinimumHeight );
|
||||
const qreal minHeight = subWindow->metric( Q::TitleBar | QskAspect::MinimumHeight );
|
||||
|
||||
return qMax( height, minHeight );
|
||||
}
|
||||
@ -119,8 +119,10 @@ qreal QskSubWindowSkinlet::titleBarHeight( const QskSubWindow* subWindow ) const
|
||||
QRectF QskSubWindowSkinlet::symbolRect(
|
||||
const QskSubWindow* subWindow, const QRectF& contentsRect ) const
|
||||
{
|
||||
auto rect = subControlRect( subWindow, contentsRect, QskSubWindow::TitleBar );
|
||||
rect = subWindow->innerBox( QskSubWindow::TitleBar, rect );
|
||||
using Q = QskSubWindow;
|
||||
|
||||
auto rect = subControlRect( subWindow, contentsRect, Q::TitleBar );
|
||||
rect = subWindow->innerBox( Q::TitleBar, rect );
|
||||
|
||||
int w = 0;
|
||||
|
||||
@ -139,21 +141,20 @@ QRectF QskSubWindowSkinlet::symbolRect(
|
||||
QRectF QskSubWindowSkinlet::titleRect(
|
||||
const QskSubWindow* subWindow, const QRectF& contentsRect ) const
|
||||
{
|
||||
auto rect = subControlRect( subWindow, contentsRect, QskSubWindow::TitleBar );
|
||||
rect = subWindow->innerBox( QskSubWindow::TitleBar, rect );
|
||||
using Q = QskSubWindow;
|
||||
|
||||
auto rect = subControlRect( subWindow, contentsRect, Q::TitleBar );
|
||||
rect = subWindow->innerBox( Q::TitleBar, rect );
|
||||
|
||||
if ( !rect.isEmpty() )
|
||||
{
|
||||
const auto spacing = subWindow->metric(
|
||||
QskSubWindow::TitleBar | QskAspect::Spacing );
|
||||
|
||||
const auto symbolRect = subControlRect(
|
||||
subWindow, rect, QskSubWindow::TitleBarSymbol );
|
||||
const auto spacing = subWindow->spacingHint( Q::TitleBar );
|
||||
const auto symbolRect = subControlRect( subWindow, rect, Q::TitleBarSymbol );
|
||||
|
||||
rect.setX( rect.x() + symbolRect.right() + spacing );
|
||||
|
||||
#if 0
|
||||
const QFontMetricsF fm( subWindow->effectiveFont( QskSubWindow::TitleBarText ) );
|
||||
const QFontMetricsF fm( subWindow->effectiveFont( Q::TitleBarText ) );
|
||||
rect.setHeight( fm.height() ); // TitleBarText | Alignment
|
||||
#endif
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ namespace
|
||||
QskTabBar::Panel, QskAspect::NoState );
|
||||
}
|
||||
|
||||
// should be a skin hint TODO ...
|
||||
return QskAnimationHint( 200, QEasingCurve::OutCubic );
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ namespace
|
||||
auto r = Inherited::clipRect();
|
||||
|
||||
if ( auto control = qskControlCast( parentItem() ) )
|
||||
r += control->marginsHint( QskTabBar::Panel | QskAspect::Padding );
|
||||
r += control->paddingHint( QskTabBar::Panel );
|
||||
|
||||
/*
|
||||
Often the current tab button grows beyond the bounding rectangle
|
||||
@ -298,7 +299,7 @@ QskTabBar::QskTabBar( Qsk::Position position, QQuickItem* parent )
|
||||
m_data->scrollBox->setOrientation( orientation );
|
||||
|
||||
m_data->buttonBox = new ButtonBox( orientation, m_data->scrollBox );
|
||||
m_data->buttonBox->setSpacing( metric( QskTabBar::Panel | QskAspect::Spacing ) );
|
||||
m_data->buttonBox->setSpacing( spacingHint( QskTabBar::Panel ) );
|
||||
m_data->buttonBox->setSizePolicy( QskSizePolicy::Maximum, QskSizePolicy::Maximum );
|
||||
|
||||
connect( this, &QskTabBar::currentIndexChanged,
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define QSK_TAB_BAR_H
|
||||
|
||||
#include "QskBox.h"
|
||||
#include "QskNamespace.h"
|
||||
|
||||
class QskTabButton;
|
||||
class QskTextOptions;
|
||||
|
@ -456,8 +456,6 @@ QSizeF QskTextInput::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) const
|
||||
if ( which != Qt::PreferredSize )
|
||||
return QSizeF();
|
||||
|
||||
using namespace QskAspect;
|
||||
|
||||
auto input = m_data->textInput;
|
||||
|
||||
input->updateMetrics();
|
||||
@ -465,8 +463,8 @@ QSizeF QskTextInput::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) const
|
||||
const qreal w = input->implicitWidth();
|
||||
const qreal h = input->implicitHeight();
|
||||
|
||||
const QSizeF minSize( metric( Panel | MinimumWidth ),
|
||||
metric( Panel | MinimumHeight ) );
|
||||
const QSizeF minSize( metric( Panel | QskAspect::MinimumWidth ),
|
||||
metric( Panel | QskAspect::MinimumHeight ) );
|
||||
|
||||
return outerBoxSize( Panel, QSizeF( w, h ) ).expandedTo( minSize );
|
||||
}
|
||||
@ -554,7 +552,7 @@ void QskTextInput::setAlignment( Qt::Alignment alignment )
|
||||
if ( alignment != this->alignment() )
|
||||
{
|
||||
const auto subControl = effectiveSubcontrol( Text );
|
||||
setFlagHint( subControl | QskAspect::Alignment, alignment );
|
||||
setAlignmentHint( subControl, alignment );
|
||||
|
||||
m_data->textInput->setAlignment( alignment );
|
||||
|
||||
@ -566,8 +564,7 @@ void QskTextInput::setAlignment( Qt::Alignment alignment )
|
||||
|
||||
Qt::Alignment QskTextInput::alignment() const
|
||||
{
|
||||
return flagHint< Qt::Alignment >(
|
||||
Text | QskAspect::Alignment, Qt::AlignLeft | Qt::AlignTop );
|
||||
return alignmentHint( Text, Qt::AlignLeft | Qt::AlignTop );
|
||||
}
|
||||
|
||||
QFont QskTextInput::font() const
|
||||
|
@ -207,8 +207,7 @@ QColor QskTextLabel::textColor() const
|
||||
|
||||
Qt::Alignment QskTextLabel::alignment() const
|
||||
{
|
||||
return flagHint< Qt::Alignment >(
|
||||
Text | QskAspect::Alignment, Qt::AlignLeft | Qt::AlignTop );
|
||||
return alignmentHint( Text, Qt::AlignLeft | Qt::AlignTop );
|
||||
}
|
||||
|
||||
void QskTextLabel::setAlignment( Qt::Alignment alignment )
|
||||
@ -217,7 +216,7 @@ void QskTextLabel::setAlignment( Qt::Alignment alignment )
|
||||
return;
|
||||
|
||||
const auto subControl = effectiveSubcontrol( Text );
|
||||
setFlagHint( subControl | QskAspect::Alignment, alignment );
|
||||
setAlignmentHint( subControl, alignment );
|
||||
|
||||
if ( m_data->text.isEmpty() )
|
||||
update();
|
||||
|
@ -335,7 +335,7 @@ void QskVirtualKeyboard::updateLayout()
|
||||
if ( r.isEmpty() )
|
||||
return;
|
||||
|
||||
const auto spacing = metric( Panel | QskAspect::Spacing );
|
||||
const auto spacing = spacingHint( Panel );
|
||||
const auto totalVSpacing = ( RowCount - 1 ) * spacing;
|
||||
|
||||
const auto keyHeight = ( r.height() - totalVSpacing ) / RowCount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user