blending modes added (#54)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <QXmlStreamWriter>
|
||||
class QSpinBox;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class LabelSlider;
|
||||
|
||||
enum VideoEffects {
|
||||
@@ -43,6 +44,7 @@ public:
|
||||
LabelSlider* anchor_x_box;
|
||||
LabelSlider* anchor_y_box;
|
||||
LabelSlider* opacity;
|
||||
QComboBox* blend_mode_box;
|
||||
public slots:
|
||||
void toggle_uniform_scale(bool enabled);
|
||||
private:
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QSpinBox>
|
||||
#include <QCheckBox>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "project/clip.h"
|
||||
@@ -14,6 +15,10 @@
|
||||
#include "io/media.h"
|
||||
#include "ui/labelslider.h"
|
||||
|
||||
#define BLEND_MODE_NORMAL 0
|
||||
#define BLEND_MODE_SCREEN 1
|
||||
#define BLEND_MODE_MULTIPLY 2
|
||||
|
||||
TransformEffect::TransformEffect(Clip* c) : Effect(c) {
|
||||
setup_effect(EFFECT_TYPE_VIDEO, VIDEO_TRANSFORM_EFFECT);
|
||||
|
||||
@@ -56,6 +61,13 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c) {
|
||||
opacity->set_maximum_value(100);
|
||||
ui_layout->addWidget(opacity, 5, 1);
|
||||
|
||||
ui_layout->addWidget(new QLabel("Blend Mode:"), 6, 0);
|
||||
blend_mode_box = new QComboBox();
|
||||
blend_mode_box->addItem("Normal", BLEND_MODE_NORMAL);
|
||||
blend_mode_box->addItem("Screen", BLEND_MODE_SCREEN);
|
||||
blend_mode_box->addItem("Multiply", BLEND_MODE_MULTIPLY);
|
||||
ui_layout->addWidget(blend_mode_box, 6, 1);
|
||||
|
||||
ui->setLayout(ui_layout);
|
||||
|
||||
container->setContents(ui);
|
||||
@@ -72,6 +84,7 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c) {
|
||||
anchor_x_box->set_default_value(default_anchor_x);
|
||||
anchor_y_box->set_default_value(default_anchor_y);
|
||||
opacity->set_default_value(100);
|
||||
blend_mode_box->setCurrentIndex(0);
|
||||
|
||||
connect(position_x, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
connect(position_y, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
@@ -83,6 +96,7 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c) {
|
||||
connect(opacity, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
connect(uniform_scale_box, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
|
||||
connect(uniform_scale_box, SIGNAL(toggled(bool)), this, SLOT(field_changed()));
|
||||
connect(blend_mode_box, SIGNAL(currentIndexChanged(int)), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
Effect* TransformEffect::copy(Clip* c) {
|
||||
@@ -96,6 +110,7 @@ Effect* TransformEffect::copy(Clip* c) {
|
||||
t->anchor_x_box->set_value(anchor_x_box->value());
|
||||
t->anchor_y_box->set_value(anchor_y_box->value());
|
||||
t->opacity->set_value(opacity->value());
|
||||
t->blend_mode_box->setCurrentIndex(blend_mode_box->currentIndex());
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -129,6 +144,9 @@ void TransformEffect::load(QXmlStreamReader *stream) {
|
||||
} else if (stream->isStartElement() && stream->name() == "opacity") {
|
||||
stream->readNext();
|
||||
opacity->set_value(stream->text().toFloat());
|
||||
} else if (stream->isStartElement() && stream->name() == "blendmode") {
|
||||
stream->readNext();
|
||||
blend_mode_box->setCurrentIndex(stream->text().toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,6 +161,7 @@ void TransformEffect::save(QXmlStreamWriter *stream) {
|
||||
stream->writeTextElement("anchorx", QString::number(anchor_x_box->value()));
|
||||
stream->writeTextElement("anchory", QString::number(anchor_y_box->value()));
|
||||
stream->writeTextElement("opacity", QString::number(opacity->value()));
|
||||
stream->writeTextElement("blendmode", QString::number(blend_mode_box->currentIndex()));
|
||||
}
|
||||
|
||||
void TransformEffect::toggle_uniform_scale(bool enabled) {
|
||||
@@ -165,6 +184,21 @@ void TransformEffect::process_gl(int* anchor_x, int* anchor_y) {
|
||||
float sy = (uniform_scale_box->isChecked()) ? sx : scale_y->value()*0.01;
|
||||
glScalef(sx, sy, 1);
|
||||
|
||||
// blend mode
|
||||
switch (blend_mode_box->currentData().toInt()) {
|
||||
case BLEND_MODE_NORMAL:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
case BLEND_MODE_SCREEN:
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||
break;
|
||||
case BLEND_MODE_MULTIPLY:
|
||||
glBlendFunc(GL_DST_COLOR, GL_ZERO);
|
||||
break;
|
||||
default:
|
||||
qDebug() << "[ERROR] Invalid blend mode. This is a bug - please contact developers";
|
||||
}
|
||||
|
||||
// opacity
|
||||
glColor4f(1.0, 1.0, 1.0, opacity->value()*0.01);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.6.2, 2018-06-23T02:01:56. -->
|
||||
<!-- Written by QtCreator 4.6.2, 2018-06-23T14:26:22. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
+3
-1
@@ -41,7 +41,7 @@ void ViewerWidget::initializeGL() {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
//void ViewerWidget::resizeGL(int w, int h)
|
||||
@@ -58,6 +58,8 @@ void ViewerWidget::paintGL()
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
long playhead = panel_timeline->playhead;
|
||||
|
||||
handle_media(sequence, playhead, multithreaded);
|
||||
|
||||
Reference in New Issue
Block a user