decoupled ui from effect row

This commit is contained in:
itsmattkc
2019-03-12 20:12:12 +11:00
parent 170fe9bd01
commit 0b090ddc21
45 changed files with 416 additions and 432 deletions
+2 -2
View File
@@ -21,13 +21,13 @@
#include <QtMath>
AudioNoiseEffect::AudioNoiseEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* amount_row = add_row(tr("Amount"));
EffectRow* amount_row = new EffectRow(this, tr("Amount"));
amount_val = new DoubleField(amount_row, "amount");
amount_val->SetMinimum(0);
amount_val->SetDefault(20);
amount_val->SetMaximum(100);
EffectRow* mix_row = add_row(tr("Mix"));
EffectRow* mix_row = new EffectRow(this, tr("Mix"));
mix_val = new BoolField(mix_row, "mix");
mix_val->SetValueAt(0, true);
}
+5 -5
View File
@@ -27,23 +27,23 @@
CornerPinEffect::CornerPinEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
SetFlags(Effect::CoordsFlag & Effect::ShaderFlag);
EffectRow* top_left = add_row(tr("Top Left"));
EffectRow* top_left = new EffectRow(this, tr("Top Left"));
top_left_x = new DoubleField(top_left, "topleftx");
top_left_y = new DoubleField(top_left, "toplefty");
EffectRow* top_right = add_row(tr("Top Right"));
EffectRow* top_right = new EffectRow(this, tr("Top Right"));
top_right_x = new DoubleField(top_right, "toprightx");
top_right_y = new DoubleField(top_right, "toprighty");
EffectRow* bottom_left = add_row(tr("Bottom Left"));
EffectRow* bottom_left = new EffectRow(this, tr("Bottom Left"));
bottom_left_x = new DoubleField(bottom_left, "bottomleftx");
bottom_left_y = new DoubleField(bottom_left, "bottomlefty");
EffectRow* bottom_right = add_row(tr("Bottom Right"));
EffectRow* bottom_right = new EffectRow(this, tr("Bottom Right"));
bottom_right_x = new DoubleField(bottom_right, "bottomrightx");
bottom_right_y = new DoubleField(bottom_right, "bottomrighty");
EffectRow* perspective_row = add_row(tr("Perspective"));
EffectRow* perspective_row = new EffectRow(this, tr("Perspective"));
perspective = new BoolField(perspective_row, "perspective");
perspective->SetValueAt(0, true);
+1 -1
View File
@@ -24,7 +24,7 @@
#define FILL_TYPE_RIGHT 1
FillLeftRightEffect::FillLeftRightEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* type_row = add_row(tr("Type"));
EffectRow* type_row = new EffectRow(this, tr("Type"));
fill_type = new ComboField(type_row, "type");
fill_type->AddItem(tr("Fill Left with Right"), FILL_TYPE_LEFT);
fill_type->AddItem(tr("Fill Right with Left"), FILL_TYPE_RIGHT);
+7 -7
View File
@@ -92,7 +92,7 @@ Frei0rEffect::Frei0rEffect(Clip* c, const EffectMeta *em) :
get_param_info(&param_info, i);
if (param_info.type >= 0 && param_info.type <= F0R_PARAM_STRING) {
EffectRow* row = add_row(param_info.name);
EffectRow* row = new EffectRow(this, param_info.name);
switch (param_info.type) {
case F0R_PARAM_BOOL:
new BoolField(row, QString::number(i));
@@ -147,19 +147,19 @@ void Frei0rEffect::process_image(double timecode, uint8_t *input, uint8_t *outpu
switch (param_info.type) {
case F0R_PARAM_BOOL:
{
double b = param_row->field(0)->GetValueAt(timecode).toBool();
double b = param_row->Field(0)->GetValueAt(timecode).toBool();
set_param(instance, &b, i);
}
break;
case F0R_PARAM_DOUBLE:
{
double d = param_row->field(0)->GetValueAt(timecode).toDouble()*0.01;
double d = param_row->Field(0)->GetValueAt(timecode).toDouble()*0.01;
set_param(instance, &d, i);
}
break;
case F0R_PARAM_COLOR:
{
QColor qcolor = param_row->field(0)->GetValueAt(timecode).value<QColor>();
QColor qcolor = param_row->Field(0)->GetValueAt(timecode).value<QColor>();
f0r_param_color fcolor;
fcolor.r = float(qcolor.redF());
@@ -172,14 +172,14 @@ void Frei0rEffect::process_image(double timecode, uint8_t *input, uint8_t *outpu
case F0R_PARAM_POSITION:
{
f0r_param_position pos;
pos.x = param_row->field(0)->GetValueAt(timecode).toDouble();
pos.y = param_row->field(1)->GetValueAt(timecode).toDouble();
pos.x = param_row->Field(0)->GetValueAt(timecode).toDouble();
pos.y = param_row->Field(1)->GetValueAt(timecode).toDouble();
set_param(instance, &pos, i);
}
break;
case F0R_PARAM_STRING:
{
QByteArray bytes = param_row->field(0)->GetValueAt(timecode).toString().toUtf8();
QByteArray bytes = param_row->Field(0)->GetValueAt(timecode).toString().toUtf8();
char* byte_data = bytes.data();
set_param(instance, &byte_data, i);
}
+1 -1
View File
@@ -29,7 +29,7 @@
#include "ui/collapsiblewidget.h"
PanEffect::PanEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* pan_row = add_row(tr("Pan"));
EffectRow* pan_row = new EffectRow(this, tr("Pan"));
pan_val = new DoubleField(pan_row, "pan");
pan_val->SetMinimum(-100);
pan_val->SetDefault(0);
+3 -3
View File
@@ -36,17 +36,17 @@
ShakeEffect::ShakeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
SetFlags(Effect::CoordsFlag);
EffectRow* intensity_row = add_row(tr("Intensity"));
EffectRow* intensity_row = new EffectRow(this, tr("Intensity"));
intensity_val = new DoubleField(intensity_row, "intensity");
intensity_val->SetMinimum(0);
intensity_val->SetDefault(25);
EffectRow* rotation_row = add_row(tr("Rotation"));
EffectRow* rotation_row = new EffectRow(this, tr("Rotation"));
rotation_val = new DoubleField(rotation_row, "rotation");
rotation_val->SetMinimum(0);
rotation_val->SetDefault(10);
EffectRow* frequency_row = add_row(tr("Frequency"));
EffectRow* frequency_row = new EffectRow(this, tr("Frequency"));
frequency_val = new DoubleField(frequency_row, "frequency");
frequency_val->SetMinimum(0);
frequency_val->SetDefault(5);
+4 -4
View File
@@ -40,23 +40,23 @@ SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) :
SetFlags(Effect::SuperimposeFlag);
// Field for solid type
EffectRow* type_row = add_row(tr("Type"));
EffectRow* type_row = new EffectRow(this, tr("Type"));
solid_type = new ComboField(type_row, "type");
solid_type->AddItem(tr("Solid Color"), SOLID_TYPE_COLOR);
solid_type->AddItem(tr("SMPTE Bars"), SOLID_TYPE_BARS);
solid_type->AddItem(tr("Checkerboard"), SOLID_TYPE_CHECKERBOARD);
EffectRow* opacity_row = add_row(tr("Opacity"));
EffectRow* opacity_row = new EffectRow(this, tr("Opacity"));
opacity_field = new DoubleField(opacity_row, "opacity");
opacity_field->SetMinimum(0);
opacity_field->SetDefault(0);
opacity_field->SetMaximum(100);
EffectRow* solid_color_row = add_row(tr("Color"));
EffectRow* solid_color_row = new EffectRow(this, tr("Color"));
solid_color_field = new ColorField(solid_color_row, "color");
solid_color_field->SetValueAt(0, QColor(Qt::red));
EffectRow* checkerboard_size = add_row(tr("Checkerboard Size"));
EffectRow* checkerboard_size = new EffectRow(this, tr("Checkerboard Size"));
checkerboard_size_field = new DoubleField(checkerboard_size, "checker_size");
checkerboard_size_field->SetMinimum(1);
checkerboard_size_field->SetDefault(10);
+16 -16
View File
@@ -47,24 +47,24 @@ TextEffect::TextEffect(Clip* c, const EffectMeta* em) :
{
SetFlags(Effect::SuperimposeFlag);
EffectRow* text_field = add_row(tr("Text"));
EffectRow* text_field = new EffectRow(this, tr("Text"));
text_val = new StringField(text_field, "text");
text_val->SetColumnSpan(2);
EffectRow* font_row = add_row(tr("Font"));
EffectRow* font_row = new EffectRow(this, tr("Font"));
set_font_combobox = new FontField(font_row, "font");
set_font_combobox->SetColumnSpan(2);
EffectRow* size_row = add_row(tr("Size"));
EffectRow* size_row = new EffectRow(this, tr("Size"));
size_val = new DoubleField(size_row, "size");
size_val->SetMinimum(0);
size_val->SetColumnSpan(2);
EffectRow* color_row = add_row(tr("Color"));
EffectRow* color_row = new EffectRow(this, tr("Color"));
set_color_button = new ColorField(color_row, "color");
set_color_button->SetColumnSpan(2);
EffectRow* alignment_row = add_row(tr("Alignment"));
EffectRow* alignment_row = new EffectRow(this, tr("Alignment"));
halign_field = new ComboField(alignment_row, "halign");
halign_field->AddItem(tr("Left"), Qt::AlignLeft);
halign_field->AddItem(tr("Center"), Qt::AlignHCenter);
@@ -76,46 +76,46 @@ TextEffect::TextEffect(Clip* c, const EffectMeta* em) :
valign_field->AddItem(tr("Center"), Qt::AlignVCenter);
valign_field->AddItem(tr("Bottom"), Qt::AlignBottom);
EffectRow* word_wrap_row = add_row(tr("Word Wrap"));
EffectRow* word_wrap_row = new EffectRow(this, tr("Word Wrap"));
word_wrap_field = new BoolField(word_wrap_row, "wordwrap");
word_wrap_field->SetColumnSpan(2);
EffectRow* outline_row = add_row(tr("Outline"));
EffectRow* outline_row = new EffectRow(this, tr("Outline"));
outline_bool = new BoolField(outline_row, "outline");
outline_bool->SetColumnSpan(2);
EffectRow* outline_color_row = add_row(tr("Outline Color"));
EffectRow* outline_color_row = new EffectRow(this, tr("Outline Color"));
outline_color = new ColorField(outline_color_row, "outlinecolor");
outline_color->SetColumnSpan(2);
EffectRow* outline_width_row = add_row(tr("Outline Width"));
EffectRow* outline_width_row = new EffectRow(this, tr("Outline Width"));
outline_width = new DoubleField(outline_width_row, "outlinewidth");
outline_width->SetColumnSpan(2);
outline_width->SetMinimum(0);
EffectRow* shadow_row = add_row(tr("Shadow"));
EffectRow* shadow_row = new EffectRow(this, tr("Shadow"));
shadow_bool = new BoolField(shadow_row, "shadow");
shadow_bool->SetColumnSpan(2);
EffectRow* shadow_color_row = add_row(tr("Shadow Color"));
EffectRow* shadow_color_row = new EffectRow(this, tr("Shadow Color"));
shadow_color = new ColorField(shadow_color_row, "shadowcolor");
shadow_color->SetColumnSpan(2);
EffectRow* shadow_angle_row = add_row(tr("Shadow Angle"));
EffectRow* shadow_angle_row = new EffectRow(this, tr("Shadow Angle"));
shadow_angle = new DoubleField(shadow_angle_row, "shadowangle");
shadow_angle->SetColumnSpan(2);
EffectRow* shadow_distance_row = add_row(tr("Shadow Distance"));
EffectRow* shadow_distance_row = new EffectRow(this, tr("Shadow Distance"));
shadow_distance = new DoubleField(shadow_distance_row, "shadowdistance");
shadow_distance->SetColumnSpan(2);
shadow_distance->SetMinimum(0);
EffectRow* shadow_softness_row = add_row(tr("Shadow Softness"));
EffectRow* shadow_softness_row = new EffectRow(this, tr("Shadow Softness"));
shadow_softness = new DoubleField(shadow_softness_row, "shadowsoftness");
shadow_softness->SetColumnSpan(2);
shadow_softness->SetMinimum(0);
EffectRow* shadow_opacity_row = add_row(tr("Shadow Opacity"));
EffectRow* shadow_opacity_row = new EffectRow(this, tr("Shadow Opacity"));
shadow_opacity = new DoubleField(shadow_opacity_row, "shadowopacity");
shadow_opacity->SetColumnSpan(2);
shadow_opacity->SetMinimum(0);
@@ -145,7 +145,7 @@ TextEffect::TextEffect(Clip* c, const EffectMeta* em) :
fragPath = "dropshadow.frag";
}
void blurred2(QImage& result, const QRect& rect, int radius, bool alphaOnly = false) {
void blurred2(QImage& result, const QRect& rect, int radius, bool alphaOnly) {
int tab[] = { 14, 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2 };
int alpha = (radius < 1) ? 16 : (radius > 17) ? 1 : tab[radius-1];
+7 -7
View File
@@ -49,41 +49,41 @@ TimecodeEffect::TimecodeEffect(Clip* c, const EffectMeta* em) :
SetAlwaysUpdate(true);
SetFlags(Effect::SuperimposeFlag);
EffectRow* tc_row = add_row(tr("Timecode"));
EffectRow* tc_row = new EffectRow(this, tr("Timecode"));
tc_select = new ComboField(tc_row, "tc_selector");
tc_select->AddItem(tr("Sequence"), true);
tc_select->AddItem(tr("Media"), false);
tc_select->SetValueAt(0, true);
EffectRow* scale_row = add_row(tr("Scale"));
EffectRow* scale_row = new EffectRow(this, tr("Scale"));
scale_val = new DoubleField(scale_row, "scale");
scale_val->SetColumnSpan(2);
scale_val->SetMinimum(1);
scale_val->SetDefault(100);
scale_val->SetMaximum(1000);
EffectRow* color_row = add_row(tr("Color"));
EffectRow* color_row = new EffectRow(this, tr("Color"));
color_val = new ColorField(color_row, "color");
color_val->SetColumnSpan(2);
color_val->SetValueAt(0, QColor(Qt::white));
EffectRow* color_bg_row = add_row(tr("Background Color"));
EffectRow* color_bg_row = new EffectRow(this, tr("Background Color"));
color_bg_val = new ColorField(color_bg_row, "bgcolor");
color_bg_val->SetColumnSpan(2);
color_bg_val->SetValueAt(0, QColor(Qt::black));
EffectRow* bg_alpha_row = add_row(tr("Background Opacity"));
EffectRow* bg_alpha_row = new EffectRow(this, tr("Background Opacity"));
bg_alpha = new DoubleField(bg_alpha_row, "bgalpha");
bg_alpha->SetColumnSpan(2);
bg_alpha->SetMinimum(0);
bg_alpha->SetDefault(50);
bg_alpha->SetMaximum(100);
EffectRow* offset_row = add_row(tr("Offset"));
EffectRow* offset_row = new EffectRow(this, tr("Offset"));
offset_x_val = new DoubleField(offset_row, "offsetx");
offset_y_val = new DoubleField(offset_row, "offsety");
EffectRow* prepent_text_row = add_row(tr("Prepend"));
EffectRow* prepent_text_row = new EffectRow(this, tr("Prepend"));
prepend_text = new StringField(prepent_text_row, "prepend");
prepend_text->SetColumnSpan(2);
}
+4 -4
View File
@@ -29,23 +29,23 @@
#include "debug.h"
ToneEffect::ToneEffect(Clip* c, const EffectMeta *em) : Effect(c, em), sinX(INT_MIN) {
EffectRow* type_row = add_row(tr("Type"));
EffectRow* type_row = new EffectRow(this, tr("Type"));
type_val = new ComboField(type_row, "type");
type_val->AddItem(tr("Sine"), TONE_TYPE_SINE);
EffectRow* frequency_row = add_row(tr("Frequency"));
EffectRow* frequency_row = new EffectRow(this, tr("Frequency"));
freq_val = new DoubleField(frequency_row, "frequency");
freq_val->SetMinimum(20);
freq_val->SetMaximum(20000);
freq_val->SetDefault(1000);
EffectRow* amount_row = add_row(tr("Amount"));
EffectRow* amount_row = new EffectRow(this, tr("Amount"));
amount_val = new DoubleField(amount_row, "amount");
amount_val->SetMinimum(0);
amount_val->SetMaximum(100);
amount_val->SetDefault(25);
EffectRow* mix_row = add_row(tr("Mix"));
EffectRow* mix_row = new EffectRow(this, tr("Mix"));
mix_val = new BoolField(mix_row, "mix");
mix_val->SetValueAt(0, true);
}
+7 -7
View File
@@ -46,12 +46,12 @@
TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) {
SetFlags(Effect::CoordsFlag);
EffectRow* position_row = add_row(tr("Position"));
EffectRow* position_row = new EffectRow(this, tr("Position"));
position_x = new DoubleField(position_row, "posx"); // position X
position_y = new DoubleField(position_row, "posy"); // position Y
EffectRow* scale_row = add_row(tr("Scale"));
EffectRow* scale_row = new EffectRow(this, tr("Scale"));
// scale X (and Y is uniform scale is selected)
scale_x = new DoubleField(scale_row, "scalex");
@@ -61,27 +61,27 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em)
scale_y = new DoubleField(scale_row, "scaley");
scale_y->SetMinimum(0);
EffectRow* uniform_scale_row = add_row(tr("Uniform Scale"));
EffectRow* uniform_scale_row = new EffectRow(this, tr("Uniform Scale"));
uniform_scale_field = new BoolField(uniform_scale_row, "uniformscale"); // uniform scale option
EffectRow* rotation_row = add_row(tr("Rotation"));
EffectRow* rotation_row = new EffectRow(this, tr("Rotation"));
rotation = new DoubleField(rotation_row, "rotation");
EffectRow* anchor_point_row = add_row(tr("Anchor Point"));
EffectRow* anchor_point_row = new EffectRow(this, tr("Anchor Point"));
anchor_x_box = new DoubleField(anchor_point_row, "anchorx"); // anchor point X
anchor_y_box = new DoubleField(anchor_point_row, "anchory"); // anchor point Y
EffectRow* opacity_row = add_row(tr("Opacity"));
EffectRow* opacity_row = new EffectRow(this, tr("Opacity"));
// opacity
opacity = new DoubleField(opacity_row, "opacity");
opacity->SetMinimum(0);
opacity->SetMaximum(100);
EffectRow* blend_mode_row = add_row(tr("Blend Mode"));
EffectRow* blend_mode_row = new EffectRow(this, tr("Blend Mode"));
// blend mode
blend_mode_box = new ComboField(blend_mode_row, "blendmode");
+31 -29
View File
@@ -28,36 +28,38 @@
#include "debug.h"
VoidEffect::VoidEffect(Clip* c, const QString& n) : Effect(c, nullptr) {
name = n;
QString display_name;
if (n.isEmpty()) {
display_name = tr("(unknown)");
} else {
display_name = n;
}
EffectRow* row = add_row(tr("Missing Effect"), false, false);
row->add_widget(new QLabel(display_name));
container->setText(display_name);
name = n;
QString display_name;
if (n.isEmpty()) {
display_name = tr("(unknown)");
} else {
display_name = n;
}
EffectRow* row = new EffectRow(this, tr("Missing Effect"), false, false);
void_meta.type = EFFECT_TYPE_EFFECT;
meta = &void_meta;
new LabelField(row, display_name);
container->setText(display_name);
void_meta.type = EFFECT_TYPE_EFFECT;
meta = &void_meta;
}
EffectPtr VoidEffect::copy(Clip* c) {
EffectPtr copy(new VoidEffect(c, name));
copy->set_enabled(is_enabled());
copy_field_keyframes(copy);
return copy;
copy->set_enabled(is_enabled());
copy_field_keyframes(copy);
return copy;
}
void VoidEffect::load(QXmlStreamReader &stream) {
QString tag = stream.name().toString();
QString tag = stream.name().toString();
QXmlStreamWriter writer(&bytes);
// copy XML from reader to writer
while (!stream.atEnd() && !(stream.name() == tag && stream.isEndElement())) {
stream.readNext();
stream.readNext();
if (stream.isStartElement()) {
writer.writeStartElement(stream.name().toString());
@@ -75,18 +77,18 @@ void VoidEffect::load(QXmlStreamReader &stream) {
}
void VoidEffect::save(QXmlStreamWriter &stream) {
if (!name.isEmpty()) {
stream.writeAttribute("name", name);
stream.writeAttribute("enabled", QString::number(is_enabled()));
if (!name.isEmpty()) {
stream.writeAttribute("name", name);
stream.writeAttribute("enabled", QString::number(is_enabled()));
// force xml writer to expand <effect> tag, ignored when loading
stream.writeStartElement("void");
stream.writeEndElement();
// force xml writer to expand <effect> tag, ignored when loading
stream.writeStartElement("void");
stream.writeEndElement();
if (!bytes.isEmpty()) {
// write stored data
QIODevice* device = stream.device();
device->write(bytes);
}
}
if (!bytes.isEmpty()) {
// write stored data
QIODevice* device = stream.device();
device->write(bytes);
}
}
}
+1 -1
View File
@@ -29,7 +29,7 @@
#include "ui/collapsiblewidget.h"
VolumeEffect::VolumeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* volume_row = add_row(tr("Volume"));
EffectRow* volume_row = new EffectRow(this, tr("Volume"));
volume_val = new DoubleField(volume_row, "volume");
// set defaults
+9 -8
View File
@@ -266,16 +266,17 @@ VSTHost::VSTHost(Clip* c, const EffectMeta *em) : Effect(c, em) {
outputs[channel] = new float[BLOCK_SIZE];
}
EffectRow* file_row = add_row(tr("Plugin"), true, false);
EffectRow* file_row = new EffectRow(this, tr("Plugin"), true, false);
file_field = new FileField(file_row, "filename");
connect(file_field, SIGNAL(changed()), this, SLOT(change_plugin()));
EffectRow* interface_row = add_row(tr("Interface"), false, false);
show_interface_btn = new QPushButton(tr("Show"));
show_interface_btn->setCheckable(true);
show_interface_btn->setEnabled(false);
EffectRow* interface_row = new EffectRow(this, tr("Interface"), false, false);
show_interface_btn = new ButtonField(interface_row, tr("Show"));
show_interface_btn->SetCheckable(true);
show_interface_btn->SetEnabled(false);
connect(show_interface_btn, SIGNAL(toggled(bool)), this, SLOT(show_interface(bool)));
interface_row->add_widget(show_interface_btn);
dialog = new QDialog(olive::MainWindow);
dialog->setWindowTitle(tr("VST Plugin"));
@@ -373,7 +374,7 @@ void VSTHost::show_interface(bool show) {
}
void VSTHost::uncheck_show_button() {
show_interface_btn->setChecked(false);
show_interface_btn->SetChecked(false);
}
void VSTHost::change_plugin() {
@@ -395,7 +396,7 @@ void VSTHost::change_plugin() {
plugin = nullptr;
}
}
show_interface_btn->setEnabled(plugin != nullptr);
show_interface_btn->SetEnabled(plugin != nullptr);
}
#endif
+2 -2
View File
@@ -37,7 +37,7 @@ typedef intptr_t (*dispatcherFuncPtr)(AEffect *effect, int32_t opCode, int32_t i
class VSTHost : public Effect {
Q_OBJECT
public:
VSTHost(Clip* c, const EffectMeta* em);
VSTHost(Clip* c, const EffectMeta* em);
~VSTHost();
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
@@ -49,6 +49,7 @@ private slots:
void change_plugin();
private:
FileField* file_field;
ButtonField* show_interface_btn;
void loadPlugin();
void freePlugin();
@@ -64,7 +65,6 @@ private:
float** inputs;
float** outputs;
QDialog* dialog;
QPushButton* show_interface_btn;
QByteArray data_cache;
#if defined(__APPLE__)