diff options
author | Hans Goudey <h.goudey@me.com> | 2020-06-19 21:42:08 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-06-19 21:42:08 +0300 |
commit | ec963d9d7d179e3ba12f5bdf748818939c2f17d8 (patch) | |
tree | 099996a967053ba95d14eaeaa1df8d602ebbfd23 /source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c | |
parent | fb7d8e2f4b87307a749537f16e80800af09cf5ae (diff) |
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
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c index da4c1f71f44..d92721f887f 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c @@ -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, }; |