PolygonGenerator: Finished main implementation
It's been 84 years, but the polygon generator not only works, but now has bezier support. The UI could still use some work, but this was the hardest part. I guess complex masking should be possible now, if perhaps slightly cumbersome until the UI is smoothed out.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_subdirectory(audiomonitor)
|
||||
add_subdirectory(bezier)
|
||||
add_subdirectory(clickablelabel)
|
||||
add_subdirectory(collapsebutton)
|
||||
add_subdirectory(colorbutton)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2021 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/bezier/bezierwidget.cpp
|
||||
widget/bezier/bezierwidget.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,101 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "bezierwidget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
|
||||
namespace olive {
|
||||
|
||||
BezierWidget::BezierWidget(QWidget *parent) :
|
||||
QWidget{parent}
|
||||
{
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
|
||||
int row = 0;
|
||||
|
||||
layout->addWidget(new QLabel(tr("Center:")), row, 0);
|
||||
|
||||
x_slider_ = new FloatSlider();
|
||||
connect(x_slider_, &FloatSlider::ValueChanged, this, &BezierWidget::ValueChanged);
|
||||
layout->addWidget(x_slider_, row, 1);
|
||||
|
||||
y_slider_ = new FloatSlider();
|
||||
connect(y_slider_, &FloatSlider::ValueChanged, this, &BezierWidget::ValueChanged);
|
||||
layout->addWidget(y_slider_, row, 2);
|
||||
|
||||
row++;
|
||||
|
||||
QGroupBox *bezier_group = new QGroupBox(tr("Bezier"));
|
||||
layout->addWidget(bezier_group, row, 0, 1, 3);
|
||||
|
||||
QGridLayout *bezier_layout = new QGridLayout(bezier_group);
|
||||
|
||||
row = 0;
|
||||
|
||||
bezier_layout->addWidget(new QLabel(tr("In:")), row, 0);
|
||||
|
||||
cp1_x_slider_ = new FloatSlider();
|
||||
connect(cp1_x_slider_, &FloatSlider::ValueChanged, this, &BezierWidget::ValueChanged);
|
||||
bezier_layout->addWidget(cp1_x_slider_, row, 1);
|
||||
|
||||
cp1_y_slider_ = new FloatSlider();
|
||||
connect(cp1_y_slider_, &FloatSlider::ValueChanged, this, &BezierWidget::ValueChanged);
|
||||
bezier_layout->addWidget(cp1_y_slider_, row, 2);
|
||||
|
||||
row++;
|
||||
|
||||
bezier_layout->addWidget(new QLabel(tr("Out:")), row, 0);
|
||||
|
||||
cp2_x_slider_ = new FloatSlider();
|
||||
connect(cp2_x_slider_, &FloatSlider::ValueChanged, this, &BezierWidget::ValueChanged);
|
||||
bezier_layout->addWidget(cp2_x_slider_, row, 1);
|
||||
|
||||
cp2_y_slider_ = new FloatSlider();
|
||||
connect(cp2_y_slider_, &FloatSlider::ValueChanged, this, &BezierWidget::ValueChanged);
|
||||
bezier_layout->addWidget(cp2_y_slider_, row, 2);
|
||||
}
|
||||
|
||||
Bezier BezierWidget::GetValue() const
|
||||
{
|
||||
Bezier b;
|
||||
|
||||
b.set_x(x_slider_->GetValue());
|
||||
b.set_y(y_slider_->GetValue());
|
||||
b.set_cp1_x(cp1_x_slider_->GetValue());
|
||||
b.set_cp1_y(cp1_y_slider_->GetValue());
|
||||
b.set_cp2_x(cp2_x_slider_->GetValue());
|
||||
b.set_cp2_y(cp2_y_slider_->GetValue());
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void BezierWidget::SetValue(const Bezier &b)
|
||||
{
|
||||
x_slider_->SetValue(b.x());
|
||||
y_slider_->SetValue(b.y());
|
||||
cp1_x_slider_->SetValue(b.cp1_x());
|
||||
cp1_y_slider_->SetValue(b.cp1_y());
|
||||
cp2_x_slider_->SetValue(b.cp2_x());
|
||||
cp2_y_slider_->SetValue(b.cp2_y());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef BEZIERWIDGET_H
|
||||
#define BEZIERWIDGET_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QWidget>
|
||||
|
||||
#include "common/bezier.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class BezierWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BezierWidget(QWidget *parent = nullptr);
|
||||
|
||||
Bezier GetValue() const;
|
||||
|
||||
void SetValue(const Bezier &b);
|
||||
|
||||
FloatSlider *x_slider() const { return x_slider_; }
|
||||
|
||||
FloatSlider *y_slider() const { return y_slider_; }
|
||||
|
||||
FloatSlider *cp1_x_slider() const { return cp1_x_slider_; }
|
||||
|
||||
FloatSlider *cp1_y_slider() const { return cp1_y_slider_; }
|
||||
|
||||
FloatSlider *cp2_x_slider() const { return cp2_x_slider_; }
|
||||
|
||||
FloatSlider *cp2_y_slider() const { return cp2_y_slider_; }
|
||||
|
||||
signals:
|
||||
void ValueChanged();
|
||||
|
||||
private:
|
||||
FloatSlider *x_slider_;
|
||||
|
||||
FloatSlider *y_slider_;
|
||||
|
||||
FloatSlider *cp1_x_slider_;
|
||||
|
||||
FloatSlider *cp1_y_slider_;
|
||||
|
||||
FloatSlider *cp2_x_slider_;
|
||||
|
||||
FloatSlider *cp2_y_slider_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // BEZIERWIDGET_H
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "nodeparamviewtextedit.h"
|
||||
#include "nodeparamviewundo.h"
|
||||
#include "undo/undostack.h"
|
||||
#include "widget/bezier/bezierwidget.h"
|
||||
#include "widget/colorbutton/colorbutton.h"
|
||||
#include "widget/filefield/filefield.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
@@ -158,6 +159,19 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
connect(font_combobox, &QFontComboBox::currentFontChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kBezier:
|
||||
{
|
||||
BezierWidget *bezier = new BezierWidget();
|
||||
widgets_.append(bezier);
|
||||
|
||||
connect(bezier->x_slider(), &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
connect(bezier->y_slider(), &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
connect(bezier->cp1_x_slider(), &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
connect(bezier->cp1_y_slider(), &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
connect(bezier->cp2_x_slider(), &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
connect(bezier->cp2_y_slider(), &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check all properties
|
||||
@@ -220,10 +234,8 @@ void NodeParamViewWidgetBridge::SetInputValueInternal(const QVariant &value, int
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewWidgetBridge::ProcessSlider(NumericSliderBase *slider, const QVariant &value)
|
||||
void NodeParamViewWidgetBridge::ProcessSlider(NumericSliderBase *slider, int slider_track, const QVariant &value)
|
||||
{
|
||||
int slider_track = widgets_.indexOf(slider);
|
||||
|
||||
if (slider->IsDragging()) {
|
||||
|
||||
// While we're dragging, we block the input's normal signalling and create our own
|
||||
@@ -371,11 +383,38 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
if (cb->itemData(i, Qt::AccessibleDescriptionRole).toString() == QStringLiteral("separator")) {
|
||||
index--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SetInputValue(index, 0);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kBezier:
|
||||
{
|
||||
// Widget is a FloatSlider (child of BezierWidget)
|
||||
BezierWidget *bw = static_cast<BezierWidget*>(widgets_.first());
|
||||
FloatSlider *fs = static_cast<FloatSlider*>(sender());
|
||||
|
||||
int index = -1;
|
||||
if (fs == bw->x_slider()) {
|
||||
index = 0;
|
||||
} else if (fs == bw->y_slider()) {
|
||||
index = 1;
|
||||
} else if (fs == bw->cp1_x_slider()) {
|
||||
index = 2;
|
||||
} else if (fs == bw->cp1_y_slider()) {
|
||||
index = 3;
|
||||
} else if (fs == bw->cp2_x_slider()) {
|
||||
index = 4;
|
||||
} else if (fs == bw->cp2_y_slider()) {
|
||||
index = 5;
|
||||
}
|
||||
|
||||
if (index != -1) {
|
||||
ProcessSlider(fs, index, fs->GetValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,6 +548,12 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
|
||||
cb->blockSignals(false);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kBezier:
|
||||
{
|
||||
BezierWidget* bw = static_cast<BezierWidget*>(widgets_.first());
|
||||
bw->SetValue(GetInnerInput().GetValueAtTime(node_time).value<Bezier>());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,11 @@ private:
|
||||
|
||||
void SetInputValueInternal(const QVariant& value, int track, MultiUndoCommand *command, bool insert_on_all_tracks_if_no_key);
|
||||
|
||||
void ProcessSlider(NumericSliderBase* slider, const QVariant& value);
|
||||
void ProcessSlider(NumericSliderBase* slider, int slider_track, const QVariant& value);
|
||||
void ProcessSlider(NumericSliderBase* slider, const QVariant& value)
|
||||
{
|
||||
ProcessSlider(slider, widgets_.indexOf(slider), value);
|
||||
}
|
||||
|
||||
void SetProperty(const QString &key, const QVariant &value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user