change: change code style to Linux style except indent.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -25,101 +25,108 @@
|
||||
#include "widget/keyframeview/keyframeview.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class CurveView : public KeyframeView
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class CurveView : public KeyframeView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CurveView(QWidget* parent = nullptr);
|
||||
CurveView(QWidget *parent = nullptr);
|
||||
|
||||
void ConnectInput(const NodeKeyframeTrackReference &ref);
|
||||
void ConnectInput(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void DisconnectInput(const NodeKeyframeTrackReference &ref);
|
||||
void DisconnectInput(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void SelectKeyframesOfInput(const NodeKeyframeTrackReference &ref);
|
||||
void SelectKeyframesOfInput(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void SetKeyframeTrackColor(const NodeKeyframeTrackReference& ref, const QColor& color);
|
||||
void SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref,
|
||||
const QColor &color);
|
||||
|
||||
const QHash<NodeKeyframeTrackReference, KeyframeViewInputConnection*> &GetConnections() const
|
||||
{
|
||||
return track_connections_;
|
||||
}
|
||||
const QHash<NodeKeyframeTrackReference, KeyframeViewInputConnection *> &
|
||||
GetConnections() const
|
||||
{
|
||||
return track_connections_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void ZoomToFit();
|
||||
void ZoomToFit();
|
||||
|
||||
void ZoomToFitSelected();
|
||||
void ZoomToFitSelected();
|
||||
|
||||
void ResetZoom();
|
||||
void ResetZoom();
|
||||
|
||||
protected:
|
||||
virtual void drawBackground(QPainter* painter, const QRectF& rect) override;
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
|
||||
virtual void drawBackground(QPainter *painter, const QRectF &rect) override;
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
|
||||
|
||||
virtual void ContextMenuEvent(Menu &m) override;
|
||||
virtual void ContextMenuEvent(Menu &m) override;
|
||||
|
||||
virtual void SceneRectUpdateEvent(QRectF &r) override;
|
||||
virtual void SceneRectUpdateEvent(QRectF &r) override;
|
||||
|
||||
virtual qreal GetKeyframeSceneY(KeyframeViewInputConnection *track, NodeKeyframe *key) override;
|
||||
virtual qreal GetKeyframeSceneY(KeyframeViewInputConnection *track,
|
||||
NodeKeyframe *key) override;
|
||||
|
||||
virtual void DrawKeyframe(QPainter *painter, NodeKeyframe *key, KeyframeViewInputConnection *track, const QRectF &key_rect) override;
|
||||
virtual void DrawKeyframe(QPainter *painter, NodeKeyframe *key,
|
||||
KeyframeViewInputConnection *track,
|
||||
const QRectF &key_rect) override;
|
||||
|
||||
virtual bool FirstChanceMousePress(QMouseEvent *event) override;
|
||||
virtual void FirstChanceMouseMove(QMouseEvent *event) override;
|
||||
virtual void FirstChanceMouseRelease(QMouseEvent *event) override;
|
||||
virtual bool FirstChanceMousePress(QMouseEvent *event) override;
|
||||
virtual void FirstChanceMouseMove(QMouseEvent *event) override;
|
||||
virtual void FirstChanceMouseRelease(QMouseEvent *event) override;
|
||||
|
||||
virtual void KeyframeDragStart(QMouseEvent *event) override;
|
||||
virtual void KeyframeDragMove(QMouseEvent *event, QString &tip) override;
|
||||
virtual void KeyframeDragRelease(QMouseEvent *event, MultiUndoCommand *command) override;
|
||||
virtual void KeyframeDragStart(QMouseEvent *event) override;
|
||||
virtual void KeyframeDragMove(QMouseEvent *event, QString &tip) override;
|
||||
virtual void KeyframeDragRelease(QMouseEvent *event,
|
||||
MultiUndoCommand *command) override;
|
||||
|
||||
private:
|
||||
void ZoomToFitInternal(bool selected_only);
|
||||
void ZoomToFitInternal(bool selected_only);
|
||||
|
||||
qreal GetItemYFromKeyframeValue(NodeKeyframe* key);
|
||||
qreal GetUnscaledItemYFromKeyframeValue(NodeKeyframe* key);
|
||||
qreal GetItemYFromKeyframeValue(NodeKeyframe *key);
|
||||
qreal GetUnscaledItemYFromKeyframeValue(NodeKeyframe *key);
|
||||
|
||||
QPointF ScalePoint(const QPointF& point);
|
||||
QPointF ScalePoint(const QPointF &point);
|
||||
|
||||
static FloatSlider::DisplayType GetFloatDisplayTypeFromKeyframe(NodeKeyframe *key);
|
||||
static FloatSlider::DisplayType
|
||||
GetFloatDisplayTypeFromKeyframe(NodeKeyframe *key);
|
||||
|
||||
static double GetOffsetFromKeyframe(NodeKeyframe *key);
|
||||
static double GetOffsetFromKeyframe(NodeKeyframe *key);
|
||||
|
||||
void AdjustLines();
|
||||
void AdjustLines();
|
||||
|
||||
QPointF GetKeyframePosition(NodeKeyframe *key);
|
||||
QPointF GetKeyframePosition(NodeKeyframe *key);
|
||||
|
||||
static QPointF GenerateBezierControlPosition(const NodeKeyframe::BezierType mode,
|
||||
const QPointF& start_point,
|
||||
const QPointF& scaled_cursor_diff);
|
||||
static QPointF
|
||||
GenerateBezierControlPosition(const NodeKeyframe::BezierType mode,
|
||||
const QPointF &start_point,
|
||||
const QPointF &scaled_cursor_diff);
|
||||
|
||||
QPointF GetScaledCursorPos(const QPointF &cursor_pos);
|
||||
QPointF GetScaledCursorPos(const QPointF &cursor_pos);
|
||||
|
||||
QHash<NodeKeyframeTrackReference, QColor> keyframe_colors_;
|
||||
QHash<NodeKeyframeTrackReference, KeyframeViewInputConnection*> track_connections_;
|
||||
QHash<NodeKeyframeTrackReference, QColor> keyframe_colors_;
|
||||
QHash<NodeKeyframeTrackReference, KeyframeViewInputConnection *>
|
||||
track_connections_;
|
||||
|
||||
int text_padding_;
|
||||
int text_padding_;
|
||||
|
||||
int minimum_grid_space_;
|
||||
int minimum_grid_space_;
|
||||
|
||||
QVector<NodeKeyframeTrackReference> connected_inputs_;
|
||||
QVector<NodeKeyframeTrackReference> connected_inputs_;
|
||||
|
||||
struct BezierPoint
|
||||
{
|
||||
QRectF rect;
|
||||
NodeKeyframe *keyframe;
|
||||
NodeKeyframe::BezierType type;
|
||||
};
|
||||
struct BezierPoint {
|
||||
QRectF rect;
|
||||
NodeKeyframe *keyframe;
|
||||
NodeKeyframe::BezierType type;
|
||||
};
|
||||
|
||||
QVector<BezierPoint> bezier_pts_;
|
||||
const BezierPoint *dragging_bezier_pt_;
|
||||
QVector<BezierPoint> bezier_pts_;
|
||||
const BezierPoint *dragging_bezier_pt_;
|
||||
|
||||
QPointF dragging_bezier_point_start_;
|
||||
QPointF dragging_bezier_point_opposing_start_;
|
||||
QPointF drag_start_;
|
||||
|
||||
QVector<QVariant> drag_keyframe_values_;
|
||||
QPointF dragging_bezier_point_start_;
|
||||
QPointF dragging_bezier_point_opposing_start_;
|
||||
QPointF drag_start_;
|
||||
|
||||
QVector<QVariant> drag_keyframe_values_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -32,346 +32,365 @@
|
||||
#include "widget/keyframeview/keyframeviewundo.h"
|
||||
#include "widget/timeruler/timeruler.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
#define super TimeBasedWidget
|
||||
|
||||
CurveWidget::CurveWidget(QWidget *parent) :
|
||||
super(parent)
|
||||
CurveWidget::CurveWidget(QWidget *parent)
|
||||
: super(parent)
|
||||
{
|
||||
QHBoxLayout* outer_layout = new QHBoxLayout(this);
|
||||
QHBoxLayout *outer_layout = new QHBoxLayout(this);
|
||||
|
||||
QSplitter* splitter = new QSplitter();
|
||||
outer_layout->addWidget(splitter);
|
||||
QSplitter *splitter = new QSplitter();
|
||||
outer_layout->addWidget(splitter);
|
||||
|
||||
tree_view_ = new NodeTreeView();
|
||||
tree_view_->SetOnlyShowKeyframable(true);
|
||||
tree_view_->SetShowKeyframeTracksAsRows(true);
|
||||
connect(tree_view_, &NodeTreeView::InputSelectionChanged, this, &CurveWidget::InputSelectionChanged);
|
||||
splitter->addWidget(tree_view_);
|
||||
tree_view_ = new NodeTreeView();
|
||||
tree_view_->SetOnlyShowKeyframable(true);
|
||||
tree_view_->SetShowKeyframeTracksAsRows(true);
|
||||
connect(tree_view_, &NodeTreeView::InputSelectionChanged, this,
|
||||
&CurveWidget::InputSelectionChanged);
|
||||
splitter->addWidget(tree_view_);
|
||||
|
||||
QWidget* workarea = new QWidget();
|
||||
QVBoxLayout* layout = new QVBoxLayout(workarea);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
splitter->addWidget(workarea);
|
||||
QWidget *workarea = new QWidget();
|
||||
QVBoxLayout *layout = new QVBoxLayout(workarea);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
splitter->addWidget(workarea);
|
||||
|
||||
QHBoxLayout* top_controls = new QHBoxLayout();
|
||||
QHBoxLayout *top_controls = new QHBoxLayout();
|
||||
|
||||
key_control_ = new NodeParamViewKeyframeControl(false);
|
||||
top_controls->addWidget(key_control_);
|
||||
key_control_ = new NodeParamViewKeyframeControl(false);
|
||||
top_controls->addWidget(key_control_);
|
||||
|
||||
top_controls->addStretch();
|
||||
top_controls->addStretch();
|
||||
|
||||
linear_button_ = new QPushButton(tr("Linear"));
|
||||
linear_button_->setCheckable(true);
|
||||
linear_button_->setEnabled(false);
|
||||
top_controls->addWidget(linear_button_);
|
||||
connect(linear_button_, &QPushButton::clicked, this, &CurveWidget::KeyframeTypeButtonTriggered);
|
||||
linear_button_ = new QPushButton(tr("Linear"));
|
||||
linear_button_->setCheckable(true);
|
||||
linear_button_->setEnabled(false);
|
||||
top_controls->addWidget(linear_button_);
|
||||
connect(linear_button_, &QPushButton::clicked, this,
|
||||
&CurveWidget::KeyframeTypeButtonTriggered);
|
||||
|
||||
bezier_button_ = new QPushButton(tr("Bezier"));
|
||||
bezier_button_->setCheckable(true);
|
||||
bezier_button_->setEnabled(false);
|
||||
top_controls->addWidget(bezier_button_);
|
||||
connect(bezier_button_, &QPushButton::clicked, this, &CurveWidget::KeyframeTypeButtonTriggered);
|
||||
bezier_button_ = new QPushButton(tr("Bezier"));
|
||||
bezier_button_->setCheckable(true);
|
||||
bezier_button_->setEnabled(false);
|
||||
top_controls->addWidget(bezier_button_);
|
||||
connect(bezier_button_, &QPushButton::clicked, this,
|
||||
&CurveWidget::KeyframeTypeButtonTriggered);
|
||||
|
||||
hold_button_ = new QPushButton(tr("Hold"));
|
||||
hold_button_->setCheckable(true);
|
||||
hold_button_->setEnabled(false);
|
||||
top_controls->addWidget(hold_button_);
|
||||
connect(hold_button_, &QPushButton::clicked, this, &CurveWidget::KeyframeTypeButtonTriggered);
|
||||
hold_button_ = new QPushButton(tr("Hold"));
|
||||
hold_button_->setCheckable(true);
|
||||
hold_button_->setEnabled(false);
|
||||
top_controls->addWidget(hold_button_);
|
||||
connect(hold_button_, &QPushButton::clicked, this,
|
||||
&CurveWidget::KeyframeTypeButtonTriggered);
|
||||
|
||||
layout->addLayout(top_controls);
|
||||
layout->addLayout(top_controls);
|
||||
|
||||
// We use a separate layout for the ruler+view combination so that there's no spacing between them
|
||||
QVBoxLayout* ruler_view_layout = new QVBoxLayout();
|
||||
ruler_view_layout->setContentsMargins(0, 0, 0, 0);
|
||||
ruler_view_layout->setSpacing(0);
|
||||
// We use a separate layout for the ruler+view combination so that there's no spacing between them
|
||||
QVBoxLayout *ruler_view_layout = new QVBoxLayout();
|
||||
ruler_view_layout->setContentsMargins(0, 0, 0, 0);
|
||||
ruler_view_layout->setSpacing(0);
|
||||
|
||||
ruler_view_layout->addWidget(ruler());
|
||||
ruler_view_layout->addWidget(ruler());
|
||||
|
||||
view_ = new CurveView();
|
||||
ConnectTimelineView(view_);
|
||||
view_->SetSnapService(this);
|
||||
ruler_view_layout->addWidget(view_);
|
||||
view_ = new CurveView();
|
||||
ConnectTimelineView(view_);
|
||||
view_->SetSnapService(this);
|
||||
ruler_view_layout->addWidget(view_);
|
||||
|
||||
layout->addLayout(ruler_view_layout);
|
||||
layout->addLayout(ruler_view_layout);
|
||||
|
||||
// Connect ruler and view together
|
||||
connect(view_, &CurveView::SelectionChanged, this, &CurveWidget::SelectionChanged);
|
||||
connect(view_, &CurveView::Dragged, this, &CurveWidget::KeyframeViewDragged);
|
||||
connect(view_, &CurveView::Released, this, &CurveWidget::KeyframeViewReleased);
|
||||
// Connect ruler and view together
|
||||
connect(view_, &CurveView::SelectionChanged, this,
|
||||
&CurveWidget::SelectionChanged);
|
||||
connect(view_, &CurveView::Dragged, this,
|
||||
&CurveWidget::KeyframeViewDragged);
|
||||
connect(view_, &CurveView::Released, this,
|
||||
&CurveWidget::KeyframeViewReleased);
|
||||
|
||||
// TimeBasedWidget's scrollbar has extra functionality that we can take advantage of
|
||||
view_->setHorizontalScrollBar(scrollbar());
|
||||
// TimeBasedWidget's scrollbar has extra functionality that we can take advantage of
|
||||
view_->setHorizontalScrollBar(scrollbar());
|
||||
|
||||
// Disable collapsing the main curve view (but allow collapsing the tree)
|
||||
splitter->setCollapsible(1, false);
|
||||
// Disable collapsing the main curve view (but allow collapsing the tree)
|
||||
splitter->setCollapsible(1, false);
|
||||
|
||||
SetScale(120.0);
|
||||
SetScale(120.0);
|
||||
}
|
||||
|
||||
const double &CurveWidget::GetVerticalScale()
|
||||
{
|
||||
return view_->GetYScale();
|
||||
return view_->GetYScale();
|
||||
}
|
||||
|
||||
void CurveWidget::SetVerticalScale(const double &vscale)
|
||||
{
|
||||
view_->SetYScale(vscale);
|
||||
view_->SetYScale(vscale);
|
||||
}
|
||||
|
||||
void CurveWidget::DeleteSelected()
|
||||
{
|
||||
view_->DeleteSelected();
|
||||
view_->DeleteSelected();
|
||||
}
|
||||
|
||||
Node *CurveWidget::GetSelectedNodeWithID(const QString &id)
|
||||
{
|
||||
for (auto it=view_->GetConnections().cbegin(); it!=view_->GetConnections().cend(); it++) {
|
||||
Node *n = it.key().input().node();
|
||||
if (n->id() == id) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
for (auto it = view_->GetConnections().cbegin();
|
||||
it != view_->GetConnections().cend(); it++) {
|
||||
Node *n = it.key().input().node();
|
||||
if (n->id() == id) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CurveWidget::CopySelected(bool cut)
|
||||
{
|
||||
if (super::CopySelected(cut)) {
|
||||
return true;
|
||||
}
|
||||
if (super::CopySelected(cut)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return view_->CopySelected(cut);
|
||||
return view_->CopySelected(cut);
|
||||
}
|
||||
|
||||
bool CurveWidget::Paste()
|
||||
{
|
||||
if (super::Paste()) {
|
||||
return true;
|
||||
}
|
||||
if (super::Paste()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return view_->Paste(std::bind(&CurveWidget::GetSelectedNodeWithID, this, std::placeholders::_1));
|
||||
return view_->Paste(std::bind(&CurveWidget::GetSelectedNodeWithID, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
void CurveWidget::SetNodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
tree_view_->SetNodes(nodes);
|
||||
tree_view_->SetNodes(nodes);
|
||||
|
||||
// Save new node list
|
||||
nodes_ = nodes;
|
||||
// Save new node list
|
||||
nodes_ = nodes;
|
||||
|
||||
// Generate colors
|
||||
foreach (Node *node, nodes_) {
|
||||
foreach (const QString& input, node->inputs()) {
|
||||
if (node->IsInputKeyframable(input) && !node->IsInputHidden(input)) {
|
||||
int arr_sz = node->InputArraySize(input);
|
||||
for (int i=-1; i<arr_sz; i++) {
|
||||
// Generate a random color for this input
|
||||
const QVector<NodeKeyframeTrack>& tracks = node->GetKeyframeTracks(input, i);
|
||||
// Generate colors
|
||||
foreach (Node *node, nodes_) {
|
||||
foreach (const QString &input, node->inputs()) {
|
||||
if (node->IsInputKeyframable(input) &&
|
||||
!node->IsInputHidden(input)) {
|
||||
int arr_sz = node->InputArraySize(input);
|
||||
for (int i = -1; i < arr_sz; i++) {
|
||||
// Generate a random color for this input
|
||||
const QVector<NodeKeyframeTrack> &tracks =
|
||||
node->GetKeyframeTracks(input, i);
|
||||
|
||||
for (int j=0; j<tracks.size(); j++) {
|
||||
NodeKeyframeTrackReference ref(NodeInput(node, input, i), j);
|
||||
for (int j = 0; j < tracks.size(); j++) {
|
||||
NodeKeyframeTrackReference ref(
|
||||
NodeInput(node, input, i), j);
|
||||
|
||||
if (!keyframe_colors_.contains(ref)) {
|
||||
QColor c = QColor::fromHsl(std::rand()%360, 255, 160);
|
||||
if (!keyframe_colors_.contains(ref)) {
|
||||
QColor c =
|
||||
QColor::fromHsl(std::rand() % 360, 255, 160);
|
||||
|
||||
keyframe_colors_.insert(ref, c);
|
||||
tree_view_->SetKeyframeTrackColor(ref, c);
|
||||
view_->SetKeyframeTrackColor(ref, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
keyframe_colors_.insert(ref, c);
|
||||
tree_view_->SetKeyframeTrackColor(ref, c);
|
||||
view_->SetKeyframeTrackColor(ref, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::TimebaseChangedEvent(const rational &timebase)
|
||||
{
|
||||
super::TimebaseChangedEvent(timebase);
|
||||
super::TimebaseChangedEvent(timebase);
|
||||
|
||||
view_->SetTimebase(timebase);
|
||||
view_->SetTimebase(timebase);
|
||||
}
|
||||
|
||||
void CurveWidget::ScaleChangedEvent(const double &scale)
|
||||
{
|
||||
super::ScaleChangedEvent(scale);
|
||||
super::ScaleChangedEvent(scale);
|
||||
|
||||
view_->SetScale(scale);
|
||||
view_->SetScale(scale);
|
||||
}
|
||||
|
||||
void CurveWidget::TimeTargetChangedEvent(ViewerOutput *target)
|
||||
{
|
||||
TimeTargetObject::TimeTargetChangedEvent(target);
|
||||
TimeTargetObject::TimeTargetChangedEvent(target);
|
||||
|
||||
key_control_->SetTimeTarget(target);
|
||||
key_control_->SetTimeTarget(target);
|
||||
|
||||
view_->SetTimeTarget(target);
|
||||
view_->SetTimeTarget(target);
|
||||
}
|
||||
|
||||
void CurveWidget::ConnectedNodeChangeEvent(ViewerOutput *n)
|
||||
{
|
||||
super::ConnectedNodeChangeEvent(n);
|
||||
super::ConnectedNodeChangeEvent(n);
|
||||
|
||||
key_control_->SetTimeTarget(n);
|
||||
key_control_->SetTimeTarget(n);
|
||||
|
||||
SetTimeTarget(n);
|
||||
SetTimeTarget(n);
|
||||
}
|
||||
|
||||
void CurveWidget::SetKeyframeButtonEnabled(bool enable)
|
||||
{
|
||||
linear_button_->setEnabled(enable);
|
||||
bezier_button_->setEnabled(enable);
|
||||
hold_button_->setEnabled(enable);
|
||||
linear_button_->setEnabled(enable);
|
||||
bezier_button_->setEnabled(enable);
|
||||
hold_button_->setEnabled(enable);
|
||||
}
|
||||
|
||||
void CurveWidget::SetKeyframeButtonChecked(bool checked)
|
||||
{
|
||||
linear_button_->setChecked(checked);
|
||||
bezier_button_->setChecked(checked);
|
||||
hold_button_->setChecked(checked);
|
||||
linear_button_->setChecked(checked);
|
||||
bezier_button_->setChecked(checked);
|
||||
hold_button_->setChecked(checked);
|
||||
}
|
||||
|
||||
void CurveWidget::SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type)
|
||||
{
|
||||
linear_button_->setChecked(type == NodeKeyframe::kLinear);
|
||||
bezier_button_->setChecked(type == NodeKeyframe::kBezier);
|
||||
hold_button_->setChecked(type == NodeKeyframe::kHold);
|
||||
linear_button_->setChecked(type == NodeKeyframe::kLinear);
|
||||
bezier_button_->setChecked(type == NodeKeyframe::kBezier);
|
||||
hold_button_->setChecked(type == NodeKeyframe::kHold);
|
||||
}
|
||||
|
||||
void CurveWidget::ConnectInput(Node *node, const QString &input, int element)
|
||||
{
|
||||
if (element == -1 && node->InputIsArray(input)) {
|
||||
// This is the root element, connect all elements (if applicable)
|
||||
int arr_sz = node->InputArraySize(input);
|
||||
for (int i=-1; i<arr_sz; i++) {
|
||||
ConnectInputInternal(node, input, i);
|
||||
}
|
||||
} else {
|
||||
// This is a single element, just connect it as-is
|
||||
ConnectInputInternal(node, input, element);
|
||||
}
|
||||
if (element == -1 && node->InputIsArray(input)) {
|
||||
// This is the root element, connect all elements (if applicable)
|
||||
int arr_sz = node->InputArraySize(input);
|
||||
for (int i = -1; i < arr_sz; i++) {
|
||||
ConnectInputInternal(node, input, i);
|
||||
}
|
||||
} else {
|
||||
// This is a single element, just connect it as-is
|
||||
ConnectInputInternal(node, input, element);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::ConnectInputInternal(Node *node, const QString &input, int element)
|
||||
void CurveWidget::ConnectInputInternal(Node *node, const QString &input,
|
||||
int element)
|
||||
{
|
||||
NodeInput input_ref(node, input, element);
|
||||
int track_count = NodeValue::get_number_of_keyframe_tracks(input_ref.GetDataType());
|
||||
for (int i=0; i<track_count; i++) {
|
||||
NodeKeyframeTrackReference track_ref(input_ref, i);
|
||||
view_->ConnectInput(track_ref);
|
||||
selected_tracks_.append(track_ref);
|
||||
}
|
||||
NodeInput input_ref(node, input, element);
|
||||
int track_count =
|
||||
NodeValue::get_number_of_keyframe_tracks(input_ref.GetDataType());
|
||||
for (int i = 0; i < track_count; i++) {
|
||||
NodeKeyframeTrackReference track_ref(input_ref, i);
|
||||
view_->ConnectInput(track_ref);
|
||||
selected_tracks_.append(track_ref);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::SelectionChanged()
|
||||
{
|
||||
const std::vector<NodeKeyframe*> &selected = view_->GetSelectedKeyframes();
|
||||
const std::vector<NodeKeyframe *> &selected = view_->GetSelectedKeyframes();
|
||||
|
||||
SetKeyframeButtonChecked(false);
|
||||
SetKeyframeButtonEnabled(!selected.empty());
|
||||
SetKeyframeButtonChecked(false);
|
||||
SetKeyframeButtonEnabled(!selected.empty());
|
||||
|
||||
if (!selected.empty()) {
|
||||
bool all_same_type = true;
|
||||
NodeKeyframe::Type type = selected.front()->type();
|
||||
if (!selected.empty()) {
|
||||
bool all_same_type = true;
|
||||
NodeKeyframe::Type type = selected.front()->type();
|
||||
|
||||
for (size_t i=1;i<selected.size();i++) {
|
||||
NodeKeyframe* prev_item = selected.at(i-1);
|
||||
NodeKeyframe* this_item = selected.at(i);
|
||||
for (size_t i = 1; i < selected.size(); i++) {
|
||||
NodeKeyframe *prev_item = selected.at(i - 1);
|
||||
NodeKeyframe *this_item = selected.at(i);
|
||||
|
||||
if (prev_item->type() != this_item->type()) {
|
||||
all_same_type = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (prev_item->type() != this_item->type()) {
|
||||
all_same_type = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (all_same_type) {
|
||||
SetKeyframeButtonCheckedFromType(type);
|
||||
}
|
||||
}
|
||||
if (all_same_type) {
|
||||
SetKeyframeButtonCheckedFromType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::KeyframeTypeButtonTriggered(bool checked)
|
||||
{
|
||||
QPushButton* key_btn = static_cast<QPushButton*>(sender());
|
||||
QPushButton *key_btn = static_cast<QPushButton *>(sender());
|
||||
|
||||
if (!checked) {
|
||||
// Keyframe buttons cannot be checked off, we undo this action here
|
||||
key_btn->setChecked(true);
|
||||
return;
|
||||
}
|
||||
if (!checked) {
|
||||
// Keyframe buttons cannot be checked off, we undo this action here
|
||||
key_btn->setChecked(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get selected items and do nothing if there are none
|
||||
const std::vector<NodeKeyframe*> &selected = view_->GetSelectedKeyframes();
|
||||
if (selected.empty()) {
|
||||
return;
|
||||
}
|
||||
// Get selected items and do nothing if there are none
|
||||
const std::vector<NodeKeyframe *> &selected = view_->GetSelectedKeyframes();
|
||||
if (selected.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set all selected keyframes to this type
|
||||
NodeKeyframe::Type new_type;
|
||||
// Set all selected keyframes to this type
|
||||
NodeKeyframe::Type new_type;
|
||||
|
||||
// Determine which type to set
|
||||
if (key_btn == bezier_button_) {
|
||||
new_type = NodeKeyframe::kBezier;
|
||||
} else if (key_btn == hold_button_) {
|
||||
new_type = NodeKeyframe::kHold;
|
||||
} else {
|
||||
new_type = NodeKeyframe::kLinear;
|
||||
}
|
||||
// Determine which type to set
|
||||
if (key_btn == bezier_button_) {
|
||||
new_type = NodeKeyframe::kBezier;
|
||||
} else if (key_btn == hold_button_) {
|
||||
new_type = NodeKeyframe::kHold;
|
||||
} else {
|
||||
new_type = NodeKeyframe::kLinear;
|
||||
}
|
||||
|
||||
// Ensure only the appropriate button is checked
|
||||
SetKeyframeButtonCheckedFromType(new_type);
|
||||
// Ensure only the appropriate button is checked
|
||||
SetKeyframeButtonCheckedFromType(new_type);
|
||||
|
||||
MultiUndoCommand* command = new MultiUndoCommand();
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
foreach (NodeKeyframe* item, selected) {
|
||||
command->add_child(new KeyframeSetTypeCommand(item, new_type));
|
||||
}
|
||||
foreach (NodeKeyframe *item, selected) {
|
||||
command->add_child(new KeyframeSetTypeCommand(item, new_type));
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(command, tr("Changed Type of %1 Keyframe(s) to %2"));
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Changed Type of %1 Keyframe(s) to %2"));
|
||||
}
|
||||
|
||||
void CurveWidget::InputSelectionChanged(const NodeKeyframeTrackReference& ref)
|
||||
void CurveWidget::InputSelectionChanged(const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
key_control_->SetInput(ref.input());
|
||||
key_control_->SetInput(ref.input());
|
||||
|
||||
foreach (const NodeKeyframeTrackReference &c, selected_tracks_) {
|
||||
view_->DisconnectInput(c);
|
||||
}
|
||||
foreach (const NodeKeyframeTrackReference &c, selected_tracks_) {
|
||||
view_->DisconnectInput(c);
|
||||
}
|
||||
|
||||
selected_tracks_.clear();
|
||||
selected_tracks_.clear();
|
||||
|
||||
if (ref.IsValid() && !ref.input().IsArray()) {
|
||||
// This reference is a track, connect it only
|
||||
view_->ConnectInput(ref);
|
||||
selected_tracks_.append(ref);
|
||||
} else if (ref.input().IsValid()) {
|
||||
// This reference is a input, connect all tracks
|
||||
ConnectInput(ref.input().node(), ref.input().input(), ref.input().element());
|
||||
} else if (Node *node = ref.input().node()) {
|
||||
// This is a node, add all inputs
|
||||
foreach (const QString &input, node->inputs()) {
|
||||
if (node->IsInputKeyframable(input) && !node->IsInputHidden(input)) {
|
||||
ConnectInput(node, input, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ref.IsValid() && !ref.input().IsArray()) {
|
||||
// This reference is a track, connect it only
|
||||
view_->ConnectInput(ref);
|
||||
selected_tracks_.append(ref);
|
||||
} else if (ref.input().IsValid()) {
|
||||
// This reference is a input, connect all tracks
|
||||
ConnectInput(ref.input().node(), ref.input().input(),
|
||||
ref.input().element());
|
||||
} else if (Node *node = ref.input().node()) {
|
||||
// This is a node, add all inputs
|
||||
foreach (const QString &input, node->inputs()) {
|
||||
if (node->IsInputKeyframable(input) &&
|
||||
!node->IsInputHidden(input)) {
|
||||
ConnectInput(node, input, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
view_->ZoomToFit();
|
||||
view_->ZoomToFit();
|
||||
}
|
||||
|
||||
void CurveWidget::KeyframeViewDragged(int x, int y)
|
||||
{
|
||||
SetCatchUpScrollValue(x);
|
||||
SetCatchUpScrollValue(view_->verticalScrollBar(), y, view_->height());
|
||||
SetCatchUpScrollValue(x);
|
||||
SetCatchUpScrollValue(view_->verticalScrollBar(), y, view_->height());
|
||||
}
|
||||
|
||||
void CurveWidget::KeyframeViewReleased()
|
||||
{
|
||||
StopCatchUpScrollTimer();
|
||||
StopCatchUpScrollTimer(view_->verticalScrollBar());
|
||||
StopCatchUpScrollTimer();
|
||||
StopCatchUpScrollTimer(view_->verticalScrollBar());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,100 +32,101 @@
|
||||
#include "widget/nodetreeview/nodetreeview.h"
|
||||
#include "widget/timebased/timebasedwidget.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class CurveWidget : public TimeBasedWidget, public TimeTargetObject
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class CurveWidget : public TimeBasedWidget, public TimeTargetObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CurveWidget(QWidget* parent = nullptr);
|
||||
CurveWidget(QWidget *parent = nullptr);
|
||||
|
||||
const double& GetVerticalScale();
|
||||
void SetVerticalScale(const double& vscale);
|
||||
const double &GetVerticalScale();
|
||||
void SetVerticalScale(const double &vscale);
|
||||
|
||||
void DeleteSelected();
|
||||
void DeleteSelected();
|
||||
|
||||
void SelectAll()
|
||||
{
|
||||
view_->SelectAll();
|
||||
}
|
||||
void SelectAll()
|
||||
{
|
||||
view_->SelectAll();
|
||||
}
|
||||
|
||||
void DeselectAll()
|
||||
{
|
||||
view_->DeselectAll();
|
||||
}
|
||||
void DeselectAll()
|
||||
{
|
||||
view_->DeselectAll();
|
||||
}
|
||||
|
||||
Node *GetSelectedNodeWithID(const QString &id);
|
||||
Node *GetSelectedNodeWithID(const QString &id);
|
||||
|
||||
virtual bool CopySelected(bool cut) override;
|
||||
virtual bool CopySelected(bool cut) override;
|
||||
|
||||
virtual bool Paste() override;
|
||||
virtual bool Paste() override;
|
||||
|
||||
public slots:
|
||||
void SetNodes(const QVector<Node *> &nodes);
|
||||
void SetNodes(const QVector<Node *> &nodes);
|
||||
|
||||
protected:
|
||||
virtual void TimebaseChangedEvent(const rational &) override;
|
||||
virtual void ScaleChangedEvent(const double &) override;
|
||||
virtual void TimebaseChangedEvent(const rational &) override;
|
||||
virtual void ScaleChangedEvent(const double &) override;
|
||||
|
||||
virtual void TimeTargetChangedEvent(ViewerOutput *target) override;
|
||||
virtual void TimeTargetChangedEvent(ViewerOutput *target) override;
|
||||
|
||||
virtual void ConnectedNodeChangeEvent(ViewerOutput* n) override;
|
||||
virtual void ConnectedNodeChangeEvent(ViewerOutput *n) override;
|
||||
|
||||
virtual const QVector<KeyframeViewInputConnection*> *GetSnapKeyframes() const override
|
||||
{
|
||||
return &view_->GetKeyframeTracks();
|
||||
}
|
||||
virtual const QVector<KeyframeViewInputConnection *> *
|
||||
GetSnapKeyframes() const override
|
||||
{
|
||||
return &view_->GetKeyframeTracks();
|
||||
}
|
||||
|
||||
virtual const TimeTargetObject *GetKeyframeTimeTarget() const override
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
virtual const TimeTargetObject *GetKeyframeTimeTarget() const override
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
|
||||
virtual const std::vector<NodeKeyframe*> *GetSnapIgnoreKeyframes() const override
|
||||
{
|
||||
return &view_->GetSelectedKeyframes();
|
||||
}
|
||||
virtual const std::vector<NodeKeyframe *> *
|
||||
GetSnapIgnoreKeyframes() const override
|
||||
{
|
||||
return &view_->GetSelectedKeyframes();
|
||||
}
|
||||
|
||||
private:
|
||||
void SetKeyframeButtonEnabled(bool enable);
|
||||
void SetKeyframeButtonEnabled(bool enable);
|
||||
|
||||
void SetKeyframeButtonChecked(bool checked);
|
||||
void SetKeyframeButtonChecked(bool checked);
|
||||
|
||||
void SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type);
|
||||
void SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type);
|
||||
|
||||
void ConnectInput(Node *node, const QString &input, int element);
|
||||
void ConnectInput(Node *node, const QString &input, int element);
|
||||
|
||||
void ConnectInputInternal(Node *node, const QString &input, int element);
|
||||
void ConnectInputInternal(Node *node, const QString &input, int element);
|
||||
|
||||
QHash<NodeKeyframeTrackReference, QColor> keyframe_colors_;
|
||||
QHash<NodeKeyframeTrackReference, QColor> keyframe_colors_;
|
||||
|
||||
NodeTreeView* tree_view_;
|
||||
NodeTreeView *tree_view_;
|
||||
|
||||
QPushButton* linear_button_;
|
||||
QPushButton *linear_button_;
|
||||
|
||||
QPushButton* bezier_button_;
|
||||
QPushButton *bezier_button_;
|
||||
|
||||
QPushButton* hold_button_;
|
||||
QPushButton *hold_button_;
|
||||
|
||||
CurveView* view_;
|
||||
CurveView *view_;
|
||||
|
||||
NodeParamViewKeyframeControl* key_control_;
|
||||
NodeParamViewKeyframeControl *key_control_;
|
||||
|
||||
QVector<Node*> nodes_;
|
||||
QVector<Node *> nodes_;
|
||||
|
||||
QVector<NodeKeyframeTrackReference> selected_tracks_;
|
||||
QVector<NodeKeyframeTrackReference> selected_tracks_;
|
||||
|
||||
private slots:
|
||||
void SelectionChanged();
|
||||
void SelectionChanged();
|
||||
|
||||
void KeyframeTypeButtonTriggered(bool checked);
|
||||
void KeyframeTypeButtonTriggered(bool checked);
|
||||
|
||||
void InputSelectionChanged(const NodeKeyframeTrackReference& ref);
|
||||
|
||||
void KeyframeViewDragged(int x, int y);
|
||||
void KeyframeViewReleased();
|
||||
void InputSelectionChanged(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void KeyframeViewDragged(int x, int y);
|
||||
void KeyframeViewReleased();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user