tornavis/source/blender/sequencer/SEQ_iterator.hh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

125 lines
4.7 KiB
C++
Raw Normal View History

/* SPDX-FileCopyrightText: 2004 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
2020-12-19 06:44:57 +01:00
#pragma once
/** \file
* \ingroup sequencer
*/
#include "BLI_vector_set.hh"
VSE: New iterator design This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
2021-05-07 10:25:13 +02:00
2021-07-16 03:48:54 +02:00
struct Sequence;
2020-12-19 06:44:57 +01:00
/**
* Callback format for the for_each function below.
*/
using SeqForEachFunc = bool (*)(Sequence *seq, void *user_data);
/**
* Utility function to recursively iterate through all sequence strips in a `seqbase` list.
* Uses callback to do operations on each sequence element.
* The callback can stop the iteration if needed.
*
* \param seqbase: #ListBase of sequences to be iterated over.
* \param callback: query function callback, returns false if iteration should stop.
* \param user_data: pointer to user data that can be used in the callback function.
*/
void SEQ_for_each_callback(ListBase *seqbase, SeqForEachFunc callback, void *user_data);
/**
* Expand set by running `seq_query_func()` for each strip, which will be used as reference.
* Results of these queries will be merged into provided collection.
*
* \param seqbase: ListBase in which strips are queried
* \param strips: set of strips to be expanded
* \param seq_query_func: query function callback
*/
void SEQ_iterator_set_expand(const Scene *scene,
ListBase *seqbase,
blender::VectorSet<Sequence *> &strips,
void seq_query_func(const Scene *scene,
Sequence *seq_reference,
ListBase *seqbase,
blender::VectorSet<Sequence *> &strips));
/**
* Query strips from seqbase. seq_reference is used by query function as filter condition.
*
* \param seq_reference: reference strip for query function
* \param seqbase: ListBase in which strips are queried
* \param seq_query_func: query function callback
* \return set of strips
*/
blender::VectorSet<Sequence *> SEQ_query_by_reference(
Sequence *seq_reference,
const Scene *scene,
ListBase *seqbase,
void seq_query_func(const Scene *scene,
Sequence *seq_reference,
ListBase *seqbase,
blender::VectorSet<Sequence *> &strips));
/**
* Query all selected strips in seqbase.
*
* \param seqbase: ListBase in which strips are queried
* \return set of strips
*/
blender::VectorSet<Sequence *> SEQ_query_selected_strips(ListBase *seqbase);
/**
* Query all unselected strips in seqbase.
*
* \param seqbase: ListBase in which strips are queried
* \return set of strips
*/
blender::VectorSet<Sequence *> SEQ_query_unselected_strips(ListBase *seqbase);
/**
* Query all strips in seqbase. This does not include strips nested in meta strips.
*
* \param seqbase: ListBase in which strips are queried
* \return set of strips
*/
blender::VectorSet<Sequence *> SEQ_query_all_strips(ListBase *seqbase);
/**
* Query all strips in seqbase and nested meta strips.
*
* \param seqbase: ListBase in which strips are queried
* \return set of strips
*/
2024-04-03 01:22:05 +02:00
blender::VectorSet<Sequence *> SEQ_query_all_strips_recursive(const ListBase *seqbase);
/**
* Query all meta strips in seqbase and nested meta strips.
*
* \param seqbase: ListBase in which strips are queried
* \return set of meta strips
*/
2024-04-03 01:22:05 +02:00
blender::VectorSet<Sequence *> SEQ_query_all_meta_strips_recursive(const ListBase *seqbase);
/**
* Query all effect strips that are directly or indirectly connected to seq_reference.
* This includes all effects of seq_reference, strips used by another inputs and their effects, so
* that whole chain is fully independent of other strips.
*
* \param seq_reference: reference strip
* \param seqbase: ListBase in which strips are queried
* \param strips: set of strips to be filled
*/
void SEQ_query_strip_effect_chain(const Scene *scene,
Sequence *seq_reference,
ListBase *seqbase,
blender::VectorSet<Sequence *> &strips);
/**
* Query strips that are rendered at \a timeline_frame when \a displayed channel is viewed
*
* \param seqbase: ListBase in which strips are queried
* \param timeline_frame: viewed frame
* \param displayed_channel: viewed channel. when set to 0, no channel filter is applied
* \return set of strips
*/
blender::VectorSet<Sequence *> SEQ_query_rendered_strips(const Scene *scene,
ListBase *channels,
ListBase *seqbase,
int timeline_frame,
int displayed_channel);