UI: Grease Pencil Modifier Drag and Drop, Layout Changes
This patch implements the list panel system D7490 for grease pencil
modifiers. It also moves their drawing to a callback in
GpencilModifierTypeInfo in line with the extensible architecture
refactoring goal T75724.
This also adds the "set_error" function for grease pencil modifiers,
which hadn't been copied from mesh modifiers yet.
The implementation is basically exactly the same as for the modifier
patch (9b099c8612).
Thanks to Matias Mendiola (mendio) for providing mockups for many
of the layout changes.
Differential Revision: https://developer.blender.org/D7978
This commit is contained in:
@@ -46,13 +46,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
||||
class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
|
||||
bl_label = "Modifiers"
|
||||
|
||||
def check_conflicts(self, layout, ob):
|
||||
for md in ob.grease_pencil_modifiers:
|
||||
if md.type == 'GP_TIME':
|
||||
row = layout.row()
|
||||
row.label(text="Build and Time Offset modifier not compatible", icon='ERROR')
|
||||
break
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
ob = context.object
|
||||
@@ -60,483 +53,8 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
ob = context.object
|
||||
|
||||
layout.operator_menu_enum("object.gpencil_modifier_add", "type")
|
||||
|
||||
for md in ob.grease_pencil_modifiers:
|
||||
box = layout.template_greasepencil_modifier(md)
|
||||
if box:
|
||||
# match enum type to our functions, avoids a lookup table.
|
||||
getattr(self, md.type)(box, ob, md)
|
||||
|
||||
# the mt.type enum is (ab)used for a lookup on function names
|
||||
# ...to avoid lengthy if statements
|
||||
# so each type must have a function here.
|
||||
|
||||
def gpencil_masking(self, layout, ob, md, use_vertex, use_curve=False):
|
||||
gpd = ob.data
|
||||
layout.separator()
|
||||
layout.label(text="Influence Filters:")
|
||||
|
||||
split = layout.split(factor=0.25)
|
||||
|
||||
col1 = split.column()
|
||||
|
||||
col1.label(text="Layer:")
|
||||
col1.label(text="Material:")
|
||||
if use_vertex:
|
||||
col1.label(text="Vertex Group:")
|
||||
|
||||
col2 = split.column()
|
||||
|
||||
split = col2.split(factor=0.6)
|
||||
row = split.row(align=True)
|
||||
row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
|
||||
row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
row = split.row(align=True)
|
||||
row.prop(md, "layer_pass", text="Pass")
|
||||
row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
split = col2.split(factor=0.6)
|
||||
|
||||
row = split.row(align=True)
|
||||
|
||||
valid = md.material in (slot.material for slot in ob.material_slots) or md.material is None
|
||||
if valid:
|
||||
icon = 'SHADING_TEXTURE'
|
||||
else:
|
||||
icon = 'ERROR'
|
||||
|
||||
row.alert = not valid
|
||||
row.prop_search(md, "material", gpd, "materials", text="", icon=icon)
|
||||
row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
row = split.row(align=True)
|
||||
row.prop(md, "pass_index", text="Pass")
|
||||
row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
if use_vertex:
|
||||
row = col2.row(align=True)
|
||||
row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
|
||||
row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
if use_curve:
|
||||
col = layout.column()
|
||||
col.separator()
|
||||
col.prop(md, "use_custom_curve")
|
||||
if md.use_custom_curve:
|
||||
col.template_curve_mapping(md, "curve")
|
||||
|
||||
def GP_NOISE(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "factor", text="Position")
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "factor_strength", text="Strength")
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "factor_thickness", text="Thickness")
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "factor_uvs", text="UV")
|
||||
|
||||
col.separator()
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "random", text="", icon='TIME', toggle=True)
|
||||
|
||||
subrow = row.row(align=True)
|
||||
subrow.enabled = md.random
|
||||
subrow.prop(md, "step")
|
||||
subrow.prop(md, "seed")
|
||||
|
||||
col.separator()
|
||||
col.prop(md, "noise_scale")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True, True)
|
||||
|
||||
def GP_SMOOTH(self, layout, ob, md):
|
||||
col = layout.column()
|
||||
col.prop(md, "factor")
|
||||
col.prop(md, "step", text="Repeat")
|
||||
|
||||
col.label(text="Affect:")
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "use_edit_position", text="Position", toggle=True)
|
||||
row.prop(md, "use_edit_strength", text="Strength", toggle=True)
|
||||
row.prop(md, "use_edit_thickness", text="Thickness", toggle=True)
|
||||
row.prop(md, "use_edit_uv", text="UV", toggle=True)
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True, True)
|
||||
|
||||
def GP_SUBDIV(self, layout, ob, md):
|
||||
layout.row().prop(md, "subdivision_type", expand=True)
|
||||
split = layout.split()
|
||||
col = split.column()
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "level", text="Subdivisions")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, False)
|
||||
|
||||
def GP_SIMPLIFY(self, layout, ob, md):
|
||||
gpd = ob.data
|
||||
|
||||
row = layout.row()
|
||||
row.prop(md, "mode")
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Settings:")
|
||||
|
||||
if md.mode == 'FIXED':
|
||||
col.prop(md, "step")
|
||||
elif md.mode == 'ADAPTIVE':
|
||||
col.prop(md, "factor")
|
||||
elif md.mode == 'SAMPLE':
|
||||
col.prop(md, "length")
|
||||
elif md.mode == 'MERGE':
|
||||
col.prop(md, "distance")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, False)
|
||||
|
||||
def GP_THICK(self, layout, ob, md):
|
||||
col = layout.column()
|
||||
|
||||
col.prop(md, "normalize_thickness")
|
||||
|
||||
if md.normalize_thickness:
|
||||
col.prop(md, "thickness")
|
||||
else:
|
||||
col.prop(md, "thickness_factor")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True, True)
|
||||
|
||||
def GP_TEXTURE(self, layout, ob, md):
|
||||
col = layout.column()
|
||||
|
||||
col.prop(md, "mode")
|
||||
if md.mode in {'STROKE', 'STROKE_AND_FILL'}:
|
||||
col.label(text="Stroke Texture:")
|
||||
col.prop(md, "fit_method")
|
||||
col.prop(md, "uv_offset")
|
||||
col.prop(md, "uv_scale")
|
||||
|
||||
if md.mode == 'STROKE_AND_FILL':
|
||||
col.separator()
|
||||
|
||||
if md.mode in {'FILL', 'STROKE_AND_FILL'}:
|
||||
col.label(text="Fill Texture:")
|
||||
col.prop(md, "fill_rotation", text="Rotation")
|
||||
col.prop(md, "fill_offset", text="Location")
|
||||
col.prop(md, "fill_scale", text="Scale")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True)
|
||||
|
||||
def GP_TINT(self, layout, ob, md):
|
||||
layout.row().prop(md, "tint_type", expand=True)
|
||||
|
||||
if md.tint_type == 'UNIFORM':
|
||||
col = layout.column()
|
||||
col.prop(md, "color")
|
||||
|
||||
col.separator()
|
||||
col.prop(md, "factor")
|
||||
|
||||
if md.tint_type == 'GRADIENT':
|
||||
col = layout.column()
|
||||
col.label(text="Colors:")
|
||||
col.template_color_ramp(md, "colors")
|
||||
|
||||
col.separator()
|
||||
|
||||
col.label(text="Object:")
|
||||
col.prop(md, "object", text="")
|
||||
|
||||
col.separator()
|
||||
row = col.row(align=True)
|
||||
row.prop(md, "radius")
|
||||
row.prop(md, "factor")
|
||||
|
||||
col.separator()
|
||||
col.prop(md, "vertex_mode")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True, True)
|
||||
|
||||
def GP_TIME(self, layout, ob, md):
|
||||
gpd = ob.data
|
||||
|
||||
row = layout.row()
|
||||
row.prop(md, "mode", text="Mode")
|
||||
|
||||
row = layout.row()
|
||||
if md.mode == 'FIX':
|
||||
txt = "Frame"
|
||||
else:
|
||||
txt = "Frame Offset"
|
||||
row.prop(md, "offset", text=txt)
|
||||
|
||||
row = layout.row()
|
||||
row.enabled = md.mode != 'FIX'
|
||||
row.prop(md, "frame_scale")
|
||||
|
||||
row = layout.row()
|
||||
row.separator()
|
||||
|
||||
row = layout.row()
|
||||
row.enabled = md.mode != 'FIX'
|
||||
row.prop(md, "use_custom_frame_range")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.enabled = md.mode != 'FIX' and md.use_custom_frame_range is True
|
||||
row.prop(md, "frame_start")
|
||||
row.prop(md, "frame_end")
|
||||
|
||||
row = layout.row()
|
||||
row.enabled = md.mode != 'FIX'
|
||||
row.prop(md, "use_keep_loop")
|
||||
|
||||
row = layout.row()
|
||||
row.label(text="Layer:")
|
||||
row = layout.row(align=True)
|
||||
row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
|
||||
row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(md, "layer_pass", text="Pass")
|
||||
row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
def GP_COLOR(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Color:")
|
||||
col.prop(md, "hue", text="H", slider=True)
|
||||
col.prop(md, "saturation", text="S", slider=True)
|
||||
col.prop(md, "value", text="V", slider=True)
|
||||
|
||||
row = layout.row()
|
||||
row.prop(md, "modify_color")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, False, True)
|
||||
|
||||
def GP_OPACITY(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.prop(md, "modify_color")
|
||||
|
||||
if md.modify_color == 'HARDNESS':
|
||||
col.prop(md, "hardness")
|
||||
show = False
|
||||
else:
|
||||
col.prop(md, "normalize_opacity")
|
||||
if md.normalize_opacity is True:
|
||||
text="Strength"
|
||||
else:
|
||||
text="Opacity Factor"
|
||||
|
||||
col.prop(md, "factor", text=text)
|
||||
show = True
|
||||
self.gpencil_masking(layout, ob, md, show, show)
|
||||
|
||||
def GP_ARRAY(self, layout, ob, md):
|
||||
col = layout.column()
|
||||
col.prop(md, "count")
|
||||
|
||||
split = layout.split()
|
||||
col = split.column()
|
||||
col.prop(md, "use_constant_offset", text="Constant Offset")
|
||||
subcol = col.column()
|
||||
subcol.enabled = md.use_constant_offset
|
||||
subcol.prop(md, "constant_offset", text="")
|
||||
|
||||
col.prop(md, "use_object_offset")
|
||||
subcol = col.column()
|
||||
subcol.enabled = md.use_object_offset
|
||||
subcol.prop(md, "offset_object", text="")
|
||||
|
||||
col = split.column()
|
||||
col.prop(md, "use_relative_offset", text="Relative Offset")
|
||||
subcol = col.column()
|
||||
subcol.enabled = md.use_relative_offset
|
||||
subcol.prop(md, "relative_offset", text="")
|
||||
|
||||
split = layout.split()
|
||||
col = split.column()
|
||||
col.label(text="Random Offset:")
|
||||
col.prop(md, "random_offset", text="")
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Random Rotation:")
|
||||
col.prop(md, "random_rotation", text="")
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Random Scale:")
|
||||
col.prop(md, "random_scale", text="")
|
||||
|
||||
col = layout.column()
|
||||
col.prop(md, "seed")
|
||||
col.separator()
|
||||
col.prop(md, "replace_material", text="Material Override")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, False)
|
||||
|
||||
def GP_BUILD(self, layout, ob, md):
|
||||
gpd = ob.data
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
self.check_conflicts(col, ob)
|
||||
|
||||
col.prop(md, "mode")
|
||||
if md.mode == 'CONCURRENT':
|
||||
col.prop(md, "concurrent_time_alignment")
|
||||
|
||||
col.separator()
|
||||
col.prop(md, "transition")
|
||||
sub = col.column(align=True)
|
||||
sub.prop(md, "start_delay")
|
||||
sub.prop(md, "length")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.prop(md, "use_restrict_frame_range")
|
||||
sub = col.column(align=True)
|
||||
sub.active = md.use_restrict_frame_range
|
||||
sub.prop(md, "frame_start", text="Start")
|
||||
sub.prop(md, "frame_end", text="End")
|
||||
|
||||
col.prop(md, "use_percentage")
|
||||
sub = col.column(align=True)
|
||||
sub.active = md.use_percentage
|
||||
sub.prop(md, "percentage_factor")
|
||||
|
||||
layout.label(text="Influence Filters:")
|
||||
|
||||
split = layout.split(factor=0.25)
|
||||
|
||||
col1 = split.column()
|
||||
|
||||
col1.label(text="Layer:")
|
||||
|
||||
col2 = split.column()
|
||||
|
||||
split = col2.split(factor=0.6)
|
||||
row = split.row(align=True)
|
||||
row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
|
||||
row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
row = split.row(align=True)
|
||||
row.prop(md, "layer_pass", text="Pass")
|
||||
row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
def GP_LATTICE(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Object:")
|
||||
col.prop(md, "object", text="")
|
||||
|
||||
layout.prop(md, "strength", slider=True)
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True)
|
||||
|
||||
def GP_MIRROR(self, layout, ob, md):
|
||||
row = layout.row(align=True)
|
||||
row.prop(md, "x_axis")
|
||||
row.prop(md, "y_axis")
|
||||
row.prop(md, "z_axis")
|
||||
|
||||
layout.label(text="Mirror Object:")
|
||||
layout.prop(md, "object", text="")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, False)
|
||||
|
||||
def GP_HOOK(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Object:")
|
||||
col.prop(md, "object", text="")
|
||||
if md.object and md.object.type == 'ARMATURE':
|
||||
col.label(text="Bone:")
|
||||
col.prop_search(md, "subtarget", md.object.data, "bones", text="")
|
||||
|
||||
use_falloff = (md.falloff_type != 'NONE')
|
||||
|
||||
layout.separator()
|
||||
|
||||
row = layout.row(align=True)
|
||||
if use_falloff:
|
||||
row.prop(md, "falloff_radius")
|
||||
row.prop(md, "strength", slider=True)
|
||||
layout.prop(md, "falloff_type")
|
||||
|
||||
col = layout.column()
|
||||
if use_falloff:
|
||||
if md.falloff_type == 'CURVE':
|
||||
col.template_curve_mapping(md, "falloff_curve")
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.prop(md, "use_falloff_uniform")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True)
|
||||
|
||||
def GP_OFFSET(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
||||
split.column().prop(md, "location")
|
||||
split.column().prop(md, "rotation")
|
||||
split.column().prop(md, "scale")
|
||||
|
||||
self.gpencil_masking(layout, ob, md, True)
|
||||
|
||||
def GP_ARMATURE(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Object:")
|
||||
col.prop(md, "object", text="")
|
||||
# col.prop(md, "use_deform_preserve_volume")
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Bind To:")
|
||||
col.prop(md, "use_vertex_groups", text="Vertex Groups")
|
||||
col.prop(md, "use_bone_envelopes", text="Bone Envelopes")
|
||||
|
||||
layout.separator()
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.label(text="Vertex Group:")
|
||||
row = layout.row(align=True)
|
||||
row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
|
||||
sub = row.row(align=True)
|
||||
sub.active = bool(md.vertex_group)
|
||||
sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
def GP_MULTIPLY(self, layout, ob, md):
|
||||
col = layout.column()
|
||||
|
||||
col.prop(md, "duplicates")
|
||||
subcol = col.column()
|
||||
subcol.enabled = md.duplicates > 0
|
||||
subcol.prop(md, "distance")
|
||||
subcol.prop(md, "offset", slider=True)
|
||||
|
||||
subcol.separator()
|
||||
|
||||
subcol.prop(md, "use_fade")
|
||||
if md.use_fade:
|
||||
subcol.prop(md, "fading_center")
|
||||
subcol.prop(md, "fading_thickness", slider=True)
|
||||
subcol.prop(md, "fading_opacity", slider=True)
|
||||
|
||||
self.gpencil_masking(layout, ob, md, False)
|
||||
layout.template_grease_pencil_modifiers()
|
||||
|
||||
|
||||
classes = (
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "DNA_gpencil_modifier_types.h" /* needed for all enum typdefs */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ARegionType;
|
||||
struct Depsgraph;
|
||||
struct GpencilModifierData;
|
||||
struct ID;
|
||||
@@ -255,11 +257,17 @@ typedef struct GpencilModifierTypeInfo {
|
||||
struct Object *ob,
|
||||
GreasePencilTexWalkFunc walk,
|
||||
void *userData);
|
||||
|
||||
/* Register the panel types for the modifier's UI. */
|
||||
void (*panelRegister)(struct ARegionType *region_type);
|
||||
} GpencilModifierTypeInfo;
|
||||
|
||||
#define GPENCIL_MODIFIER_TYPE_PANEL_PREFIX "MOD_PT_gpencil_"
|
||||
|
||||
/* Initialize modifier's global data (type info and some common global storages). */
|
||||
void BKE_gpencil_modifier_init(void);
|
||||
|
||||
void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname);
|
||||
const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType type);
|
||||
struct GpencilModifierData *BKE_gpencil_modifier_new(int type);
|
||||
void BKE_gpencil_modifier_free_ex(struct GpencilModifierData *md, const int flag);
|
||||
@@ -276,6 +284,8 @@ void BKE_gpencil_modifier_copydata(struct GpencilModifierData *md,
|
||||
void BKE_gpencil_modifier_copydata_ex(struct GpencilModifierData *md,
|
||||
struct GpencilModifierData *target,
|
||||
const int flag);
|
||||
void BKE_gpencil_modifier_set_error(struct GpencilModifierData *md, const char *format, ...)
|
||||
ATTR_PRINTF_FORMAT(2, 3);
|
||||
void BKE_gpencil_modifiers_foreach_ID_link(struct Object *ob,
|
||||
GreasePencilIDWalkFunc walk,
|
||||
void *userData);
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
static CLG_LogRef LOG = {"bke.gpencil_modifier"};
|
||||
static GpencilModifierTypeInfo *modifier_gpencil_types[NUM_GREASEPENCIL_MODIFIER_TYPES] = {NULL};
|
||||
|
||||
/* *************************************************** */
|
||||
@@ -428,9 +431,9 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type)
|
||||
BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name));
|
||||
|
||||
md->type = type;
|
||||
md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render |
|
||||
eGpencilModifierMode_Expanded;
|
||||
md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render;
|
||||
md->flag = eGpencilModifierFlag_OverrideLibrary_Local;
|
||||
md->ui_expand_flag = 1; /* Only expand the parent panel at first. */
|
||||
|
||||
if (mti->flags & eGpencilModifierTypeFlag_EnableInEditmode) {
|
||||
md->mode |= eGpencilModifierMode_Editmode;
|
||||
@@ -508,7 +511,8 @@ bool BKE_gpencil_modifier_depends_ontime(GpencilModifierData *md)
|
||||
const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType type)
|
||||
{
|
||||
/* type unsigned, no need to check < 0 */
|
||||
if (type < NUM_GREASEPENCIL_MODIFIER_TYPES && modifier_gpencil_types[type]->name[0] != '\0') {
|
||||
if (type < NUM_GREASEPENCIL_MODIFIER_TYPES && type > 0 &&
|
||||
modifier_gpencil_types[type]->name[0] != '\0') {
|
||||
return modifier_gpencil_types[type];
|
||||
}
|
||||
else {
|
||||
@@ -516,6 +520,17 @@ const GpencilModifierTypeInfo *BKE_gpencil_modifier_get_info(GpencilModifierType
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the idname of the modifier type's panel, which was defined in the #panelRegister callback.
|
||||
*/
|
||||
void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname)
|
||||
{
|
||||
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(type);
|
||||
|
||||
strcpy(r_idname, GPENCIL_MODIFIER_TYPE_PANEL_PREFIX);
|
||||
strcat(r_idname, mti->name);
|
||||
}
|
||||
|
||||
void BKE_gpencil_modifier_copydata_generic(const GpencilModifierData *md_src,
|
||||
GpencilModifierData *md_dst)
|
||||
{
|
||||
@@ -553,6 +568,7 @@ void BKE_gpencil_modifier_copydata_ex(GpencilModifierData *md,
|
||||
|
||||
target->mode = md->mode;
|
||||
target->flag = md->flag;
|
||||
target->ui_expand_flag = md->ui_expand_flag; /* Expand the parent panel by default. */
|
||||
|
||||
if (mti->copyData) {
|
||||
mti->copyData(md, target);
|
||||
@@ -587,6 +603,26 @@ GpencilModifierData *BKE_gpencil_modifiers_findby_type(Object *ob, GpencilModifi
|
||||
return md;
|
||||
}
|
||||
|
||||
void BKE_gpencil_modifier_set_error(GpencilModifierData *md, const char *_format, ...)
|
||||
{
|
||||
char buffer[512];
|
||||
va_list ap;
|
||||
const char *format = TIP_(_format);
|
||||
|
||||
va_start(ap, _format);
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
va_end(ap);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
|
||||
if (md->error) {
|
||||
MEM_freeN(md->error);
|
||||
}
|
||||
|
||||
md->error = BLI_strdup(buffer);
|
||||
|
||||
CLOG_STR_ERROR(&LOG, md->error);
|
||||
}
|
||||
|
||||
void BKE_gpencil_modifiers_foreach_ID_link(Object *ob, GreasePencilIDWalkFunc walk, void *userData)
|
||||
{
|
||||
GpencilModifierData *md = ob->greasepencil_modifiers.first;
|
||||
|
||||
@@ -268,6 +268,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
|
||||
/* Transition to saving expansion for all of a modifier's subpanels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
@@ -302,5 +303,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Transition to saving expansion for all of grease pencil modifier's subpanels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "GpencilModifierData", "short", "ui_expand_flag")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (GpencilModifierData *, md, &object->greasepencil_modifiers) {
|
||||
if (md->mode & eGpencilModifierMode_Expanded_DEPRECATED) {
|
||||
md->ui_expand_flag = 1;
|
||||
}
|
||||
else {
|
||||
md->ui_expand_flag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,6 +421,10 @@ int ED_object_gpencil_modifier_move_down(struct ReportList *reports,
|
||||
int ED_object_gpencil_modifier_move_up(struct ReportList *reports,
|
||||
struct Object *ob,
|
||||
struct GpencilModifierData *md);
|
||||
bool ED_object_gpencil_modifier_move_to_index(struct ReportList *reports,
|
||||
struct Object *ob,
|
||||
struct GpencilModifierData *md,
|
||||
const int index);
|
||||
int ED_object_gpencil_modifier_apply(struct Main *bmain,
|
||||
struct ReportList *reports,
|
||||
struct Depsgraph *depsgraph,
|
||||
|
||||
@@ -2004,6 +2004,7 @@ void uiTemplatePathBuilder(uiLayout *layout,
|
||||
struct PointerRNA *root_ptr,
|
||||
const char *text);
|
||||
void uiTemplateModifiers(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateGpencilModifiers(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateConstraints(uiLayout *layout, struct bContext *C, bool use_bone_constraints);
|
||||
|
||||
uiLayout *uiTemplateGpencilModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
|
||||
|
||||
@@ -2040,147 +2040,55 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
|
||||
/** \name Grease Pencil Modifier Template
|
||||
* \{ */
|
||||
|
||||
#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
|
||||
|
||||
static uiLayout *gpencil_draw_modifier(uiLayout *layout, Object *ob, GpencilModifierData *md)
|
||||
/**
|
||||
* Function with void * argument for #uiListPanelIDFromDataFunc.
|
||||
*/
|
||||
static void gpencil_modifier_panel_id(void *md_link, char *r_name)
|
||||
{
|
||||
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
|
||||
PointerRNA ptr;
|
||||
uiBlock *block;
|
||||
uiLayout *box, *column, *row, *sub;
|
||||
uiLayout *result = NULL;
|
||||
|
||||
/* create RNA pointer */
|
||||
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
|
||||
|
||||
column = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetContextPointer(column, "modifier", &ptr);
|
||||
|
||||
/* rounded header ------------------------------------------------------------------- */
|
||||
box = uiLayoutBox(column);
|
||||
|
||||
row = uiLayoutRow(box, false);
|
||||
block = uiLayoutGetBlock(row);
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
/* Open/Close ................................. */
|
||||
uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
|
||||
|
||||
/* modifier-type icon */
|
||||
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
||||
/* modifier name */
|
||||
if (mti->isDisabled && mti->isDisabled(md, 0)) {
|
||||
uiLayoutSetRedAlert(row, true);
|
||||
}
|
||||
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
|
||||
uiLayoutSetRedAlert(row, false);
|
||||
|
||||
/* mode enabling buttons */
|
||||
UI_block_align_begin(block);
|
||||
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
|
||||
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
|
||||
|
||||
if (mti->flags & eGpencilModifierTypeFlag_SupportsEditmode) {
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, false);
|
||||
uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
|
||||
}
|
||||
|
||||
UI_block_align_end(block);
|
||||
|
||||
/* Up/Down + Delete ........................... */
|
||||
UI_block_align_begin(block);
|
||||
uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_gpencil_modifier_move_up");
|
||||
uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_gpencil_modifier_move_down");
|
||||
UI_block_align_end(block);
|
||||
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
uiItemO(row, "", ICON_X, "OBJECT_OT_gpencil_modifier_remove");
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
||||
/* modifier settings (under the header) --------------------------------------------------- */
|
||||
if (md->mode & eGpencilModifierMode_Expanded) {
|
||||
/* apply/convert/copy */
|
||||
box = uiLayoutBox(column);
|
||||
row = uiLayoutRow(box, false);
|
||||
|
||||
/* only here obdata, the rest of modifiers is ob level */
|
||||
UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
|
||||
|
||||
sub = uiLayoutRow(row, false);
|
||||
if (mti->flags & eGpencilModifierTypeFlag_NoApply) {
|
||||
uiLayoutSetEnabled(sub, false);
|
||||
}
|
||||
uiItemEnumO(sub,
|
||||
"OBJECT_OT_gpencil_modifier_apply",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
|
||||
0,
|
||||
"apply_as",
|
||||
MODIFIER_APPLY_DATA);
|
||||
|
||||
UI_block_lock_clear(block);
|
||||
UI_block_lock_set(block, ob && ID_IS_LINKED(ob), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
uiItemO(row,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"),
|
||||
ICON_NONE,
|
||||
"OBJECT_OT_gpencil_modifier_copy");
|
||||
|
||||
/* result is the layout block inside the box,
|
||||
* that we return so that modifier settings can be drawn */
|
||||
result = uiLayoutColumn(box, false);
|
||||
block = uiLayoutAbsoluteBlock(box);
|
||||
}
|
||||
|
||||
/* error messages */
|
||||
if (md->error) {
|
||||
box = uiLayoutBox(column);
|
||||
row = uiLayoutRow(box, false);
|
||||
uiItemL(row, md->error, ICON_ERROR);
|
||||
}
|
||||
|
||||
return result;
|
||||
ModifierData *md = (ModifierData *)md_link;
|
||||
BKE_gpencil_modifierType_panel_id(md->type, r_name);
|
||||
}
|
||||
|
||||
uiLayout *uiTemplateGpencilModifier(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
|
||||
{
|
||||
Object *ob;
|
||||
GpencilModifierData *md, *vmd;
|
||||
int i;
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
Object *ob = get_context_object(C);
|
||||
ListBase *modifiers = &ob->greasepencil_modifiers;
|
||||
|
||||
/* verify we have valid data */
|
||||
if (!RNA_struct_is_a(ptr->type, &RNA_GpencilModifier)) {
|
||||
RNA_warning("Expected modifier on object");
|
||||
return NULL;
|
||||
}
|
||||
bool panels_match = UI_panel_list_matches_data(region, modifiers, gpencil_modifier_panel_id);
|
||||
|
||||
ob = (Object *)ptr->owner_id;
|
||||
md = ptr->data;
|
||||
if (!panels_match) {
|
||||
UI_panels_free_instanced(C, region);
|
||||
GpencilModifierData *md = modifiers->first;
|
||||
for (int i = 0; md; i++, md = md->next) {
|
||||
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
|
||||
if (mti->panelRegister) {
|
||||
char panel_idname[MAX_NAME];
|
||||
gpencil_modifier_panel_id(md, panel_idname);
|
||||
|
||||
if (!ob || !(GS(ob->id.name) == ID_OB)) {
|
||||
RNA_warning("Expected modifier on object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
/* find modifier and draw it */
|
||||
vmd = ob->greasepencil_modifiers.first;
|
||||
for (i = 0; vmd; i++, vmd = vmd->next) {
|
||||
if (md == vmd) {
|
||||
return gpencil_draw_modifier(layout, ob, md);
|
||||
Panel *new_panel = UI_panel_add_instanced(sa, region, ®ion->panels, panel_idname, i);
|
||||
if (new_panel != NULL) {
|
||||
UI_panel_set_expand_from_list_data(C, new_panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* The expansion might have been changed elsewhere, so we still need to set it. */
|
||||
LISTBASE_FOREACH (Panel *, panel, ®ion->panels) {
|
||||
if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED))
|
||||
UI_panel_set_expand_from_list_data(C, panel);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/** \} */
|
||||
|
||||
#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Grease Pencil Shader FX Template
|
||||
* \{ */
|
||||
|
||||
@@ -211,6 +211,40 @@ int ED_object_gpencil_modifier_move_down(ReportList *UNUSED(reports),
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool ED_object_gpencil_modifier_move_to_index(ReportList *reports,
|
||||
Object *ob,
|
||||
GpencilModifierData *md,
|
||||
const int index)
|
||||
{
|
||||
BLI_assert(md != NULL);
|
||||
BLI_assert(index >= 0);
|
||||
if (index >= BLI_listbase_count(&ob->greasepencil_modifiers)) {
|
||||
BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the stack");
|
||||
return false;
|
||||
}
|
||||
|
||||
int md_index = BLI_findindex(&ob->greasepencil_modifiers, md);
|
||||
BLI_assert(md_index != -1);
|
||||
if (md_index < index) {
|
||||
/* Move modifier down in list. */
|
||||
for (; md_index < index; md_index++) {
|
||||
if (!ED_object_gpencil_modifier_move_down(reports, ob, md)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Move modifier up in list. */
|
||||
for (; md_index > index; md_index--) {
|
||||
if (!ED_object_gpencil_modifier_move_up(reports, ob, md)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int gpencil_modifier_apply_obdata(
|
||||
ReportList *reports, Main *bmain, Depsgraph *depsgraph, Object *ob, GpencilModifierData *md)
|
||||
{
|
||||
@@ -596,6 +630,60 @@ void OBJECT_OT_gpencil_modifier_move_down(wmOperatorType *ot)
|
||||
gpencil_edit_modifier_properties(ot);
|
||||
}
|
||||
|
||||
/* ************************* Move to Index Gpencil Modifier Operator ************************* */
|
||||
|
||||
static bool gpencil_modifier_move_to_index_poll(bContext *C)
|
||||
{
|
||||
return gpencil_edit_modifier_poll(C);
|
||||
}
|
||||
|
||||
static int gpencil_modifier_move_to_index_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = ED_object_active_context(C);
|
||||
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
|
||||
int index = RNA_int_get(op->ptr, "index");
|
||||
|
||||
if (!ED_object_gpencil_modifier_move_to_index(op->reports, ob, md, index)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int gpencil_modifier_move_to_index_invoke(bContext *C,
|
||||
wmOperator *op,
|
||||
const wmEvent *UNUSED(event))
|
||||
{
|
||||
if (gpencil_edit_modifier_invoke_properties(C, op)) {
|
||||
return gpencil_modifier_move_to_index_exec(C, op);
|
||||
}
|
||||
else {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
void OBJECT_OT_gpencil_modifier_move_to_index(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Move Active Modifier to Index";
|
||||
ot->idname = "OBJECT_OT_gpencil_modifier_move_to_index";
|
||||
ot->description =
|
||||
"Change the modifier's position in the list so it evaluates after the set number of "
|
||||
"others";
|
||||
|
||||
ot->invoke = gpencil_modifier_move_to_index_invoke;
|
||||
ot->exec = gpencil_modifier_move_to_index_exec;
|
||||
ot->poll = gpencil_modifier_move_to_index_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
||||
edit_modifier_properties(ot);
|
||||
RNA_def_int(
|
||||
ot->srna, "index", 0, 0, INT_MAX, "Index", "The index to move the modifier to", 0, INT_MAX);
|
||||
}
|
||||
|
||||
/************************ apply modifier operator *********************/
|
||||
|
||||
static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op)
|
||||
|
||||
@@ -190,6 +190,7 @@ void OBJECT_OT_gpencil_modifier_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_gpencil_modifier_remove(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_gpencil_modifier_move_up(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_gpencil_modifier_move_down(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_gpencil_modifier_move_to_index(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_gpencil_modifier_apply(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_gpencil_modifier_copy(struct wmOperatorType *ot);
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@ void ED_operatortypes_object(void)
|
||||
WM_operatortype_append(OBJECT_OT_gpencil_modifier_remove);
|
||||
WM_operatortype_append(OBJECT_OT_gpencil_modifier_move_up);
|
||||
WM_operatortype_append(OBJECT_OT_gpencil_modifier_move_down);
|
||||
WM_operatortype_append(OBJECT_OT_gpencil_modifier_move_to_index);
|
||||
WM_operatortype_append(OBJECT_OT_gpencil_modifier_apply);
|
||||
WM_operatortype_append(OBJECT_OT_gpencil_modifier_copy);
|
||||
|
||||
|
||||
@@ -30,11 +30,10 @@
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil_modifier.h" /* Types for registering panels. */
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DNA_modifier_types.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_view3d.h" /* To draw toolbar UI. */
|
||||
@@ -643,6 +642,12 @@ void ED_spacetype_buttons(void)
|
||||
mti->panelRegister(art);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NUM_GREASEPENCIL_MODIFIER_TYPES; i++) {
|
||||
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(i);
|
||||
if (mti != NULL && mti->panelRegister != NULL) {
|
||||
mti->panelRegister(art);
|
||||
}
|
||||
}
|
||||
|
||||
/* regions: header */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
|
||||
|
||||
@@ -25,11 +25,14 @@ set(INC
|
||||
../blenfont
|
||||
../blenkernel
|
||||
../blenlib
|
||||
../blentranslation
|
||||
../bmesh
|
||||
../depsgraph
|
||||
../editors/include
|
||||
../makesdna
|
||||
../makesrna
|
||||
../render/extern/include
|
||||
../windowmanager
|
||||
../../../intern/eigen
|
||||
../../../intern/guardedalloc
|
||||
)
|
||||
@@ -40,6 +43,7 @@ set(INC_SYS
|
||||
|
||||
set(SRC
|
||||
intern/MOD_gpencil_util.h
|
||||
intern/MOD_gpencil_ui_common.c
|
||||
|
||||
intern/MOD_gpencil_util.c
|
||||
intern/MOD_gpencilarmature.c
|
||||
@@ -61,6 +65,7 @@ set(SRC
|
||||
intern/MOD_gpenciltime.c
|
||||
intern/MOD_gpenciltint.c
|
||||
|
||||
intern/MOD_gpencil_ui_common.h
|
||||
MOD_gpencil_modifiertypes.h
|
||||
)
|
||||
|
||||
|
||||
460
source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
Normal file
460
source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
Normal file
@@ -0,0 +1,460 @@
|
||||
/* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DNA_object_force_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_particle_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
#include "ED_object.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "MOD_gpencil_ui_common.h" /* Self include */
|
||||
|
||||
static Object *get_gpencilmodifier_object(const bContext *C)
|
||||
{
|
||||
SpaceProperties *sbuts = CTX_wm_space_properties(C);
|
||||
if (sbuts != NULL && (sbuts->pinid != NULL) && GS(sbuts->pinid->name) == ID_OB) {
|
||||
return (Object *)sbuts->pinid;
|
||||
}
|
||||
else {
|
||||
return CTX_data_active_object(C);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Poll function so these modifier panels only show for grease pencil objects.
|
||||
*/
|
||||
static bool gpencil_modifier_ui_poll(const bContext *C, PanelType *UNUSED(pt))
|
||||
{
|
||||
Object *ob = get_gpencilmodifier_object(C);
|
||||
|
||||
return (ob != NULL) && (ob->type == OB_GPENCIL);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Panel Drag and Drop, Expansion Saving
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* Move a modifier to the index it's moved to after a drag and drop.
|
||||
*/
|
||||
static void gpencil_modifier_reorder(bContext *C, Panel *panel, int new_index)
|
||||
{
|
||||
Object *ob = get_gpencilmodifier_object(C);
|
||||
|
||||
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
|
||||
PointerRNA props_ptr;
|
||||
wmOperatorType *ot = WM_operatortype_find("OBJECT_OT_gpencil_modifier_move_to_index", false);
|
||||
WM_operator_properties_create_ptr(&props_ptr, ot);
|
||||
RNA_string_set(&props_ptr, "modifier", md->name);
|
||||
RNA_int_set(&props_ptr, "index", new_index);
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
|
||||
WM_operator_properties_free(&props_ptr);
|
||||
}
|
||||
|
||||
static short get_gpencil_modifier_expand_flag(const bContext *C, Panel *panel)
|
||||
{
|
||||
Object *ob = get_gpencilmodifier_object(C);
|
||||
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
|
||||
return md->ui_expand_flag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_gpencil_modifier_expand_flag(const bContext *C, Panel *panel, short expand_flag)
|
||||
{
|
||||
Object *ob = get_gpencilmodifier_object(C);
|
||||
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
|
||||
md->ui_expand_flag = expand_flag;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Modifier Panel Layouts
|
||||
* \{ */
|
||||
|
||||
void gpencil_modifier_masking_panel_draw(const bContext *C,
|
||||
Panel *panel,
|
||||
bool use_material,
|
||||
bool use_vertex)
|
||||
{
|
||||
uiLayout *row, *col, *sub;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
|
||||
bool has_layer = RNA_string_length(&ptr, "layer") != 0;
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, true);
|
||||
row = uiLayoutRow(col, true);
|
||||
uiItemPointerR(row, &ptr, "layer", &obj_data_ptr, "layers", NULL, ICON_GREASEPENCIL);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, has_layer);
|
||||
uiLayoutSetPropDecorate(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_layers", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
|
||||
row = uiLayoutRow(col, true);
|
||||
uiItemR(row, &ptr, "layer_pass", 0, NULL, ICON_NONE);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, RNA_int_get(&ptr, "layer_pass") != 0);
|
||||
uiLayoutSetPropDecorate(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_layer_pass", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
|
||||
if (use_material) {
|
||||
PointerRNA material_ptr = RNA_pointer_get(&ptr, "material");
|
||||
bool has_material = !RNA_pointer_is_null(&material_ptr);
|
||||
|
||||
/* Because the Gpencil modifier material property used to be a string in an earlier version of
|
||||
* Blender, we need to check if the material is valid and display it differently if so. */
|
||||
bool valid = false;
|
||||
{
|
||||
if (!has_material) {
|
||||
valid = true;
|
||||
}
|
||||
else {
|
||||
Material *current_material = material_ptr.data;
|
||||
Object *ob = ob_ptr.data;
|
||||
for (int i = 0; i <= ob->totcol; i++) {
|
||||
Material *mat = BKE_object_material_get(ob, i);
|
||||
if (mat == current_material) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
col = uiLayoutColumn(layout, true);
|
||||
row = uiLayoutRow(col, true);
|
||||
uiLayoutSetRedAlert(row, !valid);
|
||||
uiItemPointerR(row,
|
||||
&ptr,
|
||||
"material",
|
||||
&obj_data_ptr,
|
||||
"materials",
|
||||
NULL,
|
||||
valid ? ICON_SHADING_TEXTURE : ICON_ERROR);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, has_material);
|
||||
uiLayoutSetPropDecorate(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_materials", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
|
||||
row = uiLayoutRow(col, true);
|
||||
uiItemR(row, &ptr, "pass_index", 0, NULL, ICON_NONE);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, RNA_int_get(&ptr, "pass_index") != 0);
|
||||
uiLayoutSetPropDecorate(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_material_pass", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
}
|
||||
|
||||
if (use_vertex) {
|
||||
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
|
||||
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, has_vertex_group);
|
||||
uiLayoutSetPropDecorate(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
void gpencil_modifier_curve_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "use_custom_curve", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
void gpencil_modifier_curve_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiTemplateCurveMapping(layout, &ptr, "curve", 0, false, false, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw modifier error message.
|
||||
*/
|
||||
void gpencil_modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
|
||||
{
|
||||
GpencilModifierData *md = ptr->data;
|
||||
if (md->error) {
|
||||
uiLayout *row = uiLayoutRow(layout, false);
|
||||
uiItemL(row, IFACE_(md->error), ICON_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets RNA pointers for the active object and the panel's modifier data.
|
||||
*/
|
||||
#define ERROR_LIBDATA_MESSAGE TIP_("External library data")
|
||||
void gpencil_modifier_panel_get_property_pointers(const bContext *C,
|
||||
Panel *panel,
|
||||
PointerRNA *r_ob_ptr,
|
||||
PointerRNA *r_md_ptr)
|
||||
{
|
||||
Object *ob = get_gpencilmodifier_object(C);
|
||||
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
|
||||
|
||||
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, r_md_ptr);
|
||||
|
||||
if (r_ob_ptr != NULL) {
|
||||
RNA_pointer_create(&ob->id, &RNA_Object, ob, r_ob_ptr);
|
||||
}
|
||||
|
||||
uiBlock *block = uiLayoutGetBlock(panel->layout);
|
||||
UI_block_lock_clear(block);
|
||||
UI_block_lock_set(block, ob && ID_IS_LINKED(ob), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
uiLayoutSetContextPointer(panel->layout, "modifier", r_md_ptr);
|
||||
}
|
||||
|
||||
static void gpencil_modifier_ops_extra_draw(bContext *C, uiLayout *layout, void *md_v)
|
||||
{
|
||||
PointerRNA op_ptr;
|
||||
uiLayout *row;
|
||||
GpencilModifierData *md = (GpencilModifierData *)md_v;
|
||||
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
|
||||
|
||||
PointerRNA ptr;
|
||||
Object *ob = get_gpencilmodifier_object(C);
|
||||
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
|
||||
uiLayoutSetContextPointer(layout, "modifier", &ptr);
|
||||
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
|
||||
|
||||
uiLayoutSetUnitsX(layout, 4.0f);
|
||||
|
||||
/* Apply. */
|
||||
if (!(mti->flags & eGpencilModifierTypeFlag_NoApply)) {
|
||||
uiItemEnumO(layout,
|
||||
"OBJECT_OT_gpencil_modifier_apply",
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
|
||||
ICON_CHECKMARK,
|
||||
"apply_as",
|
||||
MODIFIER_APPLY_DATA);
|
||||
}
|
||||
|
||||
/* Duplicate. */
|
||||
uiItemO(layout,
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Duplicate"),
|
||||
ICON_DUPLICATE,
|
||||
"OBJECT_OT_gpencil_modifier_copy");
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
/* Move to first. */
|
||||
row = uiLayoutColumn(layout, false);
|
||||
uiItemFullO(row,
|
||||
"OBJECT_OT_gpencil_modifier_move_to_index",
|
||||
IFACE_("Move to First"),
|
||||
ICON_TRIA_UP,
|
||||
NULL,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
RNA_int_set(&op_ptr, "index", 0);
|
||||
if (!md->prev) {
|
||||
uiLayoutSetEnabled(row, false);
|
||||
}
|
||||
|
||||
/* Move to last. */
|
||||
row = uiLayoutColumn(layout, false);
|
||||
uiItemFullO(row,
|
||||
"OBJECT_OT_gpencil_modifier_move_to_index",
|
||||
IFACE_("Move to Last"),
|
||||
ICON_TRIA_DOWN,
|
||||
NULL,
|
||||
WM_OP_INVOKE_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
RNA_int_set(&op_ptr, "index", BLI_listbase_count(&ob->greasepencil_modifiers) - 1);
|
||||
if (!md->next) {
|
||||
uiLayoutSetEnabled(row, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void gpencil_modifier_panel_header(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *row, *sub;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
Object *ob = get_gpencilmodifier_object(C);
|
||||
GpencilModifierData *md = BLI_findlink(&ob->greasepencil_modifiers, panel->runtime.list_index);
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr);
|
||||
uiLayoutSetContextPointer(panel->layout, "modifier", &ptr);
|
||||
|
||||
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
|
||||
bool narrow_panel = (panel->sizex < UI_UNIT_X * 9 && panel->sizex != 0);
|
||||
|
||||
/* Modifier Icon. */
|
||||
row = uiLayoutRow(layout, false);
|
||||
if (mti->isDisabled && mti->isDisabled(md, 0)) {
|
||||
uiLayoutSetRedAlert(row, true);
|
||||
}
|
||||
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
|
||||
|
||||
/* Modifier name. */
|
||||
row = uiLayoutRow(layout, true);
|
||||
if (!narrow_panel) {
|
||||
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
|
||||
}
|
||||
else {
|
||||
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
/* Display mode buttons. */
|
||||
if (mti->flags & eGpencilModifierTypeFlag_SupportsEditmode) {
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
|
||||
}
|
||||
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
|
||||
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
|
||||
|
||||
/* Extra operators. */
|
||||
// row = uiLayoutRow(layout, true);
|
||||
uiItemMenuF(row, "", ICON_DOWNARROW_HLT, gpencil_modifier_ops_extra_draw, md);
|
||||
|
||||
/* Remove button. */
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetEmboss(sub, UI_EMBOSS_NONE);
|
||||
uiItemO(sub, "", ICON_X, "OBJECT_OT_gpencil_modifier_remove");
|
||||
|
||||
/* Extra padding. */
|
||||
uiItemS(layout);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Modifier Registration Helpers
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* Create a panel in the context's region
|
||||
*/
|
||||
PanelType *gpencil_modifier_panel_register(ARegionType *region_type,
|
||||
GpencilModifierType type,
|
||||
PanelDrawFn draw)
|
||||
{
|
||||
|
||||
/* Get the name for the modifier's panel. */
|
||||
char panel_idname[BKE_ST_MAXNAME];
|
||||
BKE_gpencil_modifierType_panel_id(type, panel_idname);
|
||||
|
||||
PanelType *panel_type = MEM_callocN(sizeof(PanelType), panel_idname);
|
||||
|
||||
strcpy(panel_type->idname, panel_idname);
|
||||
strcpy(panel_type->label, "");
|
||||
strcpy(panel_type->context, "modifier");
|
||||
strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||
|
||||
panel_type->draw_header = gpencil_modifier_panel_header;
|
||||
panel_type->draw = draw;
|
||||
panel_type->poll = gpencil_modifier_ui_poll;
|
||||
|
||||
/* Give the panel the special flag that says it was built here and corresponds to a
|
||||
* modifer rather than a PanelType. */
|
||||
panel_type->flag = PNL_LAYOUT_HEADER_EXPAND | PNL_DRAW_BOX | PNL_INSTANCED;
|
||||
panel_type->reorder = gpencil_modifier_reorder;
|
||||
panel_type->get_list_data_expand_flag = get_gpencil_modifier_expand_flag;
|
||||
panel_type->set_list_data_expand_flag = set_gpencil_modifier_expand_flag;
|
||||
|
||||
BLI_addtail(®ion_type->paneltypes, panel_type);
|
||||
|
||||
return panel_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 *gpencil_modifier_subpanel_register(ARegionType *region_type,
|
||||
const char *name,
|
||||
const char *label,
|
||||
PanelDrawFn draw_header,
|
||||
PanelDrawFn draw,
|
||||
PanelType *parent)
|
||||
{
|
||||
/* Create the subpanel's ID name. */
|
||||
char panel_idname[BKE_ST_MAXNAME];
|
||||
strcpy(panel_idname, parent->idname);
|
||||
strcat(panel_idname, "_");
|
||||
strcat(panel_idname, name);
|
||||
|
||||
PanelType *panel_type = MEM_callocN(sizeof(PanelType), panel_idname);
|
||||
|
||||
strcpy(panel_type->idname, panel_idname);
|
||||
strcpy(panel_type->label, label);
|
||||
strcpy(panel_type->context, "modifier");
|
||||
strcpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||
|
||||
panel_type->draw_header = draw_header;
|
||||
panel_type->draw = draw;
|
||||
panel_type->poll = gpencil_modifier_ui_poll;
|
||||
panel_type->flag = (PNL_DEFAULT_CLOSED | PNL_DRAW_BOX);
|
||||
|
||||
BLI_assert(parent != NULL);
|
||||
strcpy(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;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#ifndef __MOD_UI_COMMON__GPENCIL_H__
|
||||
#define __MOD_UI_COMMON__GPENCIL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
|
||||
struct ARegionType;
|
||||
struct bContext;
|
||||
struct PanelType;
|
||||
struct uiLayout;
|
||||
typedef void (*PanelDrawFn)(const bContext *, Panel *);
|
||||
|
||||
void gpencil_modifier_masking_panel_draw(const bContext *C,
|
||||
Panel *panel,
|
||||
bool use_material,
|
||||
bool use_vertex);
|
||||
|
||||
void gpencil_modifier_curve_header_draw(const bContext *C, Panel *panel);
|
||||
void gpencil_modifier_curve_panel_draw(const bContext *C, Panel *panel);
|
||||
|
||||
void gpencil_modifier_panel_end(struct uiLayout *layout, PointerRNA *ptr);
|
||||
|
||||
void gpencil_modifier_panel_get_property_pointers(const bContext *C,
|
||||
struct Panel *panel,
|
||||
struct PointerRNA *r_ob_ptr,
|
||||
struct PointerRNA *r_ptr);
|
||||
|
||||
PanelType *gpencil_modifier_panel_register(struct ARegionType *region_type,
|
||||
GpencilModifierType type,
|
||||
PanelDrawFn draw);
|
||||
|
||||
struct PanelType *gpencil_modifier_subpanel_register(struct ARegionType *region_type,
|
||||
const char *name,
|
||||
const char *label,
|
||||
PanelDrawFn draw_header,
|
||||
PanelDrawFn draw,
|
||||
struct PanelType *parent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MOD_UI_COMMON__GPENCIL_H__ */
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
@@ -35,8 +37,10 @@
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
@@ -44,10 +48,17 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
@@ -181,6 +192,39 @@ static void foreachObjectLink(GpencilModifierData *md,
|
||||
walk(userData, ob, &mmd->object, IDWALK_CB_NOP);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *sub, *row, *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, has_vertex_group);
|
||||
uiLayoutSetPropDecorate(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_vertex_group", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
|
||||
col = uiLayoutColumnWithHeading(layout, true, "Bind to");
|
||||
uiItemR(col, &ptr, "use_vertex_groups", 0, IFACE_("Vertex Groups"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "use_bone_envelopes", 0, IFACE_("Bone Envelopes"), ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
gpencil_modifier_panel_register(region_type, eGpencilModifierType_Armature, panel_draw);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Armature = {
|
||||
/* name */ "Armature",
|
||||
/* structName */ "ArmatureGpencilModifierData",
|
||||
@@ -202,4 +246,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Armature = {
|
||||
/* foreachObjectLink */ foreachObjectLink,
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -35,12 +35,16 @@
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_collection.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
@@ -51,12 +55,19 @@
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_build.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
typedef struct tmpStrokes {
|
||||
@@ -78,6 +89,9 @@ static void initData(GpencilModifierData *md)
|
||||
gpmd->flag |= GP_ARRAY_USE_RELATIVE;
|
||||
gpmd->seed = 1;
|
||||
gpmd->material = NULL;
|
||||
|
||||
/* Open the first subpanel too, because it's activated by default. */
|
||||
md->ui_expand_flag = (1 << 0) | (1 << 1);
|
||||
}
|
||||
|
||||
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
|
||||
@@ -330,6 +344,143 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "count", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "replace_material", 0, IFACE_("Material Override"), ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void relative_offset_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "use_relative_offset", 0, IFACE_("Relative Offset"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void relative_offset_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayout *col = uiLayoutColumn(layout, false);
|
||||
|
||||
uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_relative_offset"));
|
||||
uiItemR(col, &ptr, "relative_offset", 0, IFACE_("Factor"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void constant_offset_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "use_constant_offset", 0, IFACE_("Constant Offset"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void constant_offset_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayout *col = uiLayoutColumn(layout, false);
|
||||
|
||||
uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_constant_offset"));
|
||||
uiItemR(col, &ptr, "constant_offset", 0, IFACE_("Distance"), ICON_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Object offset in a subpanel for consistency with the other offset types.
|
||||
*/
|
||||
static void object_offset_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "use_object_offset", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void object_offset_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayout *col = uiLayoutColumn(layout, false);
|
||||
|
||||
uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_object_offset"));
|
||||
uiItemR(col, &ptr, "offset_object", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void random_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "random_offset", 0, IFACE_("Offset"), ICON_NONE);
|
||||
uiItemR(layout, &ptr, "random_rotation", 0, IFACE_("Rotation"), ICON_NONE);
|
||||
uiItemR(layout, &ptr, "random_scale", 0, IFACE_("Scale"), ICON_NONE);
|
||||
uiItemR(layout, &ptr, "seed", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Array, panel_draw);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"relative_offset",
|
||||
"",
|
||||
relative_offset_header_draw,
|
||||
relative_offset_draw,
|
||||
panel_type);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"constant_offset",
|
||||
"",
|
||||
constant_offset_header_draw,
|
||||
constant_offset_draw,
|
||||
panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "object_offset", "", object_offset_header_draw, object_offset_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "randomize", "Randomize", NULL, random_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Array = {
|
||||
/* name */ "Array",
|
||||
/* structName */ "ArrayGpencilModifierData",
|
||||
@@ -352,4 +503,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Array = {
|
||||
/* foreachObjectLink */ foreachObjectLink,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -30,20 +30,31 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -537,6 +548,88 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
|
||||
}
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *row, *sub;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
int mode = RNA_enum_get(&ptr, "mode");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
|
||||
if (mode == GP_BUILD_MODE_CONCURRENT) {
|
||||
uiItemR(layout, &ptr, "concurrent_time_alignment", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemR(layout, &ptr, "transition", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "start_delay", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "length", 0, IFACE_("Frames"), ICON_NONE);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Use Factor"));
|
||||
uiItemR(row, &ptr, "use_percentage", 0, "", ICON_NONE);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_percentage"));
|
||||
uiItemR(sub, &ptr, "percentage_factor", 0, "", ICON_NONE);
|
||||
|
||||
/* Check for incompatible time modifier. */
|
||||
Object *ob = ob_ptr.data;
|
||||
GpencilModifierData *md = ptr.data;
|
||||
if (BKE_gpencil_modifiers_findby_type(ob, eGpencilModifierType_Time) != NULL) {
|
||||
BKE_gpencil_modifier_set_error(md, "Build and Time Offset modifiers are incompatible");
|
||||
}
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void frame_range_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "use_restrict_frame_range", 0, IFACE_("Custom Range"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void frame_range_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, false, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Build, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "frame_range", "", frame_range_header_draw, frame_range_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "_mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
/* ******************************************** */
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Build = {
|
||||
@@ -561,4 +654,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Build = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -29,22 +29,33 @@
|
||||
#include "BLI_math_color.h"
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "BKE_modifier.h"
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -186,6 +197,42 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "modify_color", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Color, panel_draw);
|
||||
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"curve",
|
||||
"",
|
||||
gpencil_modifier_curve_header_draw,
|
||||
gpencil_modifier_curve_panel_draw,
|
||||
mask_panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Color = {
|
||||
/* name */ "Hue/Saturation",
|
||||
/* structName */ "ColorGpencilModifierData",
|
||||
@@ -208,4 +255,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Color = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -28,15 +28,19 @@
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
@@ -45,10 +49,17 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
@@ -345,6 +356,81 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *sub, *row, *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
PointerRNA hook_object_ptr = RNA_pointer_get(&ptr, "object");
|
||||
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "object", 0, NULL, ICON_NONE);
|
||||
if (!RNA_pointer_is_null(&hook_object_ptr) &&
|
||||
RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) {
|
||||
PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data");
|
||||
uiItemPointerR(
|
||||
col, &ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE);
|
||||
}
|
||||
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, has_vertex_group);
|
||||
uiLayoutSetPropSep(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
|
||||
uiItemR(layout, &ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void falloff_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
bool use_falloff = RNA_enum_get(&ptr, "falloff_type") != eWarp_Falloff_None;
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "falloff_type", 0, IFACE_("Type"), ICON_NONE);
|
||||
|
||||
row = uiLayoutRow(layout, false);
|
||||
uiLayoutSetActive(row, use_falloff);
|
||||
uiItemR(row, &ptr, "falloff_radius", 0, NULL, ICON_NONE);
|
||||
|
||||
uiItemR(layout, &ptr, "use_falloff_uniform", 0, NULL, ICON_NONE);
|
||||
|
||||
if (RNA_enum_get(&ptr, "falloff_type") == eWarp_Falloff_Curve) {
|
||||
uiTemplateCurveMapping(layout, &ptr, "falloff_curve", 0, false, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Hook, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Hook = {
|
||||
/* name */ "Hook",
|
||||
/* structName */ "HookGpencilModifierData",
|
||||
@@ -367,4 +453,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Hook = {
|
||||
/* foreachObjectLink */ foreachObjectLink,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -26,12 +26,16 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
@@ -41,10 +45,17 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
@@ -208,6 +219,54 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *sub, *row, *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
PointerRNA ob_ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
|
||||
|
||||
PointerRNA hook_object_ptr = RNA_pointer_get(&ptr, "object");
|
||||
bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "object", 0, NULL, ICON_NONE);
|
||||
if (!RNA_pointer_is_null(&hook_object_ptr) &&
|
||||
RNA_enum_get(&hook_object_ptr, "type") == OB_ARMATURE) {
|
||||
PointerRNA hook_object_data_ptr = RNA_pointer_get(&hook_object_ptr, "data");
|
||||
uiItemPointerR(
|
||||
col, &ptr, "subtarget", &hook_object_data_ptr, "bones", IFACE_("Bone"), ICON_NONE);
|
||||
}
|
||||
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemPointerR(row, &ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
|
||||
sub = uiLayoutRow(row, true);
|
||||
uiLayoutSetActive(sub, has_vertex_group);
|
||||
uiLayoutSetPropSep(sub, false);
|
||||
uiItemR(sub, &ptr, "invert_vertex", 0, "", ICON_ARROW_LEFTRIGHT);
|
||||
|
||||
uiItemR(layout, &ptr, "strength", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Lattice, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Lattice = {
|
||||
/* name */ "Lattice",
|
||||
/* structName */ "LatticeGpencilModifierData",
|
||||
@@ -230,4 +289,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Lattice = {
|
||||
/* foreachObjectLink */ foreachObjectLink,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -28,12 +28,16 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
@@ -43,10 +47,17 @@
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
@@ -254,6 +265,40 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Axis"));
|
||||
uiItemR(row, &ptr, "x_axis", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, &ptr, "y_axis", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, &ptr, "z_axis", toggles_flag, NULL, ICON_NONE);
|
||||
|
||||
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Mirror, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Mirror = {
|
||||
/* name */ "Mirror",
|
||||
/* structName */ "MirrorGpencilModifierData",
|
||||
@@ -276,4 +321,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Mirror = {
|
||||
/* foreachObjectLink */ foreachObjectLink,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BLI_alloca.h"
|
||||
#include "BLI_blenlib.h"
|
||||
@@ -37,6 +38,8 @@
|
||||
#include "BLI_rand.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_collection.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
@@ -51,6 +54,7 @@
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "bmesh.h"
|
||||
#include "bmesh_tools.h"
|
||||
@@ -59,7 +63,13 @@
|
||||
#include "DEG_depsgraph_build.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -305,8 +315,71 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "duplicates", 0, NULL, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiLayoutSetActive(layout, RNA_int_get(&ptr, "duplicates") > 0);
|
||||
uiItemR(col, &ptr, "distance", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "offset", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void fade_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "use_fade", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void fade_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "use_fade"));
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "fading_center", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "fading_thickness", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "fading_opacity", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Multiply, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "fade", "", fade_header_draw, fade_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Multiply = {
|
||||
/* name */ "Multiple Strokes",
|
||||
/* name */ "MultipleStrokes",
|
||||
/* structName */ "MultiplyGpencilModifierData",
|
||||
/* structSize */ sizeof(MultiplyGpencilModifierData),
|
||||
/* type */ eGpencilModifierTypeType_Gpencil,
|
||||
@@ -327,4 +400,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Multiply = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
@@ -38,8 +40,10 @@
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
@@ -47,11 +51,18 @@
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -269,6 +280,72 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "factor", 0, IFACE_("Position"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "factor_strength", 0, IFACE_("Strength"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "factor_thickness", 0, IFACE_("Thickness"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "factor_uvs", 0, IFACE_("UV"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "noise_scale", 0, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void random_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiItemR(layout, &ptr, "random", 0, IFACE_("Randomize"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void random_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayoutSetActive(layout, RNA_boolean_get(&ptr, "random"));
|
||||
|
||||
uiItemR(layout, &ptr, "step", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "seed", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Noise, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "randomize", "", random_header_draw, random_panel_draw, panel_type);
|
||||
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"curve",
|
||||
"",
|
||||
gpencil_modifier_curve_header_draw,
|
||||
gpencil_modifier_curve_panel_draw,
|
||||
mask_panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Noise = {
|
||||
/* name */ "Noise",
|
||||
/* structName */ "NoiseGpencilModifierData",
|
||||
@@ -291,4 +368,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Noise = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -28,22 +28,33 @@
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -136,6 +147,35 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "location", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "rotation", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "scale", 0, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, true);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Offset, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Offset = {
|
||||
/* name */ "Offset",
|
||||
/* structName */ "OffsetGpencilModifierData",
|
||||
@@ -158,4 +198,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Offset = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -28,13 +28,17 @@
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
@@ -42,10 +46,17 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -180,6 +191,7 @@ static void bakeModifier(Main *UNUSED(bmain),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void freeData(GpencilModifierData *md)
|
||||
{
|
||||
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
|
||||
@@ -196,6 +208,79 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
int modify_color = RNA_enum_get(&ptr, "modify_color");
|
||||
|
||||
uiItemR(layout, &ptr, "modify_color", 0, NULL, ICON_NONE);
|
||||
|
||||
if (modify_color == GP_MODIFY_COLOR_HARDNESS) {
|
||||
uiItemR(layout, &ptr, "hardness", 0, NULL, ICON_NONE);
|
||||
}
|
||||
else {
|
||||
uiItemR(layout, &ptr, "normalize_opacity", 0, NULL, ICON_NONE);
|
||||
const char *text = (RNA_boolean_get(&ptr, "normalize_opacity")) ? IFACE_("Strength") :
|
||||
IFACE_("Opacity Factor");
|
||||
uiItemR(layout, &ptr, "hardness", 0, text, ICON_NONE);
|
||||
}
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int modify_color = RNA_enum_get(&ptr, "modify_color");
|
||||
bool show_vertex = (modify_color != GP_MODIFY_COLOR_HARDNESS);
|
||||
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, show_vertex);
|
||||
}
|
||||
|
||||
static void curve_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int modify_color = RNA_enum_get(&ptr, "modify_color");
|
||||
uiLayoutSetActive(layout, modify_color != GP_MODIFY_COLOR_HARDNESS);
|
||||
|
||||
gpencil_modifier_curve_header_draw(C, panel);
|
||||
}
|
||||
|
||||
static void curve_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int modify_color = RNA_enum_get(&ptr, "modify_color");
|
||||
uiLayoutSetActive(layout, modify_color != GP_MODIFY_COLOR_HARDNESS);
|
||||
|
||||
gpencil_modifier_curve_panel_draw(C, panel);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Opacity, panel_draw);
|
||||
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "curve", "", curve_header_draw, curve_panel_draw, mask_panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Opacity = {
|
||||
/* name */ "Opacity",
|
||||
/* structName */ "OpacityGpencilModifierData",
|
||||
@@ -218,4 +303,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Opacity = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -26,20 +26,31 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -131,6 +142,48 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int mode = RNA_enum_get(&ptr, "mode");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
|
||||
|
||||
if (mode == GP_SIMPLIFY_FIXED) {
|
||||
uiItemR(layout, &ptr, "step", 0, NULL, ICON_NONE);
|
||||
}
|
||||
else if (mode == GP_SIMPLIFY_ADAPTIVE) {
|
||||
uiItemR(layout, &ptr, "factor", 0, NULL, ICON_NONE);
|
||||
}
|
||||
else if (mode == GP_SIMPLIFY_SAMPLE) {
|
||||
uiItemR(layout, &ptr, "length", 0, NULL, ICON_NONE);
|
||||
}
|
||||
else if (mode == GP_SIMPLIFY_MERGE) {
|
||||
uiItemR(layout, &ptr, "distance", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Simplify, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Simplify = {
|
||||
/* name */ "Simplify",
|
||||
/* structName */ "SimplifyGpencilModifierData",
|
||||
@@ -153,4 +206,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Simplify = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -26,21 +26,32 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -174,6 +185,47 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemR(row, &ptr, "use_edit_position", UI_ITEM_R_TOGGLE, IFACE_("Position"), ICON_NONE);
|
||||
uiItemR(row, &ptr, "use_edit_strength", UI_ITEM_R_TOGGLE, IFACE_("Stength"), ICON_NONE);
|
||||
uiItemR(row, &ptr, "use_edit_thickness", UI_ITEM_R_TOGGLE, IFACE_("Thickness"), ICON_NONE);
|
||||
uiItemR(row, &ptr, "use_edit_uv", UI_ITEM_R_TOGGLE, IFACE_("UV"), ICON_NONE);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "factor", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "step", 0, IFACE_("Repeat"), ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, true);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Smooth, panel_draw);
|
||||
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"curve",
|
||||
"",
|
||||
gpencil_modifier_curve_header_draw,
|
||||
gpencil_modifier_curve_panel_draw,
|
||||
mask_panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Smooth = {
|
||||
/* name */ "Smooth",
|
||||
/* structName */ "SmoothGpencilModifierData",
|
||||
@@ -196,4 +248,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Smooth = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -28,20 +28,31 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -112,6 +123,34 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "subdivision_type", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "level", 0, IFACE_("Subdivisions"), ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Subdiv, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Subdiv = {
|
||||
/* name */ "Subdivide",
|
||||
/* structName */ "SubdivGpencilModifierData",
|
||||
@@ -134,4 +173,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Subdiv = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -27,23 +27,34 @@
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -147,8 +158,56 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int mode = RNA_enum_get(&ptr, "mode");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
|
||||
|
||||
if (ELEM(mode, STROKE, STROKE_AND_FILL)) {
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "fit_method", 0, IFACE_("Stroke Fit Method"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "uv_offset", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "uv_scale", 0, IFACE_("Scale"), ICON_NONE);
|
||||
}
|
||||
|
||||
if (mode == STROKE_AND_FILL) {
|
||||
uiItemS(layout);
|
||||
}
|
||||
|
||||
if (ELEM(mode, FILL, STROKE_AND_FILL)) {
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "fill_rotation", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "fill_offset", 0, IFACE_("Offset"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "fill_scale", 0, IFACE_("Scale"), ICON_NONE);
|
||||
}
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, true);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Texture, panel_draw);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Texture = {
|
||||
/* name */ "Texture Mapping",
|
||||
/* name */ "TextureMapping",
|
||||
/* structName */ "TextureGpencilModifierData",
|
||||
/* structSize */ sizeof(TextureGpencilModifierData),
|
||||
/* type */ eGpencilModifierTypeType_Gpencil,
|
||||
@@ -169,4 +228,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Texture = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -27,22 +27,33 @@
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -166,6 +177,46 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "normalize_thickness", 0, NULL, ICON_NONE);
|
||||
|
||||
if (RNA_boolean_get(&ptr, "normalize_thickness")) {
|
||||
uiItemR(layout, &ptr, "thickness", 0, NULL, ICON_NONE);
|
||||
}
|
||||
else {
|
||||
uiItemR(layout, &ptr, "thickness_factor", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, true);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Thick, panel_draw);
|
||||
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"curve",
|
||||
"",
|
||||
gpencil_modifier_curve_header_draw,
|
||||
gpencil_modifier_curve_panel_draw,
|
||||
mask_panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Thick = {
|
||||
/* name */ "Thickness",
|
||||
/* structName */ "ThickGpencilModifierData",
|
||||
@@ -188,4 +239,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Thick = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -26,20 +26,31 @@
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
static void initData(GpencilModifierData *md)
|
||||
@@ -165,8 +176,91 @@ static int remapTime(struct GpencilModifierData *md,
|
||||
return cfra + offset;
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *row, *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int mode = RNA_enum_get(&ptr, "mode");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
|
||||
const char *text = (mode == GP_TIME_MODE_FIX) ? IFACE_("Frame") : IFACE_("Frame Offset");
|
||||
uiItemR(col, &ptr, "offset", 0, text, ICON_NONE);
|
||||
|
||||
row = uiLayoutRow(col, false);
|
||||
uiLayoutSetActive(row, mode != GP_TIME_MODE_FIX);
|
||||
uiItemR(row, &ptr, "frame_scale", 0, IFACE_("Scale"), ICON_NONE);
|
||||
|
||||
row = uiLayoutRow(layout, false);
|
||||
uiLayoutSetActive(row, mode != GP_TIME_MODE_FIX);
|
||||
uiItemR(row, &ptr, "use_keep_loop", 0, NULL, ICON_NONE);
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void custom_range_header_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int mode = RNA_enum_get(&ptr, "mode");
|
||||
|
||||
uiLayoutSetActive(layout, mode != GP_TIME_MODE_FIX);
|
||||
|
||||
uiItemR(layout, &ptr, "use_custom_frame_range", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
static void custom_range_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int mode = RNA_enum_get(&ptr, "mode");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayoutSetActive(
|
||||
layout, (mode != GP_TIME_MODE_FIX) && (RNA_boolean_get(&ptr, "use_custom_frame_range")));
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, false, false);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Time, panel_draw);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"custom_range",
|
||||
"",
|
||||
custom_range_header_draw,
|
||||
custom_range_panel_draw,
|
||||
panel_type);
|
||||
gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Time = {
|
||||
/* name */ "Time Offset",
|
||||
/* name */ "TimeOffset",
|
||||
/* structName */ "TimeGpencilModifierData",
|
||||
/* structSize */ sizeof(TimeGpencilModifierData),
|
||||
/* type */ eGpencilModifierTypeType_Gpencil,
|
||||
@@ -187,4 +281,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Time = {
|
||||
/* foreachObjectLink */ NULL,
|
||||
/* foreachIDLink */ NULL,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -28,16 +28,20 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_gpencil_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_colorband.h"
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_modifier.h"
|
||||
@@ -47,10 +51,17 @@
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "MOD_gpencil_modifiertypes.h"
|
||||
#include "MOD_gpencil_ui_common.h"
|
||||
#include "MOD_gpencil_util.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
@@ -330,6 +341,56 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
|
||||
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA ptr;
|
||||
gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
|
||||
|
||||
int tint_type = RNA_enum_get(&ptr, "tint_type");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, &ptr, "vertex_mode", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "factor", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "tint_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
||||
|
||||
if (tint_type == GP_TINT_UNIFORM) {
|
||||
uiItemR(layout, &ptr, "color", 0, NULL, ICON_NONE);
|
||||
}
|
||||
else {
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiLayoutSetPropSep(col, false);
|
||||
uiTemplateColorRamp(col, &ptr, "colors", true);
|
||||
uiItemS(layout);
|
||||
uiItemR(layout, &ptr, "object", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &ptr, "radius", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
gpencil_modifier_panel_end(layout, &ptr);
|
||||
}
|
||||
|
||||
static void mask_panel_draw(const bContext *C, Panel *panel)
|
||||
{
|
||||
gpencil_modifier_masking_panel_draw(C, panel, true, true);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = gpencil_modifier_panel_register(
|
||||
region_type, eGpencilModifierType_Tint, panel_draw);
|
||||
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
|
||||
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
|
||||
gpencil_modifier_subpanel_register(region_type,
|
||||
"curve",
|
||||
"",
|
||||
gpencil_modifier_curve_header_draw,
|
||||
gpencil_modifier_curve_panel_draw,
|
||||
mask_panel_type);
|
||||
}
|
||||
|
||||
GpencilModifierTypeInfo modifierType_Gpencil_Tint = {
|
||||
/* name */ "Tint",
|
||||
/* structName */ "TintGpencilModifierData",
|
||||
@@ -352,4 +413,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Tint = {
|
||||
/* foreachObjectLink */ foreachObjectLink,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ NULL,
|
||||
/* panelRegister */ panelRegister,
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@ typedef enum GpencilModifierMode {
|
||||
eGpencilModifierMode_Realtime = (1 << 0),
|
||||
eGpencilModifierMode_Render = (1 << 1),
|
||||
eGpencilModifierMode_Editmode = (1 << 2),
|
||||
eGpencilModifierMode_Expanded = (1 << 3),
|
||||
eGpencilModifierMode_Expanded_DEPRECATED = (1 << 3),
|
||||
} GpencilModifierMode;
|
||||
|
||||
typedef enum {
|
||||
@@ -72,7 +72,7 @@ typedef struct GpencilModifierData {
|
||||
int type, mode;
|
||||
int stackindex;
|
||||
short flag;
|
||||
short _pad;
|
||||
short ui_expand_flag;
|
||||
/** MAX_NAME. */
|
||||
char name[64];
|
||||
|
||||
|
||||
@@ -1490,7 +1490,7 @@ static void rna_def_modifier_gpencilarray(BlenderRNA *brna)
|
||||
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
||||
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "relative_offset", PROP_FLOAT, PROP_NONE);
|
||||
prop = RNA_def_property(srna, "relative_offset", PROP_FLOAT, PROP_XYZ);
|
||||
RNA_def_property_float_sdna(prop, NULL, "shift");
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
@@ -2127,8 +2127,7 @@ static void rna_def_modifier_gpencilmultiply(BlenderRNA *brna)
|
||||
|
||||
prop = RNA_def_property(srna, "use_fade", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flags", GP_MULTIPLY_ENABLE_FADING);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Enable Fade", "Fade the stroke thickness for each generated stroke");
|
||||
RNA_def_property_ui_text(prop, "Fade", "Fade the stroke thickness for each generated stroke");
|
||||
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_ANGLE);
|
||||
@@ -2183,12 +2182,12 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
|
||||
{GP_TEX_CONSTANT_LENGTH,
|
||||
"CONSTANT_LENGTH",
|
||||
0,
|
||||
"Keep Texture at Constant Length",
|
||||
"Constant Length",
|
||||
"Keep the texture at a constant length regardless of the length of each stroke"},
|
||||
{GP_TEX_FIT_STROKE,
|
||||
"FIT_STROKE",
|
||||
0,
|
||||
"Fit Texture to Stroke Length",
|
||||
"Stroke Length",
|
||||
"Scale the texture to fit the length of each stroke"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
@@ -2269,7 +2268,7 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna)
|
||||
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, -100.0, 100.0, 0.1, 3);
|
||||
RNA_def_property_float_default(prop, 0.0f);
|
||||
RNA_def_property_ui_text(prop, "Offset UVs", "Offset value to add to stroke UVs");
|
||||
RNA_def_property_ui_text(prop, "UV Offset", "Offset value to add to stroke UVs");
|
||||
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "uv_scale", PROP_FLOAT, PROP_NONE);
|
||||
@@ -2360,7 +2359,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna)
|
||||
|
||||
prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "mode", eGpencilModifierMode_Expanded);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "ui_expand_flag", 0);
|
||||
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||
RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
|
||||
RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
|
||||
|
||||
@@ -1222,13 +1222,10 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
"",
|
||||
"Add panels for bone constraints instead of object constraints");
|
||||
|
||||
func = RNA_def_function(srna, "template_greasepencil_modifier", "uiTemplateGpencilModifier");
|
||||
func = RNA_def_function(srna, "template_grease_pencil_modifiers", "uiTemplateGpencilModifiers");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Generates the UI layout for grease pencil modifiers");
|
||||
parm = RNA_def_pointer(func, "data", "GpencilModifier", "", "Modifier data");
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
||||
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
|
||||
RNA_def_function_return(func, parm);
|
||||
RNA_def_function_ui_description(func,
|
||||
"Generates the panels for the grease pencil modifier stack");
|
||||
|
||||
func = RNA_def_function(srna, "template_shaderfx", "uiTemplateShaderFx");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
|
||||
Reference in New Issue
Block a user