shapenode: added gizmos
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "node/inputdragger.h"
|
||||
#include "node/output/track/track.h"
|
||||
#include "transition/transition.h"
|
||||
#include "widget/slider/rationalslider.h"
|
||||
@@ -143,7 +144,7 @@ void Block::InvalidateCache(const TimeRange& range, const QString& from, int ele
|
||||
// We must intercept the signal here
|
||||
r = TimeRange(qMin(length(), last_length_), RATIONAL_MAX);
|
||||
|
||||
if (!NumericSliderBase::IsEffectsSliderBeingDragged()) {
|
||||
if (!NodeInputDragger::IsInputBeingDragged()) {
|
||||
last_length_ = length();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "cropdistortnode.h"
|
||||
|
||||
#include "common/lerp.h"
|
||||
#include "core.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -178,7 +179,7 @@ bool CropDistortNode::GizmoPress(const NodeValueRow &row, const NodeGlobals &glo
|
||||
return false;
|
||||
}
|
||||
|
||||
void CropDistortNode::GizmoMove(const QPointF &p, const rational &time)
|
||||
void CropDistortNode::GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
if (gizmo_dragger_.isEmpty()) {
|
||||
gizmo_dragger_.resize(gizmo_start_.size());
|
||||
@@ -234,9 +235,11 @@ void CropDistortNode::GizmoMove(const QPointF &p, const rational &time)
|
||||
|
||||
void CropDistortNode::GizmoRelease()
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
for (NodeInputDragger& i : gizmo_dragger_) {
|
||||
i.End();
|
||||
i.End(command);
|
||||
}
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
gizmo_dragger_.clear();
|
||||
|
||||
gizmo_start_.clear();
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
virtual void DrawGizmos(const NodeValueRow& row, const NodeGlobals &globals, QPainter *p) override;
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow& row, const NodeGlobals &globals, const QPointF &p) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers) override;
|
||||
virtual void GizmoRelease() override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "common/range.h"
|
||||
#include "core.h"
|
||||
#include "node/traverser.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -199,7 +200,7 @@ bool TransformDistortNode::GizmoPress(const NodeValueRow &row, const NodeGlobals
|
||||
return false;
|
||||
}
|
||||
|
||||
void TransformDistortNode::GizmoMove(const QPointF &p, const rational &time)
|
||||
void TransformDistortNode::GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
QPointF movement = (p - gizmo_drag_pos_);
|
||||
QVector2D vec_movement(movement);
|
||||
@@ -302,9 +303,11 @@ void TransformDistortNode::GizmoMove(const QPointF &p, const rational &time)
|
||||
|
||||
void TransformDistortNode::GizmoRelease()
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
for (NodeInputDragger& i : gizmo_dragger_) {
|
||||
i.End();
|
||||
i.End(command);
|
||||
}
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
gizmo_dragger_.clear();
|
||||
|
||||
gizmo_start_.clear();
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
virtual void DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p) override;
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow &row, const NodeGlobals &globals, const QPointF &p) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers) override;
|
||||
virtual void GizmoRelease() override;
|
||||
|
||||
enum AutoScaleType {
|
||||
|
||||
@@ -79,11 +79,4 @@ void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, Nod
|
||||
table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
|
||||
}
|
||||
|
||||
void ShapeNode::DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p)
|
||||
{
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"), globals.resolution() * 0.5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,18 +49,8 @@ public:
|
||||
virtual ShaderCode GetShaderCode(const QString& shader_id) const override;
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
|
||||
virtual bool HasGizmos() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p) override;
|
||||
|
||||
static QString kTypeInput;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,12 @@
|
||||
|
||||
#include "shapenodebase.h"
|
||||
|
||||
#include <QtMath>
|
||||
#include <QVector2D>
|
||||
|
||||
#include "common/lerp.h"
|
||||
#include "core.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super Node
|
||||
@@ -34,6 +38,7 @@ ShapeNodeBase::ShapeNodeBase()
|
||||
{
|
||||
AddInput(kPositionInput, NodeValue::kVec2, QVector2D(0, 0));
|
||||
AddInput(kSizeInput, NodeValue::kVec2, QVector2D(100, 100));
|
||||
SetInputProperty(kSizeInput, QStringLiteral("min"), QVector2D(0, 0));
|
||||
AddInput(kColorInput, NodeValue::kColor, QVariant::fromValue(Color(1.0, 0.0, 0.0, 1.0)));
|
||||
}
|
||||
|
||||
@@ -46,4 +51,260 @@ void ShapeNodeBase::Retranslate()
|
||||
SetInputName(kColorInput, tr("Color"));
|
||||
}
|
||||
|
||||
void ShapeNodeBase::DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p)
|
||||
{
|
||||
// Use offsets to make the appearance of values that start in the top left, even though we
|
||||
// really anchor around the center
|
||||
QVector2D center_pt = globals.resolution() * 0.5;
|
||||
SetInputProperty(kPositionInput, QStringLiteral("offset"), center_pt);
|
||||
|
||||
const double handle_radius = GetGizmoHandleRadius(p->transform());
|
||||
|
||||
p->setPen(QPen(Qt::white, 0));
|
||||
|
||||
QVector2D pos = row[kPositionInput].data().value<QVector2D>();
|
||||
QVector2D sz = row[kSizeInput].data().value<QVector2D>();
|
||||
QVector2D half_sz = sz * 0.5;
|
||||
|
||||
double left_pt = pos.x() + center_pt.x() - half_sz.x();
|
||||
double top_pt = pos.y() + center_pt.y() - half_sz.y();
|
||||
double right_pt = left_pt + sz.x();
|
||||
double bottom_pt = top_pt + sz.y();
|
||||
double center_x_pt = lerp(left_pt, right_pt, 0.5);
|
||||
double center_y_pt = lerp(top_pt, bottom_pt, 0.5);
|
||||
|
||||
gizmo_whole_rect_ = QRectF(left_pt, top_pt, right_pt - left_pt, bottom_pt - top_pt);
|
||||
p->drawRect(gizmo_whole_rect_);
|
||||
|
||||
gizmo_resize_handle_[kGizmoScaleTopLeft] = CreateGizmoHandleRect(QPointF(left_pt, top_pt), handle_radius);
|
||||
gizmo_resize_handle_[kGizmoScaleTopCenter] = CreateGizmoHandleRect(QPointF(center_x_pt, top_pt), handle_radius);
|
||||
gizmo_resize_handle_[kGizmoScaleTopRight] = CreateGizmoHandleRect(QPointF(right_pt, top_pt), handle_radius);
|
||||
gizmo_resize_handle_[kGizmoScaleBottomLeft] = CreateGizmoHandleRect(QPointF(left_pt, bottom_pt), handle_radius);
|
||||
gizmo_resize_handle_[kGizmoScaleBottomCenter] = CreateGizmoHandleRect(QPointF(center_x_pt, bottom_pt), handle_radius);
|
||||
gizmo_resize_handle_[kGizmoScaleBottomRight] = CreateGizmoHandleRect(QPointF(right_pt, bottom_pt), handle_radius);
|
||||
gizmo_resize_handle_[kGizmoScaleCenterLeft] = CreateGizmoHandleRect(QPointF(left_pt, center_y_pt), handle_radius);
|
||||
gizmo_resize_handle_[kGizmoScaleCenterRight] = CreateGizmoHandleRect(QPointF(right_pt, center_y_pt), handle_radius);
|
||||
|
||||
p->setPen(Qt::NoPen);
|
||||
p->setBrush(Qt::white);
|
||||
DrawAndExpandGizmoHandles(p, handle_radius, gizmo_resize_handle_, kGizmoScaleCount);
|
||||
}
|
||||
|
||||
bool ShapeNodeBase::GizmoPress(const NodeValueRow &row, const NodeGlobals &globals, const QPointF &p)
|
||||
{
|
||||
gizmo_drag_ = -1;
|
||||
|
||||
// See if any of our resize handles have the pointer
|
||||
for (int i=0; i<kGizmoScaleCount; i++) {
|
||||
if (gizmo_resize_handle_[i].contains(p)) {
|
||||
gizmo_drag_ = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// See if the rect has the pointer
|
||||
if (gizmo_drag_ == -1 && gizmo_whole_rect_.contains(p)) {
|
||||
gizmo_drag_ = kGizmoWholeRect;
|
||||
}
|
||||
|
||||
if (gizmo_drag_ >= 0) {
|
||||
gizmo_pos_start_ = row[kPositionInput].data().value<QVector2D>();
|
||||
gizmo_sz_start_ = row[kSizeInput].data().value<QVector2D>();
|
||||
gizmo_drag_start_ = p;
|
||||
gizmo_half_res_ = globals.resolution()/2;
|
||||
|
||||
// Get aspect ratio (avoiding potential zero)
|
||||
if (qFuzzyIsNull(gizmo_sz_start_.y())) {
|
||||
gizmo_aspect_ratio_ = 0;
|
||||
} else {
|
||||
gizmo_aspect_ratio_ = gizmo_sz_start_.x() / gizmo_sz_start_.y();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
enum {
|
||||
kGDPosX,
|
||||
kGDPosY,
|
||||
kGDSzX,
|
||||
kGDSzY,
|
||||
kGDCount
|
||||
};
|
||||
|
||||
QVector2D ShapeNodeBase::GenerateGizmoAnchor(const QVector2D &pos, const QVector2D &size, int drag, QVector2D *pt = nullptr)
|
||||
{
|
||||
QVector2D anchor = pos;
|
||||
QVector2D half_sz = size/2;
|
||||
|
||||
if (drag == kGizmoScaleTopLeft || drag == kGizmoScaleCenterLeft || drag == kGizmoScaleBottomLeft) {
|
||||
anchor.setX(anchor.x() + half_sz.x());
|
||||
if (pt && pt->x() > anchor.x()) {
|
||||
pt->setX(anchor.x());
|
||||
}
|
||||
}
|
||||
|
||||
if (drag == kGizmoScaleTopRight || drag == kGizmoScaleCenterRight || drag == kGizmoScaleBottomRight) {
|
||||
anchor.setX(anchor.x() - half_sz.x());
|
||||
if (pt && pt->x() < anchor.x()) {
|
||||
pt->setX(anchor.x());
|
||||
}
|
||||
}
|
||||
|
||||
if (drag == kGizmoScaleTopLeft || drag == kGizmoScaleTopCenter || drag == kGizmoScaleTopRight) {
|
||||
anchor.setY(anchor.y() + half_sz.y());
|
||||
if (pt && pt->y() > anchor.y()) {
|
||||
pt->setY(anchor.y());
|
||||
}
|
||||
}
|
||||
|
||||
if (drag == kGizmoScaleBottomLeft || drag == kGizmoScaleBottomCenter || drag == kGizmoScaleBottomRight) {
|
||||
anchor.setY(anchor.y() - half_sz.y());
|
||||
if (pt && pt->y() < anchor.y()) {
|
||||
pt->setY(anchor.y());
|
||||
}
|
||||
}
|
||||
|
||||
return anchor;
|
||||
}
|
||||
|
||||
void ShapeNodeBase::GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
if (gizmo_dragger_.isEmpty()) {
|
||||
gizmo_dragger_.resize(kGDCount);
|
||||
gizmo_dragger_[kGDPosX].Start(NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 0), time);
|
||||
gizmo_dragger_[kGDPosY].Start(NodeKeyframeTrackReference(NodeInput(this, kPositionInput), 1), time);
|
||||
gizmo_dragger_[kGDSzX].Start(NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 0), time);
|
||||
gizmo_dragger_[kGDSzY].Start(NodeKeyframeTrackReference(NodeInput(this, kSizeInput), 1), time);
|
||||
}
|
||||
|
||||
bool from_center = modifiers & Qt::AltModifier;
|
||||
bool keep_ratio = modifiers & Qt::ShiftModifier;
|
||||
|
||||
QVector2D adjusted_pt(p.x(), p.y());
|
||||
QVector2D diff(adjusted_pt.x() - gizmo_drag_start_.x(), adjusted_pt.y() - gizmo_drag_start_.y());
|
||||
|
||||
if (gizmo_drag_ == kGizmoWholeRect) {
|
||||
// Simply move position by difference
|
||||
gizmo_dragger_[kGDPosX].Drag(gizmo_pos_start_.x() + diff.x());
|
||||
gizmo_dragger_[kGDPosY].Drag(gizmo_pos_start_.y() + diff.y());
|
||||
} else {
|
||||
|
||||
QVector2D new_size;
|
||||
QVector2D new_pos;
|
||||
QVector2D anchor;
|
||||
static const int kXYCount = 2;
|
||||
bool negative[kXYCount] = {false};
|
||||
|
||||
// Calculate new size
|
||||
if (from_center) {
|
||||
// Calculate new size by using distance from center and doubling it
|
||||
new_size = (adjusted_pt - gizmo_half_res_ - gizmo_pos_start_) * 2;
|
||||
|
||||
if (gizmo_drag_ == kGizmoScaleTopCenter || gizmo_drag_ == kGizmoScaleTopLeft || gizmo_drag_ == kGizmoScaleTopRight) {
|
||||
new_size.setY(-new_size.y());
|
||||
}
|
||||
|
||||
if (gizmo_drag_ == kGizmoScaleTopLeft || gizmo_drag_ == kGizmoScaleCenterLeft || gizmo_drag_ == kGizmoScaleBottomLeft) {
|
||||
new_size.setX(-new_size.x());
|
||||
}
|
||||
} else {
|
||||
// Calculate new size by using distance from "anchor" - i.e. the opposite point of the shape
|
||||
// from the gizmo being dragged
|
||||
adjusted_pt -= gizmo_half_res_;
|
||||
|
||||
anchor = GenerateGizmoAnchor(gizmo_pos_start_, gizmo_sz_start_, gizmo_drag_, &adjusted_pt) + gizmo_half_res_;
|
||||
|
||||
adjusted_pt += gizmo_half_res_;
|
||||
|
||||
// Calculate size and position
|
||||
new_size = adjusted_pt - anchor;
|
||||
|
||||
// Abs size so neither coord is negative
|
||||
for (int i=0; i<kXYCount; i++) {
|
||||
if (new_size[i] < 0) {
|
||||
negative[i] = true;
|
||||
new_size[i] = -new_size[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restrict sizes by constraints
|
||||
if (gizmo_drag_ == kGizmoScaleTopCenter || gizmo_drag_ == kGizmoScaleBottomCenter) {
|
||||
if (keep_ratio) {
|
||||
// Calculate width from new height
|
||||
new_size.setX(new_size.y() * gizmo_aspect_ratio_);
|
||||
} else {
|
||||
// Constrain to original width
|
||||
new_size.setX(gizmo_sz_start_.x());
|
||||
}
|
||||
}
|
||||
|
||||
if (gizmo_drag_ == kGizmoScaleCenterLeft || gizmo_drag_ == kGizmoScaleCenterRight) {
|
||||
if (keep_ratio) {
|
||||
// Calculate height from new width
|
||||
new_size.setY(new_size.x() / gizmo_aspect_ratio_);
|
||||
} else {
|
||||
// Constrain to original height
|
||||
new_size.setY(gizmo_sz_start_.y());
|
||||
}
|
||||
}
|
||||
|
||||
if (gizmo_drag_ == kGizmoScaleTopLeft || gizmo_drag_ == kGizmoScaleTopRight
|
||||
|| gizmo_drag_ == kGizmoScaleBottomRight || gizmo_drag_ == kGizmoScaleBottomLeft) {
|
||||
if (keep_ratio) {
|
||||
float hypot = std::hypot(new_size.x(), new_size.y());
|
||||
|
||||
float original_angle = std::atan2(gizmo_sz_start_.x(), gizmo_sz_start_.y());
|
||||
|
||||
// Calculate new size based on original angle and hypotenuse
|
||||
new_size.setX(std::sin(original_angle) * hypot);
|
||||
new_size.setY(std::cos(original_angle) * hypot);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate position
|
||||
if (from_center) {
|
||||
new_pos = gizmo_pos_start_;
|
||||
} else {
|
||||
QVector2D using_size = new_size;
|
||||
|
||||
// Un-abs size
|
||||
for (int i=0; i<kXYCount; i++) {
|
||||
if (negative[i]) {
|
||||
using_size[i] = -using_size[i];
|
||||
}
|
||||
}
|
||||
|
||||
// I'm pretty sure there's an algorithmic way of doing this, but I'm tired and this works
|
||||
if (gizmo_drag_ == kGizmoScaleCenterLeft || gizmo_drag_ == kGizmoScaleCenterRight) {
|
||||
using_size.setY(0);
|
||||
}
|
||||
|
||||
if (gizmo_drag_ == kGizmoScaleTopCenter || gizmo_drag_ == kGizmoScaleBottomCenter) {
|
||||
using_size.setX(0);
|
||||
}
|
||||
|
||||
new_pos = GenerateGizmoAnchor(gizmo_pos_start_, gizmo_sz_start_, gizmo_drag_) + using_size / 2;
|
||||
}
|
||||
|
||||
gizmo_dragger_[kGDPosX].Drag(new_pos.x());
|
||||
gizmo_dragger_[kGDPosY].Drag(new_pos.y());
|
||||
gizmo_dragger_[kGDSzX].Drag(new_size.x());
|
||||
gizmo_dragger_[kGDSzY].Drag(new_size.y());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNodeBase::GizmoRelease()
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
for (NodeInputDragger& i : gizmo_dragger_) {
|
||||
i.End(command);
|
||||
}
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
gizmo_dragger_.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef SHAPENODEBASE_H
|
||||
#define SHAPENODEBASE_H
|
||||
|
||||
#include "node/inputdragger.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -39,6 +40,33 @@ public:
|
||||
static QString kSizeInput;
|
||||
static QString kColorInput;
|
||||
|
||||
virtual bool HasGizmos() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p) override;
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow& row, const NodeGlobals &globals, const QPointF &p) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers) override;
|
||||
virtual void GizmoRelease() override;
|
||||
|
||||
private:
|
||||
static QVector2D GenerateGizmoAnchor(const QVector2D &pos, const QVector2D &size, int drag, QVector2D *pt);
|
||||
|
||||
// Gizmo variables
|
||||
static const int kGizmoWholeRect = kGizmoScaleCount;
|
||||
QRectF gizmo_resize_handle_[kGizmoScaleCount];
|
||||
QRectF gizmo_whole_rect_;
|
||||
|
||||
int gizmo_drag_;
|
||||
QVector<NodeInputDragger> gizmo_dragger_;
|
||||
QVector2D gizmo_pos_start_;
|
||||
QVector2D gizmo_sz_start_;
|
||||
QPointF gizmo_drag_start_;
|
||||
float gizmo_aspect_ratio_;
|
||||
QVector2D gizmo_half_res_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
int NodeInputDragger::input_being_dragged = 0;
|
||||
|
||||
NodeInputDragger::NodeInputDragger()
|
||||
{
|
||||
|
||||
@@ -48,6 +50,7 @@ void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, const rati
|
||||
|
||||
// Cache current value
|
||||
start_value_ = node->GetSplitValueAtTimeOnTrack(input_, time);
|
||||
end_value_ = start_value_;
|
||||
|
||||
// Determine whether we are creating a keyframe or not
|
||||
if (input_.input().IsKeyframing()) {
|
||||
@@ -76,6 +79,8 @@ void NodeInputDragger::Start(const NodeKeyframeTrackReference &input, const rati
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input_being_dragged++;
|
||||
}
|
||||
|
||||
void NodeInputDragger::Drag(QVariant value)
|
||||
@@ -115,13 +120,13 @@ void NodeInputDragger::Drag(QVariant value)
|
||||
//input_->blockSignals(false);
|
||||
}
|
||||
|
||||
void NodeInputDragger::End()
|
||||
void NodeInputDragger::End(MultiUndoCommand* command)
|
||||
{
|
||||
if (!IsStarted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MultiUndoCommand* command = new MultiUndoCommand();
|
||||
input_being_dragged--;
|
||||
|
||||
if (input_.input().node()->IsInputKeyframing(input_.input())) {
|
||||
for (int i=0; i<created_keys_.size(); i++) {
|
||||
@@ -138,8 +143,6 @@ void NodeInputDragger::End()
|
||||
command->add_child(new NodeParamSetStandardValueCommand(input_, end_value_, start_value_));
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
|
||||
input_.Reset();
|
||||
created_keys_.clear();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "common/rational.h"
|
||||
#include "node/keyframe.h"
|
||||
#include "node/param.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -38,7 +39,12 @@ public:
|
||||
|
||||
void Drag(QVariant value);
|
||||
|
||||
void End();
|
||||
void End(MultiUndoCommand *command);
|
||||
|
||||
static bool IsInputBeingDragged()
|
||||
{
|
||||
return input_being_dragged;
|
||||
}
|
||||
|
||||
private:
|
||||
NodeKeyframeTrackReference input_;
|
||||
@@ -52,6 +58,8 @@ private:
|
||||
NodeKeyframe* dragging_key_;
|
||||
QVector<NodeKeyframe*> created_keys_;
|
||||
|
||||
static int input_being_dragged;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1451,7 +1451,7 @@ bool Node::GizmoPress(const NodeValueRow &, const NodeGlobals &, const QPointF &
|
||||
return false;
|
||||
}
|
||||
|
||||
void Node::GizmoMove(const QPointF &, const rational&)
|
||||
void Node::GizmoMove(const QPointF &, const rational&, const Qt::KeyboardModifiers &)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -760,7 +760,7 @@ public:
|
||||
virtual void DrawGizmos(const NodeValueRow& row, const NodeGlobals &globals, QPainter* p);
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow& row, const NodeGlobals &globals, const QPointF& p);
|
||||
virtual void GizmoMove(const QPointF& p, const rational &time);
|
||||
virtual void GizmoMove(const QPointF& p, const rational &time, const Qt::KeyboardModifiers &modifiers);
|
||||
virtual void GizmoRelease();
|
||||
|
||||
const QString& GetLabel() const;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
#include "codec/conformmanager.h"
|
||||
#include "node/inputdragger.h"
|
||||
#include "node/project/project.h"
|
||||
#include "render/rendermanager.h"
|
||||
#include "render/renderprocessor.h"
|
||||
@@ -107,7 +108,7 @@ void PreviewAutoCacher::VideoInvalidated(const TimeRange &range)
|
||||
CancelVideoTasks();
|
||||
|
||||
// If a slider is not being dragged, queue up to hash these frames
|
||||
if (!NumericSliderBase::IsEffectsSliderBeingDragged()) {
|
||||
if (!NodeInputDragger::IsInputBeingDragged()) {
|
||||
invalidated_video_.insert(range);
|
||||
video_job_tracker_.insert(range, graph_changed_time_);
|
||||
|
||||
|
||||
@@ -87,6 +87,9 @@ public:
|
||||
/// A video clip showing a generic video placeholder
|
||||
kAddableBars,
|
||||
|
||||
/// A video clip showing a primitive shape
|
||||
kAddableShape,
|
||||
|
||||
/// A video clip with a solid connected
|
||||
kAddableSolid,
|
||||
|
||||
@@ -109,6 +112,8 @@ public:
|
||||
return QCoreApplication::translate("Tool", "Empty");
|
||||
case kAddableBars:
|
||||
return QCoreApplication::translate("Tool", "Bars");
|
||||
case kAddableShape:
|
||||
return QCoreApplication::translate("Tool", "Shape");
|
||||
case kAddableSolid:
|
||||
return QCoreApplication::translate("Tool", "Solid");
|
||||
case kAddableTitle:
|
||||
|
||||
@@ -253,7 +253,10 @@ void NodeParamViewWidgetBridge::ProcessSlider(NumericSliderBase *slider, const Q
|
||||
|
||||
// We were dragging and just stopped
|
||||
dragger_.Drag(value);
|
||||
dragger_.End();
|
||||
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
dragger_.End(command);
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -404,7 +407,6 @@ void NodeParamViewWidgetBridge::CreateSliders(int count)
|
||||
T* fs = new T();
|
||||
fs->SliderBase::SetDefaultValue(input_.GetSplitDefaultValueForTrack(i));
|
||||
fs->SetLadderElementCount(2);
|
||||
fs->SetIsEffectsSlider(true);
|
||||
widgets_.append(fs);
|
||||
connect(fs, &T::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
}
|
||||
|
||||
@@ -37,8 +37,7 @@ NumericSliderBase::NumericSliderBase(QWidget *parent) :
|
||||
has_max_(false),
|
||||
dragged_diff_(0),
|
||||
drag_multiplier_(1.0),
|
||||
setting_drag_value_(false),
|
||||
is_effects_slider_(false)
|
||||
setting_drag_value_(false)
|
||||
{
|
||||
// Numeric sliders are draggable, so we have a cursor that indicates that
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
@@ -64,10 +63,6 @@ void NumericSliderBase::LabelPressed()
|
||||
|
||||
connect(drag_ladder_, &SliderLadder::DraggedByValue, this, &NumericSliderBase::LadderDragged);
|
||||
connect(drag_ladder_, &SliderLadder::Released, this, &NumericSliderBase::LadderReleased);
|
||||
|
||||
if (is_effects_slider_) {
|
||||
SetEffectsSliderIsBeingDragged(true);
|
||||
}
|
||||
}
|
||||
|
||||
void NumericSliderBase::LadderDragged(int value, double multiplier)
|
||||
@@ -98,10 +93,6 @@ void NumericSliderBase::LadderDragged(int value, double multiplier)
|
||||
|
||||
void NumericSliderBase::LadderReleased()
|
||||
{
|
||||
if (is_effects_slider_) {
|
||||
SetEffectsSliderIsBeingDragged(false);
|
||||
}
|
||||
|
||||
drag_ladder_->deleteLater();
|
||||
drag_ladder_ = nullptr;
|
||||
dragged_diff_ = 0;
|
||||
|
||||
@@ -42,11 +42,6 @@ public:
|
||||
|
||||
bool IsDragging() const;
|
||||
|
||||
void SetIsEffectsSlider(bool e) {is_effects_slider_ = e;}
|
||||
|
||||
static bool IsEffectsSliderBeingDragged() { return effects_slider_is_being_dragged_; }
|
||||
void SetEffectsSliderIsBeingDragged(bool e) { effects_slider_is_being_dragged_ = e; }
|
||||
|
||||
protected:
|
||||
const QVariant& GetOffset() const
|
||||
{
|
||||
@@ -92,8 +87,6 @@ private:
|
||||
|
||||
bool setting_drag_value_;
|
||||
|
||||
bool is_effects_slider_;
|
||||
|
||||
/**
|
||||
* @brief An effects slider somewhere is being dragged
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "core.h"
|
||||
#include "node/block/subtitle/subtitle.h"
|
||||
#include "node/factory.h"
|
||||
#include "node/generator/shape/shapenode.h"
|
||||
#include "node/generator/solid/solid.h"
|
||||
#include "node/generator/text/text.h"
|
||||
#include "widget/timelinewidget/timelinewidget.h"
|
||||
@@ -51,6 +52,7 @@ void AddTool::MousePress(TimelineViewMouseEvent *event)
|
||||
case olive::Tool::kAddableBars:
|
||||
case olive::Tool::kAddableSolid:
|
||||
case olive::Tool::kAddableTitle:
|
||||
case olive::Tool::kAddableShape:
|
||||
add_type = Track::kVideo;
|
||||
break;
|
||||
case olive::Tool::kAddableTone:
|
||||
@@ -131,6 +133,9 @@ void AddTool::MouseRelease(TimelineViewMouseEvent *event)
|
||||
node_to_add = new SolidGenerator();
|
||||
break;
|
||||
}
|
||||
case olive::Tool::kAddableShape:
|
||||
node_to_add = new ShapeNode();
|
||||
break;
|
||||
case olive::Tool::kAddableTitle:
|
||||
{
|
||||
node_to_add = new TextGenerator();
|
||||
|
||||
@@ -246,7 +246,8 @@ void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
// Signal movement
|
||||
gizmos_->GizmoMove(TransformViewerSpaceToBufferSpace(event->pos()),
|
||||
gizmo_drag_time_);
|
||||
gizmo_drag_time_,
|
||||
event->modifiers());
|
||||
gizmo_start_drag_ = event->pos();
|
||||
update();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user