keyframes: implemented deleting keyframes with the delete shortcut
This commit is contained in:
@@ -737,6 +737,19 @@ void NodeInput::remove_keyframe(NodeKeyframePtr key)
|
||||
emit_time_range(time_affected);
|
||||
}
|
||||
|
||||
NodeKeyframePtr NodeInput::get_keyframe_shared_ptr_from_raw(NodeKeyframe* raw) const
|
||||
{
|
||||
foreach (const KeyframeTrack& track, keyframe_tracks_) {
|
||||
foreach (NodeKeyframePtr key, track) {
|
||||
if (key.get() == raw) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NodeInput::KeyframeTimeChanged()
|
||||
{
|
||||
NodeKeyframe* key = static_cast<NodeKeyframe*>(sender());
|
||||
|
||||
@@ -172,6 +172,11 @@ public:
|
||||
*/
|
||||
void remove_keyframe(NodeKeyframePtr key);
|
||||
|
||||
/**
|
||||
* @brief Hacky convenience function to turn a raw pointer into a shared pointer
|
||||
*/
|
||||
NodeKeyframePtr get_keyframe_shared_ptr_from_raw(NodeKeyframe *raw) const;
|
||||
|
||||
/**
|
||||
* @brief Return whether a keyframe exists at this time
|
||||
*
|
||||
|
||||
@@ -37,6 +37,11 @@ NodeInput *CurvePanel::GetInput() const
|
||||
return static_cast<CurveWidget*>(GetTimeBasedWidget())->GetInput();
|
||||
}
|
||||
|
||||
void CurvePanel::DeleteSelected()
|
||||
{
|
||||
static_cast<CurveWidget*>(GetTimeBasedWidget())->DeleteSelected();
|
||||
}
|
||||
|
||||
void CurvePanel::SetInput(NodeInput *input)
|
||||
{
|
||||
static_cast<CurveWidget*>(GetTimeBasedWidget())->SetInput(input);
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
|
||||
NodeInput* GetInput() const;
|
||||
|
||||
virtual void DeleteSelected() override;
|
||||
|
||||
public slots:
|
||||
void SetInput(NodeInput* input);
|
||||
|
||||
|
||||
@@ -59,6 +59,11 @@ void ParamPanel::SetTimestamp(const int64_t ×tamp)
|
||||
}
|
||||
}
|
||||
|
||||
void ParamPanel::DeleteSelected()
|
||||
{
|
||||
static_cast<NodeParamView*>(GetTimeBasedWidget())->DeleteSelected();
|
||||
}
|
||||
|
||||
void ParamPanel::Retranslate()
|
||||
{
|
||||
SetTitle(tr("Parameter Editor"));
|
||||
|
||||
@@ -38,6 +38,8 @@ public slots:
|
||||
|
||||
virtual void SetTimestamp(const int64_t& timestamp) override;
|
||||
|
||||
virtual void DeleteSelected() override;
|
||||
|
||||
signals:
|
||||
void TimeTargetChanged(Node* node);
|
||||
|
||||
|
||||
@@ -168,6 +168,11 @@ void CurveWidget::SetVerticalScale(const double &vscale)
|
||||
view_->SetYScale(vscale);
|
||||
}
|
||||
|
||||
void CurveWidget::DeleteSelected()
|
||||
{
|
||||
view_->DeleteSelected();
|
||||
}
|
||||
|
||||
void CurveWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
const double& GetVerticalScale();
|
||||
void SetVerticalScale(const double& vscale);
|
||||
|
||||
void DeleteSelected();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *) override;
|
||||
|
||||
|
||||
@@ -73,6 +73,25 @@ void KeyframeViewBase::SetYScale(const double &y_scale)
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeViewBase::DeleteSelected()
|
||||
{
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
QMap<NodeKeyframe*, KeyframeViewItem*>::const_iterator i;
|
||||
|
||||
for (i=item_map_.constBegin(); i!=item_map_.constEnd(); i++) {
|
||||
if (i.value()->isSelected()) {
|
||||
NodeInput* input_parent = i.key()->parent();
|
||||
|
||||
new NodeParamRemoveKeyframeCommand(input_parent,
|
||||
input_parent->get_keyframe_shared_ptr_from_raw(i.key()),
|
||||
command);
|
||||
}
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
}
|
||||
|
||||
void KeyframeViewBase::RemoveKeyframe(NodeKeyframePtr key)
|
||||
{
|
||||
KeyframeAboutToBeRemoved(key.get());
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
const double& GetYScale() const;
|
||||
void SetYScale(const double& y_scale);
|
||||
|
||||
void DeleteSelected();
|
||||
|
||||
public slots:
|
||||
void RemoveKeyframe(NodeKeyframePtr key);
|
||||
|
||||
|
||||
@@ -225,6 +225,11 @@ Node *NodeParamView::GetTimeTarget() const
|
||||
return keyframe_view_->GetTimeTarget();
|
||||
}
|
||||
|
||||
void NodeParamView::DeleteSelected()
|
||||
{
|
||||
keyframe_view_->DeleteSelected();
|
||||
}
|
||||
|
||||
void NodeParamView::UpdateItemTime(const int64_t ×tamp)
|
||||
{
|
||||
rational time = Timecode::timestamp_to_time(timestamp, keyframe_view_->timebase());
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
|
||||
Node* GetTimeTarget() const;
|
||||
|
||||
void DeleteSelected();
|
||||
|
||||
signals:
|
||||
void InputDoubleClicked(NodeInput* input);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user