Blender V5.3
FX_shader_glow.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2018 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "DNA_screen_types.h"
10
11#include "BLI_math_vector_c.hh"
12#include "BLI_utildefines.hh"
13
14#include "BLT_translation.hh"
15
16#include "BKE_context.hh"
17#include "BKE_idtype.hh"
18#include "BKE_modifier.hh"
19#include "BKE_screen.hh"
20#include "BKE_shader_fx.hh"
21
23#include "UI_resources.hh"
24
25#include "RNA_access.hh"
26
27#include "FX_shader_types.hh"
28#include "FX_ui_common.hh"
29
30namespace blender {
31
32static void init_data(ShaderFxData *md)
33{
34 GlowShaderFxData *gpfx = reinterpret_cast<GlowShaderFxData *>(md);
35 ARRAY_SET_ITEMS(gpfx->glow_color, 0.75f, 1.0f, 1.0f, 1.0f);
36 ARRAY_SET_ITEMS(gpfx->select_color, 0.0f, 0.0f, 0.0f);
37 copy_v2_fl(gpfx->blur, 50.0f);
38 gpfx->threshold = 0.1f;
39 gpfx->samples = 8;
40}
41
42static void copy_data(const ShaderFxData *md, ShaderFxData *target)
43{
45}
46
47static void panel_draw(const bContext * /*C*/, Panel *panel)
48{
49 ui::Layout &layout = *panel->layout;
50
52
53 int mode = RNA_enum_get(ptr, "mode");
54
55 layout.use_property_split_set(true);
56
57 layout.prop(ptr, "mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
58
59 layout.prop(ptr, "threshold", UI_ITEM_NONE, std::nullopt, ICON_NONE);
60 if (mode == eShaderFxGlowMode_Color) {
61 layout.prop(ptr, "select_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
62 }
63
64 layout.prop(ptr, "glow_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
65
66 layout.separator();
67
68 layout.prop(ptr, "blend_mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
69 layout.prop(ptr, "opacity", UI_ITEM_NONE, std::nullopt, ICON_NONE);
70 layout.prop(ptr, "size", UI_ITEM_NONE, std::nullopt, ICON_NONE);
71 layout.prop(ptr, "rotation", UI_ITEM_NONE, std::nullopt, ICON_NONE);
72 layout.prop(ptr, "samples", UI_ITEM_NONE, std::nullopt, ICON_NONE);
73 layout.prop(ptr, "use_glow_under", UI_ITEM_NONE, std::nullopt, ICON_NONE);
74
75 shaderfx_panel_end(layout, ptr);
76}
77
78static void panel_register(ARegionType *region_type)
79{
81}
82
85{
86 GlowShaderFxData *gpfx = reinterpret_cast<GlowShaderFxData *>(fx);
87 fn.single(gpfx->glow_color);
88 fn.single(gpfx->select_color);
89}
90
92 /*name*/ N_("Glow"),
93 /*struct_name*/ "GlowShaderFxData",
94 /*struct_size*/ sizeof(GlowShaderFxData),
96 /*flags*/ ShaderFxTypeFlag(0),
97
98 /*copy_data*/ copy_data,
99
100 /*init_data*/ init_data,
101 /*free_data*/ nullptr,
102 /*is_disabled*/ nullptr,
103 /*update_depsgraph*/ nullptr,
104 /*depends_on_time*/ nullptr,
105 /*foreach_ID_link*/ nullptr,
106 /*foreach_working_space_color*/ foreach_working_space_color,
107 /*panel_register*/ panel_register,
108};
109
110} // namespace blender
#define UI_ITEM_NONE
#define ARRAY_SET_ITEMS(...)
BMesh Iterators.
static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
ShaderFxTypeInfo shaderfx_Type_Glow
int RNA_enum_get(PointerRNA *ptr, const char *name)
MINLINE void copy_v2_fl(float r[2], float f)
PanelType * shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
static void foreach_working_space_color(ModifierData *md, const IDTypeForeachColorFunctionCallback &fn)
static void init_data(ModifierData *md)
static void panel_register(ARegionType *region_type)
@ eShaderFxType_GpencilType
void shaderfx_panel_end(ui::Layout &layout, PointerRNA *ptr)
PointerRNA * shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
static void panel_draw(const bContext *, Panel *panel)
void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst)
Definition shader_fx.cc:161
ui::Layout * layout
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
#define N_(msgid)