Files
test2/source/blender/sequencer/SEQ_utils.hh
John Kiril Swenson d910fb88b0 VSE: Clamp strip handles to video/audio bounds
This initial commit properly clamps handles for video/audio strips, and
provides functionality to enable/disable the behavior for all strip types
(addresses #90280).

Toggling handle clamping is done with "C",
just like with the redesigned slip operator (#137072).

If a strip is not already clamped when you start moving its handles,
then clamping behavior is disabled starting out. This means no abrupt
clamp until you explicitly ask for it.

Transform logic was altered, fixing a few bugs:
- When initializing a transform, `createTransSeqData` would already
  create some clamping data for channels. This patch replaces it with
  `offset_clamp` (for unconditional clamping which cannot be disabled)
  and `handle_xmin/xmax` (for hold offset clamping, which is optional).
    - Collecting this data ahead of time is necessary for the double
      handle tweak case -- `flushTransSeq` only works one strip at a
      time, so we can't clamp post-hoc.
- In `applySeqSlideValue`, we apply `transform_convert_sequencer_clamp`
  before values are printed to the header, but let the unclamped values
  get flushed to the strips themselves. This is so that we can have the
  data later at the individual strip level to recalculate clamps.
  Otherwise, if transform values are clamped preemptively, then we have
  no idea whether strips are clamped vs. merely resting at their
  boundaries.

Note that currently, handle clamping is drawn identically to overlaps.

More information in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/134319
2025-07-16 06:16:19 +02:00

96 lines
2.8 KiB
C++

/* SPDX-FileCopyrightText: 2004 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup sequencer
*/
#include "DNA_scene_types.h"
struct bSound;
struct ListBase;
struct Mask;
struct Scene;
struct Strip;
struct StripElem;
namespace blender::seq {
void strip_unique_name_set(Scene *scene, ListBase *seqbasep, Strip *strip);
const char *get_default_stripname_by_type(int type);
const char *strip_give_name(const Strip *strip);
ListBase *get_seqbase_from_strip(Strip *strip, ListBase **r_channels, int *r_offset);
const Strip *strip_topmost_get(const Scene *scene, int frame);
/**
* In cases where we don't know the strip's listbase.
*/
ListBase *get_seqbase_by_strip(const Scene *scene, Strip *strip);
/**
* Only use as last resort when the StripElem is available but not the Strip.
* (needed for RNA)
*/
Strip *strip_from_strip_elem(ListBase *seqbase, StripElem *se);
Strip *get_strip_by_name(ListBase *seqbase, const char *name, bool recursive);
Mask *active_mask_get(Scene *scene);
void alpha_mode_from_file_extension(Strip *strip);
/**
* Check if an input referenced by this strip is valid (e.g. scene for a scene strip).
* Note that this only checks data block references, for missing media referenced
* by paths use #media_presence_is_missing.
*/
bool strip_has_valid_data(const Strip *strip);
void set_scale_to_fit(const Strip *strip,
int image_width,
int image_height,
int preview_width,
int preview_height,
eSeqImageFitMethod fit_method);
/**
* Ensure, that provided Strip has unique name. If animation data exists for this Strip, it
* will be duplicated and mapped onto new name
*
* \param strip: Strip which name will be ensured to be unique
* \param scene: Scene in which name must be unique
*/
void ensure_unique_name(Strip *strip, Scene *scene);
void fontmap_clear();
/**
* Check whether a sequence strip has missing media.
* Results of the query for this strip will be cached into #MediaPresence cache. The cache
* will be created on demand.
*
* \param scene: Scene to query.
* \param strip: Sequencer strip.
* \return True if media file is missing.
*/
bool media_presence_is_missing(Scene *scene, const Strip *strip);
/**
* Set or change the missing media cache value for a given strip.
*/
void media_presence_set_missing(Scene *scene, const Strip *strip, bool missing);
/**
* Invalidate media presence cache for the given strip.
*/
void media_presence_invalidate_strip(Scene *scene, const Strip *strip);
/**
* Invalidate media presence cache for the given sound.
*/
void media_presence_invalidate_sound(Scene *scene, const bSound *sound);
/**
* Free media presence cache, if it was created.
*/
void media_presence_free(Scene *scene);
} // namespace blender::seq