diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index 43ec2d9af..a9090cdd6 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -63,7 +63,9 @@ void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) { } } for (int i=0;itreeWidget->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); + } } } diff --git a/effects/effects.cpp b/effects/effects.cpp index 7b66b7eb7..b4f216bc7 100644 --- a/effects/effects.cpp +++ b/effects/effects.cpp @@ -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"; diff --git a/effects/effects.h b/effects/effects.h index 0ec28211b..4a39c2e18 100644 --- a/effects/effects.h +++ b/effects/effects.h @@ -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 { diff --git a/effects/texteffect.cpp b/effects/texteffect.cpp index 9e588717b..07fd6c7ab 100644 --- a/effects/texteffect.cpp +++ b/effects/texteffect.cpp @@ -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); diff --git a/effects/transformeffect.cpp b/effects/transformeffect.cpp index a5e406c34..77dc15145 100644 --- a/effects/transformeffect.cpp +++ b/effects/transformeffect.cpp @@ -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()); diff --git a/panels/project.ui b/panels/project.ui index 386fbb1ef..84ca9eb7b 100644 --- a/panels/project.ui +++ b/panels/project.ui @@ -68,9 +68,6 @@ false - - 200 - true diff --git a/panels/timeline.cpp b/panels/timeline.cpp index ad2ab4d23..c4187f92d 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -21,30 +21,32 @@ #include 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())); diff --git a/panels/timeline.h b/panels/timeline.h index e8a821cfb..d65213ace 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -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); diff --git a/project/effect.cpp b/project/effect.cpp index 1592aa692..04f1a7b6d 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -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; diff --git a/project/effect.h b/project/effect.h index d5ef79f4b..f348699b5 100644 --- a/project/effect.h +++ b/project/effect.h @@ -28,6 +28,8 @@ public: bool is_enabled(); + virtual void init(); + virtual Effect* copy(Clip* c); virtual void load(QXmlStreamReader* stream); diff --git a/ui/sourcetable.cpp b/ui/sourcetable.cpp index f4e456631..5c6ee4e11 100644 --- a/ui/sourcetable.cpp +++ b/ui/sourcetable.cpp @@ -10,6 +10,7 @@ #include #include +#include #include SourceTable::SourceTable(QWidget* parent) : QTreeWidget(parent) { diff --git a/ui/timelineheader.cpp b/ui/timelineheader.cpp index 4a8ab5cb3..ed16c65c8 100644 --- a/ui/timelineheader.cpp +++ b/ui/timelineheader.cpp @@ -7,6 +7,7 @@ #include #include +#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); } diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 202c58ac8..0642722ff 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -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 diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 74e19cbc3..68c92a4b3 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -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);