25#include "RNA_prototypes.hh"
37 for (
int a = 0; a < coba->
tot; a++) {
38 data_tmp[a] = coba->
data[coba->
tot - (a + 1)];
40 for (
int a = 0; a < coba->
tot; a++) {
41 data_tmp[a].
pos = 1.0f - data_tmp[a].
pos;
42 coba->
data[a] = data_tmp[a];
54 const int tot = evenly ? coba->
tot - 1 : coba->
tot;
55 const float gap = 1.0f / tot;
57 for (
int a = 0; a < coba->
tot; a++) {
62 "Distribute Stops Evenly") :
64 "Distribute Stops from Left");
79 TIP_(
"Disabled: Color ramp only has one stop"),
116 ICON_ARROW_LEFTRIGHT,
117 IFACE_(
"Flip Color Ramp"),
127 rna_update_cb(
C, cb);
134 IFACE_(
"Distribute Stops from Left"),
144 rna_update_cb(
C, cb);
156 IFACE_(
"Distribute Stops Evenly"),
166 rna_update_cb(
C, cb);
177 layout.
op(
"UI_OT_eyedropper_colorramp",
IFACE_(
"Eyedropper"), ICON_EYEDROPPER);
185 IFACE_(
"Reset Color Ramp"),
196 rna_update_cb(
C, cb);
220 rna_update_cb(
C, cb);
245 const float xs = butr->
xmin;
246 const float ys = butr->
ymin;
265 TIP_(
"Add a new color stop to the color ramp"));
277 TIP_(
"Delete the active position"));
280 rna_update_cb(
C, cb);
289 RNAUpdateCb *tools_cb = MEM_new<RNAUpdateCb>(__func__, cb);
311 row = &
split->row(
false);
323 row = &layout.
row(
false);
326 block,
ButtonType::ColorBand,
"", xs, ys,
BLI_rctf_size_x(butr),
UI_UNIT_Y, coba, 0, 0,
"");
331 row = &layout.
row(
false);
341 row = &
split->row(
false);
351 float(std::max(0, coba->
tot - 1)),
352 TIP_(
"Choose active color stop"));
355 row = &
split->row(
false);
358 row = &layout.
row(
false);
365 row = &subsplit.
row(
false);
375 float(std::max(0, coba->
tot - 1)),
376 TIP_(
"Choose active color stop"));
379 row = &subsplit.
row(
false);
382 row = &
split->row(
false);
388 if (but.rnapoin.data != ptr.
data) {
396 if (
STREQ(prop_identifier,
"position")) {
400 if (
STREQ(prop_identifier,
"color")) {
#define CTX_N_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define ID_IS_EDITABLE(_id)
constexpr const char * c_str() const
constexpr bool is_empty() const
#define UI_MENU_WIDTH_MIN
#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)
static void colorband_flip(bContext *C, ColorBand *coba)
static void colorramp_disabled_tip_func(bContext &, TooltipData &tip, Button *but, void *)
void block_direction_set(Block *block, char direction)
static void colorband_buttons_layout(Layout &layout, Block *block, ColorBand *coba, const rctf *butr, const RNAUpdateCb &cb, int expand)
void button_func_set(Button *but, std::function< void(bContext &)> func)
void block_lock_clear(Block *block)
void block_align_begin(Block *block)
void button_number_step_size_set(Button *but, float step_size)
static void colorband_update_cb(bContext *, void *bt_v, void *coba_v)
static void colorband_distribute(bContext *C, ColorBand *coba, bool evenly)
const uiStyle * style_get_dpi()
void button_func_tooltip_custom_set(Button *but, ButtonToolTipCustomFunc func, void *arg, FreeArgFunc free_arg)
void block_bounds_set_text(Block *block, int addval)
static Block * colorband_tools_fn(bContext *C, ARegion *region, void *cb_v)
void button_flag_enable(Button *but, int64_t flag)
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)
static void colorband_add(bContext &C, const RNAUpdateCb &cb, ColorBand &coba)
void * but_func_argN_copy(const void *argN)
void block_align_end(Block *block)
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)
void tooltip_text_field_add(TooltipData &data, std::string text, std::string suffix, const TooltipStyle style, const TooltipColorID color_id, const bool is_pad=false)
void block_emboss_set(Block *block, EmbossType emboss)
void template_color_ramp(Layout *layout, PointerRNA *ptr, StringRefNull propname, bool expand)
void but_func_argN_free(void *argN)
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)
Layout & block_layout(Block *block, LayoutDirection direction, LayoutType type, int x, int y, int size, int em, int padding, const uiStyle *style)
Button * uiDefIconBlockBut(Block *block, BlockCreateFunc func, void *arg, int icon, int x, int y, short width, short height, std::optional< StringRef > tip)
void block_layout_set_current(Block *block, Layout *layout)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
void BKE_colorband_init(ColorBand *coba, bool rangetype)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
const char * RNA_property_identifier(const PropertyRNA *prop)
void ED_region_tag_redraw(ARegion *region)
PropertyType RNA_property_type(PropertyRNA *prop)
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void BKE_colorband_update_sort(ColorBand *coba)
CBData * BKE_colorband_element_add(ColorBand *coba, float position)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
bool BKE_colorband_element_remove(ColorBand *coba, int index)
ARegion * CTX_wm_region(const bContext *C)
eColorBand_ColorMode color_mode
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
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)
Layout & split(float percentage, bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & absolute(bool align=false)
void context_ptr_set(StringRef name, const PointerRNA *ptr)