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_gpencilmultiply.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_gpencilmultiply.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c index 22e46626a13..619c37015e4 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c @@ -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, }; |