Blender V5.3
FX_shader_colorize.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BKE_context.hh"
10#include "BKE_idtype.hh"
11#include "BKE_screen.hh"
12
13#include "BLI_utildefines.hh"
14
15#include "BLT_translation.hh"
16
17#include "DNA_screen_types.h"
18#include "DNA_shader_fx_types.h"
19
21#include "UI_resources.hh"
22
23#include "RNA_access.hh"
24
25#include "FX_shader_types.hh"
26#include "FX_ui_common.hh"
27
28namespace blender {
29
30static void init_data(ShaderFxData *fx)
31{
32 ColorizeShaderFxData *gpfx = reinterpret_cast<ColorizeShaderFxData *>(fx);
33 ARRAY_SET_ITEMS(gpfx->low_color, 0.0f, 0.0f, 0.0f, 1.0f);
34 ARRAY_SET_ITEMS(gpfx->high_color, 1.0f, 1.0f, 1.0f, 1.0f);
36 gpfx->factor = 0.5f;
37}
38
39static void copy_data(const ShaderFxData *md, ShaderFxData *target)
40{
42}
43
44static void panel_draw(const bContext * /*C*/, Panel *panel)
45{
46 ui::Layout &layout = *panel->layout;
47
49
50 int mode = RNA_enum_get(ptr, "mode");
51
52 layout.use_property_split_set(true);
53
54 layout.prop(ptr, "mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
55
57 const char *text = (mode == eShaderFxColorizeMode_Duotone) ? IFACE_("Low Color") :
58 IFACE_("Color");
59 layout.prop(ptr, "low_color", UI_ITEM_NONE, text, ICON_NONE);
60 }
62 layout.prop(ptr, "high_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
63 }
64
65 layout.prop(ptr, "factor", UI_ITEM_NONE, std::nullopt, ICON_NONE);
66
67 shaderfx_panel_end(layout, ptr);
68}
69
70static void panel_register(ARegionType *region_type)
71{
73}
74
77{
78 ColorizeShaderFxData *gpfx = reinterpret_cast<ColorizeShaderFxData *>(fx);
79 fn.single(gpfx->low_color);
80 fn.single(gpfx->high_color);
81}
82
84 /*name*/ N_("Colorize"),
85 /*struct_name*/ "ColorizeShaderFxData",
86 /*struct_size*/ sizeof(ColorizeShaderFxData),
88 /*flags*/ ShaderFxTypeFlag(0),
89
90 /*copy_data*/ copy_data,
91
92 /*init_data*/ init_data,
93 /*free_data*/ nullptr,
94 /*is_disabled*/ nullptr,
95 /*update_depsgraph*/ nullptr,
96 /*depends_on_time*/ nullptr,
97 /*foreach_ID_link*/ nullptr,
98 /*foreach_working_space_color*/ foreach_working_space_color,
99 /*panel_register*/ panel_register,
100};
101
102} // namespace blender
#define IFACE_(msgid)
#define UI_ITEM_NONE
#define ARRAY_SET_ITEMS(...)
#define ELEM(...)
BMesh Iterators.
static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
int RNA_enum_get(PointerRNA *ptr, const char *name)
ShaderFxTypeInfo shaderfx_Type_Colorize
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
static void foreach_working_space_color(ModifierData *md, const IDTypeForeachColorFunctionCallback &fn)
static void init_data(ModifierData *md)
static void panel_register(ARegionType *region_type)
@ eShaderFxType_GpencilType
void shaderfx_panel_end(ui::Layout &layout, PointerRNA *ptr)
@ eShaderFxColorizeMode_Custom
@ eShaderFxColorizeMode_Duotone
@ eShaderFxColorizeMode_GrayScale
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
static void panel_draw(const bContext *, Panel *panel)
void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst)
Definition shader_fx.cc:161
ui::Layout * layout
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)
#define N_(msgid)