diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_array.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_array.c | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index fc127c48fc9..68e12a8bbef 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -29,12 +29,16 @@ #include "BLI_math.h" +#include "BLT_translation.h" + #include "DNA_curve_types.h" #include "DNA_mesh_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_curve.h" #include "BKE_displist.h" #include "BKE_lib_id.h" @@ -42,7 +46,14 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object_deform.h" +#include "BKE_screen.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "RNA_access.h" +#include "MOD_ui_common.h" #include "MOD_util.h" #include "DEG_depsgraph.h" @@ -822,6 +833,179 @@ static bool isDisabled(const struct Scene *UNUSED(scene), return false; } +static void panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *col; + uiLayout *layout = panel->layout; + + PointerRNA ptr; + PointerRNA ob_ptr; + modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr); + + uiLayoutSetPropSep(layout, true); + + uiItemR(layout, &ptr, "fit_type", 0, NULL, ICON_NONE); + + int fit_type = RNA_enum_get(&ptr, "fit_type"); + if (fit_type == MOD_ARR_FIXEDCOUNT) { + uiItemR(layout, &ptr, "count", 0, NULL, ICON_NONE); + } + else if (fit_type == MOD_ARR_FITLENGTH) { + uiItemR(layout, &ptr, "fit_length", 0, NULL, ICON_NONE); + } + else if (fit_type == MOD_ARR_FITCURVE) { + uiItemR(layout, &ptr, "curve", 0, NULL, ICON_NONE); + } + + uiItemS(layout); + + col = uiLayoutColumn(layout, false); + uiItemR(col, &ptr, "start_cap", 0, IFACE_("Cap Start"), ICON_NONE); + uiItemR(col, &ptr, "end_cap", 0, IFACE_("End"), ICON_NONE); + + modifier_panel_end(layout, &ptr); +} + +static void relative_offset_header_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + + PointerRNA ptr; + modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + uiItemR(layout, &ptr, "use_relative_offset", 0, NULL, ICON_NONE); +} + +static void relative_offset_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + + PointerRNA ptr; + 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_displace", 0, IFACE_("Factor"), ICON_NONE); +} + +static void constant_offset_header_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + + PointerRNA ptr; + modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + uiItemR(layout, &ptr, "use_constant_offset", 0, NULL, ICON_NONE); +} + +static void constant_offset_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + + PointerRNA ptr; + 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_displace", 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; + 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; + 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, IFACE_("Object"), ICON_NONE); +} + +static void symmetry_panel_header_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + + PointerRNA ptr; + modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + uiItemR(layout, &ptr, "use_merge_vertices", 0, IFACE_("Merge"), ICON_NONE); +} + +static void symmetry_panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + + PointerRNA ptr; + modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + uiLayoutSetPropSep(layout, true); + + uiLayout *col = uiLayoutColumn(layout, false); + uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_merge_vertices")); + uiItemR(col, &ptr, "merge_threshold", 0, IFACE_("Distance"), ICON_NONE); + uiItemR(col, &ptr, "use_merge_vertices_cap", 0, IFACE_("First and Last Copies"), ICON_NONE); +} + +static void uv_panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *col; + uiLayout *layout = panel->layout; + + PointerRNA ptr; + modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + uiLayoutSetPropSep(layout, true); + + col = uiLayoutColumn(layout, true); + uiItemR(col, &ptr, "offset_u", UI_ITEM_R_EXPAND, IFACE_("Offset U"), ICON_NONE); + uiItemR(col, &ptr, "offset_v", UI_ITEM_R_EXPAND, IFACE_("V"), ICON_NONE); +} + +static void panelRegister(ARegionType *region_type) +{ + PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Array, panel_draw); + modifier_subpanel_register(region_type, + "relative_offset", + "", + relative_offset_header_draw, + relative_offset_draw, + panel_type); + modifier_subpanel_register(region_type, + "constant_offset", + "", + constant_offset_header_draw, + constant_offset_draw, + panel_type); + modifier_subpanel_register( + region_type, "object_offset", "", object_offset_header_draw, object_offset_draw, panel_type); + modifier_subpanel_register( + region_type, "merge", "", symmetry_panel_header_draw, symmetry_panel_draw, panel_type); + modifier_subpanel_register(region_type, "uv", "UVs", NULL, uv_panel_draw, panel_type); +} + ModifierTypeInfo modifierType_Array = { /* name */ "Array", /* structName */ "ArrayModifierData", @@ -853,4 +1037,5 @@ ModifierTypeInfo modifierType_Array = { /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, /* freeRuntimeData */ NULL, + /* panelRegister */ panelRegister, }; |