parent
ebc8494359
commit
f4531c149c
@ -670,6 +670,7 @@ void Editor::setupPushButton()
|
|||||||
|
|
||||||
setColor( Q::Text, m_pal.onPrimary );
|
setColor( Q::Text, m_pal.onPrimary );
|
||||||
setColor( Q::Text | Q::Disabled, m_pal.onSurface38 );
|
setColor( Q::Text | Q::Disabled, m_pal.onSurface38 );
|
||||||
|
setGraphicRole( Q::Graphic | Q::Disabled, QskMaterial3Skin::GraphicRoleOnSurface38 );
|
||||||
|
|
||||||
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
||||||
|
|
||||||
@ -1337,34 +1338,42 @@ void QskMaterial3Skin::setupFonts()
|
|||||||
void QskMaterial3Skin::setupGraphicFilters( const QskMaterial3Theme& palette )
|
void QskMaterial3Skin::setupGraphicFilters( const QskMaterial3Theme& palette )
|
||||||
{
|
{
|
||||||
QskColorFilter onPrimaryFilter;
|
QskColorFilter onPrimaryFilter;
|
||||||
|
onPrimaryFilter.setSubstituteAlphaValue( true );
|
||||||
onPrimaryFilter.addColorSubstitution( Qt::white, palette.onPrimary );
|
onPrimaryFilter.addColorSubstitution( Qt::white, palette.onPrimary );
|
||||||
setGraphicFilter( GraphicRoleOnPrimary, onPrimaryFilter );
|
setGraphicFilter( GraphicRoleOnPrimary, onPrimaryFilter );
|
||||||
|
|
||||||
QskColorFilter onSecondaryContainerFilter;
|
QskColorFilter onSecondaryContainerFilter;
|
||||||
|
onSecondaryContainerFilter.setSubstituteAlphaValue( true );
|
||||||
onSecondaryContainerFilter.addColorSubstitution( Qt::white, palette.onSecondaryContainer );
|
onSecondaryContainerFilter.addColorSubstitution( Qt::white, palette.onSecondaryContainer );
|
||||||
setGraphicFilter( GraphicRoleOnSecondaryContainer, onSecondaryContainerFilter );
|
setGraphicFilter( GraphicRoleOnSecondaryContainer, onSecondaryContainerFilter );
|
||||||
|
|
||||||
QskColorFilter onErrorFilter;
|
QskColorFilter onErrorFilter;
|
||||||
|
onErrorFilter.setSubstituteAlphaValue( true );
|
||||||
onErrorFilter.addColorSubstitution( Qt::white, palette.onError );
|
onErrorFilter.addColorSubstitution( Qt::white, palette.onError );
|
||||||
setGraphicFilter( GraphicRoleOnError, onErrorFilter );
|
setGraphicFilter( GraphicRoleOnError, onErrorFilter );
|
||||||
|
|
||||||
QskColorFilter onSurfaceFilter;
|
QskColorFilter onSurfaceFilter;
|
||||||
|
onSurfaceFilter.setSubstituteAlphaValue( true );
|
||||||
onSurfaceFilter.addColorSubstitution( Qt::white, palette.onSurface );
|
onSurfaceFilter.addColorSubstitution( Qt::white, palette.onSurface );
|
||||||
setGraphicFilter( GraphicRoleOnSurface, onSurfaceFilter );
|
setGraphicFilter( GraphicRoleOnSurface, onSurfaceFilter );
|
||||||
|
|
||||||
QskColorFilter onSurfaceFilter38;
|
QskColorFilter onSurfaceFilter38;
|
||||||
|
onSurfaceFilter38.setSubstituteAlphaValue( true );
|
||||||
onSurfaceFilter38.addColorSubstitution( Qt::white, palette.onSurface38 );
|
onSurfaceFilter38.addColorSubstitution( Qt::white, palette.onSurface38 );
|
||||||
setGraphicFilter( GraphicRoleOnSurface38, onSurfaceFilter38 );
|
setGraphicFilter( GraphicRoleOnSurface38, onSurfaceFilter38 );
|
||||||
|
|
||||||
QskColorFilter onSurfaceVariantFilter;
|
QskColorFilter onSurfaceVariantFilter;
|
||||||
|
onSurfaceVariantFilter.setSubstituteAlphaValue( true );
|
||||||
onSurfaceVariantFilter.addColorSubstitution( Qt::white, palette.onSurfaceVariant );
|
onSurfaceVariantFilter.addColorSubstitution( Qt::white, palette.onSurfaceVariant );
|
||||||
setGraphicFilter( GraphicRoleOnSurfaceVariant, onSurfaceVariantFilter );
|
setGraphicFilter( GraphicRoleOnSurfaceVariant, onSurfaceVariantFilter );
|
||||||
|
|
||||||
QskColorFilter primaryFilter;
|
QskColorFilter primaryFilter;
|
||||||
|
primaryFilter.setSubstituteAlphaValue( true );
|
||||||
primaryFilter.addColorSubstitution( Qt::white, palette.primary );
|
primaryFilter.addColorSubstitution( Qt::white, palette.primary );
|
||||||
setGraphicFilter( GraphicRolePrimary, primaryFilter );
|
setGraphicFilter( GraphicRolePrimary, primaryFilter );
|
||||||
|
|
||||||
QskColorFilter surfaceFilter;
|
QskColorFilter surfaceFilter;
|
||||||
|
surfaceFilter.setSubstituteAlphaValue( true );
|
||||||
surfaceFilter.addColorSubstitution( Qt::white, palette.surface );
|
surfaceFilter.addColorSubstitution( Qt::white, palette.surface );
|
||||||
setGraphicFilter( GraphicRoleSurface, surfaceFilter );
|
setGraphicFilter( GraphicRoleSurface, surfaceFilter );
|
||||||
}
|
}
|
||||||
|
@ -11,19 +11,21 @@
|
|||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
|
||||||
static inline QRgb qskSubstitutedRgb(
|
static inline QRgb qskSubstitutedRgb(
|
||||||
const QVector< QPair< QRgb, QRgb > >& substitions, QRgb rgba )
|
const QVector< QPair< QRgb, QRgb > >& substitions, QRgb rgba, bool substituteAlpha )
|
||||||
{
|
{
|
||||||
// usually we have 2-3 substitutions, so we can simply iterate
|
// usually we have 2-3 substitutions, so we can simply iterate
|
||||||
// and don't need to introduce some sort of sorting or search index
|
// and don't need to introduce some sort of sorting or search index
|
||||||
|
|
||||||
const QRgb rgb = rgba | QskRgb::AlphaMask;
|
const QRgb rgb = substituteAlpha ? rgba : ( rgba | QskRgb::AlphaMask );
|
||||||
|
|
||||||
for ( const auto& s : substitions )
|
for ( const auto& s : substitions )
|
||||||
{
|
{
|
||||||
if ( rgb == s.first )
|
if ( rgb == s.first )
|
||||||
{
|
{
|
||||||
return ( s.second & QskRgb::ColorMask ) |
|
const auto ret = substituteAlpha ? s.second
|
||||||
( rgba & QskRgb::AlphaMask );
|
: ( s.second & QskRgb::ColorMask )
|
||||||
|
| ( rgba & QskRgb::AlphaMask );
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,13 +33,13 @@ static inline QRgb qskSubstitutedRgb(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline QColor qskSubstitutedColor(
|
static inline QColor qskSubstitutedColor(
|
||||||
const QVector< QPair< QRgb, QRgb > >& substitions, const QColor& color )
|
const QVector< QPair< QRgb, QRgb > >& substitions, const QColor& color, bool substituteAlpha )
|
||||||
{
|
{
|
||||||
return QColor::fromRgba( qskSubstitutedRgb( substitions, color.rgba() ) );
|
return QColor::fromRgba( qskSubstitutedRgb( substitions, color.rgba(), substituteAlpha ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QBrush qskSubstitutedBrush(
|
static inline QBrush qskSubstitutedBrush(
|
||||||
const QVector< QPair< QRgb, QRgb > >& substitions, const QBrush& brush )
|
const QVector< QPair< QRgb, QRgb > >& substitions, const QBrush& brush, bool substituteAlpha )
|
||||||
{
|
{
|
||||||
QBrush newBrush;
|
QBrush newBrush;
|
||||||
|
|
||||||
@ -48,7 +50,7 @@ static inline QBrush qskSubstitutedBrush(
|
|||||||
auto stops = gradient->stops();
|
auto stops = gradient->stops();
|
||||||
for ( auto& stop : stops )
|
for ( auto& stop : stops )
|
||||||
{
|
{
|
||||||
const QColor c = qskSubstitutedColor( substitions, stop.second );
|
const QColor c = qskSubstitutedColor( substitions, stop.second, substituteAlpha );
|
||||||
if ( c != stop.second )
|
if ( c != stop.second )
|
||||||
{
|
{
|
||||||
stop.second = c;
|
stop.second = c;
|
||||||
@ -66,7 +68,7 @@ static inline QBrush qskSubstitutedBrush(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const QColor c = qskSubstitutedColor( substitions, brush.color() );
|
const QColor c = qskSubstitutedColor( substitions, brush.color(), substituteAlpha );
|
||||||
if ( c != brush.color() )
|
if ( c != brush.color() )
|
||||||
{
|
{
|
||||||
newBrush = brush;
|
newBrush = brush;
|
||||||
@ -166,7 +168,7 @@ QPen QskColorFilter::substituted( const QPen& pen ) const
|
|||||||
if ( m_substitutions.isEmpty() || pen.style() == Qt::NoPen )
|
if ( m_substitutions.isEmpty() || pen.style() == Qt::NoPen )
|
||||||
return pen;
|
return pen;
|
||||||
|
|
||||||
const auto newBrush = qskSubstitutedBrush( m_substitutions, pen.brush() );
|
const auto newBrush = qskSubstitutedBrush( m_substitutions, pen.brush(), m_substituteAlphaValue );
|
||||||
if ( newBrush.style() == Qt::NoBrush )
|
if ( newBrush.style() == Qt::NoBrush )
|
||||||
return pen;
|
return pen;
|
||||||
|
|
||||||
@ -180,18 +182,28 @@ QBrush QskColorFilter::substituted( const QBrush& brush ) const
|
|||||||
if ( m_substitutions.isEmpty() || brush.style() == Qt::NoBrush )
|
if ( m_substitutions.isEmpty() || brush.style() == Qt::NoBrush )
|
||||||
return brush;
|
return brush;
|
||||||
|
|
||||||
const auto newBrush = qskSubstitutedBrush( m_substitutions, brush );
|
const auto newBrush = qskSubstitutedBrush( m_substitutions, brush, m_substituteAlphaValue );
|
||||||
return ( newBrush.style() != Qt::NoBrush ) ? newBrush : brush;
|
return ( newBrush.style() != Qt::NoBrush ) ? newBrush : brush;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QskColorFilter::substituted( const QColor& color ) const
|
QColor QskColorFilter::substituted( const QColor& color ) const
|
||||||
{
|
{
|
||||||
return qskSubstitutedColor( m_substitutions, color );
|
return qskSubstitutedColor( m_substitutions, color, m_substituteAlphaValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRgb QskColorFilter::substituted( const QRgb& rgb ) const
|
QRgb QskColorFilter::substituted( const QRgb& rgb ) const
|
||||||
{
|
{
|
||||||
return qskSubstitutedRgb( m_substitutions, rgb );
|
return qskSubstitutedRgb( m_substitutions, rgb, m_substituteAlphaValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QskColorFilter::substituteAlphaValue() const noexcept
|
||||||
|
{
|
||||||
|
return m_substituteAlphaValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskColorFilter::setSubstituteAlphaValue( bool on )
|
||||||
|
{
|
||||||
|
m_substituteAlphaValue = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskColorFilter QskColorFilter::interpolated(
|
QskColorFilter QskColorFilter::interpolated(
|
||||||
|
@ -37,6 +37,9 @@ class QSK_EXPORT QskColorFilter
|
|||||||
|
|
||||||
bool isIdentity() const noexcept;
|
bool isIdentity() const noexcept;
|
||||||
|
|
||||||
|
bool substituteAlphaValue() const noexcept;
|
||||||
|
void setSubstituteAlphaValue( bool );
|
||||||
|
|
||||||
bool operator==( const QskColorFilter& other ) const noexcept;
|
bool operator==( const QskColorFilter& other ) const noexcept;
|
||||||
bool operator!=( const QskColorFilter& other ) const noexcept;
|
bool operator!=( const QskColorFilter& other ) const noexcept;
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ class QSK_EXPORT QskColorFilter
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QVector< QPair< QRgb, QRgb > > m_substitutions;
|
QVector< QPair< QRgb, QRgb > > m_substitutions;
|
||||||
|
bool m_substituteAlphaValue = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool QskColorFilter::isIdentity() const noexcept
|
inline bool QskColorFilter::isIdentity() const noexcept
|
||||||
|
Loading…
x
Reference in New Issue
Block a user