Blender V5.0
FX_shader_rim.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 "DNA_screen_types.h"
10#include "DNA_shader_fx_types.h"
11
12#include "BLI_utildefines.h"
13
14#include "BLT_translation.hh"
15
16#include "BKE_context.hh"
17#include "BKE_idtype.hh"
18#include "BKE_screen.hh"
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{
30 RimShaderFxData *gpfx = (RimShaderFxData *)fx;
31 ARRAY_SET_ITEMS(gpfx->offset, 50, -100);
32 ARRAY_SET_ITEMS(gpfx->rim_rgb, 1.0f, 1.0f, 0.5f);
33 ARRAY_SET_ITEMS(gpfx->mask_rgb, 0.0f, 0.0f, 0.0f);
35
36 ARRAY_SET_ITEMS(gpfx->blur, 0, 0);
37 gpfx->samples = 2;
38}
39
40static void copy_data(const ShaderFxData *md, ShaderFxData *target)
41{
43}
44
45static void panel_draw(const bContext * /*C*/, Panel *panel)
46{
48 uiLayout *layout = panel->layout;
49
51
52 layout->use_property_split_set(true);
53
54 layout->prop(ptr, "rim_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
55 layout->prop(ptr, "mask_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
56 layout->prop(ptr, "mode", UI_ITEM_NONE, IFACE_("Blend Mode"), ICON_NONE);
57
58 /* Add the X, Y labels manually because offset is a #PROP_PIXEL. */
59 col = &layout->column(true);
60 PropertyRNA *prop = RNA_struct_find_property(ptr, "offset");
61 col->prop(ptr, prop, 0, 0, UI_ITEM_NONE, IFACE_("Offset X"), ICON_NONE);
62 col->prop(ptr, prop, 1, 0, UI_ITEM_NONE, IFACE_("Y"), ICON_NONE);
63
64 shaderfx_panel_end(layout, ptr);
65}
66
67static void blur_panel_draw(const bContext * /*C*/, Panel *panel)
68{
70 uiLayout *layout = panel->layout;
71
73
74 layout->use_property_split_set(true);
75
76 /* Add the X, Y labels manually because blur is a #PROP_PIXEL. */
77 col = &layout->column(true);
79 col->prop(ptr, prop, 0, 0, UI_ITEM_NONE, IFACE_("Blur X"), ICON_NONE);
80 col->prop(ptr, prop, 1, 0, UI_ITEM_NONE, IFACE_("Y"), ICON_NONE);
81
82 layout->prop(ptr, "samples", UI_ITEM_NONE, std::nullopt, ICON_NONE);
83}
84
85static void panel_register(ARegionType *region_type)
86{
88 shaderfx_subpanel_register(region_type, "blur", "Blur", nullptr, blur_panel_draw, panel_type);
89}
90
93{
94 RimShaderFxData *gpfx = (RimShaderFxData *)fx;
95 fn.single(gpfx->rim_rgb);
96 fn.single(gpfx->mask_rgb);
97}
98
100 /*name*/ N_("Rim"),
101 /*struct_name*/ "RimShaderFxData",
102 /*struct_size*/ sizeof(RimShaderFxData),
104 /*flags*/ ShaderFxTypeFlag(0),
105
106 /*copy_data*/ copy_data,
107
108 /*init_data*/ init_data,
109 /*free_data*/ nullptr,
110 /*is_disabled*/ nullptr,
111 /*update_depsgraph*/ nullptr,
112 /*depends_on_time*/ nullptr,
113 /*foreach_ID_link*/ nullptr,
114 /*foreach_working_space_color*/ foreach_working_space_color,
115 /*panel_register*/ panel_register,
116};
@ eShaderFxType_GpencilType
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
ShaderFxTypeFlag
#define ARRAY_SET_ITEMS(...)
#define IFACE_(msgid)
@ eShaderFxRimMode_Overlay
@ eShaderFxType_Rim
static void foreach_working_space_color(ShaderFxData *fx, const IDTypeForeachColorFunctionCallback &fn)
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 blur_panel_draw(const bContext *, Panel *panel)
static void panel_draw(const bContext *, Panel *panel)
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
ShaderFxTypeInfo shaderfx_Type_Rim
PanelType * shaderfx_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
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
uint col
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
const blender::FunctionRef< void(float rgb[3])> single
struct uiLayout * layout
uiLayout & column(bool align)
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