various fixes
This commit is contained in:
@@ -63,7 +63,9 @@ void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) {
|
||||
}
|
||||
}
|
||||
for (int i=0;i<added_action_items.size();i++) {
|
||||
KeySequenceEditor* editor = new KeySequenceEditor(added_actions.at(i));
|
||||
ui->treeWidget->setItemWidget(added_action_items.at(i), 1, editor);
|
||||
if (added_actions.at(i)->menu() == NULL) {
|
||||
KeySequenceEditor* editor = new KeySequenceEditor(added_actions.at(i));
|
||||
ui->treeWidget->setItemWidget(added_action_items.at(i), 1, editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -24,15 +24,15 @@ void init_effects() {
|
||||
Effect* create_effect(int effect_id, Clip* c) {
|
||||
if (c->track < 0) {
|
||||
switch (effect_id) {
|
||||
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);
|
||||
case VIDEO_TRANSFORM_EFFECT: return new TransformEffect(c); break;
|
||||
case VIDEO_SHAKE_EFFECT: return new ShakeEffect(c); break;
|
||||
case VIDEO_TEXT_EFFECT: return new TextEffect(c); break;
|
||||
case VIDEO_SOLID_EFFECT: return new SolidEffect(c); break;
|
||||
}
|
||||
} else {
|
||||
switch (effect_id) {
|
||||
case AUDIO_VOLUME_EFFECT: return new VolumeEffect(c);
|
||||
case AUDIO_PAN_EFFECT: return new PanEffect(c);
|
||||
case AUDIO_VOLUME_EFFECT: return new VolumeEffect(c); break;
|
||||
case AUDIO_PAN_EFFECT: return new PanEffect(c); break;
|
||||
}
|
||||
}
|
||||
qDebug() << "[ERROR] Invalid effect ID";
|
||||
|
||||
@@ -40,6 +40,7 @@ class TransformEffect : public Effect {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TransformEffect(Clip* c);
|
||||
void init();
|
||||
void process_gl(int* anchor_x, int* anchor_y);
|
||||
Effect* copy(Clip* c);
|
||||
void load(QXmlStreamReader* stream);
|
||||
@@ -107,8 +108,12 @@ public:
|
||||
private slots:
|
||||
void update_texture();
|
||||
private:
|
||||
void destroy_texture();
|
||||
QOpenGLTexture* texture;
|
||||
QImage pixmap;
|
||||
QFont font;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
class SolidEffect : public Effect {
|
||||
|
||||
+21
-7
@@ -38,7 +38,12 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TextEffect::TextEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_TEXT_EFFECT), texture(NULL) {
|
||||
TextEffect::TextEffect(Clip *c) :
|
||||
Effect(c, EFFECT_TYPE_VIDEO, VIDEO_TEXT_EFFECT),
|
||||
texture(NULL),
|
||||
width(0),
|
||||
height(0)
|
||||
{
|
||||
ui_layout->addWidget(new QLabel("Text:"), 0, 0);
|
||||
text_val = new QTextEdit();
|
||||
text_val->setUndoRedoEnabled(true);
|
||||
@@ -69,12 +74,19 @@ TextEffect::TextEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_TEXT_EFFECT
|
||||
}
|
||||
|
||||
TextEffect::~TextEffect() {
|
||||
destroy_texture();
|
||||
}
|
||||
|
||||
void TextEffect::destroy_texture() {
|
||||
texture->destroy();
|
||||
delete texture;
|
||||
}
|
||||
|
||||
void TextEffect::update_texture() {
|
||||
QImage pixmap(parent_clip->sequence->width, parent_clip->sequence->height, QImage::Format_ARGB32_Premultiplied);
|
||||
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);
|
||||
@@ -87,15 +99,17 @@ void TextEffect::update_texture() {
|
||||
p.setFont(font);
|
||||
|
||||
p.setPen(set_color_button->get_color());
|
||||
p.drawText(QRect(0, 0, pixmap.width(), pixmap.height()), Qt::AlignCenter | Qt::TextWordWrap, text_val->toPlainText());
|
||||
p.drawText(QRect(0, 0, width, height), Qt::AlignCenter | Qt::TextWordWrap, text_val->toPlainText());
|
||||
|
||||
if (texture == NULL) {
|
||||
texture = new QOpenGLTexture(pixmap);
|
||||
} else {
|
||||
texture->destroy();
|
||||
destroy_texture();
|
||||
texture->setData(pixmap);
|
||||
}
|
||||
|
||||
texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
|
||||
|
||||
// queue a repaint of the canvas
|
||||
field_changed();
|
||||
}
|
||||
@@ -104,8 +118,8 @@ void TextEffect::post_gl() {
|
||||
if (texture != NULL) {
|
||||
texture->bind();
|
||||
|
||||
int half_width = parent_clip->sequence->width/2;
|
||||
int half_height = parent_clip->sequence->height/2;
|
||||
int half_width = width/2;
|
||||
int half_height = height/2;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
|
||||
+18
-12
@@ -68,18 +68,7 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_T
|
||||
ui_layout->addWidget(blend_mode_box, 6, 1);
|
||||
|
||||
// set defaults
|
||||
position_x->set_default_value(c->sequence->width/2);
|
||||
position_y->set_default_value(c->sequence->height/2);
|
||||
scale_x->set_default_value(100);
|
||||
scale_y->set_default_value(100);
|
||||
scale_y->setEnabled(false);
|
||||
uniform_scale_box->setChecked(true);
|
||||
default_anchor_x = c->media_stream->video_width/2;
|
||||
default_anchor_y = c->media_stream->video_height/2;
|
||||
anchor_x_box->set_default_value(default_anchor_x);
|
||||
anchor_y_box->set_default_value(default_anchor_y);
|
||||
opacity->set_default_value(100);
|
||||
blend_mode_box->setCurrentIndex(0);
|
||||
init();
|
||||
|
||||
connect(position_x, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
connect(position_y, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
@@ -95,6 +84,23 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_T
|
||||
connect(blend_mode_box, SIGNAL(currentIndexChanged(int)), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
void TransformEffect::init() {
|
||||
if (parent_clip->media_stream != NULL) {
|
||||
position_x->set_default_value(parent_clip->sequence->width/2);
|
||||
position_y->set_default_value(parent_clip->sequence->height/2);
|
||||
scale_x->set_default_value(100);
|
||||
scale_y->set_default_value(100);
|
||||
scale_y->setEnabled(false);
|
||||
uniform_scale_box->setChecked(true);
|
||||
default_anchor_x = parent_clip->media_stream->video_width/2;
|
||||
default_anchor_y = parent_clip->media_stream->video_height/2;
|
||||
anchor_x_box->set_default_value(default_anchor_x);
|
||||
anchor_y_box->set_default_value(default_anchor_y);
|
||||
opacity->set_default_value(100);
|
||||
blend_mode_box->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
Effect* TransformEffect::copy(Clip* c) {
|
||||
TransformEffect* t = new TransformEffect(c);
|
||||
t->position_x->set_value(position_x->value());
|
||||
|
||||
@@ -68,9 +68,6 @@
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
|
||||
+25
-25
@@ -21,30 +21,32 @@
|
||||
#include <QtMath>
|
||||
|
||||
Timeline::Timeline(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
ui(new Ui::Timeline)
|
||||
QDockWidget(parent),
|
||||
selecting(false),
|
||||
moving_init(false),
|
||||
moving_proc(false),
|
||||
splitting(false),
|
||||
importing(false),
|
||||
playing(false),
|
||||
trim_in_point(false),
|
||||
snapped(false),
|
||||
rect_select_init(false),
|
||||
rect_select_proc(false),
|
||||
edit_tool_selects_links(false),
|
||||
edit_tool_also_seeks(false),
|
||||
select_also_seeks(false),
|
||||
using_workarea(false),
|
||||
paste_seeks(true),
|
||||
snapping(true),
|
||||
last_frame(0),
|
||||
playhead(0),
|
||||
snap_point(0),
|
||||
cursor_frame(0),
|
||||
cursor_track(0),
|
||||
trim_target(-1),
|
||||
zoom(1.0),
|
||||
ui(new Ui::Timeline)
|
||||
{
|
||||
selecting = false;
|
||||
moving_init = false;
|
||||
moving_proc = false;
|
||||
splitting = false;
|
||||
importing = false;
|
||||
playing = false;
|
||||
trim_in_point = false;
|
||||
snapped = false;
|
||||
rect_select_init = false;
|
||||
rect_select_proc = false;
|
||||
edit_tool_selects_links = false;
|
||||
edit_tool_also_seeks = false;
|
||||
select_also_seeks = false;
|
||||
paste_seeks = true;
|
||||
snapping = true;
|
||||
last_frame = 0;
|
||||
playhead = 0;
|
||||
snap_point = 0;
|
||||
cursor_frame = 0;
|
||||
cursor_track = 0;
|
||||
trim_target = -1;
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -60,8 +62,6 @@ Timeline::Timeline(QWidget *parent) :
|
||||
|
||||
ui->toolArrowButton->click();
|
||||
|
||||
zoom = 1.0f;
|
||||
|
||||
update_sequence();
|
||||
|
||||
connect(&playback_updater, SIGNAL(timeout()), this, SLOT(repaint_timeline()));
|
||||
|
||||
+5
-1
@@ -94,6 +94,10 @@ public:
|
||||
|
||||
long playhead;
|
||||
|
||||
bool using_workarea;
|
||||
long workarea_in;
|
||||
long workarea_out;
|
||||
|
||||
// playback functions
|
||||
void go_to_start();
|
||||
void previous_frame();
|
||||
@@ -118,7 +122,7 @@ public:
|
||||
int tool;
|
||||
long cursor_frame;
|
||||
int cursor_track;
|
||||
float zoom;
|
||||
double zoom;
|
||||
long drag_frame_start;
|
||||
int drag_track_start;
|
||||
void redraw_all_clips(bool changed);
|
||||
|
||||
@@ -27,6 +27,10 @@ Effect::Effect(Clip* c, int t, int i) : parent_clip(c), type(t), id(i) {
|
||||
container->setContents(ui);
|
||||
}
|
||||
|
||||
void Effect::init() {
|
||||
qDebug() << "WRONG" << type << id;
|
||||
}
|
||||
|
||||
void Effect::field_changed() {
|
||||
panel_viewer->viewer_widget->update();
|
||||
project_changed = true;
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
|
||||
bool is_enabled();
|
||||
|
||||
virtual void init();
|
||||
|
||||
virtual Effect* copy(Clip* c);
|
||||
|
||||
virtual void load(QXmlStreamReader* stream);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <QDragEnterEvent>
|
||||
#include <QMimeData>
|
||||
#include <QHeaderView>
|
||||
#include <QDebug>
|
||||
|
||||
SourceTable::SourceTable(QWidget* parent) : QTreeWidget(parent) {
|
||||
|
||||
+22
-4
@@ -7,6 +7,7 @@
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#define CLICK_RANGE 5
|
||||
#define PLAYHEAD_SIZE 6
|
||||
|
||||
TimelineHeader::TimelineHeader(QWidget *parent) : QWidget(parent)
|
||||
@@ -23,6 +24,12 @@ void set_playhead(QMouseEvent* event) {
|
||||
}
|
||||
|
||||
void TimelineHeader::mousePressEvent(QMouseEvent* event) {
|
||||
/*if (panel_timeline->using_workarea) {
|
||||
event->pos().x()
|
||||
if (panel_timeline->workarea_in)
|
||||
} else {
|
||||
|
||||
}*/
|
||||
set_playhead(event);
|
||||
dragging = true;
|
||||
}
|
||||
@@ -51,13 +58,24 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
|
||||
p.drawLine(i, 0, i, height());
|
||||
}
|
||||
|
||||
// draw in/out selection
|
||||
int in_x;
|
||||
if (panel_timeline->using_workarea) {
|
||||
in_x = panel_timeline->getScreenPointFromFrame(panel_timeline->workarea_in);
|
||||
int out_x = panel_timeline->getScreenPointFromFrame(panel_timeline->workarea_out);
|
||||
p.fillRect(QRect(in_x, 0, out_x-in_x, height()), QColor(0, 192, 255, 128));
|
||||
p.setPen(Qt::white);
|
||||
p.drawLine(in_x, 0, in_x, height());
|
||||
p.drawLine(out_x, 0, out_x, height());
|
||||
}
|
||||
|
||||
// draw playhead triangle
|
||||
int px = panel_timeline->getScreenPointFromFrame(panel_timeline->playhead);
|
||||
QPoint start(px, height());
|
||||
in_x = panel_timeline->getScreenPointFromFrame(panel_timeline->playhead);
|
||||
QPoint start(in_x, height());
|
||||
QPainterPath path;
|
||||
path.moveTo(start);
|
||||
path.lineTo(px-PLAYHEAD_SIZE, 0);
|
||||
path.lineTo(px+PLAYHEAD_SIZE, 0);
|
||||
path.lineTo(in_x-PLAYHEAD_SIZE, 0);
|
||||
path.lineTo(in_x+PLAYHEAD_SIZE, 0);
|
||||
path.lineTo(start);
|
||||
p.fillPath(path, Qt::red);
|
||||
}
|
||||
|
||||
@@ -232,6 +232,7 @@ void TimelineWidget::dropEvent(QDropEvent* event) {
|
||||
|
||||
if (c->track < 0) {
|
||||
// add default video effects
|
||||
qDebug() << "hello";
|
||||
c->effects.append(create_effect(VIDEO_TRANSFORM_EFFECT, c));
|
||||
} else {
|
||||
// add default audio effects
|
||||
|
||||
@@ -150,9 +150,6 @@ void ViewerWidget::paintGL() {
|
||||
|
||||
c->texture->bind();
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex2f(-anchor_x, -anchor_y);
|
||||
|
||||
Reference in New Issue
Block a user