Blender  V2.93
FX_shader_colorize.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 "BKE_context.h"
27 #include "BKE_screen.h"
28 
29 #include "BLI_utildefines.h"
30 
31 #include "BLT_translation.h"
32 
33 #include "DNA_screen_types.h"
34 #include "DNA_shader_fx_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 {
47  ARRAY_SET_ITEMS(gpfx->low_color, 0.0f, 0.0f, 0.0f, 1.0f);
48  ARRAY_SET_ITEMS(gpfx->high_color, 1.0f, 1.0f, 1.0f, 1.0f);
50  gpfx->factor = 0.5f;
51 }
52 
53 static void copyData(const ShaderFxData *md, ShaderFxData *target)
54 {
56 }
57 
58 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
59 {
60  uiLayout *layout = panel->layout;
61 
63 
64  int mode = RNA_enum_get(ptr, "mode");
65 
66  uiLayoutSetPropSep(layout, true);
67 
68  uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
69 
71  const char *text = (mode == eShaderFxColorizeMode_Duotone) ? IFACE_("Low Color") :
72  IFACE_("Color");
73  uiItemR(layout, ptr, "low_color", 0, text, ICON_NONE);
74  }
75  if (mode == eShaderFxColorizeMode_Duotone) {
76  uiItemR(layout, ptr, "high_color", 0, NULL, ICON_NONE);
77  }
78 
79  uiItemR(layout, ptr, "factor", 0, NULL, ICON_NONE);
80 
81  shaderfx_panel_end(layout, ptr);
82 }
83 
84 static void panelRegister(ARegionType *region_type)
85 {
87 }
88 
90  /* name */ "Colorize",
91  /* structName */ "ColorizeShaderFxData",
92  /* structSize */ sizeof(ColorizeShaderFxData),
93  /* type */ eShaderFxType_GpencilType,
94  /* flags */ 0,
95 
96  /* copyData */ copyData,
97 
98  /* initData */ initData,
99  /* freeData */ NULL,
100  /* isDisabled */ NULL,
101  /* updateDepsgraph */ NULL,
102  /* dependsOnTime */ NULL,
103  /* foreachIDLink */ NULL,
104  /* panelRegister */ panelRegister,
105 };
@ 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 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: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 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:6402
struct uiLayout * layout
PointerRNA * ptr
Definition: wm_files.c:3157