Blender V4.5
transform_mode_edge_seq_slide.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "MEM_guardedalloc.h"
12
13#include "BLI_math_vector.h"
14#include "BLI_string.h"
15
16#include "BKE_unit.hh"
17
18#include "ED_screen.hh"
19
20#include "RNA_access.hh"
21
22#include "WM_api.hh"
23#include "WM_types.hh"
24
25#include "UI_interface.hh"
26
27#include "BLT_translation.hh"
28
29#include "ED_sequencer.hh"
30
31#include "transform.hh"
32#include "transform_convert.hh"
33#include "transform_mode.hh"
34#include "transform_snap.hh"
35
36namespace blender::ed::transform {
37
38/* -------------------------------------------------------------------- */
41
42static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRAW_STR])
43{
44 char tvec[NUM_STR_REP_LEN * 3];
45 size_t ofs = 0;
46
47 if (hasNumInput(&t->num)) {
48 outputNumInput(&(t->num), tvec, t->scene->unit);
49 }
50 else {
51 BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.0f, %.0f", val[0], val[1]);
52 }
53
54 ofs += BLI_snprintf_rlen(
55 str + ofs, UI_MAX_DRAW_STR - ofs, IFACE_("Sequence Slide: %s%s"), &tvec[0], t->con.text);
56}
57
58static void applySeqSlideValue(TransInfo *t, const float val[2])
59{
60 int i;
61
63 TransData *td = tc->data;
64 for (i = 0; i < tc->data_len; i++, td++) {
65 if (td->flag & TD_SKIP) {
66 continue;
67 }
68
69 madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor);
70 }
71 }
72}
73
74static void applySeqSlide(TransInfo *t)
75{
76 char str[UI_MAX_DRAW_STR];
77 float values_final[3] = {0.0f};
78
79 if (applyNumInput(&t->num, values_final)) {
80 if (t->con.mode & CON_APPLY) {
81 if (t->con.mode & CON_AXIS0) {
82 mul_v2_v2fl(values_final, t->spacemtx[0], values_final[0]);
83 }
84 else {
85 mul_v2_v2fl(values_final, t->spacemtx[1], values_final[0]);
86 }
87 }
88 }
89 else {
90 copy_v2_v2(values_final, t->values);
91 transform_snap_mixed_apply(t, values_final);
94 }
95
96 if (t->con.mode & CON_APPLY) {
97 t->con.applyVec(t, nullptr, nullptr, values_final, values_final);
98 }
99 }
100
101 values_final[0] = floorf(values_final[0] + 0.5f);
102 values_final[1] = floorf(values_final[1] + 0.5f);
103 copy_v2_v2(t->values_final, values_final);
104
107
108 recalc_data(t);
109
111}
112
116
118{
120 t->custom.mode.data = ssp;
121 t->custom.mode.use_free = true;
122 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_restore_handle_selection");
123 if (op != nullptr && prop != nullptr) {
125 }
126
128
129 t->idx_max = 1;
130 t->num.flag = 0;
131 t->num.idx_max = t->idx_max;
132
133 t->snap[0] = floorf(t->scene->r.frs_sec / t->scene->r.frs_sec_base);
134 t->snap[1] = 10.0f;
135
136 copy_v3_fl(t->num.val_inc, t->snap[0]);
137 t->num.unit_sys = t->scene->unit.system;
138 /* Would be nice to have a time handling in units as well
139 * (supporting frames in addition to "natural" time...). */
140 t->num.unit_type[0] = B_UNIT_NONE;
141 t->num.unit_type[1] = B_UNIT_NONE;
142}
143
145{
146 if ((U.sequencer_editor_flag & USER_SEQ_ED_SIMPLE_TWEAKING) == 0) {
147 return false;
148 }
149 SeqSlideParams *ssp = static_cast<SeqSlideParams *>(t->custom.mode.data);
150 if (ssp == nullptr) {
151 return false;
152 }
154}
155
157
159 /*flags*/ 0,
160 /*init_fn*/ initSeqSlide,
161 /*transform_fn*/ applySeqSlide,
162 /*transform_matrix_fn*/ nullptr,
163 /*handle_event_fn*/ nullptr,
164 /*snap_distance_fn*/ nullptr,
165 /*snap_apply_fn*/ snap_sequencer_apply_seqslide,
166 /*draw_fn*/ nullptr,
167};
168
169} // namespace blender::ed::transform
@ B_UNIT_NONE
Definition BKE_unit.hh:123
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
size_t BLI_snprintf_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define IFACE_(msgid)
@ USER_SEQ_ED_SIMPLE_TWEAKING
#define NUM_STR_REP_LEN
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:189
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:87
bool hasNumInput(const NumInput *n)
Definition numinput.cc:170
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:872
Read Guarded memory(de)allocation.
#define UI_MAX_DRAW_STR
#define U
#define floorf(x)
#define str(s)
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
static void applySeqSlide(TransInfo *t)
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
void recalc_data(TransInfo *t)
static void initSeqSlide(TransInfo *t, wmOperator *op)
void transform_snap_mixed_apply(TransInfo *t, float *vec)
static void applySeqSlideValue(TransInfo *t, const float val[2])
void snap_sequencer_apply_seqslide(TransInfo *t, float *vec)
bool transform_mode_edge_seq_slide_use_restore_handle_selection(const TransInfo *t)
void transform_convert_sequencer_channel_clamp(TransInfo *t, float r_val[2])
static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRAW_STR])
bool sequencer_retiming_mode_is_active(const bContext *C)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
short idx_max
float val_inc[NUM_MAX_ELEMENTS]
int unit_type[NUM_MAX_ELEMENTS]
short flag
struct RenderData r
struct UnitSettings unit
void(* applyVec)(const TransInfo *t, const TransDataContainer *tc, const TransData *td, const float in[3], float r_out[3])
Definition transform.hh:579
TransCustomDataContainer custom
Definition transform.hh:968
struct PointerRNA * ptr
i
Definition text_draw.cc:230
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:42
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.