diff --git a/effects/internal/solideffect.cpp b/effects/internal/solideffect.cpp index 41e3e7746..f175ececc 100644 --- a/effects/internal/solideffect.cpp +++ b/effects/internal/solideffect.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "project/clip.h" #include "project/sequence.h" @@ -26,38 +27,32 @@ SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) : Effect(c, em) { solid_type->add_combo_item("Checkerboard", SOLID_TYPE_CHECKERBOARD); solid_type->id = "type"; + opacity_field = add_row("Opacity:")->add_field(EFFECT_FIELD_DOUBLE); + opacity_field->set_double_minimum_value(0); + opacity_field->set_double_maximum_value(100); + opacity_field->set_double_default_value(100); + opacity_field->id = "opacity"; + solid_color_field = add_row("Color:")->add_field(EFFECT_FIELD_COLOR); solid_color_field->set_color_value(Qt::red); solid_color_field->id = "color"; - opacity_field = add_row("Opacity:")->add_field(EFFECT_FIELD_DOUBLE); - opacity_field->set_double_minimum_value(0); - opacity_field->set_double_maximum_value(100); - opacity_field->set_double_default_value(100); - opacity_field->id = "opacity"; - - solid_width_field = add_row("Width:")->add_field(EFFECT_FIELD_DOUBLE); - solid_width_field->set_double_minimum_value(1); - solid_width_field->set_double_maximum_value(c->getWidth()); - solid_width_field->set_double_default_value(c->getWidth() / 10); - solid_width_field->id = "width"; + checkerboard_size_field = add_row("Checkerboard Size:")->add_field(EFFECT_FIELD_DOUBLE); + checkerboard_size_field->set_double_minimum_value(1); + checkerboard_size_field->set_double_default_value(10); + checkerboard_size_field->id = "checker_size"; connect(solid_type, SIGNAL(changed()), this, SLOT(field_changed())); connect(solid_color_field, SIGNAL(changed()), this, SLOT(field_changed())); connect(opacity_field, SIGNAL(changed()), this, SLOT(field_changed())); - connect(solid_width_field, SIGNAL(changed()), this, SLOT(field_changed())); + connect(checkerboard_size_field, SIGNAL(changed()), this, SLOT(field_changed())); + + connect(static_cast(solid_type->get_ui_element()), SIGNAL(currentIndexChanged(int)), this, SLOT(ui_update(int))); vertPath = ":/shaders/common.vert"; fragPath = ":/shaders/solideffect.frag"; } -/*void SolidEffect::process_gl(double timecode, GLTextureCoords&) { - - - glslProgram->setUniformValue("solidColor", solid_color_field->get_color_value(timecode)); - glslProgram->setUniformValue("amount_val", (GLfloat) (opacity_field->get_double_value(timecode)*0.01)); -}*/ - void SolidEffect::redraw(double timecode) { int w = img.width(); int h = img.height(); @@ -158,122 +153,31 @@ void SolidEffect::redraw(double timecode) { { // draw checkboard QPainter p(&img); - p.setRenderHint(QPainter::Antialiasing); img.fill(Qt::transparent); - int checker_width = qCeil(solid_width_field->get_double_value(timecode)); - int checker_x, checker_y, count = 0; + int checker_width = qCeil(checkerboard_size_field->get_double_value(timecode)); + int checker_x, checker_y; int checkerboard_size_w = qCeil(double(w)/checker_width); int checkerboard_size_h = qCeil(double(h)/checker_width); - QColor checker_odd(QColor(0,0,0,alpha)); + QColor checker_odd(QColor(0, 0, 0, alpha)); QColor checker_even(solid_color_field->get_color_value(timecode)); checker_even.setAlpha(alpha); QVector checker_color{checker_odd, checker_even}; for(int i = 0; i < checkerboard_size_w; i++){ checker_x = checker_width*i; - if (checkerboard_size_h % 2 == 0 && count > 0) count++; for(int j = 0; j < checkerboard_size_h; j++){ - checker_y = checker_width*j; - p.fillRect(QRect(checker_x, checker_y, checker_width, checker_width), checker_color[count%2]); - count++; + checker_y = checker_width*j; + p.fillRect(QRect(checker_x, checker_y, checker_width, checker_width), checker_color[(i + j)%2]); } } } break; - } + } } -/*void SolidEffect::process_image(long frame, uint8_t* data, int w, int h) { - QImage img(data, w, h, QImage::Format_RGBA8888); // create QImage wrapper - QPainter p(&img); - int width = img.width(); - int height = img.height(); - - switch (solid_type->get_combo_data(frame).toInt()) { - case SOLID_TYPE_COLOR: - { - QColor brush = solid_color_field->get_color_value(frame); - p.fillRect(0, 0, width, height, QColor(brush.red(), brush.green(), brush.blue(), opacity_field->get_double_value(frame)*2.55)); - } - break; - case SOLID_TYPE_BARS: - // draw smpte bars - int bar_width = qCeil((double) parent_clip->sequence->width / 7.0); - int first_bar_height = qCeil((double) parent_clip->sequence->height / 3.0 * 2.0); - int second_bar_height = qCeil((double) parent_clip->sequence->height / 12.5); - int third_bar_y = first_bar_height + second_bar_height; - int third_bar_height = parent_clip->sequence->height - third_bar_y; - int third_bar_width = 0; - int bar_x, strip_width; - QColor first_color, second_color, third_color; - for (int i=0;iset_enabled(i == SOLID_TYPE_COLOR); + checkerboard_size_field->set_enabled(i == SOLID_TYPE_CHECKERBOARD); +} diff --git a/effects/internal/solideffect.h b/effects/internal/solideffect.h index 06ddc0661..61a4f29fb 100644 --- a/effects/internal/solideffect.h +++ b/effects/internal/solideffect.h @@ -9,12 +9,15 @@ class QOpenGLTexture; class SolidEffect : public Effect { Q_OBJECT public: - SolidEffect(Clip* c, const EffectMeta *em); - EffectField* solid_type; - EffectField* solid_color_field; - EffectField* opacity_field; - EffectField* solid_width_field; + SolidEffect(Clip* c, const EffectMeta *em); void redraw(double timecode); +private slots: + void ui_update(int); +private: + EffectField* solid_type; + EffectField* solid_color_field; + EffectField* opacity_field; + EffectField* checkerboard_size_field; }; #endif // SOLIDEFFECT_H