2018-10-24 15:18:33 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2019-06-18 15:12:21 +02:00
|
|
|
** Copyright (C) 2019 The Qt Company Ltd.
|
2018-10-24 15:18:33 +02:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
2019-06-18 15:12:21 +02:00
|
|
|
** This file is part of the Qt Design Tooling
|
2018-10-24 15:18:33 +02:00
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2019-06-18 15:12:21 +02:00
|
|
|
#include "curveeditor.h"
|
|
|
|
|
#include "curveeditormodel.h"
|
|
|
|
|
#include "detail/curveitem.h"
|
|
|
|
|
#include "detail/graphicsview.h"
|
|
|
|
|
#include "detail/treeview.h"
|
2018-10-24 15:18:33 +02:00
|
|
|
|
2019-06-28 10:45:28 +02:00
|
|
|
#include <QDoubleSpinBox>
|
2019-06-18 15:12:21 +02:00
|
|
|
#include <QHBoxLayout>
|
2019-06-28 10:45:28 +02:00
|
|
|
#include <QLabel>
|
2019-06-18 15:12:21 +02:00
|
|
|
#include <QSplitter>
|
2019-06-28 10:45:28 +02:00
|
|
|
#include <QVBoxLayout>
|
2018-10-24 15:18:33 +02:00
|
|
|
|
2019-06-18 15:12:21 +02:00
|
|
|
namespace DesignTools {
|
2018-10-24 15:18:33 +02:00
|
|
|
|
2019-06-18 15:12:21 +02:00
|
|
|
CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
, m_tree(new TreeView(model, this))
|
|
|
|
|
, m_view(new GraphicsView(model))
|
2018-10-24 15:18:33 +02:00
|
|
|
{
|
2019-06-18 15:12:21 +02:00
|
|
|
QSplitter *splitter = new QSplitter;
|
|
|
|
|
splitter->addWidget(m_tree);
|
|
|
|
|
splitter->addWidget(m_view);
|
|
|
|
|
splitter->setStretchFactor(1, 2);
|
|
|
|
|
|
2019-06-28 10:45:28 +02:00
|
|
|
QVBoxLayout *box = new QVBoxLayout;
|
|
|
|
|
box->addWidget(createToolBar());
|
2019-06-18 15:12:21 +02:00
|
|
|
box->addWidget(splitter);
|
|
|
|
|
setLayout(box);
|
|
|
|
|
|
|
|
|
|
connect(m_tree, &TreeView::curvesSelected, m_view, &GraphicsView::reset);
|
2018-10-24 15:18:33 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-18 15:12:21 +02:00
|
|
|
void CurveEditor::zoomX(double zoom)
|
2018-10-24 15:18:33 +02:00
|
|
|
{
|
2019-06-18 15:12:21 +02:00
|
|
|
m_view->setZoomX(zoom);
|
2018-10-24 15:18:33 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-18 15:12:21 +02:00
|
|
|
void CurveEditor::zoomY(double zoom)
|
2018-10-24 15:18:33 +02:00
|
|
|
{
|
2019-06-18 15:12:21 +02:00
|
|
|
m_view->setZoomY(zoom);
|
2018-10-24 15:18:33 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-28 10:45:28 +02:00
|
|
|
void CurveEditor::clearCanvas()
|
|
|
|
|
{
|
|
|
|
|
m_view->reset(m_tree->selection());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QToolBar *CurveEditor::createToolBar()
|
|
|
|
|
{
|
|
|
|
|
QToolBar *bar = new QToolBar;
|
|
|
|
|
bar->setFloatable(false);
|
|
|
|
|
|
|
|
|
|
QAction *tangentLinearAction = bar->addAction("Linear");
|
|
|
|
|
QAction *tangentStepAction = bar->addAction("Step");
|
|
|
|
|
QAction *tangentSplineAction = bar->addAction("Spline");
|
|
|
|
|
QAction *tangentDefaultAction = bar->addAction("Set Default");
|
|
|
|
|
|
|
|
|
|
auto setLinearInterpolation = [this]() {
|
|
|
|
|
m_view->setInterpolation(Keyframe::Interpolation::Linear);
|
|
|
|
|
};
|
|
|
|
|
auto setStepInterpolation = [this]() {
|
|
|
|
|
m_view->setInterpolation(Keyframe::Interpolation::Step);
|
|
|
|
|
};
|
|
|
|
|
auto setSplineInterpolation = [this]() {
|
|
|
|
|
m_view->setInterpolation(Keyframe::Interpolation::Bezier);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
connect(tangentLinearAction, &QAction::triggered, setLinearInterpolation);
|
|
|
|
|
connect(tangentStepAction, &QAction::triggered, setStepInterpolation);
|
|
|
|
|
connect(tangentSplineAction, &QAction::triggered, setSplineInterpolation);
|
|
|
|
|
|
|
|
|
|
Q_UNUSED(tangentLinearAction);
|
|
|
|
|
Q_UNUSED(tangentSplineAction);
|
|
|
|
|
Q_UNUSED(tangentStepAction);
|
|
|
|
|
Q_UNUSED(tangentDefaultAction);
|
|
|
|
|
|
|
|
|
|
auto *valueBox = new QHBoxLayout;
|
|
|
|
|
valueBox->addWidget(new QLabel(tr("Value")));
|
|
|
|
|
valueBox->addWidget(new QDoubleSpinBox);
|
|
|
|
|
auto *valueWidget = new QWidget;
|
|
|
|
|
valueWidget->setLayout(valueBox);
|
|
|
|
|
bar->addWidget(valueWidget);
|
|
|
|
|
|
|
|
|
|
auto *durationBox = new QHBoxLayout;
|
|
|
|
|
durationBox->addWidget(new QLabel(tr("Duration")));
|
|
|
|
|
durationBox->addWidget(new QSpinBox);
|
|
|
|
|
auto *durationWidget = new QWidget;
|
|
|
|
|
durationWidget->setLayout(durationBox);
|
|
|
|
|
bar->addWidget(durationWidget);
|
|
|
|
|
|
|
|
|
|
auto *positionBox = new QHBoxLayout;
|
|
|
|
|
positionBox->addWidget(new QLabel(tr("Current Frame")));
|
|
|
|
|
positionBox->addWidget(new QSpinBox);
|
|
|
|
|
auto *positionWidget = new QWidget;
|
|
|
|
|
positionWidget->setLayout(positionBox);
|
|
|
|
|
bar->addWidget(positionWidget);
|
|
|
|
|
|
|
|
|
|
return bar;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 15:12:21 +02:00
|
|
|
} // End namespace DesignTools.
|