25#include "RNA_prototypes.hh"
36struct CurveRuntimeProperties {
37 CurveMapPoint *last_pt =
nullptr;
66 const float2 threshold = 0.01f * clip_bounds.
size();
67 if (clamped_bounds.
min.x < clip_bounds.
min.x + threshold.x) {
68 clamped_bounds.
min.x = clip_bounds.
min.x;
70 if (clamped_bounds.
min.y < clip_bounds.
min.y + threshold.y) {
71 clamped_bounds.
min.y = clip_bounds.
min.y;
73 if (clamped_bounds.
max.x > clip_bounds.
max.x - threshold.x) {
74 clamped_bounds.
max.x = clip_bounds.
max.x;
76 if (clamped_bounds.
max.y > clip_bounds.
max.y - threshold.y) {
77 clamped_bounds.
max.y = clip_bounds.
max.y;
226 IFACE_(
"Extend Horizontal"),
236 rna_update_cb(
C, cb);
245 IFACE_(
"Extend Extrapolated"),
255 rna_update_cb(
C, cb);
277 rna_update_cb(
C, cb);
321 std::optional<StringRef> tip,
323 const bool neg_slope,
328 block,
ButtonType::Row, icon, 0, 0, dx, dx, &cumap->
cur, 0.0, 3.0, tip);
336 rna_update_cb(
C, cb);
373 if (labeltype ==
'v') {
379 bt =
uiDefButV(block,
ButtonType::Row,
"X", 0, 0, dx, dx, &cumap->
cur, 0.0, 0.0,
"");
383 bt =
uiDefButV(block,
ButtonType::Row,
"Y", 0, 0, dx, dx, &cumap->
cur, 0.0, 1.0,
"");
387 bt =
uiDefButV(block,
ButtonType::Row,
"Z", 0, 0, dx, dx, &cumap->
cur, 0.0, 2.0,
"");
407 TIP_(
"Combined channels"));
421 TIP_(
"Red channel"));
435 TIP_(
"Green channel"));
449 TIP_(
"Blue channel"));
453 else if (labeltype ==
'h') {
483 TIP_(
"Saturation level"));
497 TIP_(
"Value level"));
505 if (labeltype ==
'h') {
517 block,
ButtonType::But, ICON_ZOOM_IN, 0, 0, dx, dx,
nullptr, 0.0, 0.0,
TIP_(
"Zoom in"));
525 block,
ButtonType::But, ICON_ZOOM_OUT, 0, 0, dx, dx,
nullptr, 0.0, 0.0,
TIP_(
"Zoom out"));
532 const int icon = (cumap->
flag &
CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
539 RNAUpdateCb *tools_cb = MEM_new<RNAUpdateCb>(__func__, cb);
540 if (
brush && neg_slope) {
555 else if (neg_slope) {
574 MEM_new<RNAUpdateCb>(__func__, cb),
581 row = &layout->
row(
false);
601 bool point_last_or_first =
false;
602 for (
int i = 0; i < cm->
totpoint; i++) {
608 point_last_or_first =
true;
639 TIP_(
"Auto handle"));
644 rna_update_cb(
C, cb);
665 TIP_(
"Vector handle"));
670 rna_update_cb(
C, cb);
682 ICON_HANDLE_AUTOCLAMPED,
690 TIP_(
"Auto clamped"));
695 rna_update_cb(
C, cb);
706 auto curve_runtime = std::make_shared<CurveRuntimeProperties>();
708 curve_runtime->last_pos.x = curve_runtime->last_pt->x;
709 curve_runtime->last_pos.y = curve_runtime->last_pt->y;
714 if (selected_points.size() > 1) {
715 rctf selection_bounds;
722 const float loc[2] = {cmp->x, cmp->y};
726 slider_bounds.
xmin += curve_runtime->last_pt->x - selection_bounds.
xmin;
727 slider_bounds.
xmax += curve_runtime->last_pt->x - selection_bounds.
xmax;
728 slider_bounds.
ymin += curve_runtime->last_pt->y - selection_bounds.
ymin;
729 slider_bounds.
ymax += curve_runtime->last_pt->y - selection_bounds.
ymax;
732 const char *
const axis_labels[2] = {
"X:",
"Y:"};
733 float *
const axis_ptrs[2] = {&curve_runtime->last_pt->x, &curve_runtime->last_pt->y};
734 const float axis_min[2] = {slider_bounds.
xmin, slider_bounds.
ymin};
735 const float axis_max[2] = {slider_bounds.
xmax, slider_bounds.
ymax};
736 for (
int axis = 0; axis < 2; axis++) {
750 if (selected_points.size() == 1) {
754 rna_update_cb(
C, cb);
760 float *last_pt_co = &curve_runtime->last_pt->x;
761 const float delta = last_pt_co[axis] - curve_runtime->last_pos[axis];
763 last_pt_co[axis] = curve_runtime->last_pos[axis];
765 offset[axis] = delta;
768 rna_update_cb(
C, cb);
772 last_pt_co = &curve_runtime->last_pt->x;
773 curve_runtime->last_pos[axis] = last_pt_co[axis];
780 block,
ButtonType::But, ICON_X, 0, 0, dx, dx,
nullptr, 0.0, 0.0,
TIP_(
"Delete points"));
784 rna_update_cb(
C, cb);
786 if (point_last_or_first) {
808 TIP_(
"Reset curves and black/white point"));
811 for (
int a = 0; a <
CM_TOT; a++) {
821 rna_update_cb(
C, cb);
826 row = &layout->
row(
true);
831 TIP_(
"Smooth preset"),
839 TIP_(
"Round preset"),
849 TIP_(
"Sharp preset"),
897 layout, &cptr, type, levels,
brush, neg_slope, tone, presets,
RNAUpdateCb{*ptr, prop});
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_COLOR
#define ID_IS_EDITABLE(_id)
#define RNA_warning(format,...)
constexpr const char * c_str() const
void append(const T &value)
float3x3 scale(float3x3 mat, float2 scale)
#define ERROR_LIBDATA_MESSAGE
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
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)
@ BLOCK_THEME_STYLE_POPUP
void button_func_set(Button *but, std::function< void(bContext &)> func)
void block_bounds_set_normal(Block *block, int addval)
void block_lock_clear(Block *block)
void block_align_begin(Block *block)
void button_number_step_size_set(Button *but, float step_size)
void block_flag_enable(Block *block, int flag)
static void add_preset_button(Block *block, const float dx, const int icon, std::optional< StringRef > tip, CurveMapping *cumap, const bool neg_slope, const eCurveMappingPreset preset, const RNAUpdateCb &cb)
void block_bounds_set_text(Block *block, int addval)
void button_number_precision_set(Button *but, float precision)
void button_disable(Button *but, const char *disabled_hint)
static Block * curvemap_tools_func(bContext *C, ARegion *region, RNAUpdateCb &cb, bool show_extend, CurveMapSlopeType reset_mode)
void button_flag_enable(Button *but, int64_t flag)
static Block * curvemap_brush_tools_negslope_func(bContext *C, ARegion *region, void *cb_v)
Block * block_begin(const bContext *C, ARegion *region, std::string name, EmbossType emboss)
static void curvemap_buttons_redraw(bContext &C)
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)
static Block * curvemap_tools_negslope_func(bContext *C, ARegion *region, void *cb_v)
void * but_func_argN_copy(const void *argN)
void block_theme_style_set(Block *block, char theme_style)
static bool curvemap_can_zoom_in(CurveMapping *cumap)
static void curvemap_zoom(CurveMapping &cumap, const float scale)
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 curvemap_buttons_layout(Layout *layout, PointerRNA *ptr, char labeltype, bool levels, bool brush, bool neg_slope, bool tone, bool presets, const RNAUpdateCb &cb)
void block_emboss_set(Block *block, EmbossType emboss)
Button * uiDefButBit(Block *block, ButtonType type, int bit, StringRef str, int x, int y, short width, short height, T *poin, float min, float max, std::optional< StringRef > tip)
void but_func_argN_free(void *argN)
static void curvemap_buttons_zoom_out(bContext *C, CurveMapping *cumap)
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 * curvemap_clipping_func(bContext *C, ARegion *region, void *cumap_v)
static Block * curvemap_tools_posslope_func(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)
void template_curve_mapping(Layout *layout, PointerRNA *ptr, StringRefNull propname, int type, bool levels, bool brush, bool neg_slope, bool tone, bool presets)
static void curvemap_buttons_zoom_in(bContext *C, CurveMapping *cumap)
static Block * curvemap_brush_tools_func(bContext *C, ARegion *region, void *cb_v)
Button * uiDefIconBlockBut(Block *block, BlockCreateFunc func, void *arg, int icon, int x, int y, short width, short height, std::optional< StringRef > tip)
static bool curvemap_can_zoom_out(CurveMapping *cumap)
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_curvemap_remove(CurveMap *cuma, short flag)
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 ED_region_tag_redraw(ARegion *region)
PropertyType RNA_property_type(PropertyRNA *prop)
VecBase< float, 2 > float2
void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapSlopeType slope)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
void BKE_curvemapping_changed(CurveMapping *cumap, bool rem_doubles)
void BKE_curvemapping_reset_view(CurveMapping *cumap)
void BLI_rctf_init_minmax(struct rctf *rect)
CurveMapPoint * BKE_curvemap_active_get(CurveMap *cuma)
void BKE_curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
void BKE_curvemap_translate_selection(CurveMap *cuma, const blender::float2 &offset)
const char * RNA_struct_identifier(const StructRNA *type)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
void BKE_curvemap_handle_set(CurveMap *cuma, int type)
ARegion * CTX_wm_region(const bContext *C)
@ CUMA_EXTEND_EXTRAPOLATE
eCurveMappingPreset preset
void alignment_set(LayoutAlign alignment)
Layout & split(float percentage, bool align)