almost finished setting in-out points in footage viewer
This commit is contained in:
+7
-9
@@ -687,13 +687,11 @@ void MainWindow::on_actionRipple_To_In_Point_triggered()
|
||||
if (panel_timeline->focused()) panel_timeline->ripple_to_in_point(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRipple_to_Out_Point_triggered()
|
||||
{
|
||||
void MainWindow::on_actionRipple_to_Out_Point_triggered() {
|
||||
if (panel_timeline->focused()) panel_timeline->ripple_to_in_point(false);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSet_In_Point_triggered()
|
||||
{
|
||||
void MainWindow::on_actionSet_In_Point_triggered() {
|
||||
if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) {
|
||||
panel_sequence_viewer->set_in_point();
|
||||
} else if (panel_footage_viewer->is_focused()) {
|
||||
@@ -701,8 +699,7 @@ void MainWindow::on_actionSet_In_Point_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSet_Out_Point_triggered()
|
||||
{
|
||||
void MainWindow::on_actionSet_Out_Point_triggered() {
|
||||
if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) {
|
||||
panel_sequence_viewer->set_out_point();
|
||||
} else if (panel_footage_viewer->is_focused()) {
|
||||
@@ -711,9 +708,10 @@ void MainWindow::on_actionSet_Out_Point_triggered()
|
||||
}
|
||||
|
||||
void MainWindow::on_actionClear_In_Out_triggered() {
|
||||
if ((panel_timeline->focused() || panel_sequence_viewer->is_focused()) && sequence->using_workarea) {
|
||||
undo_stack.push(new SetTimelineInOutCommand(sequence, false, 0, 0));
|
||||
update_ui(false);
|
||||
if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) {
|
||||
panel_sequence_viewer->clear_inout_point();
|
||||
} else if (panel_footage_viewer->is_focused()) {
|
||||
panel_footage_viewer->clear_inout_point();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -484,6 +484,7 @@ void Project::process_file_list(bool recursive, QStringList& files, QTreeWidgetI
|
||||
m = new Media();
|
||||
}
|
||||
|
||||
m->using_inout = false;
|
||||
m->url = file;
|
||||
m->name = get_file_name_from_path(files.at(i));
|
||||
|
||||
@@ -729,6 +730,9 @@ bool Project::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
QTreeWidgetItem* item = new_item();
|
||||
Media* m = new Media();
|
||||
|
||||
// TODO make save/load-able
|
||||
m->using_inout = false;
|
||||
|
||||
for (int j=0;j<stream.attributes().size();j++) {
|
||||
const QXmlStreamAttribute& attr = stream.attributes().at(j);
|
||||
if (attr.name() == "id") {
|
||||
|
||||
+19
-4
@@ -7,6 +7,7 @@
|
||||
#include "panels/panels.h"
|
||||
#include "io/config.h"
|
||||
#include "io/media.h"
|
||||
#include "project/undo.h"
|
||||
#include "ui/audiomonitor.h"
|
||||
#include "ui_timeline.h"
|
||||
|
||||
@@ -230,16 +231,21 @@ void Viewer::update_viewer() {
|
||||
viewer_widget->update();
|
||||
update_header_zoom();
|
||||
if (seq != NULL) update_playhead_timecode(seq->playhead);
|
||||
update_end_timecode();
|
||||
update_end_timecode();
|
||||
}
|
||||
|
||||
void Viewer::clear_inout_point() {
|
||||
if (seq->using_workarea) {
|
||||
undo_stack.push(new SetTimelineInOutCommand(seq, false, 0, 0));
|
||||
update_parents();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::set_in_point() {
|
||||
qDebug() << "in h";
|
||||
ui->headers->set_in_point(seq->playhead);
|
||||
}
|
||||
|
||||
void Viewer::set_out_point() {
|
||||
qDebug() << "out h";
|
||||
ui->headers->set_out_point(seq->playhead);
|
||||
}
|
||||
|
||||
@@ -253,14 +259,18 @@ void Viewer::set_media(int type, void* media) {
|
||||
|
||||
seq = new Sequence();
|
||||
created_sequence = true;
|
||||
seq->wrapper_sequence = true;
|
||||
seq->name = footage->name;
|
||||
|
||||
seq->using_workarea = footage->using_inout;
|
||||
seq->workarea_in = footage->in;
|
||||
seq->workarea_out = footage->out;
|
||||
|
||||
if (footage->video_tracks.size() > 0) {
|
||||
MediaStream* video_stream = footage->video_tracks.at(0);
|
||||
seq->width = video_stream->video_width;
|
||||
seq->height = video_stream->video_height;
|
||||
if (video_stream->video_frame_rate > 0) seq->frame_rate = video_stream->video_frame_rate;
|
||||
qDebug() << seq->frame_rate << video_stream->video_frame_rate;
|
||||
|
||||
Clip* c = new Clip(seq);
|
||||
c->media = footage;
|
||||
@@ -338,6 +348,11 @@ void Viewer::timer_update() {
|
||||
|
||||
void Viewer::clean_created_seq() {
|
||||
if (created_sequence) {
|
||||
// TODO delete undo commands referencing this sequence to avoid crashes
|
||||
/*for (int i=0;i<undo_stack.count();i++) {
|
||||
undo_stack.command(i)
|
||||
}*/
|
||||
|
||||
delete seq;
|
||||
seq = NULL;
|
||||
created_sequence = false;
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
void update_end_timecode();
|
||||
void update_header_zoom();
|
||||
void update_viewer();
|
||||
void clear_inout_point();
|
||||
void set_in_point();
|
||||
void set_out_point();
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
#include "sequence.h"
|
||||
|
||||
#include "project/clip.h"
|
||||
#include "effects/transition.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
Sequence::Sequence() :
|
||||
playhead(0),
|
||||
using_workarea(false),
|
||||
workarea_in(0),
|
||||
workarea_out(0),
|
||||
wrapper_sequence(false)
|
||||
{
|
||||
}
|
||||
|
||||
Sequence::~Sequence() {
|
||||
// dealloc all clips
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
delete clips.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
Sequence* Sequence::copy() {
|
||||
Sequence* s = new Sequence();
|
||||
s->name = name + " (copy)";
|
||||
s->width = width;
|
||||
s->height = height;
|
||||
s->frame_rate = frame_rate;
|
||||
s->audio_frequency = audio_frequency;
|
||||
s->audio_layout = audio_layout;
|
||||
s->clips.resize(clips.size());
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
if (c == NULL) {
|
||||
s->clips[i] = NULL;
|
||||
} else {
|
||||
Clip* copy = c->copy(s);
|
||||
copy->linked = c->linked;
|
||||
s->clips[i] = copy;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
long Sequence::getEndFrame() {
|
||||
long end = 0;
|
||||
for (int j=0;j<clips.size();j++) {
|
||||
Clip* c = clips.at(j);
|
||||
if (c != NULL && c->timeline_out > end) {
|
||||
end = c->timeline_out;
|
||||
}
|
||||
}
|
||||
return end;
|
||||
}
|
||||
|
||||
void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) {
|
||||
int vt = 0;
|
||||
int at = 0;
|
||||
for (int j=0;j<clips.size();j++) {
|
||||
Clip* c = clips.at(j);
|
||||
if (c != NULL) {
|
||||
if (c->track < 0 && c->track < vt) { // video clip
|
||||
vt = c->track;
|
||||
} else if (c->track > at) {
|
||||
at = c->track;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (video_tracks != NULL) *video_tracks = vt;
|
||||
if (audio_tracks != NULL) *audio_tracks = at;
|
||||
}
|
||||
|
||||
// static variable for the currently active sequence
|
||||
Sequence* sequence = NULL;
|
||||
@@ -27,6 +27,8 @@ struct Sequence {
|
||||
long workarea_in;
|
||||
long workarea_out;
|
||||
|
||||
bool wrapper_sequence;
|
||||
|
||||
int save_id;
|
||||
|
||||
QVector<Marker> markers;
|
||||
|
||||
@@ -163,6 +163,14 @@ void SetTimelineInOutCommand::undo() {
|
||||
seq->workarea_in = old_in;
|
||||
seq->workarea_out = old_out;
|
||||
|
||||
// footage viewer functions
|
||||
if (seq->wrapper_sequence) {
|
||||
Media* m = static_cast<Media*>(seq->clips.at(0)->media);
|
||||
m->using_inout = old_enabled;
|
||||
m->in = old_in;
|
||||
m->out = old_out;
|
||||
}
|
||||
|
||||
mainWindow->setWindowModified(old_project_changed);
|
||||
}
|
||||
|
||||
@@ -175,6 +183,14 @@ void SetTimelineInOutCommand::redo() {
|
||||
seq->workarea_in = new_in;
|
||||
seq->workarea_out = new_out;
|
||||
|
||||
// footage viewer functions
|
||||
if (seq->wrapper_sequence) {
|
||||
Media* m = static_cast<Media*>(seq->clips.at(0)->media);
|
||||
m->using_inout = new_enabled;
|
||||
m->in = new_in;
|
||||
m->out = new_out;
|
||||
}
|
||||
|
||||
mainWindow->setWindowModified(true);
|
||||
}
|
||||
|
||||
|
||||
+12
-3
@@ -272,12 +272,18 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
Sequence* s = NULL;
|
||||
void* media = NULL;
|
||||
long sequence_length;
|
||||
long default_clip_in = 0;
|
||||
|
||||
switch (item_type) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
m = get_footage_from_tree(item);
|
||||
media = m;
|
||||
can_import = m->ready;
|
||||
if (m->using_inout) {
|
||||
double source_fr = 30;
|
||||
if (m->video_tracks.size() > 0) source_fr = m->video_tracks.at(0)->video_frame_rate;
|
||||
default_clip_in = refactor_frame_number(m->in, source_fr, predicted_new_frame_rate);
|
||||
}
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
s = get_sequence_from_tree(item);
|
||||
@@ -285,6 +291,9 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
if (sequence != NULL) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, sequence->frame_rate);
|
||||
media = s;
|
||||
can_import = (s != sequence && sequence_length != 0);
|
||||
if (s->using_workarea) {
|
||||
default_clip_in = refactor_frame_number(s->workarea_in, s->frame_rate, predicted_new_frame_rate);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
can_import = false;
|
||||
@@ -295,18 +304,18 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
g.clip = -1;
|
||||
g.media_type = item_type;
|
||||
g.trimming = false;
|
||||
g.old_clip_in = g.clip_in = 0;
|
||||
g.old_clip_in = g.clip_in = default_clip_in;
|
||||
g.media = media;
|
||||
g.in = entry_point;
|
||||
g.transition = NULL;
|
||||
|
||||
// is video source a still image?
|
||||
switch (item_type) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
// is video source a still image?
|
||||
if (m->video_tracks.size() > 0 && m->video_tracks[0]->infinite_length && m->audio_tracks.size() == 0) {
|
||||
g.out = g.in + 100;
|
||||
} else {
|
||||
g.out = entry_point + m->get_length_in_frames(predicted_new_frame_rate);
|
||||
g.out = entry_point + m->get_length_in_frames(predicted_new_frame_rate) - default_clip_in;
|
||||
}
|
||||
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
|
||||
Reference in New Issue
Block a user