Blender V5.0
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_utf8.h"
15
16#include "BKE_context.hh"
17#include "BKE_unit.hh"
18
19#include "ED_screen.hh"
20
21#include "RNA_access.hh"
22
23#include "WM_api.hh"
24#include "WM_types.hh"
25
26#include "UI_interface_types.hh"
27
28#include "BLT_translation.hh"
29
30#include "ED_sequencer.hh"
31
32#include "transform.hh"
33#include "transform_convert.hh"
34#include "transform_mode.hh"
35#include "transform_snap.hh"
36
37namespace blender::ed::transform {
38
39/* -------------------------------------------------------------------- */
42
43static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRAW_STR])
44{
46 char tvec[NUM_STR_REP_LEN * 3];
47 size_t ofs = 0;
48
49 if (hasNumInput(&t->num)) {
50 outputNumInput(&(t->num), tvec, scene->unit);
51 }
52 else {
53 BLI_snprintf_utf8(&tvec[0], NUM_STR_REP_LEN, "%.0f, %.0f", val[0], val[1]);
54 }
55
57 str + ofs, UI_MAX_DRAW_STR - ofs, IFACE_("Sequence Slide: %s%s"), &tvec[0], t->con.text);
58}
59
60static void applySeqSlideValue(TransInfo *t, const float val[2])
61{
62 int i;
63
65 TransData *td = tc->data;
66 for (i = 0; i < tc->data_len; i++, td++) {
67 if (td->flag & TD_SKIP) {
68 continue;
69 }
70
71 madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor);
72 }
73 }
74}
75
76static void applySeqSlide(TransInfo *t)
77{
78 char str[UI_MAX_DRAW_STR];
79 float values_final[3] = {0.0f}, values_clamped[3] = {0.0f};
80
81 if (applyNumInput(&t->num, values_final)) {
82 if (t->con.mode & CON_APPLY) {
83 if (t->con.mode & CON_AXIS0) {
84 mul_v2_v2fl(values_final, t->spacemtx[0], values_final[0]);
85 }
86 else {
87 mul_v2_v2fl(values_final, t->spacemtx[1], values_final[0]);
88 }
89 }
90 }
91 else {
92 copy_v2_v2(values_final, t->values);
93 transform_snap_mixed_apply(t, values_final);
94
95 if (t->con.mode & CON_APPLY) {
96 t->con.applyVec(t, nullptr, nullptr, values_final, values_final);
97 }
98 }
99
100 values_final[0] = round_fl_to_int(values_final[0]);
101 values_final[1] = round_fl_to_int(values_final[1]);
102
103 copy_v2_v2(values_clamped, values_final);
104 transform_convert_sequencer_clamp(t, values_clamped);
105 headerSeqSlide(t, values_clamped, str);
106
107 copy_v2_v2(t->values_final, values_final);
109
110 recalc_data(t);
111
113}
114
118
120{
122 t->custom.mode.data = ssp;
123 t->custom.mode.use_free = true;
124 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_restore_handle_selection");
125 if (op != nullptr && prop != nullptr) {
127 }
128
130
132
133 t->idx_max = 1;
134 t->num.flag = 0;
135 t->num.idx_max = t->idx_max;
136
137 t->increment = float3(floorf(scene->r.frs_sec / scene->r.frs_sec_base));
138 t->increment_precision = 10.0f / t->increment[0];
139
140 copy_v3_fl(t->num.val_inc, t->increment[0]);
141 t->num.unit_sys = scene->unit.system;
142 /* Would be nice to have a time handling in units as well
143 * (supporting frames in addition to "natural" time...). */
144 t->num.unit_type[0] = B_UNIT_NONE;
145 t->num.unit_type[1] = B_UNIT_NONE;
146}
147
149{
150 SeqSlideParams *ssp = static_cast<SeqSlideParams *>(t->custom.mode.data);
151 if (ssp == nullptr) {
152 return false;
153 }
155}
156
158
160 /*flags*/ 0,
161 /*init_fn*/ initSeqSlide,
162 /*transform_fn*/ applySeqSlide,
163 /*transform_matrix_fn*/ nullptr,
164 /*handle_event_fn*/ nullptr,
165 /*snap_distance_fn*/ nullptr,
166 /*snap_apply_fn*/ snap_sequencer_apply_seqslide,
167 /*draw_fn*/ nullptr,
168};
169
170} // namespace blender::ed::transform
Scene * CTX_data_sequencer_scene(const bContext *C)
@ B_UNIT_NONE
Definition BKE_unit.hh:136
MINLINE int round_fl_to_int(float a)
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 size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
size_t BLI_snprintf_utf8_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define IFACE_(msgid)
#define NUM_STR_REP_LEN
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:190
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:88
bool hasNumInput(const NumInput *n)
Definition numinput.cc:171
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:851
Read Guarded memory(de)allocation.
#define UI_MAX_DRAW_STR
#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)
bool transform_convert_sequencer_clamp(const TransInfo *t, float r_val[2])
static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRAW_STR])
VecBase< float, 3 > float3
#define floorf
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:585
TransCustomDataContainer custom
Definition transform.hh:974
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.