From ec963d9d7d179e3ba12f5bdf748818939c2f17d8 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 19 Jun 2020 14:42:08 -0400 Subject: 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 (9b099c86123fc82). Thanks to Matias Mendiola (mendio) for providing mockups for many of the layout changes. Differential Revision: https://developer.blender.org/D7978 --- .../gpencil_modifiers/intern/MOD_gpencilarmature.c | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c') diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c index 776e5521179..6b7c1c41e12 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c @@ -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, }; -- cgit v1.2.3