ported functions to new node type

This commit is contained in:
itsmattkc
2019-05-13 12:00:15 +10:00
parent f796c2b379
commit 49feb12999
53 changed files with 296 additions and 269 deletions
+12 -12
View File
@@ -103,11 +103,11 @@ EffectUI::EffectUI(OldEffectNode* e) :
this,
SLOT(show_context_menu(const QPoint&)));
widgets_.resize(e->row_count());
keyframe_navigators_.resize(e->row_count());
widgets_.resize(e->ParameterCount());
keyframe_navigators_.resize(e->ParameterCount());
for (int i=0;i<e->row_count();i++) {
NodeIO* row = e->row(i);
for (int i=0;i<e->ParameterCount();i++) {
NodeIO* row = e->Parameter(i);
ClickableLabel* row_label = new ClickableLabel(row->name());
connect(row_label, SIGNAL(clicked()), row, SLOT(FocusRow()));
@@ -181,17 +181,17 @@ void EffectUI::AddAdditionalEffect(OldEffectNode *e)
additional_effects_.append(e);
// Attach this UI's widgets to the additional effect
for (int i=0;i<effect_->row_count();i++) {
for (int i=0;i<effect_->ParameterCount();i++) {
NodeIO* row = effect_->row(i);
NodeIO* row = effect_->Parameter(i);
// Attach existing keyframe navigator to this effect's row
AttachKeyframeNavigationToRow(e->row(i), keyframe_navigators_.at(i));
AttachKeyframeNavigationToRow(e->Parameter(i), keyframe_navigators_.at(i));
for (int j=0;j<row->FieldCount();j++) {
// Attach existing field widget to this effect's field
e->row(i)->Field(j)->CreateWidget(Widget(i, j));
e->Parameter(i)->Field(j)->CreateWidget(Widget(i, j));
}
@@ -229,9 +229,9 @@ void EffectUI::UpdateFromEffect()
{
OldEffectNode* effect = GetEffect();
for (int j=0;j<effect->row_count();j++) {
for (int j=0;j<effect->ParameterCount();j++) {
NodeIO* row = effect->row(j);
NodeIO* row = effect->Parameter(j);
for (int k=0;k<row->FieldCount();k++) {
EffectField* field = row->Field(k);
@@ -246,8 +246,8 @@ void EffectUI::UpdateFromEffect()
bool same_value = true;
for (int i=0;i<additional_effects_.size();i++) {
EffectField* previous_field = i > 0 ? additional_effects_.at(i-1)->row(j)->Field(k) : field;
EffectField* additional_field = additional_effects_.at(i)->row(j)->Field(k);
EffectField* previous_field = i > 0 ? additional_effects_.at(i-1)->Parameter(j)->Field(k) : field;
EffectField* additional_field = additional_effects_.at(i)->Parameter(j)->Field(k);
if (additional_field->GetValueAt(additional_effects_.at(i)->Now())
!= previous_field->GetValueAt(additional_effects_.at(i)->Now())) {
+40 -37
View File
@@ -114,8 +114,8 @@ void GraphView::reset_view() {
void GraphView::set_view_to_selection() {
if (row != nullptr && selected_keys.size() > 0) {
long min_time = LONG_MAX;
long max_time = LONG_MIN;
double min_time = DBL_MAX;
double max_time = DBL_MIN;
double min_dbl = DBL_MAX;
double max_dbl = DBL_MIN;
for (int i=0;i<selected_keys.size();i++) {
@@ -126,8 +126,10 @@ void GraphView::set_view_to_selection() {
max_dbl = qMax(key.data.toDouble(), max_dbl);
}
/* FIXME
min_time -= row->GetParentEffect()->parent_clip->clip_in();
max_time -= row->GetParentEffect()->parent_clip->clip_in();
*/
set_view_to_rect(min_time, min_dbl, max_time, max_dbl);
}
@@ -137,8 +139,8 @@ void GraphView::set_view_to_all() {
if (row != nullptr) {
bool can_set = false;
long min_time = LONG_MAX;
long max_time = LONG_MIN;
double min_time = DBL_MAX;
double max_time = DBL_MIN;
double min_dbl = DBL_MAX;
double max_dbl = DBL_MIN;
for (int i=0;i<row->FieldCount();i++) {
@@ -152,15 +154,17 @@ void GraphView::set_view_to_all() {
}
}
if (can_set) {
/* FIXME
min_time -= row->GetParentEffect()->parent_clip->clip_in();
max_time -= row->GetParentEffect()->parent_clip->clip_in();
*/
set_view_to_rect(min_time, min_dbl, max_time, max_dbl);
}
}
}
void GraphView::set_view_to_rect(int x1, double y1, int x2, double y2) {
void GraphView::set_view_to_rect(double x1, double y1, double x2, double y2) {
double padding = 1.5;
double x_diff = double(x2 - x1);
double y_diff = (y2 - y1);
@@ -278,20 +282,20 @@ void GraphView::paintEvent(QPaintEvent *) {
if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier
bezier_path.cubicTo(
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one
bezier_path.quadTo(
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(last_key_x+last_post_handle*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else {
// this keyframe is the bezier one
bezier_path.quadTo(
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(key_x+pre_handle*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
}
@@ -317,12 +321,12 @@ void GraphView::paintEvent(QPaintEvent *) {
p.setPen(Qt::gray);
// pre handle line
QPointF pre_point(key_x + key.pre_handle_x*x_zoom, key_y - key.pre_handle_y*y_zoom);
QPointF pre_point(key_x + key.pre_handle.x()*x_zoom, key_y - key.pre_handle.y()*y_zoom);
p.drawLine(pre_point, QPointF(key_x, key_y));
p.drawEllipse(pre_point, kBezierHandleSize, kBezierHandleSize);
// post handle line
QPointF post_point(key_x + key.post_handle_x*x_zoom, key_y - key.post_handle_y*y_zoom);
QPointF post_point(key_x + key.post_handle.x()*x_zoom, key_y - key.post_handle.y()*y_zoom);
p.drawLine(post_point, QPointF(key_x, key_y));
p.drawEllipse(post_point, kBezierHandleSize, kBezierHandleSize);
}
@@ -400,8 +404,8 @@ void GraphView::mousePressEvent(QMouseEvent *event) {
break;
} else {
// selecting a handle
QPointF pre_point(key_x + key.pre_handle_x*x_zoom, key_y - key.pre_handle_y*y_zoom);
QPointF post_point(key_x + key.post_handle_x*x_zoom, key_y - key.post_handle_y*y_zoom);
QPointF pre_point(key_x + key.pre_handle.x()*x_zoom, key_y - key.pre_handle.y()*y_zoom);
QPointF post_point(key_x + key.post_handle.x()*x_zoom, key_y - key.post_handle.y()*y_zoom);
if (event->pos().x() > pre_point.x()-kBezierHandleSize
&& event->pos().x() < pre_point.x()+kBezierHandleSize
&& event->pos().y() > pre_point.y()-kBezierHandleSize
@@ -419,10 +423,10 @@ void GraphView::mousePressEvent(QMouseEvent *event) {
sel_key_field = i;
handle_index = j;
handle_field = i;
old_pre_handle_x = key.pre_handle_x;
old_pre_handle_y = key.pre_handle_y;
old_post_handle_x = key.post_handle_x;
old_post_handle_y = key.post_handle_y;
old_pre_handle_x = key.pre_handle.x();
old_pre_handle_y = key.pre_handle.y();
old_post_handle_x = key.post_handle.x();
old_post_handle_y = key.post_handle.y();
break;
}
}
@@ -551,10 +555,8 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) {
}
EffectKeyframe& key = row->Field(handle_field)->keyframes[handle_index];
key.pre_handle_x = qMin(0.0, new_pre_handle_x);
key.pre_handle_y = new_pre_handle_y;
key.post_handle_x = qMax(0.0, new_post_handle_x);
key.post_handle_y = new_post_handle_y;
key.pre_handle = QPointF(qMin(0.0, new_pre_handle_x), new_pre_handle_y);
key.post_handle = QPointF(qMax(0.0, new_post_handle_x), new_post_handle_y);
moved_keys = true;
update_ui(false);
@@ -580,14 +582,14 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) {
KEYFRAME_SIZE+KEYFRAME_SIZE
);
QRect pre_rect(
qRound(key_x + key.pre_handle_x*x_zoom - kBezierHandleSize),
qRound(key_y + key.pre_handle_y*y_zoom - kBezierHandleSize),
qRound(key_x + key.pre_handle.x()*x_zoom - kBezierHandleSize),
qRound(key_y + key.pre_handle.y()*y_zoom - kBezierHandleSize),
kBezierHandleSize+kBezierHandleSize,
kBezierHandleSize+kBezierHandleSize
);
QRect post_rect(
qRound(key_x + key.post_handle_x*x_zoom - kBezierHandleSize),
qRound(key_y + key.post_handle_y*y_zoom - kBezierHandleSize),
qRound(key_x + key.post_handle.x()*x_zoom - kBezierHandleSize),
qRound(key_y + key.post_handle.y()*y_zoom - kBezierHandleSize),
kBezierHandleSize+kBezierHandleSize,
kBezierHandleSize+kBezierHandleSize
);
@@ -653,20 +655,20 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) {
if (last_key.type == EFFECT_KEYFRAME_BEZIER && key.type == EFFECT_KEYFRAME_BEZIER) {
// cubic bezier
bezier_path.cubicTo(
QPointF(last_key_x+last_key.post_handle_x*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(key_x+key.pre_handle_x*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(last_key_x+last_key.post_handle.x()*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x+key.pre_handle.x()*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else if (key.type == EFFECT_KEYFRAME_LINEAR) { // quadratic bezier
// last keyframe is the bezier one
bezier_path.quadTo(
QPointF(last_key_x+last_key.post_handle_x*x_zoom, last_key_y-last_key.post_handle_y*y_zoom),
QPointF(last_key_x+last_key.post_handle.x()*x_zoom, last_key_y-last_key.post_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
} else {
// this keyframe is the bezier one
bezier_path.quadTo(
QPointF(key_x+key.pre_handle_x*x_zoom, key_y-key.pre_handle_y*y_zoom),
QPointF(key_x+key.pre_handle.x()*x_zoom, key_y-key.pre_handle.y()*y_zoom),
QPointF(key_x, key_y)
);
}
@@ -708,7 +710,7 @@ void GraphView::mouseReleaseEvent(QMouseEvent *) {
case kBezierHandleNone:
for (int i=0;i<selected_keys.size();i++) {
EffectKeyframe& key = row->Field(selected_keys_fields.at(i))->keyframes[selected_keys.at(i)];
ca->append(new SetLong(&key.time, selected_keys_old_vals.at(i), key.time));
ca->append(new SetDouble(&key.time, selected_keys_old_vals.at(i), key.time));
ca->append(new SetQVariant(&key.data, selected_keys_old_doubles.at(i), key.data));
}
break;
@@ -716,10 +718,8 @@ void GraphView::mouseReleaseEvent(QMouseEvent *) {
case kBezierHandlePost:
{
EffectKeyframe& key = row->Field(handle_field)->keyframes[handle_index];
ca->append(new SetDouble(&key.pre_handle_x, old_pre_handle_x, key.pre_handle_x));
ca->append(new SetDouble(&key.pre_handle_y, old_pre_handle_y, key.pre_handle_y));
ca->append(new SetDouble(&key.post_handle_x, old_post_handle_x, key.post_handle_x));
ca->append(new SetDouble(&key.post_handle_y, old_post_handle_y, key.post_handle_y));
ca->append(new SetPointF(&key.pre_handle, QPointF(old_pre_handle_x, old_pre_handle_y), key.pre_handle));
ca->append(new SetPointF(&key.post_handle, QPointF(old_post_handle_x, old_post_handle_y), key.post_handle));
}
break;
}
@@ -834,7 +834,8 @@ void GraphView::set_row(NodeIO *r) {
for (int i=0;i<row->FieldCount();i++) {
field_visibility[i] = row->Field(i)->IsEnabled();
}
visible_in = row->GetParentEffect()->parent_clip->timeline_in();
// FIXME
//visible_in = row->ParentNode()->parent_clip->timeline_in();
set_view_to_all();
} else {
update();
@@ -902,7 +903,8 @@ void GraphView::set_zoom(double xz, double yz) {
int GraphView::get_screen_x(double d) {
if (row != nullptr) {
d -= row->GetParentEffect()->parent_clip->clip_in();
// FIXME
//d -= row->GetParentEffect()->parent_clip->clip_in();
}
return qRound((d*x_zoom) - x_scroll);
}
@@ -914,7 +916,8 @@ int GraphView::get_screen_y(double d) {
long GraphView::get_value_x(int i) {
long frame = qRound((i + x_scroll)/x_zoom);
if (row != nullptr) {
frame += row->GetParentEffect()->parent_clip->clip_in();
// FIXME
//frame += row->GetParentEffect()->parent_clip->clip_in();
}
return frame;
}
+2 -2
View File
@@ -77,7 +77,7 @@ private:
QVector<int> selected_keys;
QVector<int> selected_keys_fields;
QVector<long> selected_keys_old_vals;
QVector<double> selected_keys_old_vals;
QVector<double> selected_keys_old_doubles;
double old_pre_handle_x;
@@ -116,7 +116,7 @@ private slots:
void reset_view();
void set_view_to_selection();
void set_view_to_all();
void set_view_to_rect(int x1, double y1, int x2, double y2);
void set_view_to_rect(double x1, double y1, double x2, double y2);
};
#endif // GRAPHVIEW_H
+3
View File
@@ -55,7 +55,10 @@ void draw_keyframe(QPainter &p, int type, int x, int y, bool darker, int r, int
// adjusts keyframe's internal time (in clip time) to timeline time
long adjust_row_keyframe(NodeIO* row, long time, long visible_in) {
return 0;
/* FIXME
return time
- row->GetParentEffect()->parent_clip->clip_in()
+ (row->GetParentEffect()->parent_clip->timeline_in() - visible_in);
*/
}
+7 -3
View File
@@ -123,8 +123,8 @@ void KeyframeView::paintEvent(QPaintEvent*) {
OldEffectNode* e = container->GetEffect();
if (container->IsExpanded()) {
for (int j=0;j<e->row_count();j++) {
NodeIO* row = e->row(j);
for (int j=0;j<e->ParameterCount();j++) {
NodeIO* row = e->Parameter(j);
int keyframe_y = container->GetRowY(j, this);
@@ -261,6 +261,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) {
for (int k=0;k<row->FieldCount();k++) {
EffectField* f = row->Field(k);
for (int j=0;j<f->keyframes.size();j++) {
/* FIXME
long eval_keyframe_time = f->keyframes.at(j).time-row->GetParentEffect()->parent_clip->clip_in()+(row->GetParentEffect()->parent_clip->timeline_in()-visible_in);
if (eval_keyframe_time >= frame_min && eval_keyframe_time <= frame_max) {
long eval_frame_diff = qAbs(eval_keyframe_time - drag_frame_start);
@@ -271,6 +272,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event) {
frame_diff = eval_frame_diff;
}
}
*/
}
}
break;
@@ -381,6 +383,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent* event) {
olive::timeline::snapped = false;
if (olive::timeline::snapping) {
for (int i=0;i<selected_keyframes.size();i++) {
/* FIXME
EffectField* field = selected_fields.at(i);
Clip* c = field->GetParentRow()->GetParentEffect()->parent_clip;
long key_time = old_key_vals.at(i) + frame_diff - c->clip_in() + c->timeline_in();
@@ -389,6 +392,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent* event) {
frame_diff += (key_eval - key_time);
break;
}
*/
}
}
@@ -428,7 +432,7 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent*) {
if (dragging) {
ComboAction* ca = new ComboAction();
for (int i=0;i<selected_fields.size();i++) {
ca->append(new SetLong(
ca->append(new SetDouble(
&selected_fields.at(i)->keyframes[selected_keyframes.at(i)].time,
old_key_vals.at(i),
selected_fields.at(i)->keyframes.at(selected_keyframes.at(i)).time
+2 -2
View File
@@ -26,7 +26,7 @@ void NodeEdgeUI::adjust()
if (node != nullptr) {
// Check if this node has the output row
int row_index = node->GetNode()->IndexOfRow(edge_->output());
int row_index = node->GetNode()->IndexOfParameter(edge_->output());
if (row_index > -1) {
output_node_ = node;
@@ -34,7 +34,7 @@ void NodeEdgeUI::adjust()
}
// Check if this node has the input row
row_index = node->GetNode()->IndexOfRow(edge_->input());
row_index = node->GetNode()->IndexOfParameter(edge_->input());
if (row_index > -1) {
input_node_ = node;
+18 -18
View File
@@ -32,14 +32,14 @@ void NodeUI::AddToScene(QGraphicsScene *scene)
scene->addItem(this);
}
void NodeUI::SetNode(OldEffectNode *n)
void NodeUI::SetNode(Node *n)
{
node_ = n;
QRectF rectangle;
rectangle.setTopLeft(pos());
rectangle.setSize(QSizeF(200, GetRowY(node_->row_count())));
rectangle.setSize(QSizeF(200, GetRowY(node_->ParameterCount())));
QRectF inner_rect = rectangle;
inner_rect.setX(inner_rect.x() + kNodePlugSize/2);
@@ -51,7 +51,7 @@ void NodeUI::SetNode(OldEffectNode *n)
setRect(rectangle);
}
OldEffectNode *NodeUI::GetNode()
Node *NodeUI::GetNode()
{
return node_;
}
@@ -90,12 +90,12 @@ void NodeUI::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
node_->name());
// Draw node row names
for (int i=0;i<node_->row_count();i++) {
for (int i=0;i<node_->ParameterCount();i++) {
int text_x;
if (node_->row(i)->IsNodeOutput()) {
if (node_->Parameter(i)->IsNodeOutput()) {
// right alignment
text_x = rect().right() - kNodePlugSize/2 - qApp->fontMetrics().width(node_->row(i)->name()) - kTextPadding;
text_x = rect().right() - kNodePlugSize/2 - qApp->fontMetrics().width(node_->Parameter(i)->name()) - kTextPadding;
} else {
// left alignment
text_x = left_text_x;
@@ -103,7 +103,7 @@ void NodeUI::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
painter->drawText(text_x,
GetRowY(i) + qApp->fontMetrics().ascent(),
node_->row(i)->name());
node_->Parameter(i)->name());
}
// Draw title splitter line
@@ -128,8 +128,8 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (clicked_socket_ > -1) {
// See if this socket already has an edge connected
QVector<NodeEdgePtr> edges = node_->row(clicked_socket_)->edges();
if (!edges.isEmpty() && edges.last()->input()->GetParentEffect() == node_) {
QVector<NodeEdgePtr> edges = node_->Parameter(clicked_socket_)->edges();
if (!edges.isEmpty() && edges.last()->input()->ParentNode() == node_) {
NodeEdge* e = edges.last().get();
@@ -137,9 +137,9 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event)
NodeIO* other_row = e->output();
OldEffectNode* other_node = other_row->GetParentEffect();
Node* other_node = other_row->ParentNode();
int other_row_index = other_node->IndexOfRow(other_row);
int other_row_index = other_node->IndexOfParameter(other_row);
NodeUI* other_node_ui = FindUIFromNode(other_node);
@@ -158,7 +158,7 @@ void NodeUI::mousePressEvent(QGraphicsSceneMouseEvent *event)
// Start a new edge here
drag_line_start_ = pos() + sockets.at(clicked_socket_).center();
drag_source_ = node_->row(clicked_socket_);
drag_source_ = node_->Parameter(clicked_socket_);
}
@@ -269,11 +269,11 @@ QVector<QRectF> NodeUI::GetNodeSocketRects()
QVector<QRectF> rects;
if (node_ != nullptr) {
OldEffectNode* e = node_;
Node* e = node_;
for (int i=0;i<e->row_count();i++) {
for (int i=0;i<e->ParameterCount();i++) {
NodeIO* row = e->row(i);
NodeIO* row = e->Parameter(i);
if (row->IsNodeInput() || row->IsNodeOutput()) {
qreal x = (row->IsNodeOutput()) ? rect().right() - kNodePlugSize : rect().x();
@@ -292,13 +292,13 @@ QVector<QRectF> NodeUI::GetNodeSocketRects()
NodeIO *NodeUI::GetRowFromIndex(int i)
{
if (node_ != nullptr && i < node_->row_count()) {
return node_->row(i);
if (node_ != nullptr && i < node_->ParameterCount()) {
return node_->Parameter(i);
}
return nullptr;
}
NodeUI *NodeUI::FindUIFromNode(OldEffectNode* n)
NodeUI *NodeUI::FindUIFromNode(Node* n)
{
QList<QGraphicsItem*> all_items = scene()->items();
+5 -5
View File
@@ -7,7 +7,7 @@
class EffectUI;
class NodeIO;
class NodeEdge;
class OldEffectNode;
class Node;
class NodeUI : public QGraphicsRectItem {
public:
@@ -15,8 +15,8 @@ public:
void AddToScene(QGraphicsScene* scene);
//void Resize(const QSize& s);
void SetNode(OldEffectNode* n);
OldEffectNode* GetNode();
void SetNode(Node* n);
Node* GetNode();
QVector<QRectF> GetNodeSocketRects();
@@ -29,10 +29,10 @@ protected:
private:
NodeIO *GetRowFromIndex(int i);
NodeUI* FindUIFromNode(OldEffectNode* n);
NodeUI* FindUIFromNode(Node *n);
int GetRowY(int index);
OldEffectNode* node_;
Node* node_;
QGraphicsPathItem* drag_line_;
QPointF drag_line_start_;