code cleanup
This commit is contained in:
+7
-7
@@ -4,15 +4,17 @@
|
||||
#include "project/effect.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QFont>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
class QSpinBox;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class LabelSlider;
|
||||
class QOpenGLTexture;
|
||||
class QTextEdit;
|
||||
class QPushButton;
|
||||
class ColorButton;
|
||||
class ComboBoxEx;
|
||||
|
||||
enum VideoEffects {
|
||||
VIDEO_TRANSFORM_EFFECT,
|
||||
@@ -51,7 +53,7 @@ public:
|
||||
LabelSlider* anchor_x_box;
|
||||
LabelSlider* anchor_y_box;
|
||||
LabelSlider* opacity;
|
||||
QComboBox* blend_mode_box;
|
||||
ComboBoxEx* blend_mode_box;
|
||||
public slots:
|
||||
void toggle_uniform_scale(bool enabled);
|
||||
private:
|
||||
@@ -99,15 +101,13 @@ public:
|
||||
void save(QXmlStreamWriter* stream);
|
||||
QTextEdit* text_val;
|
||||
LabelSlider* size_val;
|
||||
QPushButton* set_color_button;
|
||||
QColor color;
|
||||
ColorButton* set_color_button;
|
||||
ComboBoxEx* set_font_combobox;
|
||||
private slots:
|
||||
void set_color();
|
||||
void update_texture();
|
||||
private:
|
||||
void set_button_color();
|
||||
QPixmap pixmap;
|
||||
QOpenGLTexture* texture;
|
||||
QFont font;
|
||||
};
|
||||
|
||||
// audio effects
|
||||
|
||||
+2
-10
@@ -8,20 +8,12 @@
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
|
||||
PanEffect::PanEffect(Clip* c) : Effect(c) {
|
||||
setup_effect(EFFECT_TYPE_AUDIO, AUDIO_PAN_EFFECT);
|
||||
|
||||
QGridLayout* ui_layout = new QGridLayout();
|
||||
|
||||
PanEffect::PanEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_PAN_EFFECT) {
|
||||
ui_layout->addWidget(new QLabel("Pan:"), 0, 0);
|
||||
pan_val = new LabelSlider();
|
||||
pan_val->set_minimum_value(-100);
|
||||
pan_val->set_maximum_value(100);
|
||||
ui_layout->addWidget(pan_val, 0, 1);
|
||||
|
||||
ui->setLayout(ui_layout);
|
||||
|
||||
container->setContents(ui);
|
||||
ui_layout->addWidget(pan_val, 0, 1);
|
||||
|
||||
// set defaults
|
||||
pan_val->set_value(0);
|
||||
|
||||
@@ -12,11 +12,7 @@
|
||||
#include "project/sequence.h"
|
||||
#include "panels/timeline.h"
|
||||
|
||||
ShakeEffect::ShakeEffect(Clip *c) : Effect(c) {
|
||||
setup_effect(EFFECT_TYPE_VIDEO, VIDEO_SHAKE_EFFECT);
|
||||
|
||||
QGridLayout* ui_layout = new QGridLayout();
|
||||
|
||||
ShakeEffect::ShakeEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SHAKE_EFFECT) {
|
||||
ui_layout->addWidget(new QLabel("Intensity:"), 0, 0);
|
||||
intensity_val = new LabelSlider();
|
||||
intensity_val->set_minimum_value(0);
|
||||
@@ -32,10 +28,6 @@ ShakeEffect::ShakeEffect(Clip *c) : Effect(c) {
|
||||
frequency_val->set_minimum_value(0);
|
||||
ui_layout->addWidget(frequency_val, 2, 1);
|
||||
|
||||
ui->setLayout(ui_layout);
|
||||
|
||||
container->setContents(ui);
|
||||
|
||||
// set defaults
|
||||
intensity_val->set_value(50);
|
||||
rotation_val->set_value(0);
|
||||
|
||||
+52
-42
@@ -7,42 +7,62 @@
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QColorDialog>
|
||||
#include <QFontDatabase>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "project/clip.h"
|
||||
#include "project/sequence.h"
|
||||
#include "ui/comboboxex.h"
|
||||
#include "ui/colorbutton.h"
|
||||
|
||||
TextEffect::TextEffect(Clip *c) : Effect(c), texture(NULL) {
|
||||
setup_effect(EFFECT_TYPE_VIDEO, VIDEO_TEXT_EFFECT);
|
||||
|
||||
QGridLayout* ui_layout = new QGridLayout();
|
||||
class FontCombobox : public ComboBoxEx {
|
||||
public:
|
||||
FontCombobox(QWidget* parent = 0) : ComboBoxEx(parent) {}
|
||||
protected:
|
||||
void showPopup() {
|
||||
QString current = currentText();
|
||||
clear();
|
||||
QStringList fonts = QFontDatabase().families();
|
||||
bool found = false;
|
||||
for (int i=0;i<fonts.size();i++) {
|
||||
addItem(fonts.at(i));
|
||||
if (!found && fonts.at(i) == current) {
|
||||
setCurrentIndex(i);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
QComboBox::showPopup();
|
||||
}
|
||||
};
|
||||
|
||||
TextEffect::TextEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_TEXT_EFFECT), texture(NULL) {
|
||||
ui_layout->addWidget(new QLabel("Text:"), 0, 0);
|
||||
text_val = new QTextEdit();
|
||||
text_val->setUndoRedoEnabled(true);
|
||||
ui_layout->addWidget(text_val, 0, 1);
|
||||
|
||||
ui_layout->addWidget(new QLabel("Size:"), 1, 0);
|
||||
ui_layout->addWidget(new QLabel("Font:"), 1, 0);
|
||||
set_font_combobox = new FontCombobox();
|
||||
ui_layout->addWidget(set_font_combobox, 1, 1);
|
||||
|
||||
ui_layout->addWidget(new QLabel("Size:"), 2, 0);
|
||||
size_val = new LabelSlider();
|
||||
size_val->set_minimum_value(0);
|
||||
ui_layout->addWidget(size_val, 1, 1);
|
||||
ui_layout->addWidget(size_val, 2, 1);
|
||||
|
||||
ui_layout->addWidget(new QLabel("Color:"), 2, 0);
|
||||
set_color_button = new QPushButton();
|
||||
ui_layout->addWidget(set_color_button, 2, 1);
|
||||
ui_layout->addWidget(new QLabel("Color:"), 3, 0);
|
||||
set_color_button = new ColorButton();
|
||||
ui_layout->addWidget(set_color_button, 3, 1);
|
||||
|
||||
ui->setLayout(ui_layout);
|
||||
|
||||
container->setContents(ui);
|
||||
|
||||
color = Qt::white;
|
||||
set_button_color();
|
||||
set_font_combobox->addItem(font.family());
|
||||
|
||||
connect(text_val, SIGNAL(textChanged()), this, SLOT(update_texture()));
|
||||
connect(size_val, SIGNAL(valueChanged()), this, SLOT(update_texture()));
|
||||
connect(set_color_button, SIGNAL(clicked(bool)), this, SLOT(set_color()));
|
||||
connect(set_color_button, SIGNAL(color_changed()), this, SLOT(update_texture()));
|
||||
connect(set_font_combobox, SIGNAL(currentTextChanged(QString)), this, SLOT(update_texture()));
|
||||
|
||||
size_val->set_value(24);
|
||||
text_val->setText("Sample Text");
|
||||
@@ -53,38 +73,27 @@ TextEffect::~TextEffect() {
|
||||
delete texture;
|
||||
}
|
||||
|
||||
void TextEffect::set_button_color() {
|
||||
QPalette pal = set_color_button->palette();
|
||||
pal.setColor(QPalette::Button, color);
|
||||
set_color_button->setPalette(pal);
|
||||
}
|
||||
|
||||
void TextEffect::set_color() {
|
||||
color = QColorDialog::getColor(color, NULL);
|
||||
set_button_color();
|
||||
update_texture();
|
||||
}
|
||||
|
||||
void TextEffect::update_texture() {
|
||||
pixmap = QPixmap(parent_clip->sequence->width, parent_clip->sequence->height);
|
||||
QImage pixmap(parent_clip->sequence->width, parent_clip->sequence->height, QImage::Format_ARGB32_Premultiplied);
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter p(&pixmap);
|
||||
p.setRenderHint(QPainter::TextAntialiasing, true);
|
||||
|
||||
// set font
|
||||
QFont font = p.font();
|
||||
font.setFamily(set_font_combobox->currentText());
|
||||
font.setPointSize(size_val->value());
|
||||
font.setStyleHint(QFont::Helvetica, QFont::PreferAntialias);
|
||||
p.setFont(font);
|
||||
|
||||
p.setPen(color);
|
||||
p.setPen(set_color_button->get_color());
|
||||
p.drawText(QRect(0, 0, pixmap.width(), pixmap.height()), Qt::AlignCenter | Qt::TextWordWrap, text_val->toPlainText());
|
||||
|
||||
if (texture == NULL) {
|
||||
texture = new QOpenGLTexture(pixmap.toImage());
|
||||
texture = new QOpenGLTexture(pixmap);
|
||||
} else {
|
||||
texture->destroy();
|
||||
texture->setData(pixmap.toImage());
|
||||
texture->setData(pixmap);
|
||||
}
|
||||
|
||||
// queue a repaint of the canvas
|
||||
@@ -95,8 +104,8 @@ void TextEffect::post_gl() {
|
||||
if (texture != NULL) {
|
||||
texture->bind();
|
||||
|
||||
int half_width = pixmap.width()/2;
|
||||
int half_height = pixmap.height()/2;
|
||||
int half_width = parent_clip->sequence->width/2;
|
||||
int half_height = parent_clip->sequence->height/2;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
@@ -117,7 +126,7 @@ Effect* TextEffect::copy(Clip* c) {
|
||||
TextEffect* e = new TextEffect(c);
|
||||
e->text_val->setPlainText(text_val->toPlainText());
|
||||
e->size_val->set_value(size_val->value());
|
||||
e->color = color;
|
||||
e->set_color_button->set_color(set_color_button->get_color());
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -128,16 +137,17 @@ void TextEffect::load(QXmlStreamReader* stream) {
|
||||
if (a.name() == "size") {
|
||||
size_val->set_value(a.value().toDouble());
|
||||
} else if (a.name() == "r") {
|
||||
color.setRed(a.value().toInt());
|
||||
set_color_button->get_color().setRed(a.value().toInt());
|
||||
} else if (a.name() == "g") {
|
||||
color.setGreen(a.value().toInt());
|
||||
set_color_button->get_color().setGreen(a.value().toInt());
|
||||
} else if (a.name() == "b") {
|
||||
color.setBlue(a.value().toInt());
|
||||
set_color_button->get_color().setBlue(a.value().toInt());
|
||||
}
|
||||
}
|
||||
while (!(stream->name() == "effect" && stream->isEndElement())) {
|
||||
stream->readNext();
|
||||
if (stream->name() == "text" && stream->isStartElement()) {
|
||||
stream->readNext();
|
||||
text_val->setPlainText(stream->text().toString());
|
||||
}
|
||||
}
|
||||
@@ -145,8 +155,8 @@ void TextEffect::load(QXmlStreamReader* stream) {
|
||||
|
||||
void TextEffect::save(QXmlStreamWriter* stream) {
|
||||
stream->writeAttribute("size", QString::number(size_val->value()));
|
||||
stream->writeAttribute("r", QString::number(color.red()));
|
||||
stream->writeAttribute("g", QString::number(color.green()));
|
||||
stream->writeAttribute("b", QString::number(color.blue()));
|
||||
stream->writeAttribute("r", QString::number(set_color_button->get_color().red()));
|
||||
stream->writeAttribute("g", QString::number(set_color_button->get_color().green()));
|
||||
stream->writeAttribute("b", QString::number(set_color_button->get_color().blue()));
|
||||
stream->writeTextElement("text", text_val->toPlainText());
|
||||
}
|
||||
|
||||
@@ -14,17 +14,14 @@
|
||||
#include "project/sequence.h"
|
||||
#include "io/media.h"
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/comboboxex.h"
|
||||
|
||||
#define BLEND_MODE_NORMAL 0
|
||||
#define BLEND_MODE_SCREEN 1
|
||||
#define BLEND_MODE_MULTIPLY 2
|
||||
#define BLEND_MODE_OVERLAY 3
|
||||
|
||||
TransformEffect::TransformEffect(Clip* c) : Effect(c) {
|
||||
setup_effect(EFFECT_TYPE_VIDEO, VIDEO_TRANSFORM_EFFECT);
|
||||
|
||||
QGridLayout* ui_layout = new QGridLayout();
|
||||
|
||||
TransformEffect::TransformEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_TRANSFORM_EFFECT) {
|
||||
ui_layout->addWidget(new QLabel("Position:"), 0, 0);
|
||||
position_x = new LabelSlider();
|
||||
ui_layout->addWidget(position_x, 0, 1);
|
||||
@@ -63,17 +60,13 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c) {
|
||||
ui_layout->addWidget(opacity, 5, 1);
|
||||
|
||||
ui_layout->addWidget(new QLabel("Blend Mode:"), 6, 0);
|
||||
blend_mode_box = new QComboBox();
|
||||
blend_mode_box = new ComboBoxEx();
|
||||
blend_mode_box->addItem("Normal", BLEND_MODE_NORMAL);
|
||||
blend_mode_box->addItem("Overlay", BLEND_MODE_OVERLAY);
|
||||
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);
|
||||
|
||||
// set defaults
|
||||
position_x->set_default_value(c->sequence->width/2);
|
||||
position_y->set_default_value(c->sequence->height/2);
|
||||
@@ -98,6 +91,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(uniform_scale_box, SIGNAL(clicked(bool)), this, SLOT(checkbox_command()));
|
||||
connect(blend_mode_box, SIGNAL(currentIndexChanged(int)), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,20 +9,12 @@
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
|
||||
VolumeEffect::VolumeEffect(Clip* c) : Effect(c) {
|
||||
setup_effect(EFFECT_TYPE_AUDIO, AUDIO_VOLUME_EFFECT);
|
||||
|
||||
QGridLayout* ui_layout = new QGridLayout();
|
||||
|
||||
ui_layout->addWidget(new QLabel("Volume:"), 0, 0);
|
||||
VolumeEffect::VolumeEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_VOLUME_EFFECT) {
|
||||
ui_layout->addWidget(new QLabel("Volume:"), 0, 0);
|
||||
volume_val = new LabelSlider();
|
||||
volume_val->set_minimum_value(0);
|
||||
volume_val->set_maximum_value(400);
|
||||
ui_layout->addWidget(volume_val, 0, 1);
|
||||
|
||||
ui->setLayout(ui_layout);
|
||||
|
||||
container->setContents(ui);
|
||||
ui_layout->addWidget(volume_val, 0, 1);
|
||||
|
||||
// set defaults
|
||||
volume_val->set_value(100);
|
||||
|
||||
Reference in New Issue
Block a user