implemented base UI keyframe functionality

This commit implements much of the base functionality for creating and
destroying keyframes in the UI. Not complete yet, but getting there.
This commit is contained in:
itsmattkc
2019-12-26 16:32:08 +11:00
parent a514265fc9
commit 23001386d0
16 changed files with 707 additions and 301 deletions
+26
View File
@@ -10,6 +10,23 @@ KeyframeView::KeyframeView(QWidget *parent) :
setDragMode(QGraphicsView::RubberBandDrag);
}
void KeyframeView::AddKeyframe(NodeKeyframePtr key, int y)
{
QPoint global_pt(0, y);
QPoint local_pt = mapFromGlobal(global_pt);
QPointF scene_pt = mapToScene(local_pt);
KeyframeViewItem* item = new KeyframeViewItem(key, scene_pt.y());
item->SetScale(scale_);
item_map_.insert(key.get(), item);
scene()->addItem(item);
}
void KeyframeView::RemoveKeyframe(NodeKeyframePtr key)
{
delete item_map_.value(key.get());
}
void KeyframeView::mousePressEvent(QMouseEvent *event)
{
if (PlayheadPress(event)) {
@@ -36,3 +53,12 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent *event)
QGraphicsView::mouseReleaseEvent(event);
}
void KeyframeView::ScaleChangedEvent(double scale)
{
QMap<NodeKeyframe*, KeyframeViewItem*>::const_iterator iterator;
for (iterator=item_map_.begin();iterator!=item_map_.end();iterator++) {
iterator.value()->SetScale(scale);
}
}