diff options
Diffstat (limited to 'source')
34 files changed, 1973 insertions, 150 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h index 966d3a98234..ac5f4607838 100644 --- a/source/blender/blenkernel/BKE_gpencil_modifier.h +++ b/source/blender/blenkernel/BKE_gpencil_modifier.h @@ -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); diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index 2f8500bd1df..6496b219be1 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -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; diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 0dd1ecd0008..00c73ebe9a7 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -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; + } + } + } + } } } diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index ebd7321a46d..0cc926987b2 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -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, diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d89e590122c..8e9591c1963 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -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); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 189441a1f10..56a71970f90 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -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; + 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); + } + } + } } - - 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); + 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 * \{ */ diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c index 6d0f53cfa1e..99215686280 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.c @@ -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) diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 1cd91f7c1f3..8feeb3b6067 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -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); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 84bc10f8064..1060a808cfe 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -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); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 187334a5c34..2cc9679dd3f 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -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"); diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt index d3c85b891c6..92aacc74190 100644 --- a/source/blender/gpencil_modifiers/CMakeLists.txt +++ b/source/blender/gpencil_modifiers/CMakeLists.txt @@ -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 ) diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c new file mode 100644 index 00000000000..93d6dff4c16 --- /dev/null +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c @@ -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; +} + +/** \} */
\ No newline at end of file diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h new file mode 100644 index 00000000000..9c6edb51d63 --- /dev/null +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h @@ -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__ */ 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, }; 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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c index 71a051629d8..54ed2ffafe1 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c index 14125d5c8d4..03137a5cf23 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index d39c94e06d5..a0987aafcd2 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c index 92b35f390f8..0f5fc4d5cf6 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c index 10f0dd763b1..581eaa886d8 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c @@ -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, }; 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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c index 73328d7dd31..812bb5628e1 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c index 686f589ffe9..9cc3712e8f4 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c index 92b2621d211..34142709c18 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c index 2cda108682e..8d4556421eb 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c index e2e13b736e4..175a6d81b1b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c index 072159136ce..2797235c002 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c index a5adf12b617..2d16b6ead5c 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c index b9fadea7fd0..4fa47a592ba 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c index 85400b56cad..49396f56d26 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c @@ -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, }; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c index c35728bc8b3..da7d33839f1 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c @@ -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, }; diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index 674999ab465..5d35db1a960 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -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]; diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 3a8ded1a275..06bec3bf944 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -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); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 8bfee4cc26c..974daa51f99 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -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); |