Blender  V3.3
FX_shader_rim.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2018 Blender Foundation. */
3 
8 #include <stdio.h>
9 
10 #include "DNA_screen_types.h"
11 #include "DNA_shader_fx_types.h"
12 
13 #include "BLI_utildefines.h"
14 
15 #include "BLT_translation.h"
16 
17 #include "BKE_context.h"
18 #include "BKE_screen.h"
19 
20 #include "UI_interface.h"
21 #include "UI_resources.h"
22 
23 #include "RNA_access.h"
24 
25 #include "FX_shader_types.h"
26 #include "FX_ui_common.h"
27 
28 static void initData(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 
40 static void copyData(const ShaderFxData *md, ShaderFxData *target)
41 {
43 }
44 
45 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
46 {
47  uiLayout *col;
48  uiLayout *layout = panel->layout;
49 
51 
52  uiLayoutSetPropSep(layout, true);
53 
54  uiItemR(layout, ptr, "rim_color", 0, NULL, ICON_NONE);
55  uiItemR(layout, ptr, "mask_color", 0, NULL, ICON_NONE);
56  uiItemR(layout, ptr, "mode", 0, IFACE_("Blend Mode"), ICON_NONE);
57 
58  /* Add the X, Y labels manually because offset is a #PROP_PIXEL. */
59  col = uiLayoutColumn(layout, true);
60  PropertyRNA *prop = RNA_struct_find_property(ptr, "offset");
61  uiItemFullR(col, ptr, prop, 0, 0, 0, IFACE_("Offset X"), ICON_NONE);
62  uiItemFullR(col, ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
63 
64  shaderfx_panel_end(layout, ptr);
65 }
66 
67 static void blur_panel_draw(const bContext *UNUSED(C), Panel *panel)
68 {
69  uiLayout *col;
70  uiLayout *layout = panel->layout;
71 
73 
74  uiLayoutSetPropSep(layout, true);
75 
76  /* Add the X, Y labels manually because blur is a #PROP_PIXEL. */
77  col = uiLayoutColumn(layout, true);
78  PropertyRNA *prop = RNA_struct_find_property(ptr, "blur");
79  uiItemFullR(col, ptr, prop, 0, 0, 0, IFACE_("Blur X"), ICON_NONE);
80  uiItemFullR(col, ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
81 
82  uiItemR(layout, ptr, "samples", 0, NULL, ICON_NONE);
83 }
84 
85 static void panelRegister(ARegionType *region_type)
86 {
88  shaderfx_subpanel_register(region_type, "blur", "Blur", NULL, blur_panel_draw, panel_type);
89 }
90 
92  /* name */ N_("Rim"),
93  /* structName */ "RimShaderFxData",
94  /* structSize */ sizeof(RimShaderFxData),
95  /* type */ eShaderFxType_GpencilType,
96  /* flags */ 0,
97 
98  /* copyData */ copyData,
99 
100  /* initData */ initData,
101  /* freeData */ NULL,
102  /* isDisabled */ NULL,
103  /* updateDepsgraph */ NULL,
104  /* dependsOnTime */ NULL,
105  /* foreachIDLink */ NULL,
106  /* panelRegister */ panelRegister,
107 };
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:35
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
#define ARRAY_SET_ITEMS(...)
#define UNUSED(x)
#define IFACE_(msgid)
struct RimShaderFxData RimShaderFxData
@ eShaderFxRimMode_Overlay
@ eShaderFxType_Rim
ShaderFxTypeInfo shaderfx_Type_Rim
Definition: FX_shader_rim.c:91
static void blur_panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: FX_shader_rim.c:67
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: FX_shader_rim.c:45
static void panelRegister(ARegionType *region_type)
Definition: FX_shader_rim.c:85
static void copyData(const ShaderFxData *md, ShaderFxData *target)
Definition: FX_shader_rim.c:40
static void initData(ShaderFxData *fx)
Definition: FX_shader_rim.c:28
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
Definition: FX_ui_common.c:223
PanelType * shaderfx_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
Definition: FX_ui_common.c:248
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
Definition: FX_ui_common.c:84
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
Definition: FX_ui_common.c:93
#define C
Definition: RandGen.cpp:25
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiItemFullR(uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, const char *name, int icon)
uint col
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
struct uiLayout * layout
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480