QskSkinnable can be used in combination with a simple QQuickItem now
This commit is contained in:
parent
4389d3034b
commit
585f763542
@ -916,7 +916,7 @@ QSGNode* QskControl::updateItemPaintNode( QSGNode* node )
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskControl* QskControl::owningControl() const
|
QskControl* QskControl::owningItem() const
|
||||||
{
|
{
|
||||||
return const_cast< QskControl* >( this );
|
return const_cast< QskControl* >( this );
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ class QSK_EXPORT QskControl : public QskQuickItem, public QskSkinnable
|
|||||||
QSGNode* updateItemPaintNode( QSGNode* ) override final;
|
QSGNode* updateItemPaintNode( QSGNode* ) override final;
|
||||||
void updateItemPolish() override final;
|
void updateItemPolish() override final;
|
||||||
|
|
||||||
QskControl* owningControl() const override final;
|
QskControl* owningItem() const override final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DECLARE_PRIVATE( QskControl )
|
Q_DECLARE_PRIVATE( QskControl )
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "QskTextOptions.h"
|
#include "QskTextOptions.h"
|
||||||
#include "QskSkinStateChanger.h"
|
#include "QskSkinStateChanger.h"
|
||||||
#include "QskTextureRenderer.h"
|
#include "QskTextureRenderer.h"
|
||||||
|
#include "QskSetup.h"
|
||||||
|
|
||||||
#include <qquickwindow.h>
|
#include <qquickwindow.h>
|
||||||
#include <qsgsimplerectnode.h>
|
#include <qsgsimplerectnode.h>
|
||||||
@ -101,7 +102,7 @@ static inline QSGNode* qskUpdateTextNode( const QskSkinnable* skinnable,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
textNode->setTextData( skinnable->owningControl(),
|
textNode->setTextData( skinnable->owningItem(),
|
||||||
text, rect, effectiveFont, textOptions, textColors, alignment, textStyle );
|
text, rect, effectiveFont, textOptions, textColors, alignment, textStyle );
|
||||||
|
|
||||||
return textNode;
|
return textNode;
|
||||||
@ -115,21 +116,26 @@ static inline QSGNode* qskUpdateGraphicNode(
|
|||||||
if ( rect.isEmpty() )
|
if ( rect.isEmpty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const auto control = skinnable->owningControl();
|
const auto item = skinnable->owningItem();
|
||||||
if ( control == nullptr )
|
if ( item == nullptr )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto graphicNode = static_cast< QskGraphicNode* >( node );
|
auto graphicNode = static_cast< QskGraphicNode* >( node );
|
||||||
if ( graphicNode == nullptr )
|
if ( graphicNode == nullptr )
|
||||||
graphicNode = new QskGraphicNode();
|
graphicNode = new QskGraphicNode();
|
||||||
|
|
||||||
const bool useRaster = control->testUpdateFlag( QskControl::PreferRasterForTextures );
|
const auto flag = QskQuickItem::PreferRasterForTextures;
|
||||||
|
|
||||||
|
bool useRaster = qskSetup->testItemUpdateFlag( flag );
|
||||||
|
if ( auto qItem = qobject_cast< const QskQuickItem* >( item ) )
|
||||||
|
useRaster = qItem->testUpdateFlag( flag );
|
||||||
|
|
||||||
graphicNode->setRenderHint( useRaster ? QskPaintedNode::Raster : QskPaintedNode::OpenGL );
|
graphicNode->setRenderHint( useRaster ? QskPaintedNode::Raster : QskPaintedNode::OpenGL );
|
||||||
|
|
||||||
graphicNode->setMirrored( mirrored );
|
graphicNode->setMirrored( mirrored );
|
||||||
|
|
||||||
const auto r = qskSceneAlignedRect( control, rect );
|
const auto r = qskSceneAlignedRect( item, rect );
|
||||||
graphicNode->setGraphic( control->window(), graphic, colorFilter, r );
|
graphicNode->setGraphic( item->window(), graphic, colorFilter, r );
|
||||||
|
|
||||||
return graphicNode;
|
return graphicNode;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ static inline T qskColor( const QskSkinnable* skinnable,
|
|||||||
aspect | QskAspect::Color, status ).value< T >();
|
aspect | QskAspect::Color, status ).value< T >();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void qskTriggerUpdates( QskAspect aspect, QskControl* control )
|
static inline void qskTriggerUpdates( QskAspect aspect, QQuickItem* item )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
To put the hint into effect we have to call the usual suspects:
|
To put the hint into effect we have to call the usual suspects:
|
||||||
@ -137,7 +137,13 @@ static inline void qskTriggerUpdates( QskAspect aspect, QskControl* control )
|
|||||||
controls.
|
controls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( control == nullptr || aspect.isAnimator() )
|
if ( item == nullptr || aspect.isAnimator() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
item->update(); // always
|
||||||
|
|
||||||
|
auto control = qskControlCast( item );
|
||||||
|
if ( control == nullptr )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool maybeLayout = false;
|
bool maybeLayout = false;
|
||||||
@ -185,8 +191,6 @@ static inline void qskTriggerUpdates( QskAspect aspect, QskControl* control )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
control->update(); // always
|
|
||||||
|
|
||||||
if ( maybeLayout && control->hasChildItems() )
|
if ( maybeLayout && control->hasChildItems() )
|
||||||
{
|
{
|
||||||
if ( control->polishOnResize() || control->autoLayoutChildren() )
|
if ( control->polishOnResize() || control->autoLayoutChildren() )
|
||||||
@ -269,13 +273,15 @@ void QskSkinnable::setSkinlet( const QskSkinlet* skinlet )
|
|||||||
m_data->skinlet = skinlet;
|
m_data->skinlet = skinlet;
|
||||||
m_data->hasLocalSkinlet = ( skinlet != nullptr );
|
m_data->hasLocalSkinlet = ( skinlet != nullptr );
|
||||||
|
|
||||||
if ( auto control = owningControl() )
|
if ( auto item = owningItem() )
|
||||||
{
|
{
|
||||||
control->resetImplicitSize();
|
if ( auto control = qskControlCast( item ) )
|
||||||
control->polish();
|
control->resetImplicitSize();
|
||||||
|
|
||||||
if ( control->flags() & QQuickItem::ItemHasContents )
|
item->polish();
|
||||||
control->update();
|
|
||||||
|
if ( item->flags() & QQuickItem::ItemHasContents )
|
||||||
|
item->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,12 +766,12 @@ QskColorFilter QskSkinnable::effectiveGraphicFilter(
|
|||||||
return v.value< QskColorFilter >();
|
return v.value< QskColorFilter >();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( auto control = owningControl() )
|
if ( auto item = owningItem() )
|
||||||
{
|
{
|
||||||
const auto graphicRole = hint.toInt();
|
const auto graphicRole = hint.toInt();
|
||||||
|
|
||||||
const auto v = QskSkinTransition::animatedGraphicFilter(
|
const auto v = QskSkinTransition::animatedGraphicFilter(
|
||||||
control->window(), graphicRole );
|
item->window(), graphicRole );
|
||||||
|
|
||||||
if ( v.canConvert< QskColorFilter >() )
|
if ( v.canConvert< QskColorFilter >() )
|
||||||
{
|
{
|
||||||
@ -776,7 +782,7 @@ QskColorFilter QskSkinnable::effectiveGraphicFilter(
|
|||||||
filter. As a workaround we schedule the update in the
|
filter. As a workaround we schedule the update in the
|
||||||
getter: TODO ...
|
getter: TODO ...
|
||||||
*/
|
*/
|
||||||
control->update();
|
item->update();
|
||||||
#endif
|
#endif
|
||||||
return v.value< QskColorFilter >();
|
return v.value< QskColorFilter >();
|
||||||
}
|
}
|
||||||
@ -862,7 +868,7 @@ bool QskSkinnable::setSkinHint( QskAspect aspect, const QVariant& hint )
|
|||||||
|
|
||||||
if ( m_data->hintTable.setHint( aspect, hint ) )
|
if ( m_data->hintTable.setHint( aspect, hint ) )
|
||||||
{
|
{
|
||||||
qskTriggerUpdates( aspect, owningControl() );
|
qskTriggerUpdates( aspect, owningItem() );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,7 +881,7 @@ bool QskSkinnable::resetSkinHint( QskAspect aspect )
|
|||||||
|
|
||||||
if ( m_data->hintTable.removeHint( aspect ) )
|
if ( m_data->hintTable.removeHint( aspect ) )
|
||||||
{
|
{
|
||||||
qskTriggerUpdates( aspect, owningControl() );
|
qskTriggerUpdates( aspect, owningItem() );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,8 +986,8 @@ QVariant QskSkinnable::interpolatedHint(
|
|||||||
if ( !QskSkinTransition::isRunning() || m_data->hintTable.hasHint( aspect ) )
|
if ( !QskSkinTransition::isRunning() || m_data->hintTable.hasHint( aspect ) )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
const auto control = owningControl();
|
const auto item = owningItem();
|
||||||
if ( control == nullptr )
|
if ( item == nullptr )
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QVariant v;
|
QVariant v;
|
||||||
@ -990,7 +996,7 @@ QVariant QskSkinnable::interpolatedHint(
|
|||||||
|
|
||||||
Q_FOREVER
|
Q_FOREVER
|
||||||
{
|
{
|
||||||
v = QskSkinTransition::animatedHint( control->window(), aspect );
|
v = QskSkinTransition::animatedHint( item->window(), aspect );
|
||||||
|
|
||||||
if ( !v.isValid() )
|
if ( !v.isValid() )
|
||||||
{
|
{
|
||||||
@ -1227,7 +1233,7 @@ bool QskSkinnable::isTransitionAccepted( QskAspect aspect ) const
|
|||||||
happen while the skinnable is visible. There are few exceptions
|
happen while the skinnable is visible. There are few exceptions
|
||||||
like QskPopup::Closed, that is used to slide/fade in.
|
like QskPopup::Closed, that is used to slide/fade in.
|
||||||
*/
|
*/
|
||||||
if ( auto control = owningControl() )
|
if ( auto control = qskControlCast( owningItem() ) )
|
||||||
return control->isInitiallyPainted();
|
return control->isInitiallyPainted();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1252,7 +1258,7 @@ void QskSkinnable::startHintTransition( QskAspect aspect, int index,
|
|||||||
if ( animationHint.duration <= 0 || ( from == to ) )
|
if ( animationHint.duration <= 0 || ( from == to ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto control = this->owningControl();
|
auto control = qskControlCast( owningItem() );
|
||||||
if ( control->window() == nullptr || !isTransitionAccepted( aspect ) )
|
if ( control->window() == nullptr || !isTransitionAccepted( aspect ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1321,17 +1327,17 @@ void QskSkinnable::setSkinStates( QskAspect::States newStates )
|
|||||||
if ( m_data->skinStates == newStates )
|
if ( m_data->skinStates == newStates )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto control = owningControl();
|
auto item = owningItem();
|
||||||
|
|
||||||
#if DEBUG_STATE
|
#if DEBUG_STATE
|
||||||
const auto className = control ? control->className() : "QskSkinnable";
|
const auto className = item ? item->className() : "QskSkinnable";
|
||||||
|
|
||||||
qDebug() << className << ":"
|
qDebug() << className << ":"
|
||||||
<< skinStateAsPrintable( m_data->skinState ) << "->"
|
<< skinStateAsPrintable( m_data->skinState ) << "->"
|
||||||
<< skinStateAsPrintable( newState );
|
<< skinStateAsPrintable( newState );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( control && control->window() )
|
if ( item && item->window() )
|
||||||
{
|
{
|
||||||
if ( const auto skin = effectiveSkin() )
|
if ( const auto skin = effectiveSkin() )
|
||||||
{
|
{
|
||||||
@ -1347,8 +1353,8 @@ void QskSkinnable::setSkinStates( QskAspect::States newStates )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( control->flags() & QQuickItem::ItemHasContents )
|
if ( item->flags() & QQuickItem::ItemHasContents )
|
||||||
control->update();
|
item->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->skinStates = newStates;
|
m_data->skinStates = newStates;
|
||||||
@ -1370,7 +1376,9 @@ bool QskSkinnable::startHintTransitions(
|
|||||||
aspect.setSection( section() );
|
aspect.setSection( section() );
|
||||||
|
|
||||||
const auto skin = effectiveSkin();
|
const auto skin = effectiveSkin();
|
||||||
const auto control = owningControl();
|
const auto control = qskControlCast( owningItem() );
|
||||||
|
if ( control == nullptr )
|
||||||
|
return false;
|
||||||
|
|
||||||
const auto primitiveCount = QskAspect::primitiveCount();
|
const auto primitiveCount = QskAspect::primitiveCount();
|
||||||
|
|
||||||
@ -1440,8 +1448,8 @@ QskSkin* QskSkinnable::effectiveSkin() const
|
|||||||
|
|
||||||
if ( skin == nullptr )
|
if ( skin == nullptr )
|
||||||
{
|
{
|
||||||
if ( const auto control = owningControl() )
|
if ( const auto item = owningItem() )
|
||||||
skin = qskEffectiveSkin( control->window() );
|
skin = qskEffectiveSkin( item->window() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return skin ? skin : qskSetup->skin();
|
return skin ? skin : qskSetup->skin();
|
||||||
|
@ -20,6 +20,7 @@ class QVariant;
|
|||||||
class QDebug;
|
class QDebug;
|
||||||
|
|
||||||
class QSGNode;
|
class QSGNode;
|
||||||
|
class QQuickItem;
|
||||||
|
|
||||||
class QskArcMetrics;
|
class QskArcMetrics;
|
||||||
class QskControl;
|
class QskControl;
|
||||||
@ -133,7 +134,7 @@ class QSK_EXPORT QskSkinnable
|
|||||||
QskControl* controlCast();
|
QskControl* controlCast();
|
||||||
const QskControl* controlCast() const;
|
const QskControl* controlCast() const;
|
||||||
|
|
||||||
virtual QskControl* owningControl() const = 0;
|
virtual QQuickItem* owningItem() const = 0;
|
||||||
virtual const QMetaObject* metaObject() const = 0;
|
virtual const QMetaObject* metaObject() const = 0;
|
||||||
|
|
||||||
void debug( QskAspect ) const;
|
void debug( QskAspect ) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user