IOT dashboard: Use skinny shadows for light display

This commit is contained in:
Peter Hartmann 2022-12-20 16:00:05 +01:00 committed by uwerat
parent 22db20e9eb
commit 3e91e83187
4 changed files with 7 additions and 45 deletions

View File

@ -43,10 +43,6 @@ LightDisplay::LightDisplay( QQuickItem* parent )
setAlignmentHint( ValueText, Qt::AlignRight );
setBoundaries( 0, 100 );
// ### move to Skin:
setShadow( { 0, 20 } );
setShadowColor( 0xe5e5e5 );
}
bool LightDisplay::isPressed() const
@ -54,17 +50,6 @@ bool LightDisplay::isPressed() const
return hasSkinState( Pressed );
}
void LightDisplay::setShadow( const QskShadowMetrics& shadow )
{
m_shadow = shadow;
update();
}
const QskShadowMetrics& LightDisplay::shadow() const
{
return m_shadow;
}
void LightDisplay::setGradient( const QskGradient& gradient )
{
m_gradient = gradient;
@ -76,17 +61,6 @@ const QskGradient& LightDisplay::gradient() const
return m_gradient;
}
void LightDisplay::setShadowColor( const QColor& color )
{
m_shadowColor = color;
update();
}
QColor LightDisplay::shadowColor() const
{
return m_shadowColor;
}
void LightDisplay::mousePressEvent( QMouseEvent* event )
{
QRectF handleRect = subControlRect( LightDisplay::Knob );

View File

@ -22,15 +22,9 @@ class LightDisplay : public QskBoundedValueInput
bool isPressed() const;
void setShadow( const QskShadowMetrics& );
const QskShadowMetrics& shadow() const;
void setGradient( const QskGradient& );
const QskGradient& gradient() const;
void setShadowColor( const QColor& );
QColor shadowColor() const;
protected:
void mousePressEvent( QMouseEvent* e ) override;
void mouseMoveEvent( QMouseEvent* e ) override;

View File

@ -137,18 +137,7 @@ QSGNode* LightDisplaySkinlet::updateSubNode(
}
case GrooveRole:
{
const QRectF grooveRect = display->subControlRect( LightDisplay::Groove );
if ( grooveRect.isEmpty() )
return nullptr;
const auto& shadowMetrics = display->shadow();
const auto shadowRect = shadowMetrics.shadowRect( grooveRect );
auto shadowNode = QskSGNode::ensureNode< QskBoxShadowNode >( node );
shadowNode->setShadowData( shadowRect, grooveRect.width() / 2,
shadowMetrics.blurRadius(), display->shadowColor() );
return shadowNode;
return updateBoxNode( skinnable, node, LightDisplay::Groove );
}
case ColdAndWarmArcRole:
{

View File

@ -260,6 +260,11 @@ void Skin::initHints( const Palette& palette )
ed.setGradient( LightDisplay::Panel, palette.box );
ed.setGradient( LightDisplay::Knob, palette.box );
ed.setShadowMetrics( LightDisplay::Groove, { 0, 20 } );
ed.setShadowColor( LightDisplay::Groove, palette.shadow );
ed.setGradient( LightDisplay::Groove, palette.box );
ed.setBoxShape( LightDisplay::Groove, 100, Qt::RelativeSize );
ed.setGradient( RoundButton::Panel, palette.roundButton );
ed.setGradient( RoundButton::Panel | QskAbstractButton::Pressed, palette.roundButtonPressed,
{ QskStateCombination::CombinationNoState, RoundButton::Top } );
@ -297,7 +302,7 @@ Skin::Palette NighttimeSkin::palette() const
0xff1a1a1a,
0xff0c0c0c,
Qt::white,
0xff1a1a1a,
0xff4a4a4a,
{ { { 0.0, 0xff666666 }, { 0.5, 0xff222222 }, { 1.0, 0xff333333 } } },
0xff222222,
};