24#include "RNA_prototypes.hh"
33struct CurveRuntimeProperties {
34 CurveProfilePoint *last_pt =
nullptr;
47 for (
const auto &item :
49 std::pair<StringRef, eCurveProfilePresets>(
51 std::pair<StringRef, eCurveProfilePresets>(
53 std::pair<StringRef, eCurveProfilePresets>(
126 rna_update_cb(
C, cb);
218 RNAUpdateCb *presets_cb = MEM_new<RNAUpdateCb>(__func__, cb);
250 TIP_(
"Reapply and update the preset, removing changes"));
254 rna_update_cb(
C, cb);
259 row = &layout.
row(
false);
300 sub = &row->
row(
true);
306 ICON_ARROW_LEFTRIGHT,
314 TIP_(
"Reverse Path"));
318 rna_update_cb(
C, cb);
322 const int icon = (profile->
flag &
PROF_USE_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
333 TIP_(
"Toggle Profile Clipping"));
337 rna_update_cb(
C, cb);
341 RNAUpdateCb *tools_cb = MEM_new<RNAUpdateCb>(__func__, cb);
362 MEM_new<RNAUpdateCb>(__func__, cb),
370 const int path_height = path_width;
386 bool point_last_or_first =
false;
387 for (
int i = 0; i < profile->
path_len; i++) {
391 point_last_or_first =
true;
407 row = &layout.
row(
true);
409 auto curve_runtime = std::make_shared<CurveRuntimeProperties>();
413 ptr->
owner_id, RNA_CurveProfilePoint, curve_runtime->last_pt);
415 row->
prop(&point_ptr,
425 float *last_y_ptr = last_x_ptr + 1;
426 curve_runtime->last_pos.x = *last_x_ptr;
427 curve_runtime->last_pos.y = *last_y_ptr;
432 if (selected_points.
size() > 1) {
433 rctf selection_bounds;
441 const float loc[2] = {pt->x, pt->y};
452 slider_bounds.
xmin += curve_runtime->last_pos.x - selection_bounds.
xmin;
453 slider_bounds.
xmax += curve_runtime->last_pos.x - selection_bounds.
xmax;
454 slider_bounds.
ymin += curve_runtime->last_pos.y - selection_bounds.
ymin;
455 slider_bounds.
ymax += curve_runtime->last_pos.y - selection_bounds.
ymax;
460 const char *
const axis_labels[2] = {
"X:",
"Y:"};
461 float *
const axis_ptrs[2] = {last_x_ptr, last_y_ptr};
462 const float axis_min[2] = {slider_bounds.
xmin, slider_bounds.
ymin};
463 const float axis_max[2] = {slider_bounds.
xmax, slider_bounds.
ymax};
464 for (
int axis = 0; axis < 2; axis++) {
480 const float delta = last_pt_co[axis] - curve_runtime->last_pos[axis];
482 last_pt_co[axis] = curve_runtime->last_pos[axis];
484 offset[axis] = delta;
487 rna_update_cb(
C, cb);
492 curve_runtime->last_pos[axis] = last_pt_co[axis];
494 if (point_last_or_first) {
510 TIP_(
"Delete points"));
514 rna_update_cb(
C, cb);
516 if (point_last_or_first) {
521 layout.
prop(ptr,
"use_sample_straight_edges",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
522 layout.
prop(ptr,
"use_sample_even_lengths",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
534 RNA_warning(
"Curve Profile property not found: %s.%s",
541 RNA_warning(
"Curve Profile is not a pointer: %s.%s",
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_ID_MESH
#define ID_IS_EDITABLE(_id)
#define RNA_warning(format,...)
constexpr const char * c_str() const
void append(const T &value)
#define ERROR_LIBDATA_MESSAGE
Button * uiDefIconTextBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, int icon, StringRef str, int x, int y, short width, short height, void *poin, std::optional< StringRef > tip)
void block_lock_set(Block *block, bool val, const char *lockstr)
void block_direction_set(Block *block, char direction)
void template_curve_profile(Layout *layout, PointerRNA *ptr, StringRefNull propname)
void button_func_set(Button *but, std::function< void(bContext &)> func)
void block_lock_clear(Block *block)
void button_number_step_size_set(Button *but, float step_size)
static bool curve_profile_can_zoom_in(CurveProfile *profile)
static void curve_profile_zoom_in(bContext *C, CurveProfile *profile)
Button * uiDefBlockBut(Block *block, BlockCreateFunc func, void *arg, StringRef str, int x, int y, short width, short height, std::optional< StringRef > tip)
static void curve_profile_zoom_out(bContext *C, CurveProfile *profile)
void block_bounds_set_text(Block *block, int addval)
static bool curve_profile_can_zoom_out(CurveProfile *profile)
void button_number_precision_set(Button *but, float precision)
void button_disable(Button *but, const char *disabled_hint)
void button_flag_enable(Button *but, int64_t flag)
static Block * curve_profile_presets_fn(bContext *C, ARegion *region, void *cb_v)
Block * block_begin(const bContext *C, ARegion *region, std::string name, EmbossType emboss)
Button * uiDefBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
void * but_func_argN_copy(const void *argN)
void button_funcN_set(Button *but, ButtonHandleNFunc funcN, void *argN, void *arg2, ButtonArgNFree func_argN_free_fn=MEM_delete_void, ButtonArgNCopy func_argN_copy_fn=MEM_dupalloc_void)
static void CurveProfile_buttons_layout(Layout &layout, PointerRNA *ptr, const RNAUpdateCb &cb)
void block_emboss_set(Block *block, EmbossType emboss)
void but_func_argN_free(void *argN)
Button * uiDefIconBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, int icon, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
static Block * curve_profile_tools_fn(bContext *C, ARegion *region, void *cb_v)
Button * uiDefButV(Block *block, ButtonType type, StringRef str, int x, int y, short width, short height, T *poin, float min, float max, std::optional< StringRef > tip)
Button * uiDefIconBlockBut(Block *block, BlockCreateFunc func, void *arg, int icon, int x, int y, short width, short height, std::optional< StringRef > tip)
void block_funcN_set(Block *block, ButtonHandleNFunc funcN, void *argN, void *arg2, ButtonArgNFree func_argN_free_fn=MEM_delete_void, ButtonArgNCopy func_argN_copy_fn=MEM_dupalloc_void)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
void BKE_curveprofile_translate_selection(struct CurveProfile *profile, const blender::float2 &offset)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
void BLI_rctf_do_minmax_v(struct rctf *rect, const float xy[2])
MINLINE int max_ii(int a, int b)
void BKE_curveprofile_remove_by_flag(struct CurveProfile *profile, short flag)
void ED_region_tag_redraw(ARegion *region)
void BKE_curveprofile_reset(struct CurveProfile *profile)
PropertyType RNA_property_type(PropertyRNA *prop)
VecBase< float, 2 > float2
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
void BKE_curveprofile_reset_view(struct CurveProfile *profile)
void BLI_rctf_init_minmax(struct rctf *rect)
@ PROF_UPDATE_REMOVE_DOUBLES
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
const char * RNA_struct_identifier(const StructRNA *type)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
float * BKE_curveprofile_active_location_get(struct CurveProfilePoint *point)
void BKE_curveprofile_update(struct CurveProfile *profile, int update_flags)
MINLINE int min_ii(int a, int b)
CurveProfilePoint * BKE_curveprofile_active_get(CurveProfile *profile)
ARegion * CTX_wm_region(const bContext *C)
void BKE_curveprofile_reverse(struct CurveProfile *profile)
eCurveProfilePoint_Flag flag
eCurveProfilePresets preset
void alignment_set(LayoutAlign alignment)
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)