Add background blur adjustment slider to pose editor

master
Jeremy Hu 2019-06-16 18:15:03 +09:30
parent 17f5293a4c
commit bc565923aa
3 changed files with 44 additions and 12 deletions

View File

@ -24,8 +24,9 @@ MotionEditWidget::MotionEditWidget(const Document *document, QWidget *parent) :
connect(m_timelineWidget, &MotionTimelineWidget::clipsChanged, this, &MotionEditWidget::generatePreviews); connect(m_timelineWidget, &MotionTimelineWidget::clipsChanged, this, &MotionEditWidget::generatePreviews);
m_previewWidget = new ModelWidget(this); m_previewWidget = new ModelWidget(this);
m_previewWidget->setMinimumSize(128, 128); m_previewWidget->setFixedSize(384, 384);
m_previewWidget->resize(384, 384); m_previewWidget->enableMove(true);
m_previewWidget->enableZoom(false);
m_previewWidget->move(-64, 0); m_previewWidget->move(-64, 0);
connect(m_clipPlayer, &AnimationClipPlayer::frameReadyToShow, this, [=]() { connect(m_clipPlayer, &AnimationClipPlayer::frameReadyToShow, this, [=]() {

View File

@ -8,6 +8,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QSpinBox> #include <QSpinBox>
#include <QSlider>
#include "theme.h" #include "theme.h"
#include "poseeditwidget.h" #include "poseeditwidget.h"
#include "floatnumberwidget.h" #include "floatnumberwidget.h"
@ -18,6 +19,8 @@
#include "shortcuts.h" #include "shortcuts.h"
#include "imageforever.h" #include "imageforever.h"
float PoseEditWidget::m_defaultBlur = 0.5;
PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) : PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) :
QDialog(parent), QDialog(parent),
m_document(document), m_document(document),
@ -38,7 +41,7 @@ PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) :
SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(m_poseDocument); SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(m_poseDocument);
graphicsWidget->setNodePositionModifyOnly(true); graphicsWidget->setNodePositionModifyOnly(true);
graphicsWidget->setBackgroundBlur(1.0); graphicsWidget->setBackgroundBlur(m_defaultBlur);
m_poseGraphicsWidget = graphicsWidget; m_poseGraphicsWidget = graphicsWidget;
initShortCuts(this, graphicsWidget); initShortCuts(this, graphicsWidget);
@ -52,14 +55,11 @@ PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) :
containerWidget->setLayout(containerLayout); containerWidget->setLayout(containerLayout);
containerWidget->setMinimumSize(400, 400); containerWidget->setMinimumSize(400, 400);
m_previewWidget = new ModelWidget(containerWidget); m_previewWidget = new ModelWidget(this);
m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents); m_previewWidget->setFixedSize(384, 384);
m_previewWidget->setMinimumSize(DocumentWindow::m_modelRenderWidgetInitialSize, DocumentWindow::m_modelRenderWidgetInitialSize); m_previewWidget->enableMove(true);
m_previewWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_previewWidget->enableZoom(false);
m_previewWidget->move(DocumentWindow::m_modelRenderWidgetInitialX, DocumentWindow::m_modelRenderWidgetInitialY); m_previewWidget->move(-64, 0);
m_poseGraphicsWidget->setModelWidget(m_previewWidget);
containerWidget->setModelWidget(m_previewWidget);
connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged, connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged,
graphicsWidget, &SkeletonGraphicsWidget::canvasResized); graphicsWidget, &SkeletonGraphicsWidget::canvasResized);
@ -85,9 +85,39 @@ PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) :
emit parametersAdjusted(); emit parametersAdjusted();
}); });
QSlider *opacitySlider = new QSlider(Qt::Horizontal);
opacitySlider->setFixedWidth(100);
opacitySlider->setMaximum(10);
opacitySlider->setMinimum(0);
opacitySlider->setValue(m_defaultBlur * 10);
connect(opacitySlider, &QSlider::valueChanged, this, [=](int value) {
graphicsWidget->setBackgroundBlur((float)value / 10);
});
QHBoxLayout *sliderLayout = new QHBoxLayout;
sliderLayout->addStretch();
sliderLayout->addSpacing(50);
sliderLayout->addWidget(new QLabel(tr("Dark")));
sliderLayout->addWidget(opacitySlider);
sliderLayout->addWidget(new QLabel(tr("Bright")));
sliderLayout->addSpacing(50);
sliderLayout->addStretch();
QVBoxLayout *previewLayout = new QVBoxLayout;
previewLayout->addStretch();
previewLayout->addLayout(sliderLayout);
previewLayout->addSpacing(20);
QHBoxLayout *paramtersLayout = new QHBoxLayout; QHBoxLayout *paramtersLayout = new QHBoxLayout;
paramtersLayout->addWidget(containerWidget); paramtersLayout->addWidget(containerWidget);
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addLayout(previewLayout);
topLayout->addWidget(Theme::createVerticalLineWidget());
topLayout->addLayout(paramtersLayout);
topLayout->setStretch(2, 1);
m_nameEdit = new QLineEdit; m_nameEdit = new QLineEdit;
m_nameEdit->setFixedWidth(200); m_nameEdit->setFixedWidth(200);
connect(m_nameEdit, &QLineEdit::textChanged, this, [=]() { connect(m_nameEdit, &QLineEdit::textChanged, this, [=]() {
@ -180,7 +210,7 @@ PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) :
baseInfoLayout->addWidget(saveButton); baseInfoLayout->addWidget(saveButton);
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(paramtersLayout); mainLayout->addLayout(topLayout);
mainLayout->addWidget(Theme::createHorizontalLineWidget()); mainLayout->addWidget(Theme::createHorizontalLineWidget());
mainLayout->addLayout(timelineLayout); mainLayout->addLayout(timelineLayout);
mainLayout->addLayout(baseInfoLayout); mainLayout->addLayout(baseInfoLayout);

View File

@ -76,6 +76,7 @@ private:
SkeletonGraphicsWidget *m_poseGraphicsWidget = nullptr; SkeletonGraphicsWidget *m_poseGraphicsWidget = nullptr;
QPushButton *m_framesSettingButton = nullptr; QPushButton *m_framesSettingButton = nullptr;
QSlider *m_currentFrameSlider = nullptr; QSlider *m_currentFrameSlider = nullptr;
static float m_defaultBlur;
}; };
#endif #endif