rewrite nearly complete

This commit is contained in:
itsmattkc
2019-04-03 01:38:01 +11:00
parent 8989333e99
commit 2d4714547b
102 changed files with 3213 additions and 2892 deletions
+14 -9
View File
@@ -47,7 +47,7 @@
#include "ui/viewerwidget.h"
#include "ui/menuhelper.h"
#include "ui/icons.h"
#include "project/clipboard.h"
#include "global/clipboard.h"
#include "global/config.h"
#include "ui/timelineheader.h"
#include "ui/keyframeview.h"
@@ -89,7 +89,10 @@ EffectControls::~EffectControls()
void EffectControls::set_zoom(bool in) {
zoom *= (in) ? 2 : 0.5;
update_keyframes();
scroll_to_frame(olive::ActiveSequence->playhead);
if (!selected_clips_.isEmpty()) {
scroll_to_frame(selected_clips_.first()->track()->sequence()->playhead);
}
}
void EffectControls::menu_select(QAction* q) {
@@ -104,21 +107,21 @@ void EffectControls::menu_select(QAction* q) {
nullptr,
nullptr,
meta,
olive::CurrentConfig.default_transition_length));
olive::config.default_transition_length));
}
if (c->closing_transition == nullptr) {
ca->append(new AddTransitionCommand(nullptr,
c,
nullptr,
meta,
olive::CurrentConfig.default_transition_length));
olive::config.default_transition_length));
}
} else {
ca->append(new AddEffectCommand(c, nullptr, meta));
}
}
}
olive::UndoStack.push(ca);
olive::undo_stack.push(ca);
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
update_ui(true);
} else {
@@ -175,7 +178,7 @@ void EffectControls::copy(bool del) {
if (del) {
if (ca->hasActions()) {
olive::UndoStack.push(ca);
olive::undo_stack.push(ca);
} else {
delete ca;
}
@@ -587,7 +590,7 @@ void EffectControls::DeleteSelectedEffects() {
}
if (ca->hasActions()) {
olive::UndoStack.push(ca);
olive::undo_stack.push(ca);
update_ui(true);
} else {
delete ca;
@@ -620,11 +623,13 @@ void EffectControls::SetClips()
{
Clear(true);
if (olive::ActiveSequence == nullptr) {
Sequence* top_sequence = Timeline::GetTopSequence().get();
if (top_sequence == nullptr) {
selected_clips_.clear();
} else {
// replace clip vector
selected_clips_ = olive::ActiveSequence->SelectedClips(false);
selected_clips_ = top_sequence->SelectedClips(false);
Load();
}
+1 -1
View File
@@ -27,7 +27,7 @@
#include "ui/keyframenavigator.h"
#include "ui/timelineheader.h"
#include "ui/timelinetools.h"
#include "timeline/timelinetools.h"
#include "ui/labelslider.h"
#include "ui/graphview.h"
#include "effects/effect.h"
+20 -9
View File
@@ -25,6 +25,7 @@
#include "effects/transition.h"
#include "global/config.h"
#include "global/debug.h"
#include "global/math.h"
#include <QScrollBar>
#include <QCoreApplication>
@@ -33,7 +34,7 @@ QVector<Project*> panel_project;
EffectControls* panel_effect_controls = nullptr;
Viewer* panel_sequence_viewer = nullptr;
Viewer* panel_footage_viewer = nullptr;
Timeline* panel_timeline = nullptr;
QVector<Timeline*> panel_timeline;
GraphEditor* panel_graph_editor = nullptr;
void update_ui(bool modified) {
@@ -41,14 +42,16 @@ void update_ui(bool modified) {
panel_effect_controls->SetClips();
}
panel_effect_controls->update_keyframes();
panel_timeline->repaint_timeline();
for (int i=0;i<panel_timeline.size();i++) {
panel_timeline.at(i)->repaint_timeline();
}
panel_sequence_viewer->update_viewer();
panel_graph_editor->update_panel();
}
QDockWidget *get_focused_panel(bool force_hover) {
QDockWidget* w = nullptr;
if (olive::CurrentConfig.hover_focus || force_hover) {
if (olive::config.hover_focus || force_hover) {
for (int i=0;i<olive::panels.size();i++) {
if (olive::panels.at(i)->underMouse()) {
w = olive::panels.at(i);
@@ -78,8 +81,9 @@ void alloc_panels(QWidget* parent) {
panel_project.append(first_project_panel);
panel_effect_controls = new EffectControls(parent);
panel_effect_controls->setObjectName("fx_controls");
panel_timeline = new Timeline(parent);
panel_timeline->setObjectName("timeline");
Timeline* first_timeline_panel = new Timeline(parent);
first_timeline_panel->setObjectName("timeline");
panel_timeline.append(first_timeline_panel);
panel_graph_editor = new GraphEditor(parent);
panel_graph_editor->setObjectName("graph_editor");
}
@@ -89,12 +93,19 @@ void free_panels() {
panel_sequence_viewer = nullptr;
delete panel_footage_viewer;
panel_footage_viewer = nullptr;
delete panel_project;
panel_project = nullptr;
for (int i=0;i<panel_project.size();i++) {
delete panel_project.at(i);
}
panel_project.clear();
delete panel_effect_controls;
panel_effect_controls = nullptr;
delete panel_timeline;
panel_timeline = nullptr;
for (int i=0;i<panel_timeline.size();i++) {
delete panel_timeline.at(i);
}
panel_timeline.clear();
}
void scroll_to_frame_internal(QScrollBar* bar, long frame, double zoom, int area_width) {
+1 -1
View File
@@ -31,7 +31,7 @@ extern QVector<Project*> panel_project;
extern EffectControls* panel_effect_controls;
extern Viewer* panel_sequence_viewer;
extern Viewer* panel_footage_viewer;
extern Timeline* panel_timeline;
extern QVector<Timeline*> panel_timeline;
extern GraphEditor* panel_graph_editor;
void update_ui(bool modified);
+39 -51
View File
@@ -54,7 +54,7 @@ extern "C" {
#include "dialogs/mediapropertiesdialog.h"
#include "dialogs/newsequencedialog.h"
#include "dialogs/loaddialog.h"
#include "project/clipboard.h"
#include "global/clipboard.h"
#include "ui/sourcetable.h"
#include "ui/sourceiconview.h"
#include "ui/icons.h"
@@ -83,7 +83,7 @@ Project::Project(QWidget *parent) :
// optional toolbar
toolbar_widget = new QWidget();
toolbar_widget->setVisible(olive::CurrentConfig.show_project_toolbar);
toolbar_widget->setVisible(olive::config.show_project_toolbar);
toolbar_widget->setObjectName("project_toolbar");
QHBoxLayout* toolbar = new QHBoxLayout(toolbar_widget);
@@ -233,7 +233,7 @@ void Project::duplicate_selected() {
}
}
if (duped) {
olive::UndoStack.push(ca);
olive::undo_stack.push(ca);
} else {
delete ca;
}
@@ -250,7 +250,9 @@ void Project::replace_selected_file() {
}
void Project::replace_clip_media() {
if (olive::ActiveSequence == nullptr) {
Sequence* top_sequence = Timeline::GetTopSequence().get();
if (top_sequence == nullptr) {
QMessageBox::critical(this,
tr("No active sequence"),
tr("No sequence is active, please open the sequence you want to replace clips from."),
@@ -259,7 +261,7 @@ void Project::replace_clip_media() {
QModelIndexList selected_items = get_current_selected();
if (selected_items.size() == 1) {
Media* item = item_to_media(selected_items.at(0));
if (item->get_type() == MEDIA_TYPE_SEQUENCE && olive::ActiveSequence == item->to_sequence()) {
if (item->get_type() == MEDIA_TYPE_SEQUENCE && top_sequence == item->to_sequence().get()) {
QMessageBox::critical(this,
tr("Active sequence selected"),
tr("You cannot insert a sequence into itself, so no clips of this media would be in this sequence."),
@@ -299,7 +301,7 @@ void Project::open_properties() {
item->get_name());
if (!new_name.isEmpty()) {
MediaRename* mr = new MediaRename(item, new_name);
olive::UndoStack.push(mr);
olive::undo_stack.push(mr);
}
}
}
@@ -308,10 +310,10 @@ void Project::open_properties() {
void Project::new_folder() {
MediaPtr m = olive::project::CreateFolder(nullptr);
olive::UndoStack.push(new AddMediaCommand(m, get_selected_folder()));
olive::undo_stack.push(new AddMediaCommand(m, get_selected_folder()));
QModelIndex index = olive::project_model.create_index(m->row(), 0, m.get());
switch (olive::CurrentConfig.project_view_type) {
switch (olive::config.project_view_type) {
case olive::PROJECT_VIEW_TREE:
tree_view->edit(sorter.mapFromSource(index));
break;
@@ -451,8 +453,9 @@ void Project::delete_selected_media() {
panel_graph_editor->set_row(nullptr);
panel_effect_controls->Clear(true);
if (olive::ActiveSequence != nullptr) {
olive::ActiveSequence->ClearSelections();
Sequence* top_sequence = Timeline::GetTopSequence().get();
if (top_sequence != nullptr) {
top_sequence->ClearSelections();
}
// remove media and parents
@@ -474,9 +477,7 @@ void Project::delete_selected_media() {
Sequence* s = items.at(i)->to_sequence().get();
if (s == olive::ActiveSequence.get()) {
ca->append(new ChangeSequenceAction(nullptr));
}
Timeline::CloseSequence(s);
if (s == panel_footage_viewer->seq.get()) {
panel_footage_viewer->set_media(nullptr);
@@ -487,7 +488,7 @@ void Project::delete_selected_media() {
}
}
}
olive::UndoStack.push(ca);
olive::undo_stack.push(ca);
// redraw clips
if (redraw) {
@@ -527,7 +528,7 @@ bool Project::reveal_media(Media *media, QModelIndex parent) {
// retrieve its parent item
QModelIndex hierarchy = sorted_index.parent();
if (olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_TREE) {
if (olive::config.project_view_type == olive::PROJECT_VIEW_TREE) {
// if we're in tree view, expand every folder in the hierarchy containing the media
while (hierarchy.isValid()) {
@@ -542,7 +543,7 @@ bool Project::reveal_media(Media *media, QModelIndex parent) {
);
tree_view->selectionModel()->select(row_select, QItemSelectionModel::Select);
} else if (olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_ICON) {
} else if (olive::config.project_view_type == olive::PROJECT_VIEW_ICON) {
// if we're in icon view, we just "browse" to the parent folder
icon_view->setRootIndex(hierarchy);
@@ -563,55 +564,42 @@ bool Project::reveal_media(Media *media, QModelIndex parent) {
}
void Project::delete_clips_using_selected_media() {
if (olive::ActiveSequence == nullptr) {
Sequence* top_sequence = Timeline::GetTopSequence().get();
if (top_sequence == nullptr) {
QMessageBox::critical(this,
tr("No active sequence"),
tr("No sequence is active, please open the sequence you want to delete clips from."),
QMessageBox::Ok);
} else {
ComboAction* ca = new ComboAction();
bool deleted = false;
QModelIndexList items = get_current_selected();
QVector<Clip*> sequence_clips = olive::ActiveSequence->GetAllClips();
for (int i=0;i<sequence_clips.size();i++) {
Clip* c = sequence_clips.at(i);
for (int j=0;j<items.size();j++) {
Media* m = item_to_media(items.at(j));
if (c->media() == m) {
ca->append(new DeleteClipAction(c));
deleted = true;
}
}
}
for (int j=0;j<items.size();j++) {
Media* m = item_to_media(items.at(j));
if (olive::clipboard.DeleteClipsWithMedia(ca, m)) {
deleted = true;
}
}
if (deleted) {
olive::UndoStack.push(ca);
update_ui(true);
} else {
delete ca;
QModelIndexList items = get_current_selected();
QVector<Media*> media;
media.resize(items.size());
for (int i=0;i<items.size();i++) {
media[i] = item_to_media(items.at(i));
}
top_sequence->DeleteClipsUsingMedia(media);
}
}
void Project::update_view_type() {
tree_view->setVisible(olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_TREE);
icon_view_container->setVisible(olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_ICON
|| olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_LIST);
tree_view->setVisible(olive::config.project_view_type == olive::PROJECT_VIEW_TREE);
icon_view_container->setVisible(olive::config.project_view_type == olive::PROJECT_VIEW_ICON
|| olive::config.project_view_type == olive::PROJECT_VIEW_LIST);
switch (olive::CurrentConfig.project_view_type) {
switch (olive::config.project_view_type) {
case olive::PROJECT_VIEW_TREE:
sources_common.view = tree_view;
break;
case olive::PROJECT_VIEW_ICON:
case olive::PROJECT_VIEW_LIST:
icon_view->setViewMode(olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_ICON ?
icon_view->setViewMode(olive::config.project_view_type == olive::PROJECT_VIEW_ICON ?
QListView::IconMode : QListView::ListMode);
// update list/grid size since they use this value slightly differently
@@ -623,18 +611,18 @@ void Project::update_view_type() {
}
void Project::set_icon_view() {
olive::CurrentConfig.project_view_type = olive::PROJECT_VIEW_ICON;
olive::config.project_view_type = olive::PROJECT_VIEW_ICON;
update_view_type();
}
void Project::set_list_view()
{
olive::CurrentConfig.project_view_type = olive::PROJECT_VIEW_LIST;
olive::config.project_view_type = olive::PROJECT_VIEW_LIST;
update_view_type();
}
void Project::set_tree_view() {
olive::CurrentConfig.project_view_type = olive::PROJECT_VIEW_TREE;
olive::config.project_view_type = olive::PROJECT_VIEW_TREE;
update_view_type();
}
@@ -663,7 +651,7 @@ void Project::make_new_menu() {
}
QModelIndexList Project::get_current_selected() {
if (olive::CurrentConfig.project_view_type == olive::PROJECT_VIEW_TREE) {
if (olive::config.project_view_type == olive::PROJECT_VIEW_TREE) {
return tree_view->selectionModel()->selectedRows();
}
return icon_view->selectionModel()->selectedIndexes();
+248 -627
View File
File diff suppressed because it is too large Load Diff
+24 -41
View File
@@ -26,7 +26,8 @@
#include <QPushButton>
#include "ui/timelinearea.h"
#include "ui/timelinetools.h"
#include "timeline/timelinetools.h"
#include "timeline/timelinefunctions.h"
#include "timeline/selection.h"
#include "timeline/clip.h"
#include "timeline/mediaimportdata.h"
@@ -37,59 +38,44 @@
#include "ui/audiomonitor.h"
#include "ui/panel.h"
int getScreenPointFromFrame(double zoom, long frame);
long getFrameFromScreenPoint(double zoom, int x);
bool selection_contains_transition(const Selection& s, Clip *c, int type);
class Timeline : public Panel
{
Q_OBJECT
public:
explicit Timeline(QWidget *parent = nullptr);
static Timeline* GetTopTimeline();
static SequencePtr GetTopSequence();
static void OpenSequence(SequencePtr s);
static void CloseSequence(Sequence* s);
static void CloseAll();
static bool IsImporting();
void SetSequence(SequencePtr sequence);
virtual bool focused() override;
void multiply_zoom(double m);
void copy(bool del);
void clean_up_selections(QVector<Selection>& areas);
void deselect_area(long in, long out, int track);
void delete_areas_and_relink(ComboAction *ca, QVector<Selection>& areas, bool deselect_areas);
void update_sequence();
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<olive::timeline::MediaImportData> &media_list);
void add_clips_from_ghosts(ComboAction *ca, Sequence *s);
int getTimelineScreenPointFromFrame(long frame);
long getTimelineFrameFromScreenPoint(int x);
int getDisplayScreenPointFromFrame(long frame);
long getDisplayFrameFromScreenPoint(int x);
long get_snap_range();
bool snap_to_point(long point, long* l);
bool snap_to_timeline(long* l, bool use_playhead, bool use_markers, bool use_workarea);
void set_marker();
// shared information
int tool;
long cursor_frame;
int cursor_track;
Track* cursor_track;
double zoom;
bool zoom_just_changed;
long drag_frame_start;
int drag_track_start;
Track* drag_track_start;
void update_effect_controls();
bool showing_all;
double old_zoom;
// snapping
bool snapping;
bool snapped;
long snap_point;
// selecting functions
bool selecting;
int selection_offset;
@@ -102,18 +88,16 @@ public:
bool moving_init;
bool moving_proc;
QVector<Ghost> ghosts;
bool video_ghosts;
bool audio_ghosts;
bool move_insert;
// trimming
int trim_target;
Clip* trim_target;
olive::timeline::TrimType trim_type;
int transition_select;
// splitting
bool splitting;
QVector<int> split_tracks;
QVector<Track*> split_tracks;
// importing
bool importing;
@@ -121,15 +105,15 @@ public:
// creating variables
bool creating;
int creating_object;
olive::timeline::CreateObjects creating_object;
// transition variables
bool transition_tool_init;
bool transition_tool_proc;
int transition_tool_open_clip;
int transition_tool_close_clip;
Clip* transition_tool_open_clip;
Clip* transition_tool_close_clip;
const EffectMeta* transition_tool_meta;
int transition_tool_side;
Track::Type transition_tool_side;
// hand tool variables
bool hand_moving;
@@ -155,7 +139,6 @@ public:
QPushButton* snappingButton;
void scroll_to_frame(long frame);
void select_from_playhead();
bool can_ripple_empty_space(long frame, int track);
@@ -163,11 +146,9 @@ public:
protected:
virtual void resizeEvent(QResizeEvent *event) override;
public slots:
void paste(bool insert = false);
void repaint_timeline();
void toggle_show_all();
void deselect();
void toggle_links();
void split_at_playhead();
void ripple_delete();
void ripple_delete_empty_space();
@@ -184,9 +165,6 @@ public slots:
void IncreaseTrackHeight();
void DecreaseTrackHeight();
void previous_cut();
void next_cut();
void add_transition();
void nest();
@@ -194,6 +172,9 @@ public slots:
void zoom_in();
void zoom_out();
signals:
void SequenceChanged(SequencePtr s);
private slots:
void snapping_clicked(bool checked);
void add_btn_click();
@@ -206,6 +187,8 @@ private slots:
void set_tool();
private:
SequencePtr sequence_;
void ChangeTrackHeightUniformly(int diff);
void set_zoom_value(double v);
void set_tool(int tool);
+47 -47
View File
@@ -70,7 +70,8 @@ Viewer::Viewer(QWidget *parent) :
created_sequence(false),
minimum_zoom(1.0),
cue_recording_internal(false),
playback_speed(0)
playback_speed(0),
mode_(kTimelineMode)
{
setup_ui();
@@ -101,6 +102,16 @@ Viewer::Viewer(QWidget *parent) :
update_end_timecode();
}
void Viewer::SetMode(Viewer::Mode mode)
{
mode_ = mode;
}
Viewer::Mode Viewer::mode()
{
return mode_;
}
void Viewer::Retranslate() {
/// Viewer panels are retranslated through the MainWindow to differentiate Media and Sequence Viewers
// update_window_title();
@@ -116,14 +127,6 @@ bool Viewer::focused() {
|| go_to_end_frame->hasFocus();
}
bool Viewer::is_main_sequence() {
return main_sequence;
}
void Viewer::set_main_sequence() {
set_sequence(true, olive::ActiveSequence);
}
void Viewer::reset_all_audio() {
// reset all clip audio
if (seq != nullptr) {
@@ -150,20 +153,24 @@ void Viewer::reset_all_audio() {
void Viewer::seek(long p) {
pause();
if (main_sequence) {
if (mode_ == kTimelineMode) {
seq->playhead = p;
} else {
seq->playhead = qMin(seq->GetEndFrame(), qMax(0L, p));
}
bool update_fx = false;
if (main_sequence) {
panel_timeline->scroll_to_frame(p);
if (mode_ == kTimelineMode) {
panel_timeline.first()->scroll_to_frame(p);
panel_effect_controls->scroll_to_frame(p);
if (olive::CurrentConfig.seek_also_selects) {
panel_timeline->select_from_playhead();
if (olive::config.seek_also_selects) {
seq->SelectAtPlayhead();
update_fx = true;
}
}
reset_all_audio();
audio_scrub = true;
last_playhead = seq->playhead;
@@ -274,11 +281,11 @@ void Viewer::play(bool in_to_out) {
uncue_recording();
}
bool seek_to_in = (seq->using_workarea && (olive::CurrentConfig.loop || playing_in_to_out));
bool seek_to_in = (seq->using_workarea && (olive::config.loop || playing_in_to_out));
if (!is_recording_cued()
&& playback_speed >= 0
&& (playing_in_to_out
|| (olive::CurrentConfig.auto_seek_to_beginning && seq->playhead >= sequence_end_frame)
|| (olive::config.auto_seek_to_beginning && seq->playhead >= sequence_end_frame)
|| (seek_to_in && seq->playhead >= seq->workarea_out))) {
seek(seek_to_in ? seq->workarea_in : 0);
}
@@ -359,7 +366,7 @@ void Viewer::pause() {
QVector<ClipPtr> add_clips;
add_clips.append(c);
olive::UndoStack.push(new AddClipCommand(seq.get(), add_clips)); // add clip
olive::undo_stack.push(new AddClipCommand(add_clips)); // add clip
}
@@ -374,7 +381,7 @@ void Viewer::update_playhead_timecode(long p) {
}
void Viewer::update_end_timecode() {
end_timecode->setText((seq == nullptr) ? frame_to_timecode(0, olive::CurrentConfig.timecode_view, 30) : frame_to_timecode(seq->GetEndFrame(), olive::CurrentConfig.timecode_view, seq->frame_rate));
end_timecode->setText((seq == nullptr) ? frame_to_timecode(0, olive::config.timecode_view, 30) : frame_to_timecode(seq->GetEndFrame(), olive::config.timecode_view, seq->frame_rate));
}
void Viewer::update_header_zoom() {
@@ -392,11 +399,10 @@ void Viewer::update_header_zoom() {
}
void Viewer::update_parents(bool reload_fx) {
if (main_sequence) {
if (mode_ == kTimelineMode) {
update_ui(reload_fx);
} else {
update_viewer();
panel_timeline->repaint_timeline();
}
}
@@ -410,7 +416,7 @@ ViewerWidget *Viewer::viewer_widget()
}
void Viewer::set_marker() {
set_marker_internal(seq.get());
Marker::SetOnSequence(seq.get());
}
void Viewer::resizeEvent(QResizeEvent *e) {
@@ -435,7 +441,7 @@ void Viewer::prev_cut()
if (seq != nullptr
&& seq->playhead > 0) {
QVector<Clip*> sequence_clips = olive::ActiveSequence->GetAllClips();
QVector<Clip*> sequence_clips = seq->GetAllClips();
long p_cut = 0;
for (int i=0;i<sequence_clips.size();i++) {
@@ -489,7 +495,7 @@ void Viewer::initiate_drag(olive::timeline::MediaImportType drag_type)
void Viewer::clear_in() {
if (seq != nullptr
&& seq->using_workarea) {
olive::UndoStack.push(new SetTimelineInOutCommand(seq.get(), true, 0, seq->workarea_out));
olive::undo_stack.push(new SetTimelineInOutCommand(seq.get(), true, 0, seq->workarea_out));
update_parents();
}
}
@@ -497,7 +503,7 @@ void Viewer::clear_in() {
void Viewer::clear_out() {
if (seq != nullptr
&& seq->using_workarea) {
olive::UndoStack.push(new SetTimelineInOutCommand(seq.get(), true, seq->workarea_in, seq->GetEndFrame()));
olive::undo_stack.push(new SetTimelineInOutCommand(seq.get(), true, seq->workarea_in, seq->GetEndFrame()));
update_parents();
}
}
@@ -505,7 +511,7 @@ void Viewer::clear_out() {
void Viewer::clear_inout_point() {
if (seq != nullptr
&& seq->using_workarea) {
olive::UndoStack.push(new SetTimelineInOutCommand(seq.get(), false, 0, 0));
olive::undo_stack.push(new SetTimelineInOutCommand(seq.get(), false, 0, 0));
update_parents();
}
}
@@ -575,13 +581,13 @@ void Viewer::set_playback_speed(int s) {
}
long Viewer::get_seq_in() {
return ((olive::CurrentConfig.loop || playing_in_to_out) && seq->using_workarea)
return ((olive::config.loop || playing_in_to_out) && seq->using_workarea)
? seq->workarea_in
: 0;
}
long Viewer::get_seq_out() {
return ((olive::CurrentConfig.loop || playing_in_to_out) && seq->using_workarea && previous_playhead < seq->workarea_out)
return ((olive::config.loop || playing_in_to_out) && seq->using_workarea && previous_playhead < seq->workarea_out)
? seq->workarea_out
: seq->GetEndFrame();
}
@@ -713,7 +719,6 @@ void Viewer::setup_ui() {
}
void Viewer::set_media(Media* m) {
main_sequence = false;
media = m;
SequencePtr new_sequence = nullptr;
@@ -737,7 +742,7 @@ void Viewer::set_media(Media* m) {
new_sequence->workarea_out = footage->out;
}
new_sequence->frame_rate = olive::CurrentConfig.default_sequence_framerate;
new_sequence->frame_rate = olive::config.default_sequence_framerate;
if (footage->video_tracks.size() > 0) {
const FootageStream& video_stream = footage->video_tracks.at(0);
@@ -761,20 +766,19 @@ void Viewer::set_media(Media* m) {
c->refresh();
track->AddClip(c);
} else {
new_sequence->width = olive::CurrentConfig.default_sequence_width;
new_sequence->height = olive::CurrentConfig.default_sequence_height;
new_sequence->width = olive::config.default_sequence_width;
new_sequence->height = olive::config.default_sequence_height;
}
if (footage->audio_tracks.size() > 0) {
const FootageStream& audio_stream = footage->audio_tracks.at(0);
new_sequence->audio_frequency = audio_stream.audio_frequency;
ClipPtr c = std::make_shared<Clip>(new_sequence.get());
Track* track = new_sequence->GetTrackList(Track::kTypeAudio)->First();
ClipPtr c = std::make_shared<Clip>(track);
c->set_media(media, audio_stream.file_index);
c->set_timeline_in(0);
c->set_timeline_out(footage->get_length_in_frames(new_sequence->frame_rate));
Track* track = new_sequence->GetTrackList(Track::kTypeAudio)->First();
c->set_track(track);
c->set_clip_in(0);
c->refresh();
track->AddClip(c);
@@ -786,7 +790,7 @@ void Viewer::set_media(Media* m) {
viewer_widget_->frame_update();
}
} else {
new_sequence->audio_frequency = olive::CurrentConfig.default_sequence_audio_frequency;
new_sequence->audio_frequency = olive::config.default_sequence_audio_frequency;
}
new_sequence->audio_layout = AV_CH_LAYOUT_STEREO;
@@ -798,7 +802,7 @@ void Viewer::set_media(Media* m) {
}
}
set_sequence(false, new_sequence);
set_sequence(new_sequence);
}
void Viewer::update_playhead() {
@@ -810,11 +814,11 @@ void Viewer::timer_update() {
seq->playhead = qMax(0, qRound(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * seq->frame_rate * playback_speed)));
if (olive::CurrentConfig.seek_also_selects) {
panel_timeline->select_from_playhead();
if (olive::config.seek_also_selects) {
seq->SelectAtPlayhead();
}
update_parents(olive::CurrentConfig.seek_also_selects);
update_parents(olive::config.seek_also_selects);
if (playing) {
if (playback_speed < 0 && seq->playhead == 0) {
@@ -825,11 +829,11 @@ void Viewer::timer_update() {
}
} else if (playback_speed > 0) {
long end_frame = seq->GetEndFrame();
if ((olive::CurrentConfig.auto_seek_to_beginning || previous_playhead < end_frame) && seq->playhead >= end_frame) {
if ((olive::config.auto_seek_to_beginning || previous_playhead < end_frame) && seq->playhead >= end_frame) {
pause();
}
if (seq->using_workarea && seq->playhead >= seq->workarea_out) {
if (olive::CurrentConfig.loop) {
if (olive::config.loop) {
// loop
play();
} else if (playing_in_to_out) {
@@ -882,7 +886,7 @@ void Viewer::clean_created_seq() {
}
}
void Viewer::set_sequence(bool main, SequencePtr s) {
void Viewer::set_sequence(SequencePtr s) {
pause();
reset_all_audio();
@@ -896,11 +900,7 @@ void Viewer::set_sequence(bool main, SequencePtr s) {
clean_created_seq();
main_sequence = main;
seq = (main) ? olive::ActiveSequence : s;
seq = s;
bool null_sequence = (seq == nullptr);
+11 -3
View File
@@ -44,9 +44,16 @@ class Viewer : public Panel
public:
explicit Viewer(QWidget *parent = nullptr);
enum Mode {
kFootageMode,
kTimelineMode
};
void SetMode(Mode mode);
Mode mode();
virtual bool focused() override;
bool is_main_sequence();
void set_main_sequence();
void set_media(Media *m);
void compose();
void set_playpause_icon(bool play);
@@ -131,8 +138,7 @@ private slots:
private:
void update_window_title();
void clean_created_seq();
void set_sequence(bool main, SequencePtr s);
bool main_sequence;
void set_sequence(SequencePtr s);
bool created_sequence;
long cached_end_frame;
QString panel_name;
@@ -169,6 +175,8 @@ private:
long previous_playhead;
int playback_speed;
Mode mode_;
};
#endif // VIEWER_H