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"
|
|
|
|
|
|
|
|
MotionClipWidget::MotionClipWidget(const SkeletonDocument *document, QWidget *parent) :
|
|
|
|
QFrame(parent),
|
|
|
|
m_document(document)
|
|
|
|
{
|
|
|
|
setObjectName("MotionClipFrame");
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize MotionClipWidget::preferredSize()
|
|
|
|
{
|
|
|
|
int preferredWidth = 0;
|
|
|
|
switch (m_clip.clipType) {
|
|
|
|
case SkeletonMotionClipType::Motion:
|
|
|
|
preferredWidth = Theme::motionPreviewImageSize;
|
|
|
|
break;
|
|
|
|
case SkeletonMotionClipType::Pose:
|
|
|
|
preferredWidth = Theme::posePreviewImageSize;
|
|
|
|
break;
|
|
|
|
case SkeletonMotionClipType::Interpolation:
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MotionClipWidget::setClip(SkeletonMotionClip clip)
|
|
|
|
{
|
|
|
|
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) {
|
|
|
|
case SkeletonMotionClipType::Motion:
|
|
|
|
{
|
|
|
|
MotionWidget *motionWidget = new MotionWidget(m_document, m_clip.linkToId);
|
|
|
|
motionWidget->reload();
|
|
|
|
layout->addWidget(motionWidget);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SkeletonMotionClipType::Pose:
|
|
|
|
{
|
|
|
|
PoseWidget *poseWidget = new PoseWidget(m_document, m_clip.linkToId);
|
|
|
|
poseWidget->reload();
|
|
|
|
layout->addWidget(poseWidget);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SkeletonMotionClipType::Interpolation:
|
|
|
|
{
|
|
|
|
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;}");
|
|
|
|
}
|
|
|
|
|