Blender V5.0
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.h"
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.h"
26#include "FX_ui_common.h"
27
28static void init_data(ShaderFxData *fx)
29{
31 ARRAY_SET_ITEMS(gpfx->low_color, 0.0f, 0.0f, 0.0f, 1.0f);
32 ARRAY_SET_ITEMS(gpfx->high_color, 1.0f, 1.0f, 1.0f, 1.0f);
34 gpfx->factor = 0.5f;
35}
36
37static void copy_data(const ShaderFxData *md, ShaderFxData *target)
38{
40}
41
42static void panel_draw(const bContext * /*C*/, Panel *panel)
43{
44 uiLayout *layout = panel->layout;
45
47
48 int mode = RNA_enum_get(ptr, "mode");
49
50 layout->use_property_split_set(true);
51
52 layout->prop(ptr, "mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
53
55 const char *text = (mode == eShaderFxColorizeMode_Duotone) ? IFACE_("Low Color") :
56 IFACE_("Color");
57 layout->prop(ptr, "low_color", UI_ITEM_NONE, text, ICON_NONE);
58 }
60 layout->prop(ptr, "high_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
61 }
62
63 layout->prop(ptr, "factor", UI_ITEM_NONE, std::nullopt, ICON_NONE);
64
65 shaderfx_panel_end(layout, ptr);
66}
67
68static void panel_register(ARegionType *region_type)
69{
71}
72
80
82 /*name*/ N_("Colorize"),
83 /*struct_name*/ "ColorizeShaderFxData",
84 /*struct_size*/ sizeof(ColorizeShaderFxData),
86 /*flags*/ ShaderFxTypeFlag(0),
87
88 /*copy_data*/ copy_data,
89
90 /*init_data*/ init_data,
91 /*free_data*/ nullptr,
92 /*is_disabled*/ nullptr,
93 /*update_depsgraph*/ nullptr,
94 /*depends_on_time*/ nullptr,
95 /*foreach_ID_link*/ nullptr,
96 /*foreach_working_space_color*/ foreach_working_space_color,
97 /*panel_register*/ panel_register,
98};
@ eShaderFxType_GpencilType
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
ShaderFxTypeFlag
#define ARRAY_SET_ITEMS(...)
#define ELEM(...)
#define IFACE_(msgid)
@ eShaderFxColorizeMode_Custom
@ eShaderFxColorizeMode_GrayScale
@ eShaderFxColorizeMode_Duotone
@ eShaderFxType_Colorize
static void panel_register(ARegionType *region_type)
static void foreach_working_space_color(ShaderFxData *fx, const IDTypeForeachColorFunctionCallback &fn)
static void init_data(ShaderFxData *fx)
static void panel_draw(const bContext *, Panel *panel)
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
ShaderFxTypeInfo shaderfx_Type_Colorize
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
static void init_data(ModifierData *md)
static void panel_register(ARegionType *region_type)
static void panel_draw(const bContext *, Panel *panel)
static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
#define UI_ITEM_NONE
int RNA_enum_get(PointerRNA *ptr, const char *name)
const blender::FunctionRef< void(float rgb[3])> single
struct uiLayout * layout
void use_property_split_set(bool value)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
#define N_(msgid)
PointerRNA * ptr
Definition wm_files.cc:4238