本文整理汇总了C++中QEasingCurve类的典型用法代码示例。如果您正苦于以下问题:C++ QEasingCurve类的具体用法?C++ QEasingCurve怎么用?C++ QEasingCurve使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QEasingCurve类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
Window::Window(QWidget *parent)
: QWidget(parent),
m_iconSize(64, 64)
{
m_ui.setupUi(this);
QButtonGroup *buttonGroup = findChild<QButtonGroup *>(); // ### workaround for uic in 4.4
m_ui.easingCurvePicker->setIconSize(m_iconSize);
m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50);
buttonGroup->setId(m_ui.lineRadio, 0);
buttonGroup->setId(m_ui.circleRadio, 1);
QEasingCurve dummy;
m_ui.periodSpinBox->setValue(dummy.period());
m_ui.amplitudeSpinBox->setValue(dummy.amplitude());
m_ui.overshootSpinBox->setValue(dummy.overshoot());
connect(m_ui.easingCurvePicker, SIGNAL(currentRowChanged(int)), this, SLOT(curveChanged(int)));
connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pathChanged(int)));
connect(m_ui.periodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(double)));
connect(m_ui.amplitudeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(amplitudeChanged(double)));
connect(m_ui.overshootSpinBox, SIGNAL(valueChanged(double)), this, SLOT(overshootChanged(double)));
createCurveIcons();
QPixmap pix(QLatin1String(":/images/qt-logo.png"));
m_item = new PixmapItem(pix);
m_scene.addItem(m_item);
m_ui.graphicsView->setScene(&m_scene);
m_anim = new Animation(m_item, "pos");
m_anim->setEasingCurve(QEasingCurve::OutBounce);
m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce));
startAnimation();
}
示例2: ASSERT
void QtViewportInteractionEngine::animateItemRectVisible(const QRectF& itemRect)
{
ASSERT(m_scaleAnimation->state() == QAbstractAnimation::Stopped);
ASSERT(!scrollAnimationActive());
if (scrollAnimationActive())
return;
QRectF currentItemRectVisible = m_viewport->mapRectToWebContent(m_viewport->boundingRect());
if (itemRect == currentItemRectVisible)
return;
// FIXME: Investigate why that animation doesn't run when we are unfocused.
if (!m_viewport->isVisible() || !m_viewport->hasFocus()) {
// Apply the end result immediately when we are non-visible.
setItemRectVisible(itemRect);
return;
}
QEasingCurve easingCurve;
easingCurve.setCustomType(physicalOvershoot);
m_scaleAnimation->setDuration(kScaleAnimationDurationMillis);
m_scaleAnimation->setEasingCurve(easingCurve);
m_scaleAnimation->setStartValue(currentItemRectVisible);
m_scaleAnimation->setEndValue(itemRect);
m_scaleAnimation->start();
}
示例3: sipReleaseType
static PyObject *meth_QEasingCurve_addTCBSegment(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
const QPointF* a0;
int a0State = 0;
qreal a1;
qreal a2;
qreal a3;
QEasingCurve *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1ddd", &sipSelf, sipType_QEasingCurve, &sipCpp, sipType_QPointF, &a0, &a0State, &a1, &a2, &a3))
{
sipCpp->addTCBSegment(*a0,a1,a2,a3);
sipReleaseType(const_cast<QPointF *>(a0),sipType_QPointF,a0State);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QEasingCurve, sipName_addTCBSegment, doc_QEasingCurve_addTCBSegment);
return NULL;
}
示例4: PyErr_Format
static PyObject *meth_QEasingCurve_setCustomType(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
PyObject * a0;
QEasingCurve *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BF", &sipSelf, sipType_QEasingCurve, &sipCpp, &a0))
{
sipErrorState sipError = sipErrorNone;
#line 232 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\sip/QtCore/qeasingcurve.sip"
int i;
ec_custom_type *ct;
for (i = 0; i < ec_nr_custom_types; ++i)
{
ct = &ec_custom_types[i];
if (!ct->py_func || ct->py_func == a0)
break;
}
if (i == ec_nr_custom_types)
{
PyErr_Format(PyExc_ValueError, "a maximum of %d different easing functions are supported", ec_nr_custom_types);
sipError = sipErrorFail;
}
else
{
if (!ct->py_func)
{
ct->py_func = a0;
Py_INCREF(a0);
}
sipCpp->setCustomType(ct->func);
}
#line 401 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtCore/sipQtCoreQEasingCurve.cpp"
if (sipError == sipErrorFail)
return 0;
if (sipError == sipErrorNone)
{
Py_INCREF(Py_None);
return Py_None;
}
sipAddException(sipError, &sipParseErr);
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QEasingCurve, sipName_setCustomType, doc_QEasingCurve_setCustomType);
return NULL;
}
示例5: inOutBack
// Test getting and setting easing properties via the metaobject system.
void tst_QEasingCurve::properties()
{
tst_QEasingProperties obj;
QEasingCurve inOutBack(QEasingCurve::InOutBack);
qreal overshoot = 1.5;
inOutBack.setOvershoot(overshoot);
qreal amplitude = inOutBack.amplitude();
qreal period = inOutBack.period();
obj.setEasing(inOutBack);
QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
QCOMPARE(easing.type(), QEasingCurve::InOutBack);
QCOMPARE(easing.overshoot(), overshoot);
QCOMPARE(easing.amplitude(), amplitude);
QCOMPARE(easing.period(), period);
QEasingCurve linear(QEasingCurve::Linear);
overshoot = linear.overshoot();
amplitude = linear.amplitude();
period = linear.period();
obj.setProperty("easing",
qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));
easing = qVariantValue<QEasingCurve>(obj.property("easing"));
QCOMPARE(easing.type(), QEasingCurve::Linear);
QCOMPARE(easing.overshoot(), overshoot);
QCOMPARE(easing.amplitude(), amplitude);
QCOMPARE(easing.period(), period);
}
示例6: pix
void Window::createCurveIcons()
{
QPixmap pix(m_iconSize);
QPainter painter(&pix);
QLinearGradient gradient(0,0, 0, m_iconSize.height());
gradient.setColorAt(0.0, QColor(240, 240, 240));
gradient.setColorAt(1.0, QColor(224, 224, 224));
QBrush brush(gradient);
const QMetaObject &mo = QEasingCurve::staticMetaObject;
QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type"));
// Skip QEasingCurve::Custom
for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) {
painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush);
QEasingCurve curve = createEasingCurve((QEasingCurve::Type) i);
painter.setPen(QColor(0, 0, 255, 64));
qreal xAxis = m_iconSize.height()/1.5;
qreal yAxis = m_iconSize.width()/3;
painter.drawLine(0, xAxis, m_iconSize.width(), xAxis);
painter.drawLine(yAxis, 0, yAxis, m_iconSize.height());
qreal curveScale = m_iconSize.height()/2;
painter.setPen(Qt::NoPen);
// start point
painter.setBrush(Qt::red);
QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0));
painter.drawRect(start.x() - 1, start.y() - 1, 3, 3);
// end point
painter.setBrush(Qt::blue);
QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1));
painter.drawRect(end.x() - 1, end.y() - 1, 3, 3);
QPainterPath curvePath;
curvePath.moveTo(start);
for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) {
QPoint to;
to.setX(yAxis + curveScale * t);
to.setY(xAxis - curveScale * curve.valueForProgress(t));
curvePath.lineTo(to);
}
painter.setRenderHint(QPainter::Antialiasing, true);
painter.strokePath(curvePath, QColor(32, 32, 32));
painter.setRenderHint(QPainter::Antialiasing, false);
QListWidgetItem *item = new QListWidgetItem;
item->setIcon(QIcon(pix));
item->setText(metaEnum.key(i));
m_ui.easingCurvePicker->addItem(item);
}
}
示例7: EasingCurveEditor
void PropertiesEditorItem::slotOpenEasingCurveEditor()
{
EasingCurveEditor *editor = new EasingCurveEditor(parent());
editor->setEasingCurve(mProperty.read(mObject.data()).toEasingCurve());
if (editor->exec() == QDialog::Accepted) {
QEasingCurve curve = editor->easingCurve();
mProperty.write(mObject.data(), curve);
QPushButton *button = qobject_cast<QPushButton*>(mWidget.data());
button->setText(curve.staticMetaObject.enumerator(0).valueToKey(curve.type()));
}
delete editor;
}
示例8: applyAnimation
slideShowEngine::AnimationState slideShowEngine::applyAnimation()
{
effect e;
QEasingCurve curve;
qreal currentValue;
Pixmap *item;
if(m_currentStep==EnterAnimation)
e=m_currentNode.enterEffect();
else
if(m_currentStep==DisplayAnimation)
e=m_currentNode.displayEffect();
else
if(m_currentStep==ExitAnimation)
e=m_currentNode.exitEffect();
int duration=e.duration();
//int elapsed=m_stepCurrentTime;
curve.setPeriod(duration);
qreal startVal=qreal(e.startValue());
qreal endVal=qreal(e.endValue());
curve.setType(e.easingCurve());
//qreal valore=qreal(m_stepCurrentTime*TIMER_ANIMATION);
qreal valore=qreal(m_stepCurrentTime);
//qreal valore=qreal(m_stepCurrentTime*10);
valore=valore/(qreal(duration));
//valore=valore/10;
//currentValue=curve.valueForProgress(valore);
currentValue=endVal+(1.0-curve.valueForProgress(valore))*(startVal-endVal);
item=m_PixmapList[m_currentSlideIndex];
if(e.effectType()=="pos")
item->setProperty(e.effectType().toLatin1(),QVariant(QPointF(currentValue,0)));
else
item->setProperty(e.effectType().toLatin1(),QVariant(currentValue));
//if(m_stepCurrentTime*TIMER_ANIMATION < e.duration()/**10*/)
if(m_stepCurrentTime < duration)
//if(m_stepCurrentTime*10 < e.duration()/**10*/)
return RunningAnimation;
else
return EndAnimation;
}
示例9: QCOMPARE
void tst_QEasingCurve::operators()
{
// operator=
QEasingCurve curve;
QEasingCurve curve2;
curve.setCustomType(&discreteEase);
curve2 = curve;
QCOMPARE(curve2.type(), QEasingCurve::Custom);
QCOMPARE(curve2.valueForProgress(0.0), 0.0);
QCOMPARE(curve2.valueForProgress(0.05), 0.0);
QCOMPARE(curve2.valueForProgress(0.15), 0.1);
QCOMPARE(curve2.valueForProgress(0.25), 0.2);
QCOMPARE(curve2.valueForProgress(0.35), 0.3);
QCOMPARE(curve2.valueForProgress(0.999999), 0.9);
// operator==
curve.setType(QEasingCurve::InBack);
curve2 = curve;
curve2.setOvershoot(qreal(1.70158f));
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
curve.setOvershoot(3.0);
QVERIFY(curve2 != curve);
curve2.setOvershoot(3.0);
QVERIFY(curve2 == curve);
curve2.setType(QEasingCurve::Linear);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 != curve);
curve2.setType(QEasingCurve::InBack);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
}
示例10: if
/*!
Compare this easing curve with \a other and returns true if they are
equal. It will also compare the properties of a curve.
*/
bool QEasingCurve::operator==(const QEasingCurve &other) const
{
bool res = d_ptr->func == other.d_ptr->func
&& d_ptr->type == other.d_ptr->type;
if (res) {
if (d_ptr->config && other.d_ptr->config) {
// catch the config content
res = d_ptr->config->operator==(*(other.d_ptr->config));
} else if (d_ptr->config || other.d_ptr->config) {
// one one has a config object, which could contain default values
res = qFuzzyCompare(amplitude(), other.amplitude()) &&
qFuzzyCompare(period(), other.period()) &&
qFuzzyCompare(overshoot(), other.overshoot());
}
}
return res;
}
示例11: switch
void GameScene::spawnEnemies(GraphicsEnemyObject::EnemyType type, bool inverted)
{
QEasingCurve curve;
switch (type)
{
case GraphicsEnemyObject::EnemyType::White:
case GraphicsEnemyObject::EnemyType::Green:
curve.setType(static_cast<QEasingCurve::Type>(qrand() % 41));
break;
case GraphicsEnemyObject::EnemyType::Boss:
curve.setCustomType(&CustomEasingCurve::simpleEasingCurve);
break;
}
auto enemy = new GraphicsEnemyObject(type, curve, inverted);
addItem(enemy);
connect(enemy, &GraphicsEnemyObject::cannonTriggered, this,
&GameScene::planeShot);
connect(enemy, &GraphicsEnemyObject::exploded, this,
&GameScene::planeExploded);
}
示例12: Py_INCREF
static PyObject *meth_QEasingCurve_setType(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QEasingCurve::Type a0;
QEasingCurve *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BE", &sipSelf, sipType_QEasingCurve, &sipCpp, sipType_QEasingCurve_Type, &a0))
{
sipCpp->setType(a0);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QEasingCurve, sipName_setType, doc_QEasingCurve_setType);
return NULL;
}
示例13: GenEasingCurveCode
QString GenEasingCurveCode(QEasingCurve easingCurve, QString strLabel)
{
QString str = strLabel + "\r\n";
for (int i = 0; i <= 1000; ++i)
{
str += QString("%1f, ").arg(easingCurve.valueForProgress((i * 1.0 / 1000)));
if (i % 10 == 0 && i != 0)
{
str += "\r\n";
}
}
str += "\r\n";
return str;
}
示例14: QCOMPARE
void tst_QEasingCurve::operators()
{
// operator=
QEasingCurve curve;
QEasingCurve curve2;
curve.setCustomType(&discreteEase);
curve2 = curve;
QCOMPARE(curve2.type(), QEasingCurve::Custom);
QCOMPARE(curve2.valueForProgress(0.0), 0.0);
QCOMPARE(curve2.valueForProgress(0.05), 0.0);
QCOMPARE(curve2.valueForProgress(0.15), 0.1);
QCOMPARE(curve2.valueForProgress(0.25), 0.2);
QCOMPARE(curve2.valueForProgress(0.35), 0.3);
QCOMPARE(curve2.valueForProgress(0.999999), 0.9);
// operator==
curve.setType(QEasingCurve::InBack);
curve2 = curve;
curve2.setOvershoot(qreal(1.70158));
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
curve.setOvershoot(3.0);
QVERIFY(curve2 != curve);
curve2.setOvershoot(3.0);
QVERIFY(curve2 == curve);
curve2.setType(QEasingCurve::Linear);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 != curve);
curve2.setType(QEasingCurve::InBack);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
QEasingCurve curve3;
QEasingCurve curve4;
curve4.setAmplitude(curve4.amplitude());
QEasingCurve curve5;
curve5.setAmplitude(0.12345);
QVERIFY(curve3 == curve4); // default value and not assigned
QVERIFY(curve3 != curve5); // unassinged and other value
QVERIFY(curve4 != curve5);
}
示例15: overshootChanged
void Window::overshootChanged(double value)
{
QEasingCurve curve = m_anim->easingCurve();
curve.setOvershoot(value);
m_anim->setEasingCurve(curve);
}