Using existing box shape metrics functions
This commit is contained in:
parent
213370d0c6
commit
532f388156
|
@ -18,17 +18,6 @@ BlurredBox::BlurredBox( QQuickItem* parentItem )
|
||||||
|
|
||||||
BlurredBox::~BlurredBox() = default;
|
BlurredBox::~BlurredBox() = default;
|
||||||
|
|
||||||
void BlurredBox::setShape( const QskBoxShapeMetrics& shape )
|
|
||||||
{
|
|
||||||
m_shape = shape;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
const QskBoxShapeMetrics& BlurredBox::shape() const
|
|
||||||
{
|
|
||||||
return m_shape;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF BlurredBox::rectOnScreen() const
|
QRectF BlurredBox::rectOnScreen() const
|
||||||
{
|
{
|
||||||
return mapRectToScene( contentsRect() );
|
return mapRectToScene( contentsRect() );
|
||||||
|
|
|
@ -23,9 +23,6 @@ class BlurredBox : public QskBox
|
||||||
|
|
||||||
QRectF layoutRectForSize( const QSizeF& size ) const override;
|
QRectF layoutRectForSize( const QSizeF& size ) const override;
|
||||||
|
|
||||||
void setShape( const QskBoxShapeMetrics& );
|
|
||||||
const QskBoxShapeMetrics& shape() const;
|
|
||||||
|
|
||||||
QRectF rectOnScreen() const;
|
QRectF rectOnScreen() const;
|
||||||
QRectF rectOfScreen() const;
|
QRectF rectOfScreen() const;
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,11 @@ QSGNode* BlurredBoxSkinlet::updateSubNode(
|
||||||
switch ( nodeRole )
|
switch ( nodeRole )
|
||||||
{
|
{
|
||||||
case PanelRole:
|
case PanelRole:
|
||||||
auto blurred = QskSGNode::ensureNode< BlurredBoxNode >( node );
|
auto* const blurred = QskSGNode::ensureNode< BlurredBoxNode >( node );
|
||||||
auto rectOfScreen = box->rectOfScreen();
|
const auto rectOfScreen = box->rectOfScreen();
|
||||||
auto rectOnScreen = box->rectOnScreen();
|
const auto rectOnScreen = box->rectOnScreen();
|
||||||
blurred->setBlurData( r, box->shape(), rectOfScreen, rectOnScreen,
|
const auto boxShapeHint = box->boxShapeHint(BlurredBox::Panel);
|
||||||
|
blurred->setBlurData( r, boxShapeHint, rectOfScreen, rectOnScreen,
|
||||||
static_cast< float >( box->opacity() ), box->blurDirections(), box->blurQuality(),
|
static_cast< float >( box->opacity() ), box->blurDirections(), box->blurQuality(),
|
||||||
box->blurSize() );
|
box->blurSize() );
|
||||||
return blurred;
|
return blurred;
|
||||||
|
|
|
@ -28,7 +28,8 @@ MainWindow::MainWindow()
|
||||||
auto* const stack = new QskStackBox( layout );
|
auto* const stack = new QskStackBox( layout );
|
||||||
stack->setAutoLayoutChildren( true );
|
stack->setAutoLayoutChildren( true );
|
||||||
auto* const blurred = new BlurredBox( stack );
|
auto* const blurred = new BlurredBox( stack );
|
||||||
blurred->setShape( { 40, 40, 40, 40 } );
|
blurred->setBlurSize( 16.0 );
|
||||||
|
blurred->setBoxShapeHint(BlurredBox::Panel, { 40, 40, 40, 40 });
|
||||||
auto* const l = new QskLinearBox( Qt::Vertical, layout );
|
auto* const l = new QskLinearBox( Qt::Vertical, layout );
|
||||||
stack->addItem( l );
|
stack->addItem( l );
|
||||||
|
|
||||||
|
@ -147,7 +148,7 @@ void MainWindow::createBlurCornerRadiiControls( BlurredBox* blurred, QskLinearBo
|
||||||
slider->setMinimum( 0.0 );
|
slider->setMinimum( 0.0 );
|
||||||
slider->setMaximum( 80.0 );
|
slider->setMaximum( 80.0 );
|
||||||
connect( slider, &QskSlider::valueChanged, [ blurred, bar, label ]( qreal value ) {
|
connect( slider, &QskSlider::valueChanged, [ blurred, bar, label ]( qreal value ) {
|
||||||
auto shape = blurred->shape();
|
auto shape = blurred->boxShapeHint(BlurredBox::Panel);
|
||||||
const auto format = tr( "Corner Radius" ) + " ( %1 )";
|
const auto format = tr( "Corner Radius" ) + " ( %1 )";
|
||||||
|
|
||||||
switch ( bar->currentIndex() )
|
switch ( bar->currentIndex() )
|
||||||
|
@ -167,11 +168,11 @@ void MainWindow::createBlurCornerRadiiControls( BlurredBox* blurred, QskLinearBo
|
||||||
}
|
}
|
||||||
|
|
||||||
label->setText( format.arg( value ) );
|
label->setText( format.arg( value ) );
|
||||||
blurred->setShape( shape );
|
blurred->setBoxShapeHint(BlurredBox::Panel, shape );
|
||||||
blurred->update();
|
blurred->update();
|
||||||
} );
|
} );
|
||||||
connect( bar, &QskSegmentedBar::currentIndexChanged, [ blurred, slider ]( int index ) {
|
connect( bar, &QskSegmentedBar::currentIndexChanged, [ blurred, slider ]( int index ) {
|
||||||
const auto shape = blurred->shape();
|
const auto shape = blurred->boxShapeHint(BlurredBox::Panel);
|
||||||
|
|
||||||
switch ( index )
|
switch ( index )
|
||||||
{
|
{
|
||||||
|
@ -189,7 +190,7 @@ void MainWindow::createBlurCornerRadiiControls( BlurredBox* blurred, QskLinearBo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
slider->setValue( blurred->shape().topLeft().width() );
|
slider->setValue( blurred->boxShapeHint(BlurredBox::Panel).topLeft().width() );
|
||||||
bar->setSelectedIndex( TL );
|
bar->setSelectedIndex( TL );
|
||||||
bar->setCurrentIndex( TL );
|
bar->setCurrentIndex( TL );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue