example improved
This commit is contained in:
parent
f0ad71fb7c
commit
4e00c73f92
@ -74,7 +74,7 @@ class MySkin : public QskSkin
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initToggleButtonHints(
|
void initToggleButtonHints(
|
||||||
qreal width, qreal height, qreal radius,
|
bool raised, qreal width, qreal height, qreal radius,
|
||||||
QRgb baseColor, QRgb baseTextColor,
|
QRgb baseColor, QRgb baseTextColor,
|
||||||
QRgb foregroundColor, QRgb foregroundTextColor )
|
QRgb foregroundColor, QRgb foregroundTextColor )
|
||||||
{
|
{
|
||||||
@ -115,19 +115,33 @@ class MySkin : public QskSkin
|
|||||||
}
|
}
|
||||||
|
|
||||||
setGradient( Q::Panel, baseColor );
|
setGradient( Q::Panel, baseColor );
|
||||||
|
|
||||||
|
if ( raised )
|
||||||
|
{
|
||||||
|
setBoxBorderMetrics( Q::Panel, 3 );
|
||||||
|
|
||||||
|
auto light = QColor( baseColor ).light( 110 );
|
||||||
|
auto dark = QColor( baseColor ).dark( 120 );
|
||||||
|
setBoxBorderColors( Q::Panel,
|
||||||
|
QskBoxBorderColors( light, light, dark, dark ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setBoxBorderMetrics( Q::Panel, 1 );
|
||||||
setBoxBorderColors( Q::Panel, QColor( baseColor ).dark( 120 ) );
|
setBoxBorderColors( Q::Panel, QColor( baseColor ).dark( 120 ) );
|
||||||
|
}
|
||||||
|
|
||||||
setGradient( Q::Cursor, foregroundColor );
|
setGradient( Q::Cursor, foregroundColor );
|
||||||
setBoxBorderColors( Q::Cursor, QColor( foregroundColor ).dark( 120 ) );
|
setBoxBorderColors( Q::Cursor, QColor( foregroundColor ).dark( 120 ) );
|
||||||
|
setBoxBorderMetrics( Q::Cursor, 1 );
|
||||||
|
|
||||||
for( auto subControl : { Q::Panel, Q::Cursor } )
|
for( auto subControl : { Q::Panel, Q::Cursor } )
|
||||||
{
|
{
|
||||||
setMetric( subControl | MinimumWidth, width );
|
setMetric( subControl | MinimumWidth, width );
|
||||||
setMetric( subControl | MinimumHeight, height );
|
setMetric( subControl | MinimumHeight, height );
|
||||||
setMargins( subControl | Padding, -4 );
|
//setMargins( subControl | Padding, +2 );
|
||||||
|
|
||||||
setBoxShape( subControl, radius );
|
setBoxShape( subControl, radius );
|
||||||
setBoxBorderMetrics( subControl, 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setMargins( Q::CheckedPanel | Padding, 10 );
|
setMargins( Q::CheckedPanel | Padding, 10 );
|
||||||
@ -170,9 +184,9 @@ class MySkin1 : public MySkin
|
|||||||
setGraphicFilter( GraphicRoleNormal, QskRgbValue::Crimson );
|
setGraphicFilter( GraphicRoleNormal, QskRgbValue::Crimson );
|
||||||
setGraphicFilter( GraphicRoleInverted, QskRgbValue::Gold );
|
setGraphicFilter( GraphicRoleInverted, QskRgbValue::Gold );
|
||||||
|
|
||||||
initFocusIndicatorHints( 2, 3, 6, Teal );
|
initFocusIndicatorHints( 2, 3, 6, DarkBlue );
|
||||||
initBoxHints( 2, 8, DarkCyan, LightCyan );
|
initBoxHints( 2, 8, DarkCyan, LightCyan );
|
||||||
initToggleButtonHints( 150, 120, 6,
|
initToggleButtonHints( false, 150, 120, 6,
|
||||||
AliceBlue, Black, CornflowerBlue, White );
|
AliceBlue, Black, CornflowerBlue, White );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +208,8 @@ class MySkin2 : public MySkin
|
|||||||
|
|
||||||
initFocusIndicatorHints( 2, 6, 6, Crimson );
|
initFocusIndicatorHints( 2, 6, 6, Crimson );
|
||||||
initBoxHints( 4, 30, LightPink, MistyRose );
|
initBoxHints( 4, 30, LightPink, MistyRose );
|
||||||
initToggleButtonHints( 130, 100, 40,
|
initToggleButtonHints( true, 130, 100, 40,
|
||||||
Linen, Black, HotPink, White );
|
LightPink, Black, HotPink, White );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskAnimationHint animator() const override
|
QskAnimationHint animator() const override
|
||||||
|
@ -53,14 +53,16 @@ class ContentBox : public QskBox
|
|||||||
|
|
||||||
{
|
{
|
||||||
auto button = new MyToggleButton( layout );
|
auto button = new MyToggleButton( layout );
|
||||||
button->setSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding );
|
button->setSizePolicy( QskSizePolicy::MinimumExpanding,
|
||||||
|
QskSizePolicy::MinimumExpanding );
|
||||||
button->setTextAt( 0, "On" );
|
button->setTextAt( 0, "On" );
|
||||||
button->setTextAt( 1, "Off" );
|
button->setTextAt( 1, "Off" );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto button = new MyToggleButton( layout );
|
auto button = new MyToggleButton( layout );
|
||||||
button->setSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding );
|
button->setSizePolicy( QskSizePolicy::MinimumExpanding,
|
||||||
|
QskSizePolicy::MinimumExpanding );
|
||||||
button->setIconAt( 0, "image://shapes/Ring/Khaki" );
|
button->setIconAt( 0, "image://shapes/Ring/Khaki" );
|
||||||
button->setIconAt( 1, "image://shapes/Diamond/Khaki" );
|
button->setIconAt( 1, "image://shapes/Diamond/Khaki" );
|
||||||
}
|
}
|
||||||
@ -82,6 +84,7 @@ class Window : public QskWindow
|
|||||||
|
|
||||||
box->setMargins( 20 );
|
box->setMargins( 20 );
|
||||||
box->addItem( button, Qt::AlignRight );
|
box->addItem( button, Qt::AlignRight );
|
||||||
|
box->addSpacer( 10 );
|
||||||
box->addItem( new ContentBox() );
|
box->addItem( new ContentBox() );
|
||||||
|
|
||||||
connect( button, &MyToggleButton::toggled,
|
connect( button, &MyToggleButton::toggled,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user