Skip to content

Commit

Permalink
QskArcShadowNode introduced ( kudos to Rick )
Browse files Browse the repository at this point in the history
  • Loading branch information
uwerat committed Jan 6, 2024
1 parent a420407 commit e63b064
Show file tree
Hide file tree
Showing 32 changed files with 1,310 additions and 194 deletions.
109 changes: 109 additions & 0 deletions playground/shadows/ArcPage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/

#include "ArcPage.h"
#include "ShadowedArc.h"
#include "Slider.h"

#include <QskGridBox.h>

namespace
{
class ControlPanel : public QskGridBox
{
Q_OBJECT

public:
ControlPanel( ShadowedArc* arc, QQuickItem* parent = nullptr )
: QskGridBox( parent )
{
setMargins( 5 );
setSpacing( 10 );

{
auto slider = new Slider( "Start", 0, 360, 10, arc->startAngle() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setStartAngle );

addItem( slider, 0, 0 );
}
{
auto slider = new Slider( "Span", -360, 360, 10, arc->spanAngle() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setSpanAngle );

addItem( slider, 0, 1 );
}
{
auto slider = new Slider( "Extent", 0, 100, 1, arc->thickness() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setThickness );

addItem( slider, 1, 0 );
}
{
auto slider = new Slider( "Border", 0, 10, 1, arc->borderWidth() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setBorderWidth );

addItem( slider, 1, 1);
}
{
auto slider = new Slider( "Spread Radius", -10, 50, 1, arc->spreadRadius() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setSpreadRadius );

addItem( slider, 2, 0 );
}
{
auto slider = new Slider( "Blur Radius", 0, 50, 1, arc->blurRadius() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setBlurRadius );

addItem( slider, 2, 1 );
}
{
auto slider = new Slider( "Offset X", -50, 50, 1, arc->offsetX() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setOffsetX );

addItem( slider, 3, 0 );

}
{
auto slider = new Slider( "Offset Y", -50, 50, 1, arc->offsetY() );
connect( slider, &Slider::valueChanged, arc, &ShadowedArc::setOffsetY );

addItem( slider, 3, 1 );
}
}
};
}

ArcPage::ArcPage( QQuickItem* parent )
: QskLinearBox( Qt::Vertical, parent )
{
auto arc = new ShadowedArc();
arc->setMargins( 40 ); // some extra space for testing the offsets

{
// initial settings
arc->setStartAngle( 45.0 );
arc->setSpanAngle( 270.0 );
arc->setThickness( 10.0 );

arc->setFillColor( Qt::darkRed );

arc->setBorderWidth( 0 );
arc->setBorderColor( Qt::darkYellow );

arc->setShadowColor( Qt::black );
arc->setSpreadRadius( 0.0 );
arc->setBlurRadius( 4.0 );
arc->setOffsetX( 2.0 );
arc->setOffsetY( 2.0 );
}

auto panel = new ControlPanel( arc );
panel->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed );

addItem( panel );
addItem( arc );
}

#include "ArcPage.moc"
14 changes: 14 additions & 0 deletions playground/shadows/ArcPage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/

#pragma once

#include <QskLinearBox.h>

class ArcPage : public QskLinearBox
{
public:
ArcPage( QQuickItem* parent = nullptr );
};
73 changes: 73 additions & 0 deletions playground/shadows/BoxPage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/

#include "BoxPage.h"
#include "ShadowedBox.h"
#include "Slider.h"

#include <QskRgbValue.h>
#include <QFontMetrics>

namespace
{
class ControlPanel : public QskLinearBox
{
public:
ControlPanel( ShadowedBox* box, QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Vertical, parent )
{
{
auto slider = new Slider( "Offset X", -50, 50, 1, box->offsetX() );
connect( slider, &Slider::valueChanged, box, &ShadowedBox::setOffsetX );

addItem( slider );
}
{
auto slider = new Slider( "Offset Y", -50, 50, 1, box->offsetY() );
connect( slider, &Slider::valueChanged, box, &ShadowedBox::setOffsetY );

addItem( slider );
}
{
auto slider = new Slider( "Spread Radius", -10, 50, 1, box->spreadRadius() );
connect( slider, &Slider::valueChanged, box, &ShadowedBox::setSpreadRadius );

addItem( slider );
}
{
auto slider = new Slider( "Blur Radius", 0, 50, 1, box->blurRadius() );
connect( slider, &Slider::valueChanged, box, &ShadowedBox::setBlurRadius );

addItem( slider );
}
{
auto slider = new Slider( "Opacity", 0, 1, 0.01, box->opacity() );
connect( slider, &Slider::valueChanged, box, &ShadowedBox::setOpacity );

addItem( slider );
}
}
};
}

BoxPage::BoxPage( QQuickItem* parent )
: QskLinearBox( Qt::Vertical, parent )
{
auto box = new ShadowedBox();
box->setMargins( 40 ); // some extra space for testing the offsets

{
box->setOffsetX( 10 );
box->setOffsetY( 10 );
box->setSpreadRadius( 0 );
box->setBlurRadius( 5 );
}

auto panel = new ControlPanel( box );
panel->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed );

addItem( panel );
addItem( box );
}
19 changes: 19 additions & 0 deletions playground/shadows/BoxPage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/

#pragma once

#include <QskLinearBox.h>

class QskSlider;

class BoxPage : public QskLinearBox
{
public:
BoxPage( QQuickItem* parent = nullptr );

private:
void addSlider( int row, const QString&, QskSlider* );
};
5 changes: 4 additions & 1 deletion playground/shadows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause
############################################################################

qsk_add_example(shadows ShadowedBox.h ShadowedBox.cpp main.cpp)
qsk_add_example(shadows
BoxPage.h BoxPage.cpp ShadowedBox.h ShadowedBox.cpp
ArcPage.h ArcPage.cpp ShadowedArc.h ShadowedArc.cpp
Slider.h Slider.cpp main.cpp)
Loading

0 comments on commit e63b064

Please sign in to comment.