added buttons to drag just video or just audio
This commit is contained in:
@@ -174,7 +174,8 @@ SOURCES += \
|
||||
undo/undostack.cpp \
|
||||
effects/internal/richtexteffect.cpp \
|
||||
ui/blur.cpp \
|
||||
ui/menu.cpp
|
||||
ui/menu.cpp \
|
||||
timeline/mediaimportdata.cpp
|
||||
|
||||
HEADERS += \
|
||||
ui/mainwindow.h \
|
||||
@@ -302,7 +303,8 @@ HEADERS += \
|
||||
undo/undostack.h \
|
||||
effects/internal/richtexteffect.h \
|
||||
ui/blur.h \
|
||||
ui/menu.h
|
||||
ui/menu.h \
|
||||
timeline/mediaimportdata.h
|
||||
|
||||
FORMS +=
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ void alloc_panels(QWidget* parent) {
|
||||
panel_sequence_viewer->setObjectName("seq_viewer");
|
||||
panel_footage_viewer = new Viewer(parent);
|
||||
panel_footage_viewer->setObjectName("footage_viewer");
|
||||
panel_footage_viewer->show_videoaudio_buttons(true);
|
||||
panel_project = new Project(parent);
|
||||
panel_project->setObjectName("proj_root");
|
||||
panel_effect_controls = new EffectControls(parent);
|
||||
|
||||
+2
-2
@@ -245,7 +245,7 @@ QString Project::get_next_sequence_name(QString start) {
|
||||
return name;
|
||||
}
|
||||
|
||||
SequencePtr create_sequence_from_media(QVector<Media*>& media_list) {
|
||||
SequencePtr create_sequence_from_media(QVector<olive::timeline::MediaImportData>& media_list) {
|
||||
SequencePtr s(new Sequence());
|
||||
|
||||
s->name = panel_project->get_next_sequence_name();
|
||||
@@ -260,7 +260,7 @@ SequencePtr create_sequence_from_media(QVector<Media*>& media_list) {
|
||||
bool got_video_values = false;
|
||||
bool got_audio_values = false;
|
||||
for (int i=0;i<media_list.size();i++) {
|
||||
Media* media = media_list.at(i);
|
||||
Media* media = media_list.at(i).media();
|
||||
switch (media->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@
|
||||
#include "project/sourcescommon.h"
|
||||
#include "ui/panel.h"
|
||||
#include "ui/sourceiconview.h"
|
||||
#include "timeline/mediaimportdata.h"
|
||||
#include "undo/undo.h"
|
||||
|
||||
#include "ui/sourcetable.h"
|
||||
@@ -45,7 +46,7 @@
|
||||
extern QString autorecovery_filename;
|
||||
extern QStringList recent_projects;
|
||||
|
||||
SequencePtr create_sequence_from_media(QVector<Media *> &media_list);
|
||||
SequencePtr create_sequence_from_media(QVector<olive::timeline::MediaImportData> &media_list);
|
||||
|
||||
QString get_channel_layout_name(int channels, uint64_t layout);
|
||||
QString get_interlacing_name(int interlacing);
|
||||
|
||||
+37
-20
@@ -192,14 +192,15 @@ void Timeline::toggle_show_all() {
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector<Media*>& media_list) {
|
||||
void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector<olive::timeline::MediaImportData>& media_list) {
|
||||
video_ghosts = false;
|
||||
audio_ghosts = false;
|
||||
|
||||
for (int i=0;i<media_list.size();i++) {
|
||||
bool can_import = true;
|
||||
|
||||
Media* medium = media_list.at(i);
|
||||
const olive::timeline::MediaImportData import_data = media_list.at(i);
|
||||
Media* medium = import_data.media();
|
||||
Footage* m = nullptr;
|
||||
Sequence* s = nullptr;
|
||||
long sequence_length = 0;
|
||||
@@ -212,7 +213,9 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
|
||||
can_import = m->ready;
|
||||
if (m->using_inout) {
|
||||
double source_fr = 30;
|
||||
if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0).video_frame_rate)) source_fr = m->video_tracks.at(0).video_frame_rate * m->speed;
|
||||
if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0).video_frame_rate)) {
|
||||
source_fr = m->video_tracks.at(0).video_frame_rate * m->speed;
|
||||
}
|
||||
default_clip_in = rescale_frame_number(m->in, source_fr, seq->frame_rate);
|
||||
default_clip_out = rescale_frame_number(m->out, source_fr, seq->frame_rate);
|
||||
}
|
||||
@@ -253,20 +256,27 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
|
||||
}
|
||||
}
|
||||
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
if (m->audio_tracks.at(j).enabled) {
|
||||
g.track = j;
|
||||
g.media_stream = m->audio_tracks.at(j).file_index;
|
||||
ghosts.append(g);
|
||||
audio_ghosts = true;
|
||||
if (import_data.type() == olive::timeline::kImportAudioOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
if (m->audio_tracks.at(j).enabled) {
|
||||
g.track = j;
|
||||
g.media_stream = m->audio_tracks.at(j).file_index;
|
||||
ghosts.append(g);
|
||||
audio_ghosts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j=0;j<m->video_tracks.size();j++) {
|
||||
if (m->video_tracks.at(j).enabled) {
|
||||
g.track = -1-j;
|
||||
g.media_stream = m->video_tracks.at(j).file_index;
|
||||
ghosts.append(g);
|
||||
video_ghosts = true;
|
||||
|
||||
if (import_data.type() == olive::timeline::kImportVideoOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
for (int j=0;j<m->video_tracks.size();j++) {
|
||||
if (m->video_tracks.at(j).enabled) {
|
||||
g.track = -1-j;
|
||||
g.media_stream = m->video_tracks.at(j).file_index;
|
||||
ghosts.append(g);
|
||||
video_ghosts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -277,10 +287,17 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
|
||||
g.out -= (sequence_length - default_clip_out);
|
||||
}
|
||||
|
||||
g.track = -1;
|
||||
ghosts.append(g);
|
||||
g.track = 0;
|
||||
ghosts.append(g);
|
||||
if (import_data.type() == olive::timeline::kImportVideoOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
g.track = -1;
|
||||
ghosts.append(g);
|
||||
}
|
||||
|
||||
if (import_data.type() == olive::timeline::kImportAudioOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
g.track = 0;
|
||||
ghosts.append(g);
|
||||
}
|
||||
|
||||
video_ghosts = true;
|
||||
audio_ghosts = true;
|
||||
@@ -446,7 +463,7 @@ void Timeline::nest() {
|
||||
MediaPtr m = panel_project->create_sequence_internal(ca, s, false, nullptr);
|
||||
|
||||
// add nested sequence to active sequence
|
||||
QVector<Media*> media_list;
|
||||
QVector<olive::timeline::MediaImportData> media_list;
|
||||
media_list.append(m.get());
|
||||
create_ghosts_from_media(olive::ActiveSequence.get(), earliest_point, media_list);
|
||||
add_clips_from_ghosts(ca, olive::ActiveSequence.get());
|
||||
|
||||
+2
-1
@@ -29,6 +29,7 @@
|
||||
#include "ui/timelinetools.h"
|
||||
#include "timeline/selection.h"
|
||||
#include "timeline/clip.h"
|
||||
#include "timeline/mediaimportdata.h"
|
||||
#include "undo/undo.h"
|
||||
#include "ui/timelineheader.h"
|
||||
#include "ui/resizablescrollbar.h"
|
||||
@@ -125,7 +126,7 @@ public:
|
||||
void edit_to_point_internal(bool in, bool ripple);
|
||||
void delete_in_out_internal(bool ripple);
|
||||
|
||||
void create_ghosts_from_media(Sequence *seq, long entry_point, QVector<Media *> &media_list);
|
||||
void create_ghosts_from_media(Sequence *seq, long entry_point, QVector<olive::timeline::MediaImportData> &media_list);
|
||||
void add_clips_from_ghosts(ComboAction *ca, Sequence *s);
|
||||
|
||||
int getTimelineScreenPointFromFrame(long frame);
|
||||
|
||||
+88
-14
@@ -20,6 +20,21 @@
|
||||
|
||||
#include "viewer.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
#include <QtMath>
|
||||
#include <QAudioOutput>
|
||||
#include <QPainter>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "rendering/audio.h"
|
||||
#include "timeline.h"
|
||||
#include "panels/project.h"
|
||||
@@ -45,19 +60,6 @@
|
||||
#define FRAMES_IN_ONE_MINUTE 1798 // 1800 - 2
|
||||
#define FRAMES_IN_TEN_MINUTES 17978 // (FRAMES_IN_ONE_MINUTE * 10) - 2
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
#include <QtMath>
|
||||
#include <QAudioOutput>
|
||||
#include <QPainter>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
Viewer::Viewer(QWidget *parent) :
|
||||
Panel(parent),
|
||||
playing(false),
|
||||
@@ -538,6 +540,17 @@ void Viewer::update_viewer() {
|
||||
update_end_timecode();
|
||||
}
|
||||
|
||||
void Viewer::initiate_drag(olive::timeline::MediaImportType drag_type)
|
||||
{
|
||||
// FIXME: This should contain actual metadata rather than fake metadata
|
||||
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
mimeData->setText(QString::number(drag_type));
|
||||
drag->setMimeData(mimeData);
|
||||
drag->exec();
|
||||
}
|
||||
|
||||
void Viewer::clear_in() {
|
||||
if (seq != nullptr
|
||||
&& seq->using_workarea) {
|
||||
@@ -585,6 +598,12 @@ void Viewer::set_panel_name(const QString &n) {
|
||||
update_window_title();
|
||||
}
|
||||
|
||||
void Viewer::show_videoaudio_buttons(bool s)
|
||||
{
|
||||
video_only_button->setVisible(s);
|
||||
audio_only_button->setVisible(s);
|
||||
}
|
||||
|
||||
void Viewer::update_window_title() {
|
||||
QString name;
|
||||
if (seq == nullptr) {
|
||||
@@ -658,8 +677,12 @@ void Viewer::setup_ui() {
|
||||
QHBoxLayout* lower_control_layout = new QHBoxLayout(lower_controls);
|
||||
lower_control_layout->setMargin(0);
|
||||
|
||||
// current time code
|
||||
QSizePolicy timecode_container_policy(QSizePolicy::Minimum, QSizePolicy::Maximum);
|
||||
QSizePolicy lower_control_policy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
||||
|
||||
// Current time code container
|
||||
QWidget* current_timecode_container = new QWidget();
|
||||
current_timecode_container->setSizePolicy(timecode_container_policy);
|
||||
QHBoxLayout* current_timecode_container_layout = new QHBoxLayout(current_timecode_container);
|
||||
current_timecode_container_layout->setSpacing(0);
|
||||
current_timecode_container_layout->setMargin(0);
|
||||
@@ -667,11 +690,19 @@ void Viewer::setup_ui() {
|
||||
current_timecode_container_layout->addWidget(current_timecode_slider);
|
||||
lower_control_layout->addWidget(current_timecode_container);
|
||||
|
||||
// Left controls container
|
||||
QWidget* left_controls = new QWidget();
|
||||
left_controls->setSizePolicy(lower_control_policy);
|
||||
lower_control_layout->addWidget(left_controls);
|
||||
|
||||
// Playback controls container
|
||||
QWidget* playback_controls = new QWidget();
|
||||
playback_controls->setSizePolicy(lower_control_policy);
|
||||
|
||||
QHBoxLayout* playback_control_layout = new QHBoxLayout(playback_controls);
|
||||
playback_control_layout->setSpacing(0);
|
||||
playback_control_layout->setMargin(0);
|
||||
playback_control_layout->addStretch();
|
||||
|
||||
go_to_start_button = new QPushButton();
|
||||
go_to_start_button->setIcon(olive::icon::ViewerGoToStart);
|
||||
@@ -698,9 +729,40 @@ void Viewer::setup_ui() {
|
||||
connect(go_to_end_frame, SIGNAL(clicked(bool)), this, SLOT(go_to_out()));
|
||||
playback_control_layout->addWidget(go_to_end_frame);
|
||||
|
||||
playback_control_layout->addStretch();
|
||||
|
||||
lower_control_layout->addWidget(playback_controls);
|
||||
|
||||
// Right controls container
|
||||
QWidget* right_controls = new QWidget();
|
||||
right_controls->setSizePolicy(lower_control_policy);
|
||||
|
||||
QHBoxLayout* right_control_layout = new QHBoxLayout(right_controls);
|
||||
right_control_layout->setSpacing(0);
|
||||
right_control_layout->setMargin(0);
|
||||
right_control_layout->addStretch();
|
||||
|
||||
video_only_button = new QPushButton();
|
||||
video_only_button->setToolTip(tr("Drag video only"));
|
||||
video_only_button->setIcon(olive::icon::MediaVideo);
|
||||
video_only_button->setVisible(false);
|
||||
right_control_layout->addWidget(video_only_button);
|
||||
connect(video_only_button, SIGNAL(pressed()), this, SLOT(drag_video_only()));
|
||||
|
||||
audio_only_button = new QPushButton();
|
||||
audio_only_button->setToolTip(tr("Drag audio only"));
|
||||
audio_only_button->setIcon(olive::icon::MediaAudio);
|
||||
audio_only_button->setVisible(false);
|
||||
right_control_layout->addWidget(audio_only_button);
|
||||
connect(audio_only_button, SIGNAL(pressed()), this, SLOT(drag_audio_only()));
|
||||
|
||||
right_control_layout->addStretch();
|
||||
|
||||
lower_control_layout->addWidget(right_controls);
|
||||
|
||||
// End time code container
|
||||
QWidget* end_timecode_container = new QWidget();
|
||||
end_timecode_container->setSizePolicy(timecode_container_policy);
|
||||
|
||||
QHBoxLayout* end_timecode_layout = new QHBoxLayout(end_timecode_container);
|
||||
end_timecode_layout->setSpacing(0);
|
||||
@@ -851,6 +913,16 @@ void Viewer::resize_move(double d) {
|
||||
set_zoom_value(headers->get_zoom()*d);
|
||||
}
|
||||
|
||||
void Viewer::drag_video_only()
|
||||
{
|
||||
initiate_drag(olive::timeline::kImportVideoOnly);
|
||||
}
|
||||
|
||||
void Viewer::drag_audio_only()
|
||||
{
|
||||
initiate_drag(olive::timeline::kImportAudioOnly);
|
||||
}
|
||||
|
||||
void Viewer::clean_created_seq() {
|
||||
viewer_widget->waveform = false;
|
||||
|
||||
@@ -902,6 +974,8 @@ void Viewer::set_sequence(bool main, SequencePtr s) {
|
||||
play_button->setEnabled(!null_sequence);
|
||||
next_frame_button->setEnabled(!null_sequence);
|
||||
go_to_end_frame->setEnabled(!null_sequence);
|
||||
video_only_button->setEnabled(!null_sequence);
|
||||
audio_only_button->setEnabled(!null_sequence);
|
||||
|
||||
if (!null_sequence) {
|
||||
current_timecode_slider->SetFrameRate(seq->frame_rate);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#include "timeline/marker.h"
|
||||
#include "timeline/mediaimportdata.h"
|
||||
#include "project/media.h"
|
||||
|
||||
#include "ui/panel.h"
|
||||
@@ -64,6 +65,7 @@ public:
|
||||
void set_out_point();
|
||||
void set_zoom(bool in);
|
||||
void set_panel_name(const QString& n);
|
||||
void show_videoaudio_buttons(bool s);
|
||||
|
||||
// playback functions
|
||||
void seek(long p);
|
||||
@@ -98,6 +100,10 @@ public:
|
||||
|
||||
TimelineHeader* headers;
|
||||
|
||||
|
||||
|
||||
void initiate_drag(olive::timeline::MediaImportType drag_type);
|
||||
|
||||
virtual void Retranslate() override;
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
@@ -116,12 +122,17 @@ public slots:
|
||||
void close_media();
|
||||
void update_viewer();
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void update_playhead();
|
||||
void timer_update();
|
||||
void recording_flasher_update();
|
||||
void resize_move(double d);
|
||||
|
||||
void drag_video_only();
|
||||
void drag_audio_only();
|
||||
|
||||
private:
|
||||
|
||||
void update_window_title();
|
||||
@@ -155,6 +166,9 @@ private:
|
||||
QPushButton* next_frame_button;
|
||||
QPushButton* go_to_end_frame;
|
||||
|
||||
QPushButton* video_only_button;
|
||||
QPushButton* audio_only_button;
|
||||
|
||||
bool cue_recording_internal;
|
||||
QTimer recording_flasher;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ SourcesCommon::SourcesCommon(Project* parent) :
|
||||
|
||||
void SourcesCommon::create_seq_from_selected() {
|
||||
if (!selected_items.isEmpty()) {
|
||||
QVector<Media*> media_list;
|
||||
QVector<olive::timeline::MediaImportData> media_list;
|
||||
for (int i=0;i<selected_items.size();i++) {
|
||||
media_list.append(project_parent->item_to_media(selected_items.at(i)));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "mediaimportdata.h"
|
||||
|
||||
olive::timeline::MediaImportData::MediaImportData(Media *media, olive::timeline::MediaImportType import_type) :
|
||||
media_(media),
|
||||
import_type_(import_type)
|
||||
{
|
||||
}
|
||||
|
||||
Media *olive::timeline::MediaImportData::media() const
|
||||
{
|
||||
return media_;
|
||||
}
|
||||
|
||||
olive::timeline::MediaImportType olive::timeline::MediaImportData::type() const
|
||||
{
|
||||
return import_type_;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef MEDIAIMPORTDATA_H
|
||||
#define MEDIAIMPORTDATA_H
|
||||
|
||||
#include "project/media.h"
|
||||
|
||||
namespace olive {
|
||||
namespace timeline {
|
||||
|
||||
enum MediaImportType {
|
||||
kImportVideoOnly,
|
||||
kImportAudioOnly,
|
||||
kImportBoth
|
||||
};
|
||||
|
||||
class MediaImportData {
|
||||
public:
|
||||
MediaImportData(Media* media = nullptr, MediaImportType import_type = kImportBoth);
|
||||
Media* media() const;
|
||||
MediaImportType type() const;
|
||||
private:
|
||||
Media* media_;
|
||||
MediaImportType import_type_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // MEDIAIMPORTDATA_H
|
||||
@@ -237,7 +237,7 @@ bool same_sign(int a, int b) {
|
||||
void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
bool import_init = false;
|
||||
|
||||
QVector<Media*> media_list;
|
||||
QVector<olive::timeline::MediaImportData> media_list;
|
||||
panel_timeline->importing_files = false;
|
||||
|
||||
if (event->source() == panel_project->tree_view || event->source() == panel_project->icon_view) {
|
||||
@@ -249,10 +249,13 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
import_init = true;
|
||||
}
|
||||
|
||||
if (event->source() == panel_footage_viewer->viewer_widget) {
|
||||
if (event->source() == panel_footage_viewer) {
|
||||
if (panel_footage_viewer->seq != olive::ActiveSequence) { // don't allow nesting the same sequence
|
||||
media_list.append(panel_footage_viewer->media);
|
||||
|
||||
media_list.append(olive::timeline::MediaImportData(panel_footage_viewer->media,
|
||||
static_cast<olive::timeline::MediaImportType>(event->mimeData()->text().toInt())));
|
||||
import_init = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -339,11 +339,7 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) {
|
||||
container->dragScrollMove(event->pos()*container->zoom);
|
||||
} else if (event->buttons() & Qt::LeftButton) {
|
||||
if (gizmos == nullptr) {
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
mimeData->setText("h"); // QMimeData will fail without some kind of data
|
||||
drag->setMimeData(mimeData);
|
||||
drag->exec();
|
||||
viewer->initiate_drag(olive::timeline::kImportBoth);
|
||||
dragging = false;
|
||||
} else {
|
||||
move_gizmos(event, false);
|
||||
|
||||
Reference in New Issue
Block a user