diff --git a/effects/effects.cpp b/effects/effects.cpp index e2bfd0f00..7b66b7eb7 100644 --- a/effects/effects.cpp +++ b/effects/effects.cpp @@ -15,6 +15,7 @@ void init_effects() { video_effect_names[VIDEO_TRANSFORM_EFFECT] = "Transform"; video_effect_names[VIDEO_SHAKE_EFFECT] = "Shake"; video_effect_names[VIDEO_TEXT_EFFECT] = "Text"; + video_effect_names[VIDEO_SOLID_EFFECT] = "Solid"; audio_effect_names[AUDIO_VOLUME_EFFECT] = "Volume"; audio_effect_names[AUDIO_PAN_EFFECT] = "Pan"; @@ -26,6 +27,7 @@ Effect* create_effect(int effect_id, Clip* c) { case VIDEO_TRANSFORM_EFFECT: return new TransformEffect(c); case VIDEO_SHAKE_EFFECT: return new ShakeEffect(c); case VIDEO_TEXT_EFFECT: return new TextEffect(c); + case VIDEO_SOLID_EFFECT: return new SolidEffect(c); } } else { switch (effect_id) { diff --git a/effects/effects.h b/effects/effects.h index 4fe398f86..0ec28211b 100644 --- a/effects/effects.h +++ b/effects/effects.h @@ -20,6 +20,7 @@ enum VideoEffects { VIDEO_TRANSFORM_EFFECT, VIDEO_SHAKE_EFFECT, VIDEO_TEXT_EFFECT, + VIDEO_SOLID_EFFECT, VIDEO_EFFECT_COUNT }; @@ -110,6 +111,17 @@ private: QFont font; }; +class SolidEffect : public Effect { + Q_OBJECT +public: + SolidEffect(Clip* c); + void post_gl(); +private slots: + void update_texture(); +private: + QOpenGLTexture* texture; +}; + // audio effects class VolumeEffect : public Effect { public: diff --git a/effects/solideffect.cpp b/effects/solideffect.cpp new file mode 100644 index 000000000..d2c004b7d --- /dev/null +++ b/effects/solideffect.cpp @@ -0,0 +1,128 @@ +#include "effects.h" + +#include +#include +#include + +#include "project/clip.h" +#include "project/sequence.h" + +#define SMPTE_BARS 7 +#define SMPTE_STRIP_COUNT 3 +#define SMPTE_LOWER_BARS 4 + +bool solid = false; + +SolidEffect::SolidEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SOLID_EFFECT), texture(NULL) { + update_texture(); +} + +void SolidEffect::update_texture() { + QImage img(parent_clip->sequence->width, parent_clip->sequence->height, QImage::Format_RGB888); + + if (solid) { + img.fill(Qt::red); + } else { + // draw smpte bars + img.fill(Qt::black); + + QPainter p(&img); + 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;idestroy(); + texture->setData(img); + } + + field_changed(); +} + +void SolidEffect::post_gl() { + if (texture != NULL) { + texture->bind(); + + int half_width = parent_clip->sequence->width/2; + int half_height = parent_clip->sequence->height/2; + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex2f(-half_width, -half_height); + glTexCoord2f(1.0, 0.0); + glVertex2f(half_width, -half_height); + glTexCoord2f(1.0, 1.0); + glVertex2f(half_width, half_height); + glTexCoord2f(0.0, 1.0); + glVertex2f(-half_width, half_height); + glEnd(); + + texture->release(); + } +} diff --git a/olive.pro b/olive.pro index 8ec662c6f..5b70bd5c5 100644 --- a/olive.pro +++ b/olive.pro @@ -64,7 +64,8 @@ SOURCES += \ effects/shakeeffect.cpp \ effects/texteffect.cpp \ ui/comboboxex.cpp \ - ui/colorbutton.cpp + ui/colorbutton.cpp \ + effects/solideffect.cpp HEADERS += \ mainwindow.h \ diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 76c55c21b..2c673c04e 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -60,7 +60,18 @@ void EffectControls::show_menu(bool video) { QAction* action = new QAction(&effects_menu); action->setText(effect_names->at(i)); action->setData(i); - effects_menu.addAction(action); + + // sort alphabetically + bool added = false; + for (int j=0;jtext() > effect_names->at(i)) { + effects_menu.insertAction(comp_action, action); + added = true; + break; + } + } + if (!added) effects_menu.addAction(action); } connect(&effects_menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_select(QAction*)));