Blender V4.5
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_screen.hh"
11
12#include "BLI_utildefines.h"
13
14#include "BLT_translation.hh"
15
16#include "DNA_screen_types.h"
17#include "DNA_shader_fx_types.h"
18
19#include "UI_interface.hh"
20#include "UI_resources.hh"
21
22#include "RNA_access.hh"
23
24#include "FX_shader_types.h"
25#include "FX_ui_common.h"
26
27static void init_data(ShaderFxData *fx)
28{
30 ARRAY_SET_ITEMS(gpfx->low_color, 0.0f, 0.0f, 0.0f, 1.0f);
31 ARRAY_SET_ITEMS(gpfx->high_color, 1.0f, 1.0f, 1.0f, 1.0f);
33 gpfx->factor = 0.5f;
34}
35
36static void copy_data(const ShaderFxData *md, ShaderFxData *target)
37{
39}
40
41static void panel_draw(const bContext * /*C*/, Panel *panel)
42{
43 uiLayout *layout = panel->layout;
44
46
47 int mode = RNA_enum_get(ptr, "mode");
48
49 uiLayoutSetPropSep(layout, true);
50
51 layout->prop(ptr, "mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
52
54 const char *text = (mode == eShaderFxColorizeMode_Duotone) ? IFACE_("Low Color") :
55 IFACE_("Color");
56 layout->prop(ptr, "low_color", UI_ITEM_NONE, text, ICON_NONE);
57 }
59 layout->prop(ptr, "high_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
60 }
61
62 layout->prop(ptr, "factor", UI_ITEM_NONE, std::nullopt, ICON_NONE);
63
64 shaderfx_panel_end(layout, ptr);
65}
66
67static void panel_register(ARegionType *region_type)
68{
70}
71
73 /*name*/ N_("Colorize"),
74 /*struct_name*/ "ColorizeShaderFxData",
75 /*struct_size*/ sizeof(ColorizeShaderFxData),
77 /*flags*/ ShaderFxTypeFlag(0),
78
79 /*copy_data*/ copy_data,
80
81 /*init_data*/ init_data,
82 /*free_data*/ nullptr,
83 /*is_disabled*/ nullptr,
84 /*update_depsgraph*/ nullptr,
85 /*depends_on_time*/ nullptr,
86 /*foreach_ID_link*/ nullptr,
87 /*panel_register*/ panel_register,
88};
@ 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 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)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
#define UI_ITEM_NONE
int RNA_enum_get(PointerRNA *ptr, const char *name)
struct uiLayout * layout
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:4227