2018-10-23 14:57:47 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include "motionclipwidget.h"
|
|
|
|
#include "posewidget.h"
|
|
|
|
#include "motionwidget.h"
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
MotionClipWidget::MotionClipWidget(const Document *document, QWidget *parent) :
|
2018-10-23 14:57:47 +00:00
|
|
|
QFrame(parent),
|
|
|
|
m_document(document)
|
|
|
|
{
|
|
|
|
setObjectName("MotionClipFrame");
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize MotionClipWidget::preferredSize()
|
|
|
|
{
|
|
|
|
int preferredWidth = 0;
|
|
|
|
switch (m_clip.clipType) {
|
2018-10-25 00:19:38 +00:00
|
|
|
case MotionClipType::Motion:
|
2018-10-23 14:57:47 +00:00
|
|
|
preferredWidth = Theme::motionPreviewImageSize;
|
|
|
|
break;
|
2018-10-25 00:19:38 +00:00
|
|
|
case MotionClipType::Pose:
|
2018-10-23 14:57:47 +00:00
|
|
|
preferredWidth = Theme::posePreviewImageSize;
|
|
|
|
break;
|
2019-09-21 14:30:27 +00:00
|
|
|
case MotionClipType::ProceduralAnimation:
|
|
|
|
{
|
|
|
|
QPushButton testButton(ProceduralAnimationToDispName(m_clip.proceduralAnimation));
|
|
|
|
preferredWidth = testButton.sizeHint().width();
|
|
|
|
}
|
|
|
|
break;
|
2018-10-25 00:19:38 +00:00
|
|
|
case MotionClipType::Interpolation:
|
2018-10-23 14:57:47 +00:00
|
|
|
preferredWidth = Theme::normalButtonSize;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QSize(preferredWidth, maxSize().height());
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize MotionClipWidget::maxSize()
|
|
|
|
{
|
|
|
|
auto maxWidth = std::max(Theme::posePreviewImageSize, Theme::motionPreviewImageSize);
|
|
|
|
auto maxHeight = std::max(PoseWidget::preferredHeight(), MotionWidget::preferredHeight());
|
|
|
|
return QSize(maxWidth, maxHeight);
|
|
|
|
}
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
void MotionClipWidget::setClip(MotionClip clip)
|
2018-10-23 14:57:47 +00:00
|
|
|
{
|
|
|
|
m_clip = clip;
|
|
|
|
reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MotionClipWidget::reload()
|
|
|
|
{
|
2018-10-23 22:51:33 +00:00
|
|
|
if (nullptr != m_reloadToWidget)
|
|
|
|
m_reloadToWidget->deleteLater();
|
2018-10-23 14:57:47 +00:00
|
|
|
m_reloadToWidget = new QWidget(this);
|
|
|
|
m_reloadToWidget->setContentsMargins(1, 0, 0, 0);
|
|
|
|
m_reloadToWidget->setFixedSize(preferredSize());
|
|
|
|
m_reloadToWidget->show();
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
layout->setSpacing(0);
|
|
|
|
layout->setSizeConstraint(QLayout::SetMinimumSize);
|
|
|
|
layout->addStretch();
|
|
|
|
|
|
|
|
switch (m_clip.clipType) {
|
2018-10-25 00:19:38 +00:00
|
|
|
case MotionClipType::Motion:
|
2018-10-23 14:57:47 +00:00
|
|
|
{
|
|
|
|
MotionWidget *motionWidget = new MotionWidget(m_document, m_clip.linkToId);
|
|
|
|
motionWidget->reload();
|
|
|
|
layout->addWidget(motionWidget);
|
|
|
|
}
|
|
|
|
break;
|
2018-10-25 00:19:38 +00:00
|
|
|
case MotionClipType::Pose:
|
2018-10-23 14:57:47 +00:00
|
|
|
{
|
|
|
|
PoseWidget *poseWidget = new PoseWidget(m_document, m_clip.linkToId);
|
|
|
|
poseWidget->reload();
|
|
|
|
layout->addWidget(poseWidget);
|
|
|
|
}
|
|
|
|
break;
|
2019-09-21 14:30:27 +00:00
|
|
|
case MotionClipType::ProceduralAnimation:
|
|
|
|
{
|
|
|
|
QPushButton *proceduralAnimationButton = new QPushButton(ProceduralAnimationToDispName(m_clip.proceduralAnimation));
|
|
|
|
proceduralAnimationButton->setFocusPolicy(Qt::NoFocus);
|
|
|
|
layout->addWidget(proceduralAnimationButton);
|
|
|
|
}
|
|
|
|
break;
|
2018-10-25 00:19:38 +00:00
|
|
|
case MotionClipType::Interpolation:
|
2018-10-23 14:57:47 +00:00
|
|
|
{
|
|
|
|
QHBoxLayout *interpolationButtonLayout = new QHBoxLayout;
|
|
|
|
QPushButton *interpolationButton = new QPushButton(QChar(fa::arrowsh));
|
|
|
|
Theme::initAwesomeButton(interpolationButton);
|
|
|
|
interpolationButtonLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
interpolationButtonLayout->setSpacing(0);
|
|
|
|
interpolationButtonLayout->addStretch();
|
|
|
|
interpolationButtonLayout->addWidget(interpolationButton);
|
|
|
|
interpolationButtonLayout->addStretch();
|
|
|
|
|
|
|
|
layout->addLayout(interpolationButtonLayout);
|
|
|
|
|
|
|
|
connect(interpolationButton, &QPushButton::clicked, this, &MotionClipWidget::modifyInterpolation);
|
|
|
|
|
|
|
|
QHBoxLayout *interpolationDurationLayout = new QHBoxLayout;
|
|
|
|
QLabel *durationLabel = new QLabel;
|
|
|
|
durationLabel->setText(QString::number(m_clip.duration) + "s");
|
|
|
|
interpolationDurationLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
interpolationDurationLayout->setSpacing(0);
|
|
|
|
interpolationDurationLayout->addStretch();
|
|
|
|
interpolationDurationLayout->addWidget(durationLabel);
|
|
|
|
interpolationDurationLayout->addStretch();
|
|
|
|
|
|
|
|
layout->addLayout(interpolationDurationLayout);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
layout->addStretch();
|
|
|
|
m_reloadToWidget->setLayout(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MotionClipWidget::updateCheckedState(bool checked)
|
|
|
|
{
|
|
|
|
if (checked)
|
|
|
|
setStyleSheet("#MotionClipFrame {border: 1px solid " + Theme::red.name() + ";}");
|
|
|
|
else
|
|
|
|
setStyleSheet("#MotionClipFrame {border: 1px solid transparent;}");
|
|
|
|
}
|
|
|
|
|