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;
|
||||
|
||||
void BlurredBox::setShape( const QskBoxShapeMetrics& shape )
|
||||
{
|
||||
m_shape = shape;
|
||||
update();
|
||||
}
|
||||
|
||||
const QskBoxShapeMetrics& BlurredBox::shape() const
|
||||
{
|
||||
return m_shape;
|
||||
}
|
||||
|
||||
QRectF BlurredBox::rectOnScreen() const
|
||||
{
|
||||
return mapRectToScene( contentsRect() );
|
||||
|
|
|
@ -23,9 +23,6 @@ class BlurredBox : public QskBox
|
|||
|
||||
QRectF layoutRectForSize( const QSizeF& size ) const override;
|
||||
|
||||
void setShape( const QskBoxShapeMetrics& );
|
||||
const QskBoxShapeMetrics& shape() const;
|
||||
|
||||
QRectF rectOnScreen() const;
|
||||
QRectF rectOfScreen() const;
|
||||
|
||||
|
|
|
@ -29,10 +29,11 @@ QSGNode* BlurredBoxSkinlet::updateSubNode(
|
|||
switch ( nodeRole )
|
||||
{
|
||||
case PanelRole:
|
||||
auto blurred = QskSGNode::ensureNode< BlurredBoxNode >( node );
|
||||
auto rectOfScreen = box->rectOfScreen();
|
||||
auto rectOnScreen = box->rectOnScreen();
|
||||
blurred->setBlurData( r, box->shape(), rectOfScreen, rectOnScreen,
|
||||
auto* const blurred = QskSGNode::ensureNode< BlurredBoxNode >( node );
|
||||
const auto rectOfScreen = box->rectOfScreen();
|
||||
const auto rectOnScreen = box->rectOnScreen();
|
||||
const auto boxShapeHint = box->boxShapeHint(BlurredBox::Panel);
|
||||
blurred->setBlurData( r, boxShapeHint, rectOfScreen, rectOnScreen,
|
||||
static_cast< float >( box->opacity() ), box->blurDirections(), box->blurQuality(),
|
||||
box->blurSize() );
|
||||
return blurred;
|
||||
|
|
|
@ -28,7 +28,8 @@ MainWindow::MainWindow()
|
|||
auto* const stack = new QskStackBox( layout );
|
||||
stack->setAutoLayoutChildren( true );
|
||||
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 );
|
||||
stack->addItem( l );
|
||||
|
||||
|
@ -147,7 +148,7 @@ void MainWindow::createBlurCornerRadiiControls( BlurredBox* blurred, QskLinearBo
|
|||
slider->setMinimum( 0.0 );
|
||||
slider->setMaximum( 80.0 );
|
||||
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 )";
|
||||
|
||||
switch ( bar->currentIndex() )
|
||||
|
@ -167,11 +168,11 @@ void MainWindow::createBlurCornerRadiiControls( BlurredBox* blurred, QskLinearBo
|
|||
}
|
||||
|
||||
label->setText( format.arg( value ) );
|
||||
blurred->setShape( shape );
|
||||
blurred->setBoxShapeHint(BlurredBox::Panel, shape );
|
||||
blurred->update();
|
||||
} );
|
||||
connect( bar, &QskSegmentedBar::currentIndexChanged, [ blurred, slider ]( int index ) {
|
||||
const auto shape = blurred->shape();
|
||||
const auto shape = blurred->boxShapeHint(BlurredBox::Panel);
|
||||
|
||||
switch ( index )
|
||||
{
|
||||
|
@ -189,7 +190,7 @@ void MainWindow::createBlurCornerRadiiControls( BlurredBox* blurred, QskLinearBo
|
|||
break;
|
||||
}
|
||||
} );
|
||||
slider->setValue( blurred->shape().topLeft().width() );
|
||||
slider->setValue( blurred->boxShapeHint(BlurredBox::Panel).topLeft().width() );
|
||||
bar->setSelectedIndex( TL );
|
||||
bar->setCurrentIndex( TL );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue