Blender  V2.93
FX_shader_blur.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) 2017, Blender Foundation
17  * This is a new part of Blender
18  */
19 
24 #include <stdio.h>
25 
26 #include "BLI_math.h"
27 #include "BLI_utildefines.h"
28 
29 #include "BLT_translation.h"
30 
31 #include "BKE_context.h"
32 #include "BKE_screen.h"
33 
34 #include "DNA_screen_types.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  BlurShaderFxData *gpfx = (BlurShaderFxData *)fx;
47  copy_v2_fl(gpfx->radius, 50.0f);
48  gpfx->samples = 8;
49  gpfx->rotation = 0.0f;
50 }
51 
52 static void copyData(const ShaderFxData *md, ShaderFxData *target)
53 {
55 }
56 
57 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
58 {
59  uiLayout *col;
60  uiLayout *layout = panel->layout;
61 
63 
64  uiLayoutSetPropSep(layout, true);
65 
66  uiItemR(layout, ptr, "samples", 0, NULL, ICON_NONE);
67 
68  uiItemR(layout, ptr, "use_dof_mode", 0, IFACE_("Use Depth of Field"), ICON_NONE);
69  col = uiLayoutColumn(layout, false);
70  uiLayoutSetActive(col, !RNA_boolean_get(ptr, "use_dof_mode"));
71  uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
72  uiItemR(col, ptr, "rotation", 0, NULL, ICON_NONE);
73 
74  shaderfx_panel_end(layout, ptr);
75 }
76 
77 static void panelRegister(ARegionType *region_type)
78 {
80 }
81 
83  /* name */ "Blur",
84  /* structName */ "BlurShaderFxData",
85  /* structSize */ sizeof(BlurShaderFxData),
86  /* type */ eShaderFxType_GpencilType,
87  /* flags */ 0,
88 
89  /* copyData */ copyData,
90 
91  /* initData */ initData,
92  /* freeData */ NULL,
93  /* isDisabled */ NULL,
94  /* updateDepsgraph */ NULL,
95  /* dependsOnTime */ NULL,
96  /* foreachIDLink */ NULL,
97  /* panelRegister */ panelRegister,
98 };
@ eShaderFxType_GpencilType
Definition: BKE_shader_fx.h:49
void BKE_shaderfx_copydata_generic(const struct ShaderFxData *fx_src, struct ShaderFxData *fx_dst)
MINLINE void copy_v2_fl(float r[2], float f)
#define UNUSED(x)
#define IFACE_(msgid)
struct BlurShaderFxData BlurShaderFxData
@ eShaderFxType_Blur
ShaderFxTypeInfo shaderfx_Type_Blur
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
static void panelRegister(ARegionType *region_type)
static void copyData(const ShaderFxData *md, ShaderFxData *target)
static void initData(ShaderFxData *fx)
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
Definition: FX_ui_common.c:242
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
void uiLayoutSetActive(uiLayout *layout, bool active)
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)
uint col
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
struct uiLayout * layout
PointerRNA * ptr
Definition: wm_files.c:3157