Blender  V3.3
FX_shader_colorize.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 "BKE_context.h"
11 #include "BKE_screen.h"
12 
13 #include "BLI_utildefines.h"
14 
15 #include "BLT_translation.h"
16 
17 #include "DNA_screen_types.h"
18 #include "DNA_shader_fx_types.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 {
31  ARRAY_SET_ITEMS(gpfx->low_color, 0.0f, 0.0f, 0.0f, 1.0f);
32  ARRAY_SET_ITEMS(gpfx->high_color, 1.0f, 1.0f, 1.0f, 1.0f);
34  gpfx->factor = 0.5f;
35 }
36 
37 static void copyData(const ShaderFxData *md, ShaderFxData *target)
38 {
40 }
41 
42 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
43 {
44  uiLayout *layout = panel->layout;
45 
47 
48  int mode = RNA_enum_get(ptr, "mode");
49 
50  uiLayoutSetPropSep(layout, true);
51 
52  uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
53 
55  const char *text = (mode == eShaderFxColorizeMode_Duotone) ? IFACE_("Low Color") :
56  IFACE_("Color");
57  uiItemR(layout, ptr, "low_color", 0, text, ICON_NONE);
58  }
59  if (mode == eShaderFxColorizeMode_Duotone) {
60  uiItemR(layout, ptr, "high_color", 0, NULL, ICON_NONE);
61  }
62 
63  uiItemR(layout, ptr, "factor", 0, NULL, ICON_NONE);
64 
65  shaderfx_panel_end(layout, ptr);
66 }
67 
68 static void panelRegister(ARegionType *region_type)
69 {
71 }
72 
74  /* name */ N_("Colorize"),
75  /* structName */ "ColorizeShaderFxData",
76  /* structSize */ sizeof(ColorizeShaderFxData),
77  /* type */ eShaderFxType_GpencilType,
78  /* flags */ 0,
79 
80  /* copyData */ copyData,
81 
82  /* initData */ initData,
83  /* freeData */ NULL,
84  /* isDisabled */ NULL,
85  /* updateDepsgraph */ NULL,
86  /* dependsOnTime */ NULL,
87  /* foreachIDLink */ NULL,
88  /* panelRegister */ panelRegister,
89 };
@ 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 ELEM(...)
#define IFACE_(msgid)
@ eShaderFxColorizeMode_Custom
@ eShaderFxColorizeMode_GrayScale
@ eShaderFxColorizeMode_Duotone
struct ColorizeShaderFxData ColorizeShaderFxData
@ eShaderFxType_Colorize
ShaderFxTypeInfo shaderfx_Type_Colorize
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:223
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
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
struct uiLayout * layout
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480