QskCorner removed - using QskBoxShapeMetrics instead
This commit is contained in:
parent
b188491568
commit
71da4dcdff
|
@ -9,7 +9,7 @@ Qsk.PushButton
|
|||
verticalPolicy: Qsk.SizePolicy.Ignored
|
||||
}
|
||||
|
||||
corner
|
||||
shape
|
||||
{
|
||||
sizeMode: Qt.RelativeSize
|
||||
aspectRatioMode: Qt.KeepAspectRatio
|
||||
|
|
|
@ -112,7 +112,7 @@ Qsk.Window
|
|||
{
|
||||
graphicSource: "image://shapes/Diamond/SandyBrown"
|
||||
|
||||
corner
|
||||
shape
|
||||
{
|
||||
sizeMode: Qt.RelativeSize
|
||||
aspectRatioMode: Qt.IgnoreAspectRatio
|
||||
|
@ -124,7 +124,7 @@ Qsk.Window
|
|||
{
|
||||
text: "Push Me"
|
||||
|
||||
corner
|
||||
shape
|
||||
{
|
||||
sizeMode: Qt.AbsoluteSize
|
||||
radius: 0.0
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "QskMainQml.h"
|
||||
#include "QskRgbValueQml.h"
|
||||
|
||||
#include <QskCorner.h>
|
||||
#include <QskBoxShapeMetrics.h>
|
||||
#include <QskDialog.h>
|
||||
#include <QskDialogButton.h>
|
||||
#include <QskDialogButtonBox.h>
|
||||
|
@ -193,7 +193,7 @@ void QskQml::registerTypes()
|
|||
|
||||
QSK_REGISTER_GADGET( QskRgbValueQml, "RgbValue" );
|
||||
QSK_REGISTER_GADGET( QskStandardSymbol, "StandardSymbol" );
|
||||
QSK_REGISTER_GADGET( QskCorner, "Corner" );
|
||||
QSK_REGISTER_GADGET( QskBoxShapeMetrics, "Shape" );
|
||||
QSK_REGISTER_GADGET( QskGradient, "Gradient" );
|
||||
QSK_REGISTER_GADGET( QskGradientStop, "GradientStop" );
|
||||
QSK_REGISTER_GADGET( QskIntervalF, "IntervalF" );
|
||||
|
|
|
@ -60,6 +60,26 @@ void QskBoxShapeMetrics::setRadius( Qt::Corner corner, qreal radiusX, qreal radi
|
|||
qskSetRadius( radiusX, radiusY, m_radii[ corner ] );
|
||||
}
|
||||
|
||||
void QskBoxShapeMetrics::setTopLeft( const QSizeF& radius ) noexcept
|
||||
{
|
||||
setRadius( Qt::TopLeftCorner, radius );
|
||||
}
|
||||
|
||||
void QskBoxShapeMetrics::setTopRight( const QSizeF& radius ) noexcept
|
||||
{
|
||||
setRadius( Qt::TopRightCorner, radius );
|
||||
}
|
||||
|
||||
void QskBoxShapeMetrics::setBottomLeft( const QSizeF& radius ) noexcept
|
||||
{
|
||||
setRadius( Qt::BottomLeftCorner, radius );
|
||||
}
|
||||
|
||||
void QskBoxShapeMetrics::setBottomRight( const QSizeF& radius ) noexcept
|
||||
{
|
||||
setRadius( Qt::BottomRightCorner, radius );
|
||||
}
|
||||
|
||||
QskBoxShapeMetrics QskBoxShapeMetrics::toAbsolute( const QSizeF& size ) const noexcept
|
||||
{
|
||||
if ( m_sizeMode != Qt::RelativeSize )
|
||||
|
@ -161,3 +181,5 @@ QDebug operator<<( QDebug debug, const QskBoxShapeMetrics& metrics )
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#include "moc_QskBoxShapeMetrics.cpp"
|
||||
|
|
|
@ -16,6 +16,19 @@ class QVariant;
|
|||
|
||||
class QSK_EXPORT QskBoxShapeMetrics
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
Q_PROPERTY( QSizeF topLeft READ topLeft WRITE setTopLeft )
|
||||
Q_PROPERTY( QSizeF topRight READ topRight WRITE setTopRight )
|
||||
Q_PROPERTY( QSizeF bottomLeft READ bottomLeft WRITE setBottomLeft )
|
||||
Q_PROPERTY( QSizeF bottomRight READ bottomRight WRITE setBottomRight )
|
||||
|
||||
Q_PROPERTY( qreal radius READ radiusX WRITE setRadius )
|
||||
|
||||
Q_PROPERTY( Qt::SizeMode sizeMode READ sizeMode WRITE setSizeMode )
|
||||
Q_PROPERTY( Qt::AspectRatioMode aspectRatioMode
|
||||
READ aspectRatioMode WRITE setAspectRatioMode )
|
||||
|
||||
public:
|
||||
constexpr QskBoxShapeMetrics() noexcept;
|
||||
|
||||
|
@ -54,6 +67,16 @@ class QSK_EXPORT QskBoxShapeMetrics
|
|||
|
||||
constexpr QSizeF radius( Qt::Corner ) const noexcept;
|
||||
|
||||
constexpr QSizeF topLeft() const noexcept;
|
||||
constexpr QSizeF topRight() const noexcept;
|
||||
constexpr QSizeF bottomLeft() const noexcept;
|
||||
constexpr QSizeF bottomRight() const noexcept;
|
||||
|
||||
void setTopLeft( const QSizeF& ) noexcept;
|
||||
void setTopRight( const QSizeF& ) noexcept;
|
||||
void setBottomLeft( const QSizeF& ) noexcept;
|
||||
void setBottomRight( const QSizeF& ) noexcept;
|
||||
|
||||
constexpr bool isRectangle() const noexcept;
|
||||
constexpr bool isRectellipse() const noexcept;
|
||||
|
||||
|
@ -76,6 +99,9 @@ class QSK_EXPORT QskBoxShapeMetrics
|
|||
const QskBoxShapeMetrics&, qreal progress ) noexcept;
|
||||
|
||||
private:
|
||||
// dummy getter to suppress moc warnings
|
||||
inline qreal radiusX() const { return radius( Qt::TopLeftCorner ).width(); }
|
||||
|
||||
inline constexpr QskBoxShapeMetrics(
|
||||
const QSizeF& topLeft, const QSizeF& topRight,
|
||||
const QSizeF& bottomLeft, const QSizeF& bottomRight,
|
||||
|
@ -194,6 +220,26 @@ inline constexpr QSizeF QskBoxShapeMetrics::radius( Qt::Corner corner ) const no
|
|||
? m_radii[ corner ] : QSizeF();
|
||||
}
|
||||
|
||||
inline constexpr QSizeF QskBoxShapeMetrics::topLeft() const noexcept
|
||||
{
|
||||
return radius( Qt::TopLeftCorner );
|
||||
}
|
||||
|
||||
inline constexpr QSizeF QskBoxShapeMetrics::topRight() const noexcept
|
||||
{
|
||||
return radius( Qt::TopRightCorner );
|
||||
}
|
||||
|
||||
inline constexpr QSizeF QskBoxShapeMetrics::bottomLeft() const noexcept
|
||||
{
|
||||
return radius( Qt::BottomLeftCorner );
|
||||
}
|
||||
|
||||
inline constexpr QSizeF QskBoxShapeMetrics::bottomRight() const noexcept
|
||||
{
|
||||
return radius( Qt::BottomRightCorner );
|
||||
}
|
||||
|
||||
inline void QskBoxShapeMetrics::setSizeMode( Qt::SizeMode sizeMode ) noexcept
|
||||
{
|
||||
m_sizeMode = sizeMode;
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskCorner.h"
|
||||
|
||||
QskCorner::QskCorner()
|
||||
{
|
||||
}
|
||||
|
||||
void QskCorner::setRadius( qreal radius )
|
||||
{
|
||||
m_metrics.setRadius( radius );
|
||||
}
|
||||
|
||||
qreal QskCorner::radius() const
|
||||
{
|
||||
return m_metrics.radius( Qt::TopLeftCorner ).width();
|
||||
}
|
||||
|
||||
void QskCorner::setSizeMode( Qt::SizeMode mode )
|
||||
{
|
||||
m_metrics.setSizeMode( mode );
|
||||
}
|
||||
|
||||
Qt::SizeMode QskCorner::sizeMode() const
|
||||
{
|
||||
return m_metrics.sizeMode();
|
||||
}
|
||||
|
||||
void QskCorner::setAspectRatioMode( Qt::AspectRatioMode mode )
|
||||
{
|
||||
m_metrics.setAspectRatioMode( mode );
|
||||
}
|
||||
|
||||
Qt::AspectRatioMode QskCorner::aspectRatioMode() const
|
||||
{
|
||||
return m_metrics.aspectRatioMode();
|
||||
}
|
||||
|
||||
#include "moc_QskCorner.cpp"
|
|
@ -1,53 +0,0 @@
|
|||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QSK_CORNER_H
|
||||
#define QSK_CORNER_H
|
||||
|
||||
#include "QskBoxShapeMetrics.h"
|
||||
|
||||
#include <qmetatype.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
class QDebug;
|
||||
class QSizeF;
|
||||
|
||||
class QSK_EXPORT QskCorner
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
Q_PROPERTY( qreal radius READ radius WRITE setRadius )
|
||||
Q_PROPERTY( Qt::SizeMode sizeMode READ sizeMode WRITE setSizeMode )
|
||||
Q_PROPERTY( Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode )
|
||||
|
||||
public:
|
||||
QskCorner();
|
||||
QskCorner( Qt::SizeMode, qreal radius );
|
||||
|
||||
qreal radius() const;
|
||||
void setRadius( qreal width );
|
||||
|
||||
Qt::SizeMode sizeMode() const;
|
||||
void setSizeMode( Qt::SizeMode );
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const;
|
||||
void setAspectRatioMode( Qt::AspectRatioMode );
|
||||
|
||||
const QskBoxShapeMetrics& metrics() const;
|
||||
|
||||
private:
|
||||
// QskCorner could be replaced by QskBoxShapeMetrics TODO ...
|
||||
QskBoxShapeMetrics m_metrics;
|
||||
};
|
||||
|
||||
inline const QskBoxShapeMetrics& QskCorner::metrics() const
|
||||
{
|
||||
return m_metrics;
|
||||
}
|
||||
|
||||
Q_DECLARE_TYPEINFO( QskCorner, Q_MOVABLE_TYPE );
|
||||
Q_DECLARE_METATYPE( QskCorner )
|
||||
|
||||
#endif
|
|
@ -6,7 +6,6 @@
|
|||
#include "QskPushButton.h"
|
||||
#include "QskAspect.h"
|
||||
#include "QskBoxShapeMetrics.h"
|
||||
#include "QskCorner.h"
|
||||
#include "QskGraphic.h"
|
||||
#include "QskGraphicProvider.h"
|
||||
#include "QskSetup.h"
|
||||
|
@ -84,24 +83,21 @@ bool QskPushButton::isCheckable() const
|
|||
return m_data->isCheckable;
|
||||
}
|
||||
|
||||
void QskPushButton::setCorner( const QskCorner& corner )
|
||||
void QskPushButton::setShape( const QskBoxShapeMetrics& shape )
|
||||
{
|
||||
if ( setBoxShapeHint( Panel, corner.metrics() ) )
|
||||
Q_EMIT cornerChanged();
|
||||
if ( setBoxShapeHint( Panel, shape ) )
|
||||
Q_EMIT shapeChanged();
|
||||
}
|
||||
|
||||
QskCorner QskPushButton::corner() const
|
||||
void QskPushButton::resetShape()
|
||||
{
|
||||
const auto shape = boxShapeHint( Panel );
|
||||
if ( resetBoxShapeHint( Panel ) )
|
||||
Q_EMIT shapeChanged();
|
||||
}
|
||||
|
||||
#if 1
|
||||
QskCorner corner;
|
||||
corner.setRadius( shape.radius( Qt::TopLeftCorner ).width() );
|
||||
corner.setSizeMode( shape.sizeMode() );
|
||||
corner.setAspectRatioMode( shape.aspectRatioMode() );
|
||||
#endif
|
||||
|
||||
return corner;
|
||||
QskBoxShapeMetrics QskPushButton::shape() const
|
||||
{
|
||||
return boxShapeHint( Panel );
|
||||
}
|
||||
|
||||
void QskPushButton::setFlat( bool on )
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "QskAbstractButton.h"
|
||||
|
||||
class QskCorner;
|
||||
class QskBoxShapeMetrics;
|
||||
class QskGraphic;
|
||||
class QskTextOptions;
|
||||
|
||||
|
@ -37,7 +37,9 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
|||
WRITE setCheckable NOTIFY checkableChanged FINAL )
|
||||
|
||||
Q_PROPERTY( bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL )
|
||||
Q_PROPERTY( QskCorner corner READ corner WRITE setCorner NOTIFY cornerChanged )
|
||||
|
||||
Q_PROPERTY( QskBoxShapeMetrics shape READ shape
|
||||
WRITE setShape RESET resetShape NOTIFY shapeChanged )
|
||||
|
||||
using Inherited = QskAbstractButton;
|
||||
|
||||
|
@ -52,8 +54,9 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
|||
void setCheckable( bool );
|
||||
bool isCheckable() const override final;
|
||||
|
||||
void setCorner( const QskCorner& );
|
||||
QskCorner corner() const;
|
||||
void setShape( const QskBoxShapeMetrics& );
|
||||
QskBoxShapeMetrics shape() const;
|
||||
void resetShape();
|
||||
|
||||
QString text() const;
|
||||
|
||||
|
@ -83,7 +86,7 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
|||
|
||||
Q_SIGNALS:
|
||||
void checkableChanged( bool );
|
||||
void cornerChanged();
|
||||
void shapeChanged();
|
||||
void textChanged();
|
||||
void textOptionsChanged();
|
||||
void flatChanged();
|
||||
|
|
|
@ -16,7 +16,6 @@ HEADERS += \
|
|||
common/QskBoxBorderColors.h \
|
||||
common/QskBoxBorderMetrics.h \
|
||||
common/QskBoxShapeMetrics.h \
|
||||
common/QskCorner.h \
|
||||
common/QskFunctions.h \
|
||||
common/QskGlobal.h \
|
||||
common/QskGradient.h \
|
||||
|
@ -42,7 +41,6 @@ SOURCES += \
|
|||
common/QskBoxBorderColors.cpp \
|
||||
common/QskBoxBorderMetrics.cpp \
|
||||
common/QskBoxShapeMetrics.cpp \
|
||||
common/QskCorner.cpp \
|
||||
common/QskFunctions.cpp \
|
||||
common/QskGradient.cpp \
|
||||
common/QskIntervalF.cpp \
|
||||
|
|
Loading…
Reference in New Issue