improved effects signalling
This commit is contained in:
+52
-29
@@ -38,54 +38,77 @@ TextEffect::TextEffect(Clip *c) :
|
||||
EffectRow* color_row = add_row("Color:");
|
||||
set_color_button = color_row->add_field(EFFECT_FIELD_COLOR);
|
||||
|
||||
connect(static_cast<QTextEdit*>(text_val->get_ui_element()), SIGNAL(textChanged()), this, SLOT(update_texture()));
|
||||
connect(static_cast<LabelSlider*>(size_val->get_ui_element()), SIGNAL(valueChanged()), this, SLOT(update_texture()));
|
||||
connect(static_cast<ColorButton*>(set_color_button->get_ui_element()), SIGNAL(color_changed()), this, SLOT(update_texture()));
|
||||
connect(static_cast<FontCombobox*>(set_font_combobox->get_ui_element()), SIGNAL(currentTextChanged(QString)), this, SLOT(update_texture()));
|
||||
EffectRow* alignment_row = add_row("Alignment:");
|
||||
halign_field = alignment_row->add_field(EFFECT_FIELD_COMBO);
|
||||
halign_field->add_combo_item("Left", Qt::AlignLeft);
|
||||
halign_field->add_combo_item("Center", Qt::AlignHCenter);
|
||||
halign_field->add_combo_item("Right", Qt::AlignRight);
|
||||
halign_field->add_combo_item("Justify", Qt::AlignJustify);
|
||||
valign_field = alignment_row->add_field(EFFECT_FIELD_COMBO);
|
||||
valign_field->add_combo_item("Top", Qt::AlignTop);
|
||||
valign_field->add_combo_item("Center", Qt::AlignVCenter);
|
||||
valign_field->add_combo_item("Bottom", Qt::AlignBottom);
|
||||
|
||||
size_val->set_double_default_value(24);
|
||||
size_val->set_double_default_value(48);
|
||||
text_val->set_string_value("Sample Text");
|
||||
halign_field->set_combo_index(1);
|
||||
valign_field->set_combo_index(1);
|
||||
|
||||
connect(text_val, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(size_val, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(set_color_button, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(set_font_combobox, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(halign_field, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(valign_field, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
|
||||
update_texture();
|
||||
}
|
||||
|
||||
TextEffect::~TextEffect() {
|
||||
destroy_texture();
|
||||
}
|
||||
|
||||
void TextEffect::refresh() {
|
||||
update_texture();
|
||||
}
|
||||
|
||||
void TextEffect::destroy_texture() {
|
||||
texture->destroy();
|
||||
}
|
||||
|
||||
void TextEffect::update_texture() {
|
||||
if (parent_clip->sequence->width != width || parent_clip->sequence->height != height) {
|
||||
width = parent_clip->sequence->width;
|
||||
height = parent_clip->sequence->height;
|
||||
pixmap = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
pixmap.fill(Qt::transparent);
|
||||
if (parent_clip->sequence != NULL) {
|
||||
if (parent_clip->sequence->width != width || parent_clip->sequence->height != height) {
|
||||
width = parent_clip->sequence->width;
|
||||
height = parent_clip->sequence->height;
|
||||
pixmap = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter p(&pixmap);
|
||||
p.setRenderHint(QPainter::TextAntialiasing, true);
|
||||
QPainter p(&pixmap);
|
||||
p.setRenderHint(QPainter::TextAntialiasing, true);
|
||||
|
||||
// set font
|
||||
font.setFamily(set_font_combobox->get_font_name());
|
||||
font.setPointSize(size_val->get_double_value());
|
||||
font.setStyleHint(QFont::Helvetica, QFont::PreferAntialias);
|
||||
p.setFont(font);
|
||||
// set font
|
||||
font.setFamily(set_font_combobox->get_font_name());
|
||||
font.setPointSize(size_val->get_double_value());
|
||||
font.setStyleHint(QFont::Helvetica, QFont::PreferAntialias);
|
||||
p.setFont(font);
|
||||
|
||||
p.setPen(set_color_button->get_color_value());
|
||||
p.drawText(QRect(0, 0, width, height), Qt::AlignCenter | Qt::TextWordWrap, text_val->get_string_value());
|
||||
p.setPen(set_color_button->get_color_value());
|
||||
p.drawText(QRect(0, 0, width, height), halign_field->get_combo_data().toInt() | valign_field->get_combo_data().toInt() | Qt::TextWordWrap, text_val->get_string_value());
|
||||
|
||||
if (texture == NULL) {
|
||||
texture = new QOpenGLTexture(pixmap);
|
||||
} else {
|
||||
destroy_texture();
|
||||
texture->setData(pixmap);
|
||||
}
|
||||
if (texture == NULL) {
|
||||
texture = new QOpenGLTexture(pixmap);
|
||||
} else {
|
||||
destroy_texture();
|
||||
texture->setData(pixmap);
|
||||
}
|
||||
|
||||
texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
|
||||
texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
|
||||
|
||||
// queue a repaint of the canvas
|
||||
field_changed();
|
||||
// queue a repaint of the canvas
|
||||
field_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void TextEffect::post_gl() {
|
||||
|
||||
Reference in New Issue
Block a user