[Bf-blender-cvs] [68c96b8bb27] modifier-panels-ui: Add a modifier callback to register UI panels
Hans Goudey
noreply at git.blender.org
Sat Mar 28 05:38:12 CET 2020
Commit: 68c96b8bb2760baf7c3f9447b0a13080dc824ead
Author: Hans Goudey
Date: Fri Mar 27 23:12:11 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rB68c96b8bb2760baf7c3f9447b0a13080dc824ead
Add a modifier callback to register UI panels
The modifier UI is defined in each modifier file. This commit only
implements the callback for a few modifiers, with work in progress UI.
New common UI functions handle the common parts of registering panels
and retrieving modifier pointers from them.
===================================================================
M source/blender/blenkernel/BKE_modifier.h
M source/blender/editors/space_buttons/space_buttons.c
M source/blender/modifiers/CMakeLists.txt
M source/blender/modifiers/intern/MOD_array.c
M source/blender/modifiers/intern/MOD_bevel.c
M source/blender/modifiers/intern/MOD_boolean.c
M source/blender/modifiers/intern/MOD_datatransfer.c
A source/blender/modifiers/intern/MOD_ui_common.c
A source/blender/modifiers/intern/MOD_ui_common.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index c37e56149eb..33b73152d5f 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -28,6 +28,8 @@
extern "C" {
#endif
+struct ARegionType;
+struct bContext;
struct BMEditMesh;
struct CustomData_MeshMasks;
struct DepsNodeHandle;
@@ -38,8 +40,10 @@ struct Main;
struct Mesh;
struct ModifierData;
struct Object;
+struct PointerRNA;
struct Scene;
struct bArmature;
+struct uiLayout;
typedef enum {
/* Should not be used, only for None modifier type */
@@ -338,8 +342,13 @@ typedef struct ModifierTypeInfo {
* more like "ensure the data is freed".
*/
void (*freeRuntimeData)(void *runtime_data);
+
+ /* Define the modifier's UI panels. */
+ void (*panel)(struct ARegionType *region_type);
} ModifierTypeInfo;
+#define MODIFIER_TYPE_PANEL_PREFIX "MOD_PT_"
+
/* Initialize modifier's global data (type info and some common global storages). */
void BKE_modifier_init(void);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 2fd54db667b..12608d86bec 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -30,8 +30,11 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#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. */
@@ -632,6 +635,15 @@ void ED_spacetype_buttons(void)
#endif
BLI_addhead(&st->regiontypes, art);
+ /* Register the panel types from modifiers. The actual panels are built per modifier rather than
+ * per modifier type. */
+ for (int i = 0; i < NUM_MODIFIER_TYPES; i++) {
+ const ModifierTypeInfo *mti = modifierType_getInfo(i);
+ if (mti != NULL && mti->panel != NULL) {
+ mti->panel(art);
+ }
+ }
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
art->regionid = RGN_TYPE_HEADER;
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 48acbdc17f3..791c0199a3e 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -23,12 +23,15 @@ set(INC
intern
../blenfont
../blenkernel
+ ../blentranslation
../blenlib
../bmesh
../depsgraph
+ ../editors/include
../makesdna
../makesrna
../render/extern/include
+ ../windowmanager
../../../intern/eigen
../../../intern/guardedalloc
)
@@ -88,6 +91,7 @@ set(SRC
intern/MOD_surface.c
intern/MOD_surfacedeform.c
intern/MOD_triangulate.c
+ intern/MOD_ui_common.c
intern/MOD_util.c
intern/MOD_uvproject.c
intern/MOD_uvwarp.c
@@ -104,6 +108,7 @@ set(SRC
MOD_modifiertypes.h
intern/MOD_meshcache_util.h
intern/MOD_solidify_util.h
+ intern/MOD_ui_common.h
intern/MOD_util.h
intern/MOD_weightvg_util.h
)
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index ff5bf3d0ee4..35600535bc5 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"
@@ -792,6 +803,99 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
return false;
}
+static void panel_draw(const bContext *C, Panel *panel)
+{
+ uiLayout *sub, *row, *col, *split;
+
+ uiLayout *layout = panel->layout;
+ PointerRNA ptr;
+ PointerRNA ob_ptr;
+
+ modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
+
+ 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);
+
+ /* Column 1. */
+ split = uiLayoutSplit(layout, 0.5f, false);
+ col = uiLayoutColumn(split, false);
+ uiItemR(col, &ptr, "use_constant_offset", 0, NULL, ICON_NONE);
+ sub = uiLayoutColumn(col, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_constant_offset"));
+ uiItemR(sub, &ptr, "constant_offset_displace", 0, "", ICON_NONE);
+
+ /* Column 2. */
+ col = uiLayoutColumn(split, false);
+ uiItemR(col, &ptr, "use_relative_offset", 0, NULL, ICON_NONE);
+ sub = uiLayoutColumn(col, false);
+ uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_relative_offset"));
+ uiItemR(sub, &ptr, "relative_offset_displace", 0, "", ICON_NONE);
+
+ uiItemR(layout, &ptr, "use_object_offset", 0, NULL, ICON_NONE);
+ col = uiLayoutColumn(layout, false);
+ uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_object_offset"));
+ uiItemR(col, &ptr, "offset_object", 0, "", ICON_NONE);
+
+ /* Rows. */
+ uiItemL(layout, IFACE_("UV Offsets:"), ICON_NONE);
+ row = uiLayoutRow(layout, false);
+ sub = uiLayoutColumn(row, true);
+ uiItemR(sub, &ptr, "offset_u", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ uiItemR(sub, &ptr, "offset_v", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
+ uiItemS(layout);
+ uiItemR(layout, &ptr, "start_cap", 0, NULL, ICON_NONE);
+ uiItemR(layout, &ptr, "end_cap", 0, NULL, ICON_NONE);
+
+ modifier_panel_end(layout, &ptr);
+}
+
+static void array_merge_header_draw(const bContext *C, Panel *panel)
+{
+ PointerRNA ptr;
+ modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ uiLayout *layout = panel->layout;
+
+ uiItemR(layout, &ptr, "use_merge_vertices", 0, IFACE_("Merge"), ICON_NONE);
+}
+
+static void array_merge_panel_draw(const bContext *C, Panel *panel)
+{
+ PointerRNA ptr;
+ modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ uiLayout *layout = panel->layout;
+
+ uiItemR(layout, &ptr, "use_merge_vertices", 0, IFACE_("Merge"), ICON_NONE);
+ uiLayout *col = uiLayoutColumn(layout, false);
+ uiLayoutSetActive(col, RNA_boolean_get(&ptr, "use_merge_vertices"));
+ uiItemR(col, &ptr, "use_merge_vertices_cap", 0, IFACE_("First Last"), ICON_NONE);
+ uiItemR(col, &ptr, "merge_threshold", 0, IFACE_("Distance"), ICON_NONE);
+}
+
+static void panel(ARegionType *region_type)
+{
+ PanelType *panel_type = modifier_panel_register(region_type, "Array", panel_draw);
+ modifier_subpanel_register(region_type,
+ "array_merge",
+ "",
+ array_merge_header_draw,
+ array_merge_panel_draw,
+ false,
+ panel_type);
+}
+
ModifierTypeInfo modifierType_Array = {
/* name */ "Array",
/* structName */ "ArrayModifierData",
@@ -820,4 +924,5 @@ ModifierTypeInfo modifierType_Array = {
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
+ /* panel */ panel,
};
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index bd2f8a6dca3..99f2d604d70 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -27,16 +27,28 @@
#include "BLI_math.h"
+#include "BLT_translation.h"
+
#include "DNA_curveprofile_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_curveprofile.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
#include "BKE_modifier.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 "BKE_curveprofile.h"
@@ -263,6 +275,128 @@ static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED
return (bmd->value == 0.0f);
}
+static void panel_draw(const bContext *C, Panel *panel)
+{
+ uiLayout *sub, *row, *col, *split;
+
+ uiLayout *layout = panel->layout;
+ PointerRNA ptr;
+ PointerRNA ob_ptr;
+ modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
+
+ bool has_vertex_group = RNA_string_length(&ptr, "vertex_group") != 0;
+
+ col = uiLayoutColumn(layout, true);
+ const char *offset_name = "";
+ if (RNA_enum_get(&ptr, "offset_type") == BEVEL_AMT_PERCENT) {
+ uiItemR(col, &ptr, "width_pct", 0, NULL, ICON_NONE);
+ }
+ else {
+ switch (RNA_enum_get(&ptr, "offset_type")) {
+ case BEVEL_AMT_DEPTH:
+ offset_name = "Depth";
+ break;
+ case BEVEL_AMT_WIDTH:
+ offset_name = "Width";
+ break;
+ case BEVEL_AMT_OFFSET:
+ offset_name = "Offset";
+ break;
+ }
+ uiItemR(col, &ptr, "width", 0, IFACE_(offset_name), ICON_NONE);
+ }
+ row = uiLayoutRow(col, true);
+ uiItemR(row, &ptr, "offset_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ uiItemR(layout, &ptr, "segments", 0, NULL, ICON_NONE);
+
+ split = uiLayoutSplit(layout, 0.5f, true);
+ col = uiLayoutColumn(split, true);
+ uiItemR(col, &ptr, "use_only_vertices", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "use_clamp_overlap", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "loop_slide", 0, NULL, ICON_NONE);
+ col = uiLayoutColumn(split, true);
+ uiItemR(col, &ptr, "mark_seam", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "mark_sharp", 0, NULL, ICON_NONE);
+ uiItemR(col, &ptr, "harden_normals", 0, NULL, ICON_NONE);
+
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list