show only transitions in effect controls if only transitions are selected
This commit is contained in:
+90
-70
@@ -55,8 +55,7 @@
|
||||
|
||||
EffectControls::EffectControls(QWidget *parent) :
|
||||
Panel(parent),
|
||||
zoom(1),
|
||||
mode_(kTransitionNone)
|
||||
zoom(1)
|
||||
{
|
||||
setup_ui();
|
||||
Retranslate();
|
||||
@@ -145,38 +144,38 @@ void EffectControls::delete_selected_keyframes() {
|
||||
}
|
||||
|
||||
void EffectControls::copy(bool del) {
|
||||
if (mode_ == kTransitionNone) {
|
||||
bool cleared = false;
|
||||
bool cleared = false;
|
||||
|
||||
ComboAction* ca = nullptr;
|
||||
if (del) {
|
||||
ca = new ComboAction();
|
||||
}
|
||||
ComboAction* ca = nullptr;
|
||||
if (del) {
|
||||
ca = new ComboAction();
|
||||
}
|
||||
|
||||
for (int i=0;i<open_effects_.size();i++) {
|
||||
if (open_effects_.at(i)->IsSelected()) {
|
||||
Effect* e = open_effects_.at(i)->GetEffect();
|
||||
for (int i=0;i<open_effects_.size();i++) {
|
||||
if (open_effects_.at(i)->IsSelected()) {
|
||||
Effect* e = open_effects_.at(i)->GetEffect();
|
||||
|
||||
if (!cleared) {
|
||||
clear_clipboard();
|
||||
cleared = true;
|
||||
clipboard_type = CLIPBOARD_TYPE_EFFECT;
|
||||
}
|
||||
if (!cleared) {
|
||||
clear_clipboard();
|
||||
cleared = true;
|
||||
clipboard_type = CLIPBOARD_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
clipboard.append(e->copy(nullptr));
|
||||
clipboard.append(e->copy(nullptr));
|
||||
|
||||
if (del) {
|
||||
|
||||
DeleteEffect(ca, e);
|
||||
|
||||
if (del) {
|
||||
ca->append(new EffectDeleteCommand(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (del) {
|
||||
if (ca->hasActions()) {
|
||||
olive::UndoStack.push(ca);
|
||||
} else {
|
||||
delete ca;
|
||||
}
|
||||
if (del) {
|
||||
if (ca->hasActions()) {
|
||||
olive::UndoStack.push(ca);
|
||||
} else {
|
||||
delete ca;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,47 +539,48 @@ void EffectControls::effects_area_context_menu() {
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void EffectControls::delete_effects() {
|
||||
void EffectControls::DeleteEffect(ComboAction* ca, Effect* effect_ref) {
|
||||
if (effect_ref->meta->type == EFFECT_TYPE_EFFECT) {
|
||||
|
||||
ca->append(new EffectDeleteCommand(effect_ref));
|
||||
|
||||
} else if (effect_ref->meta->type == EFFECT_TYPE_TRANSITION) {
|
||||
|
||||
// Retrieve shared ptr for this transition
|
||||
|
||||
Clip* attached_clip = effect_ref->parent_clip;
|
||||
|
||||
TransitionPtr t = nullptr;
|
||||
|
||||
if (attached_clip->opening_transition.get() == effect_ref) {
|
||||
|
||||
t = attached_clip->opening_transition;
|
||||
|
||||
} else if (attached_clip->closing_transition.get() == effect_ref) {
|
||||
|
||||
t = attached_clip->closing_transition;
|
||||
|
||||
}
|
||||
|
||||
if (t == nullptr) {
|
||||
|
||||
qWarning() << "Failed to delete transition, couldn't find clip link.";
|
||||
|
||||
} else {
|
||||
|
||||
ca->append(new DeleteTransitionCommand(t));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EffectControls::DeleteSelectedEffects() {
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
for (int i=0;i<open_effects_.size();i++) {
|
||||
if (open_effects_.at(i)->IsSelected()) {
|
||||
|
||||
Effect* effect_ref = open_effects_.at(i)->GetEffect();
|
||||
|
||||
if (effect_ref->meta->type == EFFECT_TYPE_EFFECT) {
|
||||
|
||||
ca->append(new EffectDeleteCommand(effect_ref));
|
||||
|
||||
} else if (effect_ref->meta->type == EFFECT_TYPE_TRANSITION) {
|
||||
|
||||
// Retrieve shared ptr for this transition
|
||||
|
||||
Clip* attached_clip = effect_ref->parent_clip;
|
||||
|
||||
TransitionPtr t = nullptr;
|
||||
|
||||
if (attached_clip->opening_transition.get() == effect_ref) {
|
||||
|
||||
t = attached_clip->opening_transition;
|
||||
|
||||
} else if (attached_clip->closing_transition.get() == effect_ref) {
|
||||
|
||||
t = attached_clip->closing_transition;
|
||||
|
||||
}
|
||||
|
||||
if (t == nullptr) {
|
||||
|
||||
qWarning() << "Failed to delete transition, couldn't find clip link.";
|
||||
|
||||
} else {
|
||||
|
||||
ca->append(new DeleteTransitionCommand(t));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
DeleteEffect(ca, open_effects_.at(i)->GetEffect());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,13 +597,25 @@ void EffectControls::Reload() {
|
||||
Load();
|
||||
}
|
||||
|
||||
void EffectControls::SetClips(const QVector<Clip*> &clips, int mode)
|
||||
void EffectControls::SetClips()
|
||||
{
|
||||
Clear(true);
|
||||
|
||||
// replace clip vector
|
||||
selected_clips_ = clips;
|
||||
mode_ = mode;
|
||||
selected_clips_ = olive::ActiveSequence->SelectedClips();
|
||||
|
||||
if (selected_clips_.isEmpty()) {
|
||||
// If no clips are selected, there may be transitions that are
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
Clip* c = olive::ActiveSequence->clips.at(i).get();
|
||||
if (c != nullptr) {
|
||||
if (olive::ActiveSequence->IsTransitionSelected(c->opening_transition.get())
|
||||
|| olive::ActiveSequence->IsTransitionSelected(c->closing_transition.get())) {
|
||||
selected_clips_.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Load();
|
||||
}
|
||||
@@ -627,13 +639,21 @@ void EffectControls::Load() {
|
||||
|
||||
// Create a list of the effects we'll open
|
||||
QVector<Effect*> effects_to_open;
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
effects_to_open.append(c->effects.at(j).get());
|
||||
|
||||
// Determine based on the current selections whether to load all effects or just the transitions
|
||||
bool whole_clip_is_selected = c->sequence->IsClipSelected(c, true);
|
||||
|
||||
if (whole_clip_is_selected) {
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
effects_to_open.append(c->effects.at(j).get());
|
||||
}
|
||||
}
|
||||
if (c->opening_transition != nullptr) {
|
||||
if (c->opening_transition != nullptr
|
||||
&& (whole_clip_is_selected || c->sequence->IsTransitionSelected(c->opening_transition.get()))) {
|
||||
effects_to_open.append(c->opening_transition.get());
|
||||
}
|
||||
if (c->closing_transition != nullptr) {
|
||||
if (c->closing_transition != nullptr
|
||||
&& (whole_clip_is_selected || c->sequence->IsTransitionSelected(c->closing_transition.get()))) {
|
||||
effects_to_open.append(c->closing_transition.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -61,12 +61,12 @@ public:
|
||||
|
||||
|
||||
void Reload();
|
||||
void SetClips(const QVector<Clip *> &clips, int mode);
|
||||
void SetClips();
|
||||
void Clear(bool clear_cache = true);
|
||||
|
||||
bool IsEffectSelected(Effect* e);
|
||||
|
||||
void delete_effects();
|
||||
void DeleteSelectedEffects();
|
||||
bool is_focused();
|
||||
void set_zoom(bool in);
|
||||
bool keyframe_focus();
|
||||
@@ -110,6 +110,8 @@ private:
|
||||
|
||||
void Load();
|
||||
|
||||
void DeleteEffect(ComboAction* ca, Effect* effect_ref);
|
||||
|
||||
void show_effect_menu(int type, int subtype);
|
||||
void load_keyframes();
|
||||
void open_effect(QVBoxLayout* hlayout, Effect *e);
|
||||
@@ -120,7 +122,6 @@ private:
|
||||
int effect_menu_type;
|
||||
int effect_menu_subtype;
|
||||
QString panel_name;
|
||||
int mode_;
|
||||
|
||||
QWidget* video_effect_area;
|
||||
QWidget* audio_effect_area;
|
||||
|
||||
+1
-12
@@ -37,20 +37,9 @@ Viewer* panel_footage_viewer = nullptr;
|
||||
Timeline* panel_timeline = nullptr;
|
||||
GraphEditor* panel_graph_editor = nullptr;
|
||||
|
||||
void update_effect_controls() {
|
||||
QVector<Clip*> selected_clips;
|
||||
int mode = kTransitionNone;
|
||||
|
||||
if (olive::ActiveSequence != nullptr) {
|
||||
selected_clips = olive::ActiveSequence->SelectedClips();
|
||||
}
|
||||
|
||||
panel_effect_controls->SetClips(selected_clips, mode);
|
||||
}
|
||||
|
||||
void update_ui(bool modified) {
|
||||
if (modified) {
|
||||
update_effect_controls();
|
||||
panel_effect_controls->SetClips();
|
||||
}
|
||||
panel_effect_controls->update_keyframes();
|
||||
panel_timeline->repaint_timeline();
|
||||
|
||||
@@ -174,6 +174,48 @@ bool Sequence::IsClipSelected(Clip *clip, bool containing)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Sequence::IsTransitionSelected(Transition *t)
|
||||
{
|
||||
if (t == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Clip* c = t->parent_clip;
|
||||
|
||||
int transition_track = t->parent_clip->track();
|
||||
long transition_in_point;
|
||||
long transition_out_point;
|
||||
|
||||
// Get positions of the transition on the timeline
|
||||
|
||||
if (t == c->opening_transition.get()) {
|
||||
transition_in_point = c->timeline_in();
|
||||
transition_out_point = c->timeline_in() + t->get_true_length();
|
||||
|
||||
if (t->secondary_clip != nullptr) {
|
||||
transition_in_point -= t->get_true_length();
|
||||
}
|
||||
} else {
|
||||
transition_in_point = c->timeline_out() - t->get_true_length();
|
||||
transition_out_point = c->timeline_out();
|
||||
|
||||
if (t->secondary_clip != nullptr) {
|
||||
transition_out_point += t->get_true_length();
|
||||
}
|
||||
}
|
||||
|
||||
// See if there's a selection matching this
|
||||
for (int i=0;i<selections.size();i++) {
|
||||
if (selections.at(i).in <= transition_in_point
|
||||
&& selections.at(i).out >= transition_out_point
|
||||
&& selections.at(i).track == transition_track) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) {
|
||||
int vt = 0;
|
||||
int at = 0;
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
bool IsClipSelected(int clip_index, bool containing);
|
||||
bool IsClipSelected(Clip* clip, bool containing);
|
||||
bool IsTransitionSelected(Transition* t);
|
||||
|
||||
QVector<Selection> selections;
|
||||
long playhead;
|
||||
|
||||
+1
-1
@@ -197,7 +197,7 @@ void FocusFilter::delete_function() {
|
||||
} else if (panel_sequence_viewer->headers->hasFocus()) {
|
||||
panel_sequence_viewer->headers->delete_markers();
|
||||
} else if (panel_effect_controls->is_focused()) {
|
||||
panel_effect_controls->delete_effects();
|
||||
panel_effect_controls->DeleteSelectedEffects();
|
||||
} else if (panel_project->is_focused()) {
|
||||
panel_project->delete_selected_media();
|
||||
} else if (panel_effect_controls->keyframe_focus()) {
|
||||
|
||||
Reference in New Issue
Block a user