Blender V4.3
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
9#include <cstdio>
10
11#include "DNA_screen_types.h"
12#include "DNA_shader_fx_types.h"
13
14#include "BLI_utildefines.h"
15
16#include "BLT_translation.hh"
17
18#include "BKE_context.hh"
19#include "BKE_screen.hh"
20
21#include "UI_interface.hh"
22#include "UI_resources.hh"
23
24#include "RNA_access.hh"
25
26#include "FX_shader_types.h"
27#include "FX_ui_common.h"
28
29static void init_data(ShaderFxData *fx)
30{
31 RimShaderFxData *gpfx = (RimShaderFxData *)fx;
32 ARRAY_SET_ITEMS(gpfx->offset, 50, -100);
33 ARRAY_SET_ITEMS(gpfx->rim_rgb, 1.0f, 1.0f, 0.5f);
34 ARRAY_SET_ITEMS(gpfx->mask_rgb, 0.0f, 0.0f, 0.0f);
36
37 ARRAY_SET_ITEMS(gpfx->blur, 0, 0);
38 gpfx->samples = 2;
39}
40
41static void copy_data(const ShaderFxData *md, ShaderFxData *target)
42{
44}
45
46static void panel_draw(const bContext * /*C*/, Panel *panel)
47{
49 uiLayout *layout = panel->layout;
50
52
53 uiLayoutSetPropSep(layout, true);
54
55 uiItemR(layout, ptr, "rim_color", UI_ITEM_NONE, nullptr, ICON_NONE);
56 uiItemR(layout, ptr, "mask_color", UI_ITEM_NONE, nullptr, ICON_NONE);
57 uiItemR(layout, ptr, "mode", UI_ITEM_NONE, IFACE_("Blend Mode"), ICON_NONE);
58
59 /* Add the X, Y labels manually because offset is a #PROP_PIXEL. */
60 col = uiLayoutColumn(layout, true);
61 PropertyRNA *prop = RNA_struct_find_property(ptr, "offset");
62 uiItemFullR(col, ptr, prop, 0, 0, UI_ITEM_NONE, IFACE_("Offset X"), ICON_NONE);
63 uiItemFullR(col, ptr, prop, 1, 0, UI_ITEM_NONE, IFACE_("Y"), ICON_NONE);
64
65 shaderfx_panel_end(layout, ptr);
66}
67
68static void blur_panel_draw(const bContext * /*C*/, Panel *panel)
69{
71 uiLayout *layout = panel->layout;
72
74
75 uiLayoutSetPropSep(layout, true);
76
77 /* Add the X, Y labels manually because blur is a #PROP_PIXEL. */
78 col = uiLayoutColumn(layout, true);
80 uiItemFullR(col, ptr, prop, 0, 0, UI_ITEM_NONE, IFACE_("Blur X"), ICON_NONE);
81 uiItemFullR(col, ptr, prop, 1, 0, UI_ITEM_NONE, IFACE_("Y"), ICON_NONE);
82
83 uiItemR(layout, ptr, "samples", UI_ITEM_NONE, nullptr, ICON_NONE);
84}
85
86static void panel_register(ARegionType *region_type)
87{
89 shaderfx_subpanel_register(region_type, "blur", "Blur", nullptr, blur_panel_draw, panel_type);
90}
91
93 /*name*/ N_("Rim"),
94 /*struct_name*/ "RimShaderFxData",
95 /*struct_size*/ sizeof(RimShaderFxData),
97 /*flags*/ ShaderFxTypeFlag(0),
98
99 /*copy_data*/ copy_data,
100
101 /*init_data*/ init_data,
102 /*free_data*/ nullptr,
103 /*is_disabled*/ nullptr,
104 /*update_depsgraph*/ nullptr,
105 /*depends_on_time*/ nullptr,
106 /*foreach_ID_link*/ nullptr,
107 /*panel_register*/ panel_register,
108};
@ eShaderFxType_GpencilType
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
ShaderFxTypeFlag
#define ARRAY_SET_ITEMS(...)
#define IFACE_(msgid)
struct RimShaderFxData RimShaderFxData
@ eShaderFxRimMode_Overlay
@ eShaderFxType_Rim
static void panel_register(ARegionType *region_type)
ShaderFxTypeInfo shaderfx_Type_Rim
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)
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)
void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, const char *name, int icon, const char *placeholder=nullptr)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
#define UI_ITEM_NONE
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
uint col
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
struct uiLayout * layout
#define N_(msgid)
PointerRNA * ptr
Definition wm_files.cc:4126