Blender V4.5
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_screen.hh"
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{
29 RimShaderFxData *gpfx = (RimShaderFxData *)fx;
30 ARRAY_SET_ITEMS(gpfx->offset, 50, -100);
31 ARRAY_SET_ITEMS(gpfx->rim_rgb, 1.0f, 1.0f, 0.5f);
32 ARRAY_SET_ITEMS(gpfx->mask_rgb, 0.0f, 0.0f, 0.0f);
34
35 ARRAY_SET_ITEMS(gpfx->blur, 0, 0);
36 gpfx->samples = 2;
37}
38
39static void copy_data(const ShaderFxData *md, ShaderFxData *target)
40{
42}
43
44static void panel_draw(const bContext * /*C*/, Panel *panel)
45{
47 uiLayout *layout = panel->layout;
48
50
51 uiLayoutSetPropSep(layout, true);
52
53 layout->prop(ptr, "rim_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
54 layout->prop(ptr, "mask_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
55 layout->prop(ptr, "mode", UI_ITEM_NONE, IFACE_("Blend Mode"), ICON_NONE);
56
57 /* Add the X, Y labels manually because offset is a #PROP_PIXEL. */
58 col = &layout->column(true);
59 PropertyRNA *prop = RNA_struct_find_property(ptr, "offset");
60 col->prop(ptr, prop, 0, 0, UI_ITEM_NONE, IFACE_("Offset X"), ICON_NONE);
61 col->prop(ptr, prop, 1, 0, UI_ITEM_NONE, IFACE_("Y"), ICON_NONE);
62
63 shaderfx_panel_end(layout, ptr);
64}
65
66static void blur_panel_draw(const bContext * /*C*/, Panel *panel)
67{
69 uiLayout *layout = panel->layout;
70
72
73 uiLayoutSetPropSep(layout, true);
74
75 /* Add the X, Y labels manually because blur is a #PROP_PIXEL. */
76 col = &layout->column(true);
78 col->prop(ptr, prop, 0, 0, UI_ITEM_NONE, IFACE_("Blur X"), ICON_NONE);
79 col->prop(ptr, prop, 1, 0, UI_ITEM_NONE, IFACE_("Y"), ICON_NONE);
80
81 layout->prop(ptr, "samples", UI_ITEM_NONE, std::nullopt, ICON_NONE);
82}
83
84static void panel_register(ARegionType *region_type)
85{
87 shaderfx_subpanel_register(region_type, "blur", "Blur", nullptr, blur_panel_draw, panel_type);
88}
89
91 /*name*/ N_("Rim"),
92 /*struct_name*/ "RimShaderFxData",
93 /*struct_size*/ sizeof(RimShaderFxData),
95 /*flags*/ ShaderFxTypeFlag(0),
96
97 /*copy_data*/ copy_data,
98
99 /*init_data*/ init_data,
100 /*free_data*/ nullptr,
101 /*is_disabled*/ nullptr,
102 /*update_depsgraph*/ nullptr,
103 /*depends_on_time*/ nullptr,
104 /*foreach_ID_link*/ nullptr,
105 /*panel_register*/ panel_register,
106};
@ 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 panel_register(ARegionType *region_type)
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)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
#define UI_ITEM_NONE
uint col
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
struct uiLayout * layout
uiLayout & column(bool align)
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:4226