work towards timeline/nodeview interactivity

This commit is contained in:
itsmattkc
2021-05-17 11:14:56 +10:00
parent 8e9859b2b3
commit f2d64728f9
15 changed files with 204 additions and 132 deletions
+29 -18
View File
@@ -97,24 +97,9 @@ QPointF NodeViewItem::GetNodePosition() const
void NodeViewItem::SetNodePosition(const QPointF &pos)
{
switch (flow_dir_) {
case NodeViewCommon::kLeftToRight:
setPos(pos.x() * DefaultItemHorizontalPadding(),
pos.y() * DefaultItemVerticalPadding());
break;
case NodeViewCommon::kRightToLeft:
setPos(-pos.x() * DefaultItemHorizontalPadding(),
pos.y() * DefaultItemVerticalPadding());
break;
case NodeViewCommon::kTopToBottom:
setPos(pos.y() * DefaultItemHorizontalPadding(),
pos.x() * DefaultItemVerticalPadding());
break;
case NodeViewCommon::kBottomToTop:
setPos(pos.y() * DefaultItemHorizontalPadding(),
-pos.x() * DefaultItemVerticalPadding());
break;
}
cached_node_pos_ = pos;
UpdateNodePosition();
}
int NodeViewItem::DefaultTextPadding()
@@ -466,6 +451,8 @@ QPointF NodeViewItem::GetOutputPoint(const QString& output) const
void NodeViewItem::SetFlowDirection(NodeViewCommon::FlowDirection dir)
{
flow_dir_ = dir;
UpdateNodePosition();
}
QPointF NodeViewItem::GetInputPointInternal(int index, const QPointF& source_pos) const
@@ -490,4 +477,28 @@ QPointF NodeViewItem::GetInputPointInternal(int index, const QPointF& source_pos
}
}
void NodeViewItem::UpdateNodePosition()
{
const QPointF &pos = cached_node_pos_;
switch (flow_dir_) {
case NodeViewCommon::kLeftToRight:
setPos(pos.x() * DefaultItemHorizontalPadding(),
pos.y() * DefaultItemVerticalPadding());
break;
case NodeViewCommon::kRightToLeft:
setPos(-pos.x() * DefaultItemHorizontalPadding(),
pos.y() * DefaultItemVerticalPadding());
break;
case NodeViewCommon::kTopToBottom:
setPos(pos.y() * DefaultItemHorizontalPadding(),
pos.x() * DefaultItemVerticalPadding());
break;
case NodeViewCommon::kBottomToTop:
setPos(pos.y() * DefaultItemHorizontalPadding(),
-pos.x() * DefaultItemVerticalPadding());
break;
}
}
}