[Bf-blender-cvs] [c052346fbf0] blender2.8: UI: move object selector into 3D view

Campbell Barton noreply at git.blender.org
Tue May 1 22:35:15 CEST 2018


Commit: c052346fbf0e3bdfdd9dd48669985ea065e07185
Author: Campbell Barton
Date:   Tue May 1 20:12:06 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc052346fbf0e3bdfdd9dd48669985ea065e07185

UI: move object selector into 3D view

This matches the new convention for left-handed mode selectors,
however we're still undecided on exactly how this should work.

For now test this out as a convention for all space types.

===================================================================

M	release/scripts/startup/bl_ui/space_topbar.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/space_view3d/view3d_header.c
M	source/blender/makesrna/intern/rna_ui_api.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 0189f9fc100..dad13ce9f1e 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -117,13 +117,12 @@ class TOPBAR_HT_lower_bar(Header):
         # Object Mode
         # -----------
 
+        # Testing move to 3D header.
+        '''
         object_mode = 'OBJECT' if object is None else object.mode
         act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[object_mode]
         layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
-
-    def draw_center(self, context):
-        layout = self.layout
-        mode = context.mode
+        '''
 
         # Active Tool
         # -----------
@@ -131,6 +130,10 @@ class TOPBAR_HT_lower_bar(Header):
         from .space_toolsystem_common import ToolSelectPanelHelper
         ToolSelectPanelHelper.draw_active_tool_header(context, layout)
 
+    def draw_center(self, context):
+        layout = self.layout
+        mode = context.mode
+
         layout.separator()
 
         # Object Mode Options
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 23ae4118a57..089e83c9aab 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -42,6 +42,13 @@ class VIEW3D_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
+        mode = 'OBJECT' if obj is None else obj.mode
+        act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[mode]
+        layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
+        del act_mode_item
+
+        layout.template_header_3D_mode()
+
         VIEW3D_MT_editor_menus.draw_collapsible(context, layout)
 
         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
@@ -52,7 +59,9 @@ class VIEW3D_HT_header(Header):
         layout.template_header_3D()
 
         if obj:
-            mode = obj.mode
+            # Set above:
+            # mode = obj.mode
+
             # Particle edit
             if mode == 'PARTICLE_EDIT':
                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 20c4552e6b2..33dc12f83aa 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1031,6 +1031,7 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs(
         const struct bContext *C, uiLayout *layout, struct wmOperator *op,
         bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
         const eButLabelAlign label_align, const short flag);
+void uiTemplateHeader3D_mode(uiLayout *layout, struct bContext *C);
 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
 void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 8f6f0b70fdc..52a8562b6ba 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -274,6 +274,47 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
 	}
 }
 
+static void uiTemplatePaintModeSelection(uiLayout *layout, struct bContext *C)
+{
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	Object *ob = OBACT(view_layer);
+
+	/* Manipulators aren't used in paint modes */
+	if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) {
+		/* masks aren't used for sculpt and particle painting */
+		PointerRNA meshptr;
+
+		RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
+		if (ob->mode & (OB_MODE_TEXTURE_PAINT)) {
+			uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
+		}
+		else {
+			uiLayout *row = uiLayoutRow(layout, true);
+			uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
+			uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
+		}
+	}
+}
+
+void uiTemplateHeader3D_mode(uiLayout *layout, struct bContext *C)
+{
+	/* Extracted from: uiTemplateHeader3D */
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	Object *ob = OBACT(view_layer);
+	Object *obedit = CTX_data_edit_object(C);
+	bGPdata *gpd = CTX_data_gpencil_data(C);
+
+	bool is_paint = (
+	        ob && !(gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
+	        ELEM(ob->mode,
+	             OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT));
+
+	uiTemplateEditModeSelection(layout, C);
+	if ((obedit == NULL) && is_paint) {
+		uiTemplatePaintModeSelection(layout, C);
+	}
+}
+
 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 {
 	bScreen *screen = CTX_wm_screen(C);
@@ -310,21 +351,11 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 	}
 
 	if (obedit == NULL && is_paint) {
-		/* Manipulators aren't used in paint modes */
-		if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) {
-			/* masks aren't used for sculpt and particle painting */
-			PointerRNA meshptr;
-
-			RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
-			if (ob->mode & (OB_MODE_TEXTURE_PAINT)) {
-				uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-			}
-			else {
-				row = uiLayoutRow(layout, true);
-				uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-				uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
-			}
-		}
+		/* Currently Python calls this directly. */
+#if 0
+		uiTemplatePaintModeSelection(layout, C);
+#endif
+
 	}
 	else {
 		/* Transform widget / manipulators */
@@ -337,6 +368,9 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 		/* Scene lock */
 		uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
 	}
-	
+
+	/* Currently Python calls this directly. */
+#if 0
 	uiTemplateEditModeSelection(layout, C);
+#endif
 }
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index eb23f624438..cb72e237577 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -982,6 +982,9 @@ void RNA_api_ui_layout(StructRNA *srna)
 	RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 	RNA_def_function_ui_description(func, "Inserts common 3DView header UI (selectors for context mode, shading, etc.)");
 
+	func = RNA_def_function(srna, "template_header_3D_mode", "uiTemplateHeader3D_mode");
+	RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+	RNA_def_function_ui_description(func, "");
 
 	func = RNA_def_function(srna, "template_edit_mode_selection", "uiTemplateEditModeSelection");
 	RNA_def_function_flag(func, FUNC_USE_CONTEXT);



More information about the Bf-blender-cvs mailing list