text: minor refactoring to make rect setting code more reusable

This commit is contained in:
itsmattkc
2022-05-13 08:41:22 -07:00
parent b63b792d5a
commit 07f92911cd
5 changed files with 54 additions and 36 deletions
+8 -6
View File
@@ -38,6 +38,7 @@
#include "config/config.h"
#include "core.h"
#include "node/block/gap/gap.h"
#include "node/generator/shape/shapenodebase.h"
#include "node/project/project.h"
#include "render/rendermanager.h"
#include "task/taskmanager.h"
@@ -480,7 +481,7 @@ void ViewerWidget::UpdateAudioProcessor()
}
}
void ViewerWidget::CreateAddableAt(QRectF f)
void ViewerWidget::CreateAddableAt(const QRectF &f)
{
if (Sequence *s = dynamic_cast<Sequence*>(GetConnectedNode())) {
Track::Type type = Track::kVideo;
@@ -510,12 +511,13 @@ void ViewerWidget::CreateAddableAt(QRectF f)
}
}
// Normalize around center of sequence
f.translate(-s->GetVideoParams().width()*0.5, -s->GetVideoParams().height()*0.5);
f.translate(f.width()*0.5, f.height()*0.5);
MultiUndoCommand *command = new MultiUndoCommand();
Node *clip = AddTool::CreateAddableClip(command, s, Track::Reference(type, track_index), in, length, f);
Node *clip = AddTool::CreateAddableClip(command, s, Track::Reference(type, track_index), in, length);
if (ShapeNodeBase *shape = dynamic_cast<ShapeNodeBase*>(clip)) {
shape->SetRect(f, s->GetVideoParams(), command);
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
SetGizmos(clip);
}