Add Chromium-only Blender WebEngine parity work
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
/* SPDX-FileCopyrightText: 2017 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *fx)
|
||||
{
|
||||
BlurShaderFxData *gpfx = reinterpret_cast<BlurShaderFxData *>(fx);
|
||||
copy_v2_fl(gpfx->radius, 50.0f);
|
||||
gpfx->samples = 8;
|
||||
gpfx->rotation = 0.0f;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "samples", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
layout.prop(ptr, "use_dof_mode", UI_ITEM_NONE, IFACE_("Use Depth of Field"), ICON_NONE);
|
||||
ui::Layout &col = layout.column(false);
|
||||
col.active_set(!RNA_boolean_get(ptr, "use_dof_mode"));
|
||||
col.prop(ptr, "size", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
col.prop(ptr, "rotation", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
shaderfx_panel_register(region_type, eShaderFxType_Blur, panel_draw);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Blur = {
|
||||
/*name*/ N_("Blur"),
|
||||
/*struct_name*/ "BlurShaderFxData",
|
||||
/*struct_size*/ sizeof(BlurShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ nullptr,
|
||||
/*update_depsgraph*/ nullptr,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ nullptr,
|
||||
/*foreach_working_space_color*/ nullptr,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
@@ -0,0 +1,102 @@
|
||||
/* SPDX-FileCopyrightText: 2018 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_idtype.hh"
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_shader_fx_types.h"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *fx)
|
||||
{
|
||||
ColorizeShaderFxData *gpfx = reinterpret_cast<ColorizeShaderFxData *>(fx);
|
||||
ARRAY_SET_ITEMS(gpfx->low_color, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
ARRAY_SET_ITEMS(gpfx->high_color, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
gpfx->mode = eShaderFxColorizeMode_GrayScale;
|
||||
gpfx->factor = 0.5f;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
int mode = RNA_enum_get(ptr, "mode");
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
if (ELEM(mode, eShaderFxColorizeMode_Custom, eShaderFxColorizeMode_Duotone)) {
|
||||
const char *text = (mode == eShaderFxColorizeMode_Duotone) ? IFACE_("Low Color") :
|
||||
IFACE_("Color");
|
||||
layout.prop(ptr, "low_color", UI_ITEM_NONE, text, ICON_NONE);
|
||||
}
|
||||
if (mode == eShaderFxColorizeMode_Duotone) {
|
||||
layout.prop(ptr, "high_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
}
|
||||
|
||||
layout.prop(ptr, "factor", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
shaderfx_panel_register(region_type, eShaderFxType_Colorize, panel_draw);
|
||||
}
|
||||
|
||||
static void foreach_working_space_color(ShaderFxData *fx,
|
||||
const IDTypeForeachColorFunctionCallback &fn)
|
||||
{
|
||||
ColorizeShaderFxData *gpfx = reinterpret_cast<ColorizeShaderFxData *>(fx);
|
||||
fn.single(gpfx->low_color);
|
||||
fn.single(gpfx->high_color);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Colorize = {
|
||||
/*name*/ N_("Colorize"),
|
||||
/*struct_name*/ "ColorizeShaderFxData",
|
||||
/*struct_size*/ sizeof(ColorizeShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ nullptr,
|
||||
/*update_depsgraph*/ nullptr,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ nullptr,
|
||||
/*foreach_working_space_color*/ foreach_working_space_color,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
@@ -0,0 +1,77 @@
|
||||
/* SPDX-FileCopyrightText: 2017 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *fx)
|
||||
{
|
||||
FlipShaderFxData *gpfx = reinterpret_cast<FlipShaderFxData *>(fx);
|
||||
gpfx->flag |= FX_FLIP_HORIZONTAL;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
const ui::eUI_Item_Flag toggles_flag = ui::ITEM_R_TOGGLE | ui::ITEM_R_FORCE_BLANK_DECORATE;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
ui::Layout &row = layout.row(true, IFACE_("Axis"));
|
||||
row.prop(ptr, "use_flip_x", toggles_flag, std::nullopt, ICON_NONE);
|
||||
row.prop(ptr, "use_flip_y", toggles_flag, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
shaderfx_panel_register(region_type, eShaderFxType_Flip, panel_draw);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Flip = {
|
||||
/*name*/ N_("Flip"),
|
||||
/*struct_name*/ "FlipShaderFxData",
|
||||
/*struct_size*/ sizeof(FlipShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ nullptr,
|
||||
/*update_depsgraph*/ nullptr,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ nullptr,
|
||||
/*foreach_working_space_color*/ nullptr,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
110
blender-5.2.0/source/blender/shader_fx/intern/FX_shader_glow.cc
Normal file
110
blender-5.2.0/source/blender/shader_fx/intern/FX_shader_glow.cc
Normal file
@@ -0,0 +1,110 @@
|
||||
/* SPDX-FileCopyrightText: 2018 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_idtype.hh"
|
||||
#include "BKE_modifier.hh"
|
||||
#include "BKE_screen.hh"
|
||||
#include "BKE_shader_fx.hh"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *md)
|
||||
{
|
||||
GlowShaderFxData *gpfx = reinterpret_cast<GlowShaderFxData *>(md);
|
||||
ARRAY_SET_ITEMS(gpfx->glow_color, 0.75f, 1.0f, 1.0f, 1.0f);
|
||||
ARRAY_SET_ITEMS(gpfx->select_color, 0.0f, 0.0f, 0.0f);
|
||||
copy_v2_fl(gpfx->blur, 50.0f);
|
||||
gpfx->threshold = 0.1f;
|
||||
gpfx->samples = 8;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
int mode = RNA_enum_get(ptr, "mode");
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
layout.prop(ptr, "threshold", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
if (mode == eShaderFxGlowMode_Color) {
|
||||
layout.prop(ptr, "select_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
}
|
||||
|
||||
layout.prop(ptr, "glow_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
layout.separator();
|
||||
|
||||
layout.prop(ptr, "blend_mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "opacity", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "size", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "rotation", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "samples", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "use_glow_under", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
shaderfx_panel_register(region_type, eShaderFxType_Glow, panel_draw);
|
||||
}
|
||||
|
||||
static void foreach_working_space_color(ShaderFxData *fx,
|
||||
const IDTypeForeachColorFunctionCallback &fn)
|
||||
{
|
||||
GlowShaderFxData *gpfx = reinterpret_cast<GlowShaderFxData *>(fx);
|
||||
fn.single(gpfx->glow_color);
|
||||
fn.single(gpfx->select_color);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Glow = {
|
||||
/*name*/ N_("Glow"),
|
||||
/*struct_name*/ "GlowShaderFxData",
|
||||
/*struct_size*/ sizeof(GlowShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ nullptr,
|
||||
/*update_depsgraph*/ nullptr,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ nullptr,
|
||||
/*foreach_working_space_color*/ foreach_working_space_color,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
@@ -0,0 +1,78 @@
|
||||
/* SPDX-FileCopyrightText: 2017 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *fx)
|
||||
{
|
||||
PixelShaderFxData *gpfx = reinterpret_cast<PixelShaderFxData *>(fx);
|
||||
ARRAY_SET_ITEMS(gpfx->size, 5, 5);
|
||||
ARRAY_SET_ITEMS(gpfx->rgba, 0.0f, 0.0f, 0.0f, 0.9f);
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "size", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "use_antialiasing", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
shaderfx_panel_register(region_type, eShaderFxType_Pixel, panel_draw);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Pixel = {
|
||||
/*name*/ N_("Pixelate"),
|
||||
/*struct_name*/ "PixelShaderFxData",
|
||||
/*struct_size*/ sizeof(PixelShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ nullptr,
|
||||
/*update_depsgraph*/ nullptr,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ nullptr,
|
||||
/*foreach_working_space_color*/ nullptr,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
108
blender-5.2.0/source/blender/shader_fx/intern/FX_shader_rim.cc
Normal file
108
blender-5.2.0/source/blender/shader_fx/intern/FX_shader_rim.cc
Normal file
@@ -0,0 +1,108 @@
|
||||
/* SPDX-FileCopyrightText: 2018 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_shader_fx_types.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_idtype.hh"
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *fx)
|
||||
{
|
||||
RimShaderFxData *gpfx = reinterpret_cast<RimShaderFxData *>(fx);
|
||||
ARRAY_SET_ITEMS(gpfx->offset, 50, -100);
|
||||
ARRAY_SET_ITEMS(gpfx->rim_rgb, 1.0f, 1.0f, 0.5f);
|
||||
ARRAY_SET_ITEMS(gpfx->mask_rgb, 0.0f, 0.0f, 0.0f);
|
||||
gpfx->mode = eShaderFxRimMode_Overlay;
|
||||
|
||||
ARRAY_SET_ITEMS(gpfx->blur, 0, 0);
|
||||
gpfx->samples = 2;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "rim_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "mask_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "mode", UI_ITEM_NONE, IFACE_("Blend Mode"), ICON_NONE);
|
||||
layout.prop(ptr, "offset", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void blur_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "blur", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "samples", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = shaderfx_panel_register(region_type, eShaderFxType_Rim, panel_draw);
|
||||
shaderfx_subpanel_register(region_type, "blur", "Blur", nullptr, blur_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
static void foreach_working_space_color(ShaderFxData *fx,
|
||||
const IDTypeForeachColorFunctionCallback &fn)
|
||||
{
|
||||
RimShaderFxData *gpfx = reinterpret_cast<RimShaderFxData *>(fx);
|
||||
fn.single(gpfx->rim_rgb);
|
||||
fn.single(gpfx->mask_rgb);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Rim = {
|
||||
/*name*/ N_("Rim"),
|
||||
/*struct_name*/ "RimShaderFxData",
|
||||
/*struct_size*/ sizeof(RimShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ nullptr,
|
||||
/*update_depsgraph*/ nullptr,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ nullptr,
|
||||
/*foreach_working_space_color*/ foreach_working_space_color,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
@@ -0,0 +1,172 @@
|
||||
/* SPDX-FileCopyrightText: 2018 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_idtype.hh"
|
||||
#include "BKE_lib_query.hh"
|
||||
#include "BKE_modifier.hh"
|
||||
#include "BKE_screen.hh"
|
||||
#include "BKE_shader_fx.hh"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
#include "DEG_depsgraph_build.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *md)
|
||||
{
|
||||
ShadowShaderFxData *gpfx = reinterpret_cast<ShadowShaderFxData *>(md);
|
||||
gpfx->rotation = 0.0f;
|
||||
ARRAY_SET_ITEMS(gpfx->offset, 15, 20);
|
||||
ARRAY_SET_ITEMS(gpfx->scale, 1.0f, 1.0f);
|
||||
ARRAY_SET_ITEMS(gpfx->shadow_rgba, 0.0f, 0.0f, 0.0f, 0.8f);
|
||||
|
||||
gpfx->amplitude = 10.0f;
|
||||
gpfx->period = 20.0f;
|
||||
gpfx->phase = 0.0f;
|
||||
gpfx->orientation = 1;
|
||||
|
||||
ARRAY_SET_ITEMS(gpfx->blur, 5, 5);
|
||||
gpfx->samples = 2;
|
||||
|
||||
gpfx->object = nullptr;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void update_depsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphContext *ctx)
|
||||
{
|
||||
ShadowShaderFxData *fxd = reinterpret_cast<ShadowShaderFxData *>(fx);
|
||||
if (fxd->object != nullptr) {
|
||||
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Shadow ShaderFx");
|
||||
}
|
||||
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Shadow ShaderFx");
|
||||
}
|
||||
|
||||
static bool is_disabled(ShaderFxData *fx, bool /*use_render_params*/)
|
||||
{
|
||||
ShadowShaderFxData *fxd = reinterpret_cast<ShadowShaderFxData *>(fx);
|
||||
|
||||
return (!fxd->object) && (fxd->flag & FX_SHADOW_USE_OBJECT);
|
||||
}
|
||||
|
||||
static void foreach_ID_link(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *user_data)
|
||||
{
|
||||
ShadowShaderFxData *fxd = reinterpret_cast<ShadowShaderFxData *>(fx);
|
||||
|
||||
walk(user_data, ob, reinterpret_cast<ID **>(&fxd->object), IDWALK_CB_NOP);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "shadow_color", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "offset", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "scale", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "rotation", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
ui::Layout &row = layout.row(true, IFACE_("Object Pivot"));
|
||||
row.prop(ptr, "use_object", UI_ITEM_NONE, "", ICON_NONE);
|
||||
row.prop(ptr, "object", UI_ITEM_NONE, "", ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void blur_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "blur", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "samples", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
}
|
||||
|
||||
static void wave_header_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.prop(ptr, "use_wave", UI_ITEM_NONE, IFACE_("Wave Effect"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void wave_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.active_set(RNA_boolean_get(ptr, "use_wave"));
|
||||
|
||||
layout.prop(ptr, "orientation", ui::ITEM_R_EXPAND, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "amplitude", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "period", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "phase", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = shaderfx_panel_register(region_type, eShaderFxType_Shadow, panel_draw);
|
||||
shaderfx_subpanel_register(region_type, "blur", "Blur", nullptr, blur_panel_draw, panel_type);
|
||||
shaderfx_subpanel_register(
|
||||
region_type, "wave", "", wave_header_draw, wave_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
static void foreach_working_space_color(ShaderFxData *fx,
|
||||
const IDTypeForeachColorFunctionCallback &fn)
|
||||
{
|
||||
ShadowShaderFxData *fxd = reinterpret_cast<ShadowShaderFxData *>(fx);
|
||||
fn.single(fxd->shadow_rgba);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Shadow = {
|
||||
/*name*/ N_("Shadow"),
|
||||
/*struct_name*/ "ShadowShaderFxData",
|
||||
/*struct_size*/ sizeof(ShadowShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ is_disabled,
|
||||
/*update_depsgraph*/ update_depsgraph,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ foreach_ID_link,
|
||||
/*foreach_working_space_color*/ foreach_working_space_color,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
107
blender-5.2.0/source/blender/shader_fx/intern/FX_shader_swirl.cc
Normal file
107
blender-5.2.0/source/blender/shader_fx/intern/FX_shader_swirl.cc
Normal file
@@ -0,0 +1,107 @@
|
||||
/* SPDX-FileCopyrightText: 2018 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_lib_query.hh"
|
||||
#include "BKE_modifier.hh"
|
||||
#include "BKE_screen.hh"
|
||||
#include "BKE_shader_fx.hh"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
#include "DEG_depsgraph_build.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *md)
|
||||
{
|
||||
SwirlShaderFxData *gpmd = reinterpret_cast<SwirlShaderFxData *>(md);
|
||||
gpmd->radius = 100;
|
||||
gpmd->angle = M_PI_2;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void update_depsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphContext *ctx)
|
||||
{
|
||||
SwirlShaderFxData *fxd = reinterpret_cast<SwirlShaderFxData *>(fx);
|
||||
if (fxd->object != nullptr) {
|
||||
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
|
||||
}
|
||||
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
|
||||
}
|
||||
|
||||
static bool is_disabled(ShaderFxData *fx, bool /*use_render_params*/)
|
||||
{
|
||||
SwirlShaderFxData *fxd = reinterpret_cast<SwirlShaderFxData *>(fx);
|
||||
|
||||
return !fxd->object;
|
||||
}
|
||||
|
||||
static void foreach_ID_link(ShaderFxData *fx, Object *ob, IDWalkFunc walk, void *user_data)
|
||||
{
|
||||
SwirlShaderFxData *fxd = reinterpret_cast<SwirlShaderFxData *>(fx);
|
||||
|
||||
walk(user_data, ob, reinterpret_cast<ID **>(&fxd->object), IDWALK_CB_NOP);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "object", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "radius", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "angle", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
shaderfx_panel_register(region_type, eShaderFxType_Swirl, panel_draw);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Swirl = {
|
||||
/*name*/ N_("Swirl"),
|
||||
/*struct_name*/ "SwirlShaderFxData",
|
||||
/*struct_size*/ sizeof(SwirlShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ is_disabled,
|
||||
/*update_depsgraph*/ update_depsgraph,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ foreach_ID_link,
|
||||
/*foreach_working_space_color*/ nullptr,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
@@ -0,0 +1,30 @@
|
||||
/* SPDX-FileCopyrightText: 2018 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "BKE_shader_fx.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
void shaderfx_type_init(ShaderFxTypeInfo *types[])
|
||||
{
|
||||
#define INIT_FX_TYPE(typeName) (types[eShaderFxType_##typeName] = &shaderfx_Type_##typeName)
|
||||
INIT_FX_TYPE(Blur);
|
||||
INIT_FX_TYPE(Colorize);
|
||||
INIT_FX_TYPE(Flip);
|
||||
INIT_FX_TYPE(Glow);
|
||||
INIT_FX_TYPE(Pixel);
|
||||
INIT_FX_TYPE(Rim);
|
||||
INIT_FX_TYPE(Shadow);
|
||||
INIT_FX_TYPE(Swirl);
|
||||
INIT_FX_TYPE(Wave);
|
||||
#undef INIT_FX_TYPE
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
@@ -0,0 +1,9 @@
|
||||
/* SPDX-FileCopyrightText: Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -0,0 +1,80 @@
|
||||
/* SPDX-FileCopyrightText: 2018 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup shader_fx
|
||||
*/
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "FX_shader_types.hh"
|
||||
#include "FX_ui_common.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static void init_data(ShaderFxData *fx)
|
||||
{
|
||||
WaveShaderFxData *gpfx = reinterpret_cast<WaveShaderFxData *>(fx);
|
||||
gpfx->amplitude = 10.0f;
|
||||
gpfx->period = 20.0f;
|
||||
gpfx->phase = 0.0f;
|
||||
gpfx->orientation = 1;
|
||||
}
|
||||
|
||||
static void copy_data(const ShaderFxData *md, ShaderFxData *target)
|
||||
{
|
||||
BKE_shaderfx_copydata_generic(md, target);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
layout.use_property_split_set(true);
|
||||
|
||||
layout.prop(ptr, "orientation", ui::ITEM_R_EXPAND, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "amplitude", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "period", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
layout.prop(ptr, "phase", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
||||
|
||||
shaderfx_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void panel_register(ARegionType *region_type)
|
||||
{
|
||||
shaderfx_panel_register(region_type, eShaderFxType_Wave, panel_draw);
|
||||
}
|
||||
|
||||
ShaderFxTypeInfo shaderfx_Type_Wave = {
|
||||
/*name*/ N_("WaveDistortion"),
|
||||
/*struct_name*/ "WaveShaderFxData",
|
||||
/*struct_size*/ sizeof(WaveShaderFxData),
|
||||
/*type*/ eShaderFxType_GpencilType,
|
||||
/*flags*/ ShaderFxTypeFlag(0),
|
||||
|
||||
/*copy_data*/ copy_data,
|
||||
|
||||
/*init_data*/ init_data,
|
||||
/*free_data*/ nullptr,
|
||||
/*is_disabled*/ nullptr,
|
||||
/*update_depsgraph*/ nullptr,
|
||||
/*depends_on_time*/ nullptr,
|
||||
/*foreach_ID_link*/ nullptr,
|
||||
/*foreach_working_space_color*/ nullptr,
|
||||
/*panel_register*/ panel_register,
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
269
blender-5.2.0/source/blender/shader_fx/intern/FX_ui_common.cc
Normal file
269
blender-5.2.0/source/blender/shader_fx/intern/FX_ui_common.cc
Normal file
@@ -0,0 +1,269 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string_utf8.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_library.hh"
|
||||
#include "BKE_screen.hh"
|
||||
#include "BKE_shader_fx.hh"
|
||||
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_shader_fx_types.h"
|
||||
|
||||
#include "ED_object.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "UI_interface.hh"
|
||||
#include "UI_interface_layout.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "FX_ui_common.hh" /* Self include */
|
||||
|
||||
namespace blender {
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Panel Drag and Drop, Expansion Saving
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* Move an effect to the index it's moved to after a drag and drop.
|
||||
*/
|
||||
static void shaderfx_reorder(bContext *C, Panel *panel, int new_index)
|
||||
{
|
||||
PointerRNA *fx_ptr = ui::panel_custom_data_get(panel);
|
||||
ShaderFxData *fx = static_cast<ShaderFxData *>(fx_ptr->data);
|
||||
|
||||
wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_shaderfx_move_to_index", false);
|
||||
PointerRNA props_ptr = WM_operator_properties_create_ptr(ot);
|
||||
RNA_string_set(&props_ptr, "shaderfx", fx->name);
|
||||
RNA_int_set(&props_ptr, "index", new_index);
|
||||
WM_operator_name_call_ptr(C, ot, wm::OpCallContext::InvokeDefault, &props_ptr, nullptr);
|
||||
WM_operator_properties_free(&props_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expand flag from the active effect to use for the panel.
|
||||
*/
|
||||
static short get_shaderfx_expand_flag(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
PointerRNA *fx_ptr = ui::panel_custom_data_get(panel);
|
||||
ShaderFxData *fx = static_cast<ShaderFxData *>(fx_ptr->data);
|
||||
return fx->ui_expand_flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the expand flag for the panel and sub-panels to the effect.
|
||||
*/
|
||||
static void set_shaderfx_expand_flag(const bContext * /*C*/, Panel *panel, short expand_flag)
|
||||
{
|
||||
PointerRNA *fx_ptr = ui::panel_custom_data_get(panel);
|
||||
ShaderFxData *fx = static_cast<ShaderFxData *>(fx_ptr->data);
|
||||
fx->ui_expand_flag = expand_flag;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name ShaderFx Panel Layouts
|
||||
* \{ */
|
||||
|
||||
void shaderfx_panel_end(ui::Layout &layout, PointerRNA *ptr)
|
||||
{
|
||||
ShaderFxData *fx = static_cast<ShaderFxData *>(ptr->data);
|
||||
if (fx->error) {
|
||||
ui::Layout &row = layout.row(false);
|
||||
row.label(RPT_(fx->error), ICON_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
PointerRNA *shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
|
||||
{
|
||||
PointerRNA *ptr = ui::panel_custom_data_get(panel);
|
||||
BLI_assert(RNA_struct_is_a(ptr->type, RNA_ShaderFx));
|
||||
|
||||
if (r_ob_ptr != nullptr) {
|
||||
*r_ob_ptr = RNA_pointer_create_discrete(ptr->owner_id, RNA_Object, ptr->owner_id);
|
||||
}
|
||||
|
||||
ui::panel_context_pointer_set(panel, "shaderfx", ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#define ERROR_LIBDATA_MESSAGE N_("External library data")
|
||||
|
||||
static void gpencil_shaderfx_ops_extra_draw(bContext *C, ui::Layout *layout, void *fx_v)
|
||||
{
|
||||
ShaderFxData *fx = static_cast<ShaderFxData *>(fx_v);
|
||||
|
||||
Object *ob = ed::object::context_active_object(C);
|
||||
PointerRNA ptr = RNA_pointer_create_discrete(&ob->id, RNA_ShaderFx, fx);
|
||||
layout->context_ptr_set("shaderfx", &ptr);
|
||||
layout->operator_context_set(wm::OpCallContext::InvokeDefault);
|
||||
|
||||
layout->ui_units_x_set(4.0f);
|
||||
|
||||
/* Duplicate. */
|
||||
layout->op("OBJECT_OT_shaderfx_copy",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Duplicate"),
|
||||
ICON_DUPLICATE);
|
||||
|
||||
layout->separator();
|
||||
|
||||
/* Move to first. */
|
||||
ui::Layout *col = &layout->column(false);
|
||||
PointerRNA op_ptr = col->op("OBJECT_OT_shaderfx_move_to_index",
|
||||
IFACE_("Move to First"),
|
||||
ICON_TRIA_UP,
|
||||
wm::OpCallContext::InvokeDefault,
|
||||
UI_ITEM_NONE);
|
||||
RNA_int_set(&op_ptr, "index", 0);
|
||||
if (!fx->prev) {
|
||||
col->enabled_set(false);
|
||||
}
|
||||
|
||||
/* Move to last. */
|
||||
col = &layout->column(false);
|
||||
op_ptr = col->op("OBJECT_OT_shaderfx_move_to_index",
|
||||
IFACE_("Move to Last"),
|
||||
ICON_TRIA_DOWN,
|
||||
wm::OpCallContext::InvokeDefault,
|
||||
UI_ITEM_NONE);
|
||||
RNA_int_set(&op_ptr, "index", ob->shader_fx.count() - 1);
|
||||
if (!fx->next) {
|
||||
col->enabled_set(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void shaderfx_panel_header(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
ui::Layout &layout = *panel->layout;
|
||||
bool narrow_panel = (panel->sizex < UI_UNIT_X * 7 && panel->sizex != 0);
|
||||
|
||||
PointerRNA *ptr = shaderfx_panel_get_property_pointers(panel, nullptr);
|
||||
Object *ob = id_cast<Object *>(ptr->owner_id);
|
||||
ShaderFxData *fx = static_cast<ShaderFxData *>(ptr->data);
|
||||
|
||||
const ShaderFxTypeInfo *fxti = BKE_shaderfx_get_info(ShaderFxType(fx->type));
|
||||
|
||||
block_lock_set(layout.block(), (ob && !ID_IS_EDITABLE(ob)), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
/* Effect type icon. */
|
||||
ui::Layout *row = &layout.row(false);
|
||||
if (fxti->is_disabled && fxti->is_disabled(fx, false)) {
|
||||
row->red_alert_set(true);
|
||||
}
|
||||
row->label("", RNA_struct_ui_icon(ptr->type));
|
||||
|
||||
/* Effect name. */
|
||||
row = &layout.row(true);
|
||||
if (!narrow_panel) {
|
||||
row->prop(ptr, "name", UI_ITEM_NONE, "", ICON_NONE);
|
||||
}
|
||||
|
||||
/* Mode enabling buttons. */
|
||||
if (fxti->flags & eShaderFxTypeFlag_SupportsEditmode) {
|
||||
ui::Layout &sub = row->row(true);
|
||||
sub.active_set(false);
|
||||
sub.prop(ptr, "show_in_editmode", UI_ITEM_NONE, "", ICON_NONE);
|
||||
}
|
||||
row->prop(ptr, "show_viewport", UI_ITEM_NONE, "", ICON_NONE);
|
||||
row->prop(ptr, "show_render", UI_ITEM_NONE, "", ICON_NONE);
|
||||
|
||||
/* Extra operators. */
|
||||
row->menu_fn("", ICON_DOWNARROW_HLT, gpencil_shaderfx_ops_extra_draw, fx);
|
||||
|
||||
ui::Layout &sub = row->row(false);
|
||||
sub.emboss_set(ui::EmbossType::None);
|
||||
sub.op("OBJECT_OT_shaderfx_remove", "", ICON_X);
|
||||
|
||||
/* Some padding so the X isn't too close to the drag icon. */
|
||||
layout.separator();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name ShaderFx Registration Helpers
|
||||
* \{ */
|
||||
|
||||
static bool shaderfx_ui_poll(const bContext *C, PanelType * /*pt*/)
|
||||
{
|
||||
Object *ob = ed::object::context_active_object(C);
|
||||
|
||||
return (ob != nullptr) && ob->type == OB_GREASE_PENCIL;
|
||||
}
|
||||
|
||||
PanelType *shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)
|
||||
{
|
||||
PanelType *panel_type = MEM_new_zeroed<PanelType>(__func__);
|
||||
|
||||
BKE_shaderfxType_panel_id(type, panel_type->idname);
|
||||
STRNCPY_UTF8(panel_type->label, "");
|
||||
STRNCPY_UTF8(panel_type->context, "shaderfx");
|
||||
STRNCPY_UTF8(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||
|
||||
panel_type->draw_header = shaderfx_panel_header;
|
||||
panel_type->draw = draw;
|
||||
panel_type->poll = shaderfx_ui_poll;
|
||||
|
||||
/* Give the panel the special flag that says it was built here and corresponds to a
|
||||
* shader effect rather than a PanelType. */
|
||||
panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_INSTANCED;
|
||||
panel_type->reorder = shaderfx_reorder;
|
||||
panel_type->get_list_data_expand_flag = get_shaderfx_expand_flag;
|
||||
panel_type->set_list_data_expand_flag = set_shaderfx_expand_flag;
|
||||
|
||||
BLI_addtail(®ion_type->paneltypes, panel_type);
|
||||
|
||||
return panel_type;
|
||||
}
|
||||
|
||||
PanelType *shaderfx_subpanel_register(ARegionType *region_type,
|
||||
const char *name,
|
||||
const char *label,
|
||||
PanelDrawFn draw_header,
|
||||
PanelDrawFn draw,
|
||||
PanelType *parent)
|
||||
{
|
||||
PanelType *panel_type = MEM_new_zeroed<PanelType>(__func__);
|
||||
|
||||
BLI_assert(parent != nullptr);
|
||||
SNPRINTF_UTF8(panel_type->idname, "%s_%s", parent->idname, name);
|
||||
STRNCPY_UTF8(panel_type->label, label);
|
||||
STRNCPY_UTF8(panel_type->context, "shaderfx");
|
||||
STRNCPY_UTF8(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||
|
||||
panel_type->draw_header = draw_header;
|
||||
panel_type->draw = draw;
|
||||
panel_type->poll = shaderfx_ui_poll;
|
||||
panel_type->flag = PANEL_TYPE_DEFAULT_CLOSED;
|
||||
|
||||
STRNCPY_UTF8(panel_type->parent_id, parent->idname);
|
||||
panel_type->parent = parent;
|
||||
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
|
||||
BLI_addtail(®ion_type->paneltypes, panel_type);
|
||||
|
||||
return panel_type;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender
|
||||
@@ -0,0 +1,55 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FX_shader_types.hh" // IWYU pragma: export
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct PointerRNA;
|
||||
struct Panel;
|
||||
struct ARegionType;
|
||||
struct PanelType;
|
||||
struct bContext;
|
||||
|
||||
namespace ui {
|
||||
struct Layout;
|
||||
} // namespace ui
|
||||
|
||||
using PanelDrawFn = void (*)(const bContext *, Panel *);
|
||||
|
||||
/**
|
||||
* Draw shaderfx error message.
|
||||
*/
|
||||
void shaderfx_panel_end(ui::Layout &layout, PointerRNA *ptr);
|
||||
|
||||
/**
|
||||
* Gets RNA pointers for the active object and the panel's shaderfx data.
|
||||
*/
|
||||
PointerRNA *shaderfx_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr);
|
||||
|
||||
/**
|
||||
* Create a panel in the context's region
|
||||
*/
|
||||
PanelType *shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw);
|
||||
|
||||
/**
|
||||
* Add a child panel to the parent.
|
||||
*
|
||||
* \note To create the panel type's idname, it appends the \a name argument to the \a parent's
|
||||
* idname.
|
||||
*/
|
||||
PanelType *shaderfx_subpanel_register(ARegionType *region_type,
|
||||
const char *name,
|
||||
const char *label,
|
||||
PanelDrawFn draw_header,
|
||||
PanelDrawFn draw,
|
||||
PanelType *parent);
|
||||
|
||||
} // namespace blender
|
||||
Reference in New Issue
Block a user