using QskSkin::symbol for the indicator
This commit is contained in:
parent
5545d124e8
commit
f7cd259fb0
@ -214,7 +214,8 @@ void Editor::setupCheckBox()
|
|||||||
setGradient( Q::Box | Q::Checked, m_pal.accentColor );
|
setGradient( Q::Box | Q::Checked, m_pal.accentColor );
|
||||||
setGradient( Q::Box | Q::Disabled, QskRgb::Grey );
|
setGradient( Q::Box | Q::Disabled, QskRgb::Grey );
|
||||||
|
|
||||||
setColor( Q::Indicator, m_pal.contrastColor );
|
setColor( Q::Indicator | Q::Checked, m_pal.contrastColor );
|
||||||
|
setColor( Q::Indicator, m_pal.textColor );
|
||||||
|
|
||||||
setColor( Q::Text, m_pal.textColor );
|
setColor( Q::Text, m_pal.textColor );
|
||||||
setColor( Q::Text | Q::Disabled, qskShadedColor( m_pal.textColor, 0.6 ) );
|
setColor( Q::Text | Q::Disabled, qskShadedColor( m_pal.textColor, 0.6 ) );
|
||||||
|
@ -320,7 +320,8 @@ void Editor::setupCheckBox()
|
|||||||
setGradient( Q::Box | Q::Disabled, m_pal.lighter110 );
|
setGradient( Q::Box | Q::Disabled, m_pal.lighter110 );
|
||||||
setBoxBorderColors( Q::Box, m_pal.theme );
|
setBoxBorderColors( Q::Box, m_pal.theme );
|
||||||
|
|
||||||
setColor( Q::Indicator, m_pal.lighter135 );
|
setColor( Q::Indicator, m_pal.darker200 );
|
||||||
|
setColor( Q::Indicator | Q::Checked, m_pal.lighter135 );
|
||||||
|
|
||||||
setFlagHint( Q::Text | Q::Disabled | A::Style, Qsk::Sunken );
|
setFlagHint( Q::Text | Q::Disabled | A::Style, Qsk::Sunken );
|
||||||
setColor( Q::Text, m_pal.themeForeground );
|
setColor( Q::Text, m_pal.themeForeground );
|
||||||
|
@ -5,62 +5,12 @@
|
|||||||
|
|
||||||
#include "QskCheckBoxSkinlet.h"
|
#include "QskCheckBoxSkinlet.h"
|
||||||
#include "QskCheckBox.h"
|
#include "QskCheckBox.h"
|
||||||
#include "QskSGNode.h"
|
|
||||||
#include "QskTextOptions.h"
|
#include "QskTextOptions.h"
|
||||||
#include "QskFunctions.h"
|
#include "QskFunctions.h"
|
||||||
|
#include "QskGraphic.h"
|
||||||
#include <QSGFlatColorMaterial>
|
#include "QskStandardSymbol.h"
|
||||||
#include <qsgnode.h>
|
#include "QskColorFilter.h"
|
||||||
|
#include "QskSkin.h"
|
||||||
namespace
|
|
||||||
{
|
|
||||||
class IndicatorNode : public QSGGeometryNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IndicatorNode()
|
|
||||||
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 3 )
|
|
||||||
{
|
|
||||||
m_geometry.setDrawingMode( QSGGeometry::DrawLineStrip );
|
|
||||||
m_geometry.setLineWidth( 2 );
|
|
||||||
setGeometry( &m_geometry );
|
|
||||||
|
|
||||||
setMaterial( &m_material );
|
|
||||||
}
|
|
||||||
|
|
||||||
void update( const QRectF& rect, const QColor& color )
|
|
||||||
{
|
|
||||||
if ( color != m_material.color() )
|
|
||||||
{
|
|
||||||
m_material.setColor( color );
|
|
||||||
markDirty( QSGNode::DirtyMaterial );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( rect != m_rect )
|
|
||||||
{
|
|
||||||
m_rect = rect;
|
|
||||||
|
|
||||||
const auto x = rect.x();
|
|
||||||
const auto y = rect.y();
|
|
||||||
const auto w = rect.width();
|
|
||||||
const auto h = rect.height();
|
|
||||||
|
|
||||||
auto points = m_geometry.vertexDataAsPoint2D();
|
|
||||||
|
|
||||||
points[0].set( x, y + h / 2 );
|
|
||||||
points[1].set( x + w / 3, y + h );
|
|
||||||
points[2].set( x + w, y );
|
|
||||||
|
|
||||||
markDirty( QSGNode::DirtyGeometry );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QSGFlatColorMaterial m_material;
|
|
||||||
QSGGeometry m_geometry;
|
|
||||||
|
|
||||||
QRectF m_rect;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
QskCheckBoxSkinlet::QskCheckBoxSkinlet( QskSkin* skin )
|
QskCheckBoxSkinlet::QskCheckBoxSkinlet( QskSkin* skin )
|
||||||
: QskSkinlet( skin )
|
: QskSkinlet( skin )
|
||||||
@ -161,19 +111,31 @@ QSGNode* QskCheckBoxSkinlet::updateSubNode(
|
|||||||
QSGNode* QskCheckBoxSkinlet::updateIndicatorNode(
|
QSGNode* QskCheckBoxSkinlet::updateIndicatorNode(
|
||||||
const QskCheckBox* checkBox, QSGNode* node ) const
|
const QskCheckBox* checkBox, QSGNode* node ) const
|
||||||
{
|
{
|
||||||
using Q = QskCheckBox;
|
auto symbol = QskStandardSymbol::CheckMark;
|
||||||
|
|
||||||
if ( !checkBox->isChecked() )
|
if ( !checkBox->isChecked() )
|
||||||
return nullptr;
|
{
|
||||||
|
#if 0
|
||||||
|
symbol = QskStandardSymbol::NoSymbol;
|
||||||
|
#else
|
||||||
|
symbol = QskStandardSymbol::CrossMark;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const auto rect = checkBox->subControlRect( Q::Indicator );
|
auto graphic = checkBox->effectiveSkin()->symbol( symbol );
|
||||||
if ( rect.isEmpty() )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
auto indicatorNode = QskSGNode::ensureNode< IndicatorNode >( node );
|
#if 1
|
||||||
indicatorNode->update( rect, checkBox->color( Q::Indicator ) );
|
/*
|
||||||
|
Our default skins do not have the concept of colorRoles
|
||||||
|
implemented. Until then we do the recoloring manually here
|
||||||
|
*/
|
||||||
|
QskColorFilter filter;
|
||||||
|
filter.addColorSubstitution( Qt::black,
|
||||||
|
checkBox->color( QskCheckBox::Indicator ).rgba() );
|
||||||
|
|
||||||
return indicatorNode;
|
graphic = QskGraphic::fromGraphic( graphic, filter );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return updateGraphicNode( checkBox, node, graphic, QskCheckBox::Indicator );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskCheckBoxSkinlet::updateTextNode(
|
QSGNode* QskCheckBoxSkinlet::updateTextNode(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user