Blender  V2.93
FX_shader_rim.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2018, Blender Foundation
17  * This is a new part of Blender
18  */
19 
24 #include <stdio.h>
25 
26 #include "DNA_screen_types.h"
27 #include "DNA_shader_fx_types.h"
28 
29 #include "BLI_utildefines.h"
30 
31 #include "BLT_translation.h"
32 
33 #include "BKE_context.h"
34 #include "BKE_screen.h"
35 
36 #include "UI_interface.h"
37 #include "UI_resources.h"
38 
39 #include "RNA_access.h"
40 
41 #include "FX_shader_types.h"
42 #include "FX_ui_common.h"
43 
44 static void initData(ShaderFxData *fx)
45 {
46  RimShaderFxData *gpfx = (RimShaderFxData *)fx;
47  ARRAY_SET_ITEMS(gpfx->offset, 50, -100);
48  ARRAY_SET_ITEMS(gpfx->rim_rgb, 1.0f, 1.0f, 0.5f);
49  ARRAY_SET_ITEMS(gpfx->mask_rgb, 0.0f, 0.0f, 0.0f);
51 
52  ARRAY_SET_ITEMS(gpfx->blur, 0, 0);
53  gpfx->samples = 2;
54 }
55 
56 static void copyData(const ShaderFxData *md, ShaderFxData *target)
57 {
59 }
60 
61 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
62 {
63  uiLayout *col;
64  uiLayout *layout = panel->layout;
65 
67 
68  uiLayoutSetPropSep(layout, true);
69 
70  uiItemR(layout, ptr, "rim_color", 0, NULL, ICON_NONE);
71  uiItemR(layout, ptr, "mask_color", 0, NULL, ICON_NONE);
72  uiItemR(layout, ptr, "mode", 0, IFACE_("Blend Mode"), ICON_NONE);
73 
74  /* Add the X, Y labels manually because offset is a #PROP_PIXEL. */
75  col = uiLayoutColumn(layout, true);
76  PropertyRNA *prop = RNA_struct_find_property(ptr, "offset");
77  uiItemFullR(col, ptr, prop, 0, 0, 0, IFACE_("Offset X"), ICON_NONE);
78  uiItemFullR(col, ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
79 
80  shaderfx_panel_end(layout, ptr);
81 }
82 
83 static void blur_panel_draw(const bContext *UNUSED(C), Panel *panel)
84 {
85  uiLayout *col;
86  uiLayout *layout = panel->layout;
87 
89 
90  uiLayoutSetPropSep(layout, true);
91 
92  /* Add the X, Y labels manually because blur is a #PROP_PIXEL. */
93  col = uiLayoutColumn(layout, true);
94  PropertyRNA *prop = RNA_struct_find_property(ptr, "blur");
95  uiItemFullR(col, ptr, prop, 0, 0, 0, IFACE_("Blur X"), ICON_NONE);
96  uiItemFullR(col, ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
97 
98  uiItemR(layout, ptr, "samples", 0, NULL, ICON_NONE);
99 }
100 
101 static void panelRegister(ARegionType *region_type)
102 {
103  PanelType *panel_type = shaderfx_panel_register(region_type, eShaderFxType_Rim, panel_draw);
104  shaderfx_subpanel_register(region_type, "blur", "Blur", NULL, blur_panel_draw, panel_type);
105 }
106 
108  /* name */ "Rim",
109  /* structName */ "RimShaderFxData",
110  /* structSize */ sizeof(RimShaderFxData),
111  /* type */ eShaderFxType_GpencilType,
112  /* flags */ 0,
113 
114  /* copyData */ copyData,
115 
116  /* initData */ initData,
117  /* freeData */ NULL,
118  /* isDisabled */ NULL,
119  /* updateDepsgraph */ NULL,
120  /* dependsOnTime */ NULL,
121  /* foreachIDLink */ NULL,
122  /* panelRegister */ panelRegister,
123 };
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:49
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
static void blur_panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: FX_shader_rim.c:83
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: FX_shader_rim.c:61
static void panelRegister(ARegionType *region_type)
static void copyData(const ShaderFxData *md, ShaderFxData *target)
Definition: FX_shader_rim.c:56
static void initData(ShaderFxData *fx)
Definition: FX_shader_rim.c:44
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
Definition: FX_ui_common.c:242
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:273
void shaderfx_panel_end(uiLayout *layout, PointerRNA *ptr)
Definition: FX_ui_common.c:99
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
Definition: FX_ui_common.c:111
#define C
Definition: RandGen.cpp:39
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:866
struct uiLayout * layout
PointerRNA * ptr
Definition: wm_files.c:3157