rename and reduce example
This commit is contained in:
parent
8f6b83be8e
commit
34a94e52f9
|
@ -1,15 +1,10 @@
|
||||||
#include "RadialNodes.h"
|
#include "RadialNodes.h"
|
||||||
|
|
||||||
QSK_SUBCONTROL(RadialNodes, Foreground)
|
QSK_SUBCONTROL(RadialTickmarks, Lines)
|
||||||
QSK_SUBCONTROL(RadialNodes, Text)
|
|
||||||
QSK_SUBCONTROL(RadialNodes, Lines)
|
|
||||||
|
|
||||||
RadialNodes::RadialNodes( QQuickItem* const parent ) : QskControl( parent )
|
RadialTickmarks::RadialTickmarks( QQuickItem* const parent ) : QskControl( parent )
|
||||||
{
|
{
|
||||||
// TODO move into your skin
|
// TODO move into your skin
|
||||||
setColor(Background, Qt::lightGray);
|
|
||||||
setColor(Foreground, Qt::black);
|
|
||||||
setColor(Text, Qt::white);
|
|
||||||
setColor(Lines, Qt::red);
|
setColor(Lines, Qt::red);
|
||||||
setStrutSizeHint( Lines, 2, 10 );
|
setStrutSizeHint( Lines, 2, 10 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include <QskControl.h>
|
#include <QskControl.h>
|
||||||
|
|
||||||
class RadialNodes : public QskControl
|
class RadialTickmarks : public QskControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS(Foreground, Text, Lines)
|
QSK_SUBCONTROLS(Lines)
|
||||||
explicit RadialNodes( QQuickItem* parent = nullptr );
|
explicit RadialTickmarks( QQuickItem* parent = nullptr );
|
||||||
};
|
};
|
|
@ -164,41 +164,29 @@ namespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
RadialNodesSkinlet::RadialNodesSkinlet( QskSkin* const skin )
|
RadialTickmarksSkinlet::RadialTickmarksSkinlet( QskSkin* const skin )
|
||||||
: QskSkinlet( skin )
|
: QskSkinlet( skin )
|
||||||
{
|
{
|
||||||
setNodeRoles( { Lines } );
|
setNodeRoles( { Lines } );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF RadialNodesSkinlet::subControlRect( const QskSkinnable* const skinnable,
|
QRectF RadialTickmarksSkinlet::subControlRect( const QskSkinnable* const skinnable,
|
||||||
const QRectF& contentsRect, const QskAspect::Subcontrol subControl ) const
|
const QRectF& contentsRect, const QskAspect::Subcontrol subControl ) const
|
||||||
{
|
{
|
||||||
if ( subControl == RadialNodes::Text )
|
if ( subControl == RadialTickmarks::Lines )
|
||||||
{
|
|
||||||
return contentsRect.adjusted( +20, +20, -20, -20 );
|
|
||||||
}
|
|
||||||
else if ( subControl == RadialNodes::Foreground )
|
|
||||||
{
|
|
||||||
return contentsRect.adjusted( +10, +10, -10, -10 );
|
|
||||||
}
|
|
||||||
else if ( subControl == RadialNodes::Lines )
|
|
||||||
{
|
{
|
||||||
return contentsRect;
|
return contentsRect;
|
||||||
}
|
}
|
||||||
return QskSkinlet::subControlRect( skinnable, contentsRect, subControl );
|
return QskSkinlet::subControlRect( skinnable, contentsRect, subControl );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* RadialNodesSkinlet::updateSubNode(
|
QSGNode* RadialTickmarksSkinlet::updateSubNode(
|
||||||
const QskSkinnable* const skinnable, const quint8 nodeRole, QSGNode* const node ) const
|
const QskSkinnable* const skinnable, const quint8 nodeRole, QSGNode* const node ) const
|
||||||
{
|
{
|
||||||
using Q = RadialNodes;
|
using Q = RadialTickmarks;
|
||||||
|
|
||||||
switch ( static_cast< NodeRole >( nodeRole ) )
|
switch ( static_cast< NodeRole >( nodeRole ) )
|
||||||
{
|
{
|
||||||
case Text:
|
|
||||||
return updateTextNode( skinnable, node, "RadialNodes", RadialNodes::Text );
|
|
||||||
case Foreground:
|
|
||||||
return updateBoxNode( skinnable, node, RadialNodes::Foreground );
|
|
||||||
case Lines: {
|
case Lines: {
|
||||||
const auto* const control = static_cast< const Q* >( skinnable );
|
const auto* const control = static_cast< const Q* >( skinnable );
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,17 @@
|
||||||
|
|
||||||
#include <QskSkinlet.h>
|
#include <QskSkinlet.h>
|
||||||
|
|
||||||
class RadialNodesSkinlet : public QskSkinlet
|
class RadialTickmarksSkinlet : public QskSkinlet
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
public:
|
public:
|
||||||
enum NodeRole
|
enum NodeRole
|
||||||
{
|
{
|
||||||
Text,
|
|
||||||
Foreground,
|
|
||||||
Lines,
|
Lines,
|
||||||
RoleCount
|
RoleCount
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_INVOKABLE RadialNodesSkinlet( QskSkin* skin = nullptr );
|
Q_INVOKABLE RadialTickmarksSkinlet( QskSkin* skin = nullptr );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Q_REQUIRED_RESULT QRectF subControlRect( const QskSkinnable* skinnable, const QRectF& contentsRect, QskAspect::Subcontrol subControl) const override;
|
Q_REQUIRED_RESULT QRectF subControlRect( const QskSkinnable* skinnable, const QRectF& contentsRect, QskAspect::Subcontrol subControl) const override;
|
||||||
|
|
|
@ -45,8 +45,8 @@ int main( int argc, char* argv[] )
|
||||||
auto* const layout = new QskLinearBox(Qt::Horizontal, window.contentItem() );
|
auto* const layout = new QskLinearBox(Qt::Horizontal, window.contentItem() );
|
||||||
auto* const left = new QskLinearBox(Qt::Vertical, layout);
|
auto* const left = new QskLinearBox(Qt::Vertical, layout);
|
||||||
auto* const right = new QskLinearBox(Qt::Vertical, layout);
|
auto* const right = new QskLinearBox(Qt::Vertical, layout);
|
||||||
auto* const control = new RadialNodes( left );
|
auto* const control = new RadialTickmarks( left );
|
||||||
auto* const skinlet = new RadialNodesSkinlet;
|
auto* const skinlet = new RadialTickmarksSkinlet;
|
||||||
{
|
{
|
||||||
(void) new QskTextLabel("Tickmark Alignment", right);
|
(void) new QskTextLabel("Tickmark Alignment", right);
|
||||||
auto* const alignment = new QskSegmentedBar(right);
|
auto* const alignment = new QskSegmentedBar(right);
|
||||||
|
@ -54,7 +54,7 @@ int main( int argc, char* argv[] )
|
||||||
QObject::connect(alignment, &QskSegmentedBar::selectedIndexChanged, control, [=](const int i){
|
QObject::connect(alignment, &QskSegmentedBar::selectedIndexChanged, control, [=](const int i){
|
||||||
static const Qt::Alignment a[ 3 ]{ Qt::AlignVCenter, Qt::AlignBottom,
|
static const Qt::Alignment a[ 3 ]{ Qt::AlignVCenter, Qt::AlignBottom,
|
||||||
Qt::AlignTop };
|
Qt::AlignTop };
|
||||||
control->setAlignmentHint(RadialNodes::Lines, a[i]);
|
control->setAlignmentHint(RadialTickmarks::Lines, a[i]);
|
||||||
});
|
});
|
||||||
|
|
||||||
(void) new QskTextLabel("Tickmark Size", right);
|
(void) new QskTextLabel("Tickmark Size", right);
|
||||||
|
@ -69,7 +69,7 @@ int main( int argc, char* argv[] )
|
||||||
auto updateStrutSizeHint = [=](const qreal){
|
auto updateStrutSizeHint = [=](const qreal){
|
||||||
const auto width = sliderW->value();
|
const auto width = sliderW->value();
|
||||||
const auto height = sliderH->value() * control->height();
|
const auto height = sliderH->value() * control->height();
|
||||||
control->setStrutSizeHint(RadialNodes::Lines, width, height );
|
control->setStrutSizeHint(RadialTickmarks::Lines, width, height );
|
||||||
};
|
};
|
||||||
|
|
||||||
QObject::connect( sliderW, &QskSlider::valueChanged, control, updateStrutSizeHint );
|
QObject::connect( sliderW, &QskSlider::valueChanged, control, updateStrutSizeHint );
|
||||||
|
|
Loading…
Reference in New Issue