Blender V5.0
interface_template_curve_mapping.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BKE_colortools.hh"
10#include "BKE_context.hh"
11#include "BKE_library.hh"
12
13#include "BLI_bounds.hh"
14#include "BLI_math_base.h"
15#include "BLI_rect.h"
16#include "BLI_string_ref.hh"
17
18#include "BLT_translation.hh"
19
20#include "ED_screen.hh"
21#include "ED_undo.hh"
22
23#include "RNA_access.hh"
24#include "RNA_prototypes.hh"
25
27#include "interface_intern.hh"
29
31
33{
34 return (cumap->flag & CUMA_DO_CLIP) == 0 ||
35 (BLI_rctf_size_x(&cumap->curr) < BLI_rctf_size_x(&cumap->clipr));
36}
37
39{
40 return (cumap->flag & CUMA_DO_CLIP) == 0 ||
42}
43
44static void curvemap_zoom(CurveMapping &cumap, const float scale)
45{
46 using namespace blender;
47
48 const Bounds<float2> curr_bounds(float2(cumap.curr.xmin, cumap.curr.ymin),
49 float2(cumap.curr.xmax, cumap.curr.ymax));
50 const float2 offset = curr_bounds.size() * 0.5f * (scale - 1.0f);
51 const Bounds<float2> new_bounds(curr_bounds.min - offset, curr_bounds.max + offset);
52
53 Bounds<float2> clamped_bounds = new_bounds;
54 /* Clamp to clip bounds if enabled, snap if the difference is small. */
55 if (cumap.flag & CUMA_DO_CLIP) {
56 const Bounds<float2> clip_bounds(float2(cumap.clipr.xmin, cumap.clipr.ymin),
57 float2(cumap.clipr.xmax, cumap.clipr.ymax));
58 const float2 threshold = 0.01f * clip_bounds.size();
59 if (clamped_bounds.min.x < clip_bounds.min.x + threshold.x) {
60 clamped_bounds.min.x = clip_bounds.min.x;
61 }
62 if (clamped_bounds.min.y < clip_bounds.min.y + threshold.y) {
63 clamped_bounds.min.y = clip_bounds.min.y;
64 }
65 if (clamped_bounds.max.x > clip_bounds.max.x - threshold.x) {
66 clamped_bounds.max.x = clip_bounds.max.x;
67 }
68 if (clamped_bounds.max.y > clip_bounds.max.y - threshold.y) {
69 clamped_bounds.max.y = clip_bounds.max.y;
70 }
71 }
72 cumap.curr.xmin = clamped_bounds.min.x;
73 cumap.curr.ymin = clamped_bounds.min.y;
74 cumap.curr.xmax = clamped_bounds.max.x;
75 cumap.curr.ymax = clamped_bounds.max.y;
76}
77
79{
80 if (!curvemap_can_zoom_in(cumap)) {
81 return;
82 }
83
84 curvemap_zoom(*cumap, 0.7692f);
85
87}
88
90{
91 using namespace blender;
92
93 if (!curvemap_can_zoom_out(cumap)) {
94 return;
95 }
96
97 curvemap_zoom(*cumap, 1.3f);
98
100}
101
102/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
103static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap_v)
104{
105 CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
106 uiBut *bt;
107 const float width = 8 * UI_UNIT_X;
108
109 uiBlock *block = UI_block_begin(C, region, __func__, blender::ui::EmbossType::Emboss);
112
113 bt = uiDefButBitI(block,
116 1,
117 IFACE_("Clipping"),
118 0,
119 5 * UI_UNIT_Y,
120 width,
121 UI_UNIT_Y,
122 &cumap->flag,
123 0.0,
124 0.0,
125 "");
126 UI_but_func_set(bt, [cumap](bContext & /*C*/) { BKE_curvemapping_changed(cumap, false); });
127
129 bt = uiDefButF(block,
131 0,
132 IFACE_("Min X:"),
133 0,
134 4 * UI_UNIT_Y,
135 width,
136 UI_UNIT_Y,
137 &cumap->clipr.xmin,
138 -100.0,
139 cumap->clipr.xmax,
140 "");
143 bt = uiDefButF(block,
145 0,
146 IFACE_("Min Y:"),
147 0,
148 3 * UI_UNIT_Y,
149 width,
150 UI_UNIT_Y,
151 &cumap->clipr.ymin,
152 -100.0,
153 cumap->clipr.ymax,
154 "");
157 bt = uiDefButF(block,
159 0,
160 IFACE_("Max X:"),
161 0,
162 2 * UI_UNIT_Y,
163 width,
164 UI_UNIT_Y,
165 &cumap->clipr.xmax,
166 cumap->clipr.xmin,
167 100.0,
168 "");
171 bt = uiDefButF(block,
173 0,
174 IFACE_("Max Y:"),
175 0,
176 UI_UNIT_Y,
177 width,
178 UI_UNIT_Y,
179 &cumap->clipr.ymax,
180 cumap->clipr.ymin,
181 100.0,
182 "");
185
186 UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
188
189 return block;
190}
191
193 bContext *C, ARegion *region, RNAUpdateCb &cb, bool show_extend, CurveMapSlopeType reset_mode)
194{
195 PointerRNA cumap_ptr = RNA_property_pointer_get(&cb.ptr, cb.prop);
196 CurveMapping *cumap = static_cast<CurveMapping *>(cumap_ptr.data);
197
198 short yco = 0;
199 const short menuwidth = 10 * UI_UNIT_X;
200
201 uiBlock *block = UI_block_begin(C, region, __func__, blender::ui::EmbossType::Emboss);
202
203 {
204 uiBut *but = uiDefIconTextBut(block,
206 1,
207 ICON_BLANK1,
208 IFACE_("Reset View"),
209 0,
210 yco -= UI_UNIT_Y,
211 menuwidth,
212 UI_UNIT_Y,
213 nullptr,
214 "");
215 UI_but_func_set(but, [cumap](bContext &C) {
218 });
219 }
220
221 if (show_extend && !(cumap->flag & CUMA_USE_WRAPPING)) {
222 {
223 uiBut *but = uiDefIconTextBut(block,
225 1,
226 ICON_BLANK1,
227 IFACE_("Extend Horizontal"),
228 0,
229 yco -= UI_UNIT_Y,
230 menuwidth,
231 UI_UNIT_Y,
232 nullptr,
233 "");
234 UI_but_func_set(but, [cumap, cb](bContext &C) {
236 BKE_curvemapping_changed(cumap, false);
237 rna_update_cb(C, cb);
238 ED_undo_push(&C, "CurveMap tools");
240 });
241 }
242 {
243 uiBut *but = uiDefIconTextBut(block,
245 1,
246 ICON_BLANK1,
247 IFACE_("Extend Extrapolated"),
248 0,
249 yco -= UI_UNIT_Y,
250 menuwidth,
251 UI_UNIT_Y,
252 nullptr,
253 "");
254 UI_but_func_set(but, [cumap, cb](bContext &C) {
256 BKE_curvemapping_changed(cumap, false);
257 rna_update_cb(C, cb);
258 ED_undo_push(&C, "CurveMap tools");
260 });
261 }
262 }
263
264 {
265 uiBut *but = uiDefIconTextBut(block,
267 1,
268 ICON_BLANK1,
269 IFACE_("Reset Curve"),
270 0,
271 yco -= UI_UNIT_Y,
272 menuwidth,
273 UI_UNIT_Y,
274 nullptr,
275 "");
276 UI_but_func_set(but, [cumap, cb, reset_mode](bContext &C) {
277 CurveMap *cuma = cumap->cm + cumap->cur;
278 BKE_curvemap_reset(cuma, &cumap->clipr, cumap->preset, reset_mode);
279 BKE_curvemapping_changed(cumap, false);
280 rna_update_cb(C, cb);
281 ED_undo_push(&C, "CurveMap tools");
283 });
284 }
285
287 UI_block_bounds_set_text(block, 3.0f * UI_UNIT_X);
288
289 return block;
290}
291
293{
294 return curvemap_tools_func(
295 C, region, *static_cast<RNAUpdateCb *>(cb_v), true, CurveMapSlopeType::Positive);
296}
297
299{
300 return curvemap_tools_func(
301 C, region, *static_cast<RNAUpdateCb *>(cb_v), true, CurveMapSlopeType::Negative);
302}
303
304static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *region, void *cb_v)
305{
306 return curvemap_tools_func(
307 C, region, *static_cast<RNAUpdateCb *>(cb_v), false, CurveMapSlopeType::Positive);
308}
309
311{
312 return curvemap_tools_func(
313 C, region, *static_cast<RNAUpdateCb *>(cb_v), false, CurveMapSlopeType::Negative);
314}
315
320
321static void add_preset_button(uiBlock *block,
322 const float dx,
323 const int icon,
324 std::optional<blender::StringRef> tip,
325 CurveMapping *cumap,
326 const bool neg_slope,
327 const int preset,
328 const RNAUpdateCb &cb)
329{
330 uiBut *bt = uiDefIconBut(block, ButType::Row, 0, icon, 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, tip);
331 UI_but_func_set(bt, [&, cumap, neg_slope, preset, cb](bContext &C) {
332 const CurveMapSlopeType slope = neg_slope ? CurveMapSlopeType::Negative :
335 cumap->preset = preset;
336 BKE_curvemap_reset(cumap->cm, &cumap->clipr, cumap->preset, slope);
337 BKE_curvemapping_changed(cumap, false);
338 rna_update_cb(C, cb);
339 });
340}
341
349 char labeltype,
350 bool levels,
351 bool brush,
352 bool neg_slope,
353 bool tone,
354 bool presets,
355 const RNAUpdateCb &cb)
356{
357 CurveMapping *cumap = static_cast<CurveMapping *>(ptr->data);
358 CurveMap *cm = &cumap->cm[cumap->cur];
359 uiBut *bt;
360 const float dx = UI_UNIT_X;
362
363 uiBlock *block = layout->block();
364
366
367 if (tone) {
368 uiLayout *split = &layout->split(0.0f, false);
369 split->row(false).prop(ptr, "tone", UI_ITEM_R_EXPAND, std::nullopt, ICON_NONE);
370 }
371
372 /* curve chooser */
373 uiLayout *row = &layout->row(false);
374
375 if (labeltype == 'v') {
376 /* vector */
377 uiLayout *sub = &row->row(true);
379
380 if (cumap->cm[0].curve) {
381 bt = uiDefButI(block, ButType::Row, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, "");
383 }
384 if (cumap->cm[1].curve) {
385 bt = uiDefButI(block, ButType::Row, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, "");
387 }
388 if (cumap->cm[2].curve) {
389 bt = uiDefButI(block, ButType::Row, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, "");
391 }
392 }
393 else if (labeltype == 'c' && cumap->tone != CURVE_TONE_FILMLIKE) {
394 /* color */
395 uiLayout *sub = &row->row(true);
397
398 if (cumap->cm[3].curve) {
399 bt = uiDefButI(block,
401 0,
403 0,
404 0,
405 dx,
406 dx,
407 &cumap->cur,
408 0.0,
409 3.0,
410 TIP_("Combined channels"));
412 }
413 if (cumap->cm[0].curve) {
414 bt = uiDefButI(block,
416 0,
418 0,
419 0,
420 dx,
421 dx,
422 &cumap->cur,
423 0.0,
424 0.0,
425 TIP_("Red channel"));
427 }
428 if (cumap->cm[1].curve) {
429 bt = uiDefButI(block,
431 0,
433 0,
434 0,
435 dx,
436 dx,
437 &cumap->cur,
438 0.0,
439 1.0,
440 TIP_("Green channel"));
442 }
443 if (cumap->cm[2].curve) {
444 bt = uiDefButI(block,
446 0,
448 0,
449 0,
450 dx,
451 dx,
452 &cumap->cur,
453 0.0,
454 2.0,
455 TIP_("Blue channel"));
457 }
458 }
459 else if (labeltype == 'h') {
460 /* HSV */
461 uiLayout *sub = &row->row(true);
463
464 if (cumap->cm[0].curve) {
465 bt = uiDefButI(block,
467 0,
468 IFACE_("H"),
469 0,
470 0,
471 dx,
472 dx,
473 &cumap->cur,
474 0.0,
475 0.0,
476 TIP_("Hue level"));
478 }
479 if (cumap->cm[1].curve) {
480 bt = uiDefButI(block,
482 0,
483 IFACE_("S"),
484 0,
485 0,
486 dx,
487 dx,
488 &cumap->cur,
489 0.0,
490 1.0,
491 TIP_("Saturation level"));
493 }
494 if (cumap->cm[2].curve) {
495 bt = uiDefButI(block,
497 0,
498 IFACE_("V"),
499 0,
500 0,
501 dx,
502 dx,
503 &cumap->cur,
504 0.0,
505 2.0,
506 TIP_("Value level"));
508 }
509 }
510 else {
512 }
513
514 if (labeltype == 'h') {
515 bg = UI_GRAD_H;
516 }
517
518 /* operation buttons */
519 /* (Right aligned) */
520 uiLayout *sub = &row->row(true);
522
523 if (!(cumap->flag & CUMA_USE_WRAPPING)) {
524 /* Zoom in */
525 bt = uiDefIconBut(
526 block, ButType::But, 0, ICON_ZOOM_IN, 0, 0, dx, dx, nullptr, 0.0, 0.0, TIP_("Zoom in"));
527 UI_but_func_set(bt, [cumap](bContext &C) { curvemap_buttons_zoom_in(&C, cumap); });
528 if (!curvemap_can_zoom_in(cumap)) {
529 UI_but_disable(bt, "");
530 }
531
532 /* Zoom out */
533 bt = uiDefIconBut(
534 block, ButType::But, 0, ICON_ZOOM_OUT, 0, 0, dx, dx, nullptr, 0.0, 0.0, TIP_("Zoom out"));
535 UI_but_func_set(bt, [cumap](bContext &C) { curvemap_buttons_zoom_out(&C, cumap); });
536 if (!curvemap_can_zoom_out(cumap)) {
537 UI_but_disable(bt, "");
538 }
539
540 /* Clipping button. */
541 const int icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
543 block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping options"));
545 UI_but_func_set(bt, [cb](bContext &C) { rna_update_cb(C, cb); });
546 }
547
548 RNAUpdateCb *tools_cb = MEM_new<RNAUpdateCb>(__func__, cb);
549 if (brush && neg_slope) {
550 bt = uiDefIconBlockBut(block,
552 tools_cb,
553 0,
554 ICON_NONE,
555 0,
556 0,
557 dx,
558 dx,
559 TIP_("Tools"));
560 }
561 else if (brush) {
563 block, curvemap_brush_tools_func, tools_cb, 0, ICON_NONE, 0, 0, dx, dx, TIP_("Tools"));
564 }
565 else if (neg_slope) {
567 block, curvemap_tools_negslope_func, tools_cb, 0, ICON_NONE, 0, 0, dx, dx, TIP_("Tools"));
568 }
569 else {
571 block, curvemap_tools_posslope_func, tools_cb, 0, ICON_NONE, 0, 0, dx, dx, TIP_("Tools"));
572 }
573 /* Pass ownership of `tools_cb` to the button. */
575 bt,
576 [](bContext *, void *, void *) {},
577 tools_cb,
578 nullptr,
581
582 UI_block_funcN_set(block,
584 MEM_new<RNAUpdateCb>(__func__, cb),
585 nullptr,
588
589 /* Curve itself. */
590 const int size = max_ii(layout->width(), UI_UNIT_X);
591 row = &layout->row(false);
592 uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut(block,
594 0,
595 IFACE_("Edit Curve Map"),
596 0,
597 0,
598 size,
599 8.0f * UI_UNIT_X,
600 cumap,
601 0.0f,
602 1.0f,
603 "");
604 curve_but->gradient_type = bg;
605 if (!layout->active()) {
607 }
608
609 /* Sliders for selected curve point. */
610 int i;
611 CurveMapPoint *cmp = nullptr;
612 bool point_last_or_first = false;
613 for (i = 0; i < cm->totpoint; i++) {
614 if (cm->curve[i].flag & CUMA_SELECT) {
615 cmp = &cm->curve[i];
616 break;
617 }
618 }
619 if (ELEM(i, 0, cm->totpoint - 1)) {
620 point_last_or_first = true;
621 }
622
623 if (cmp) {
624 rctf bounds;
625 if (cumap->flag & CUMA_DO_CLIP) {
626 bounds = cumap->clipr;
627 }
628 else {
629 bounds.xmin = bounds.ymin = -1000.0;
630 bounds.xmax = bounds.ymax = 1000.0;
631 }
632
634
635 layout->row(true);
636
637 /* Curve handle buttons. */
638 bt = uiDefIconBut(block,
640 1,
641 ICON_HANDLE_AUTO,
642 0,
643 UI_UNIT_Y,
644 UI_UNIT_X,
645 UI_UNIT_Y,
646 nullptr,
647 0.0,
648 0.0,
649 TIP_("Auto handle"));
650 UI_but_func_set(bt, [cumap, cb](bContext &C) {
651 CurveMap *cuma = cumap->cm + cumap->cur;
653 BKE_curvemapping_changed(cumap, false);
654 rna_update_cb(C, cb);
655 });
656 if (((cmp->flag & CUMA_HANDLE_AUTO_ANIM) == false) &&
657 ((cmp->flag & CUMA_HANDLE_VECTOR) == false))
658 {
659 bt->flag |= UI_SELECT_DRAW;
660 }
661
662 bt = uiDefIconBut(block,
664 1,
665 ICON_HANDLE_VECTOR,
666 0,
667 UI_UNIT_Y,
668 UI_UNIT_X,
669 UI_UNIT_Y,
670 nullptr,
671 0.0,
672 0.0,
673 TIP_("Vector handle"));
674 UI_but_func_set(bt, [cumap, cb](bContext &C) {
675 CurveMap *cuma = cumap->cm + cumap->cur;
677 BKE_curvemapping_changed(cumap, false);
678 rna_update_cb(C, cb);
679 });
680 if (cmp->flag & CUMA_HANDLE_VECTOR) {
681 bt->flag |= UI_SELECT_DRAW;
682 }
683
684 bt = uiDefIconBut(block,
686 1,
687 ICON_HANDLE_AUTOCLAMPED,
688 0,
689 UI_UNIT_Y,
690 UI_UNIT_X,
691 UI_UNIT_Y,
692 nullptr,
693 0.0,
694 0.0,
695 TIP_("Auto clamped"));
696 UI_but_func_set(bt, [cumap, cb](bContext &C) {
697 CurveMap *cuma = cumap->cm + cumap->cur;
699 BKE_curvemapping_changed(cumap, false);
700 rna_update_cb(C, cb);
701 });
702 if (cmp->flag & CUMA_HANDLE_AUTO_ANIM) {
703 bt->flag |= UI_SELECT_DRAW;
704 }
705
706 /* Curve handle position */
707 bt = uiDefButF(block,
709 0,
710 "X:",
711 0,
712 2 * UI_UNIT_Y,
713 UI_UNIT_X * 10,
714 UI_UNIT_Y,
715 &cmp->x,
716 bounds.xmin,
717 bounds.xmax,
718 "");
721 UI_but_func_set(bt, [cumap, cb](bContext &C) {
722 BKE_curvemapping_changed(cumap, true);
723 rna_update_cb(C, cb);
724 });
725
726 bt = uiDefButF(block,
728 0,
729 "Y:",
730 0,
731 1 * UI_UNIT_Y,
732 UI_UNIT_X * 10,
733 UI_UNIT_Y,
734 &cmp->y,
735 bounds.ymin,
736 bounds.ymax,
737 "");
740 UI_but_func_set(bt, [cumap, cb](bContext &C) {
741 BKE_curvemapping_changed(cumap, true);
742 rna_update_cb(C, cb);
743 });
744
745 /* Curve handle delete point */
746 bt = uiDefIconBut(
747 block, ButType::But, 0, ICON_X, 0, 0, dx, dx, nullptr, 0.0, 0.0, TIP_("Delete points"));
748 UI_but_func_set(bt, [cumap, cb](bContext &C) {
749 BKE_curvemap_remove(cumap->cm + cumap->cur, SELECT);
750 BKE_curvemapping_changed(cumap, false);
751 rna_update_cb(C, cb);
752 });
753 if (point_last_or_first) {
755 }
756 }
757
758 /* black/white levels */
759 if (levels) {
760 uiLayout *split = &layout->split(0.0f, false);
761 split->column(false).prop(ptr, "black_level", UI_ITEM_R_EXPAND, std::nullopt, ICON_NONE);
762 split->column(false).prop(ptr, "white_level", UI_ITEM_R_EXPAND, std::nullopt, ICON_NONE);
763
764 layout->row(false);
765 bt = uiDefBut(block,
767 0,
768 IFACE_("Reset"),
769 0,
770 0,
771 UI_UNIT_X * 10,
772 UI_UNIT_Y,
773 nullptr,
774 0.0f,
775 0.0f,
776 TIP_("Reset curves and black/white point"));
777 UI_but_func_set(bt, [cumap, cb](bContext &C) {
778 cumap->preset = CURVE_PRESET_LINE;
779 for (int a = 0; a < CM_TOT; a++) {
781 cumap->cm + a, &cumap->clipr, cumap->preset, CurveMapSlopeType::Positive);
782 }
783
784 cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f;
785 cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
786 BKE_curvemapping_set_black_white(cumap, nullptr, nullptr);
787
788 BKE_curvemapping_changed(cumap, false);
789 rna_update_cb(C, cb);
790 });
791 }
792
793 if (presets) {
794 row = &layout->row(true);
796 add_preset_button(block,
797 dx,
798 ICON_SMOOTHCURVE,
799 TIP_("Smooth preset"),
800 cumap,
801 neg_slope,
803 cb);
804 add_preset_button(block,
805 dx,
806 ICON_SPHERECURVE,
807 TIP_("Round preset"),
808 cumap,
809 neg_slope,
811 cb);
813 block, dx, ICON_ROOTCURVE, TIP_("Root preset"), cumap, neg_slope, CURVE_PRESET_ROOT, cb);
814 add_preset_button(block,
815 dx,
816 ICON_SHARPCURVE,
817 TIP_("Sharp preset"),
818 cumap,
819 neg_slope,
821 cb);
823 block, dx, ICON_LINCURVE, TIP_("Linear preset"), cumap, neg_slope, CURVE_PRESET_LINE, cb);
825 block, dx, ICON_NOCURVE, TIP_("Constant preset"), cumap, neg_slope, CURVE_PRESET_MAX, cb);
826 }
827
828 UI_block_funcN_set(block, nullptr, nullptr, nullptr);
829}
830
833 const StringRefNull propname,
834 int type,
835 bool levels,
836 bool brush,
837 bool neg_slope,
838 bool tone,
839 bool presets)
840{
841 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
842 uiBlock *block = layout->block();
843
844 if (!prop) {
846 "curve property not found: %s.%s", RNA_struct_identifier(ptr->type), propname.c_str());
847 return;
848 }
849
850 if (RNA_property_type(prop) != PROP_POINTER) {
852 "curve is not a pointer: %s.%s", RNA_struct_identifier(ptr->type), propname.c_str());
853 return;
854 }
855
857 if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) {
858 return;
859 }
860
861 ID *id = cptr.owner_id;
863
865 layout, &cptr, type, levels, brush, neg_slope, tone, presets, RNAUpdateCb{*ptr, prop});
866
867 UI_block_lock_clear(block);
868}
void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, CurveMapSlopeType slope)
void BKE_curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
void BKE_curvemapping_reset_view(CurveMapping *cumap)
CurveMapSlopeType
void BKE_curvemapping_changed(CurveMapping *cumap, bool rem_doubles)
void BKE_curvemap_remove(CurveMap *cuma, short flag)
void BKE_curvemap_handle_set(CurveMap *cuma, int type)
ARegion * CTX_wm_region(const bContext *C)
MINLINE int max_ii(int a, int b)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.h:202
#define ELEM(...)
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_COLOR
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:705
#define CM_TOT
@ CUMA_EXTEND_EXTRAPOLATE
@ CUMA_DO_CLIP
@ CUMA_USE_WRAPPING
@ CUMA_HANDLE_AUTO_ANIM
@ CUMA_SELECT
@ CUMA_HANDLE_VECTOR
@ CURVE_TONE_FILMLIKE
@ CURVE_PRESET_ROOT
@ CURVE_PRESET_SMOOTH
@ CURVE_PRESET_ROUND
@ CURVE_PRESET_LINE
@ CURVE_PRESET_SHARP
@ CURVE_PRESET_MAX
@ HD_AUTO_ANIM
@ HD_VECT
@ HD_AUTO
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:618
void ED_undo_push(bContext *C, const char *str)
Definition ed_undo.cc:98
static void split(const char *text, const char *seps, char ***str, int *count)
#define RNA_warning(format,...)
@ PROP_POINTER
Definition RNA_types.hh:167
#define C
Definition RandGen.cpp:29
void UI_but_func_set(uiBut *but, std::function< void(bContext &)> func)
void * but_func_argN_copy(const void *argN)
void but_func_argN_free(void *argN)
uiBut * uiDefButF(uiBlock *block, ButType type, int retval, blender::StringRef str, int x, int y, short width, short height, float *poin, float min, float max, std::optional< blender::StringRef > tip)
uiBut * uiDefButI(uiBlock *block, ButType type, int retval, blender::StringRef str, int x, int y, short width, short height, int *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_disable(uiBut *but, const char *disabled_hint)
uiBut * uiDefIconTextBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_type, int retval, int icon, blender::StringRef str, int x, int y, short width, short height, void *poin, std::optional< blender::StringRef > tip)
#define UI_UNIT_Y
void UI_block_emboss_set(uiBlock *block, blender::ui::EmbossType emboss)
@ UI_BLOCK_MOVEMOUSE_QUIT
@ UI_BLOCK_KEEP_OPEN
void UI_block_theme_style_set(uiBlock *block, char theme_style)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, blender::ui::EmbossType emboss)
void UI_block_lock_clear(uiBlock *block)
@ UI_BUT_DISABLED
@ UI_BUT_INACTIVE
uiBut * uiDefIconBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_type, int retval, int icon, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_block_bounds_set_normal(uiBlock *block, int addval)
Definition interface.cc:637
void UI_but_number_step_size_set(uiBut *but, float step_size)
void UI_block_bounds_set_text(uiBlock *block, int addval)
Definition interface.cc:647
void UI_block_align_begin(uiBlock *block)
eButGradientType
@ UI_GRAD_H
@ UI_GRAD_NONE
void UI_block_funcN_set(uiBlock *block, uiButHandleNFunc funcN, void *argN, void *arg2, uiButArgNFree func_argN_free_fn=MEM_freeN, uiButArgNCopy func_argN_copy_fn=MEM_dupallocN)
void UI_but_number_precision_set(uiBut *but, float precision)
void UI_block_direction_set(uiBlock *block, char direction)
@ UI_BLOCK_THEME_STYLE_POPUP
#define UI_UNIT_X
void UI_block_flag_enable(uiBlock *block, int flag)
uiBut * uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x, int y, short width, short height, std::optional< blender::StringRef > tip)
@ UI_BUT_ICON_LEFT
void UI_but_funcN_set(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2, uiButArgNFree func_argN_free_fn=MEM_freeN, uiButArgNCopy func_argN_copy_fn=MEM_dupallocN)
uiBut * uiDefButBitI(uiBlock *block, ButType type, int bit, int retval, blender::StringRef str, int x, int y, short width, short height, int *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_block_lock_set(uiBlock *block, bool val, const char *lockstr)
uiBut * uiDefBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_flag_enable(uiBut *but, int flag)
@ UI_DIR_DOWN
@ UI_ITEM_R_EXPAND
#define U
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:299
constexpr const char * c_str() const
#define SELECT
VecBase< float, 2 > float2
@ UI_SELECT_DRAW
static void curvemap_buttons_redraw(bContext &C)
static uiBlock * curvemap_tools_negslope_func(bContext *C, ARegion *region, void *cb_v)
static bool curvemap_can_zoom_in(CurveMapping *cumap)
static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, bool levels, bool brush, bool neg_slope, bool tone, bool presets, const RNAUpdateCb &cb)
static void add_preset_button(uiBlock *block, const float dx, const int icon, std::optional< blender::StringRef > tip, CurveMapping *cumap, const bool neg_slope, const int preset, const RNAUpdateCb &cb)
static void curvemap_zoom(CurveMapping &cumap, const float scale)
static uiBlock * curvemap_tools_func(bContext *C, ARegion *region, RNAUpdateCb &cb, bool show_extend, CurveMapSlopeType reset_mode)
static uiBlock * curvemap_brush_tools_func(bContext *C, ARegion *region, void *cb_v)
static void curvemap_buttons_zoom_in(bContext *C, CurveMapping *cumap)
static uiBlock * curvemap_tools_posslope_func(bContext *C, ARegion *region, void *cb_v)
static bool curvemap_can_zoom_out(CurveMapping *cumap)
static void curvemap_buttons_zoom_out(bContext *C, CurveMapping *cumap)
static uiBlock * curvemap_brush_tools_negslope_func(bContext *C, ARegion *region, void *cb_v)
void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const StringRefNull propname, int type, bool levels, bool brush, bool neg_slope, bool tone, bool presets)
static uiBlock * curvemap_clipping_func(bContext *C, ARegion *region, void *cumap_v)
#define CURVE_ZOOM_MAX
static void rna_update_cb(bContext &C, const RNAUpdateCb &cb)
#define ERROR_LIBDATA_MESSAGE
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
PropertyType RNA_property_type(PropertyRNA *prop)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
const char * RNA_struct_identifier(const StructRNA *type)
T size() const
CurveMapPoint * curve
CurveMap cm[4]
Definition DNA_ID.h:414
ID * owner_id
Definition RNA_types.hh:51
StructRNA * type
Definition RNA_types.hh:52
void * data
Definition RNA_types.hh:53
float x
float y
float xmax
float xmin
float ymax
float ymin
eButGradientType gradient_type
bool active() const
void alignment_set(blender::ui::LayoutAlign alignment)
uiBlock * block() const
int width() const
uiLayout & row(bool align)
uiLayout & split(float percentage, bool align)
i
Definition text_draw.cc:230
PointerRNA * ptr
Definition wm_files.cc:4238