diff --git a/examples/iot-dashboard/Box.cpp b/examples/iot-dashboard/Box.cpp index ba0cfc47..cdb40538 100644 --- a/examples/iot-dashboard/Box.cpp +++ b/examples/iot-dashboard/Box.cpp @@ -1,13 +1,39 @@ #include "Box.h" #include "DaytimeSkin.h" -#include "QskShadowedRectangle.h" +#include "src/shadowedrectangle.h" #include #include #include #include +ShadowBox::ShadowBox( QskControl* control, QQuickItem* parent ) + : QskControl( parent ) + , m_control( control ) + , m_rectangle( new ShadowedRectangle( this ) ) +{ + setAutoLayoutChildren( true ); + + m_rectangle->shadow()->setColor( Qt::black ); + m_rectangle->shadow()->setSize( 15 ); + m_rectangle->setColor( Qt::white ); // ### opacity should only be for the shadow, not the background + m_rectangle->setOpacity( 0.1 ); + m_rectangle->setSize( m_control->preferredSize() ); + m_rectangle->corners()->setTopLeft( 6 ); + m_rectangle->corners()->setTopRight( 6 ); + m_rectangle->corners()->setBottomLeft( 6 ); + m_rectangle->corners()->setBottomRight( 6 ); +} + +void ShadowBox::updateLayout() +{ + const auto s = m_rectangle->shadow()->size(); + qDebug() << m_control->geometry() << geometry(); + m_control->setPosition( {15, 0} ); // ### why? + m_control->setZ( 1 ); +} + Box::Box( const QString& title, QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent ) , m_title( title ) @@ -26,16 +52,16 @@ Box::Box( const QString& title, QQuickItem* parent ) setBoxBorderColorsHint( QskBox::Panel, borderColors ); - auto* r = new QskShadowedRectangle( this ); -// r->setPosition( {50, 50} ); -// r->setColor( Qt::green ); -// r->setOpacity( 0.5 ); -// r->setSize( {100, 50} ); -// r->setVisible( true ); -// r->corners()->setTopLeft( 5 ); -// r->corners()->setTopRight( 5 ); -// r->corners()->setBottomLeft( 5 ); -// r->corners()->setBottomRight( 5 ); + auto* r = new ShadowedRectangle( this ); + r->shadow()->setColor( Qt::black ); + r->shadow()->setSize( 15 ); + r->setPosition( {0, 0} ); + r->setOpacity( 0.1 ); + r->setSize( {100, 50} ); + r->corners()->setTopLeft( 6 ); + r->corners()->setTopRight( 6 ); + r->corners()->setBottomLeft( 6 ); + r->corners()->setBottomRight( 6 ); // r->setRadius( 5 ); auto* t = new QskTextLabel( "bla", r ); diff --git a/examples/iot-dashboard/Box.h b/examples/iot-dashboard/Box.h index 1cf09ea6..7915d1ea 100644 --- a/examples/iot-dashboard/Box.h +++ b/examples/iot-dashboard/Box.h @@ -1,10 +1,26 @@ #ifndef CARD_H #define CARD_H +#include "src/shadowedrectangle.h" + #include class QskTextLabel; +class ShadowBox : public QskControl +{ + Q_OBJECT + public: + ShadowBox( QskControl* control, QQuickItem* parent ); + + protected: + void updateLayout() override; + + private: + QskControl* m_control; + ShadowedRectangle* m_rectangle; +}; + class Box : public QskLinearBox { public: diff --git a/examples/iot-dashboard/MainContent.cpp b/examples/iot-dashboard/MainContent.cpp index 969ac884..a93eb501 100644 --- a/examples/iot-dashboard/MainContent.cpp +++ b/examples/iot-dashboard/MainContent.cpp @@ -32,7 +32,8 @@ MainContent::MainContent( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, par gridBox->setBoxBorderMetricsHint( QskBox::Panel, 2 ); auto* usage = new Usage( gridBox ); - gridBox->addItem( usage, 0, 0, 2, 1 ); + auto* usageShadowBox = new ShadowBox( usage, this ); + gridBox->addItem( usageShadowBox, 0, 0, 2, 1 ); auto* indoorTemperature = new IndoorTemperature( gridBox ); gridBox->addItem( indoorTemperature, 0, 1 );