[Bf-blender-cvs] [fbfe7cc50a2] topbar: Cleanup: Use enum instead of char codes, naming

Julian Eisel noreply at git.blender.org
Sat Nov 18 05:33:28 CET 2017


Commit: fbfe7cc50a2f8b9aedce69cf456afb434bd50ff8
Author: Julian Eisel
Date:   Sat Nov 18 04:48:43 2017 +0100
Branches: topbar
https://developer.blender.org/rBfbfe7cc50a2f8b9aedce69cf456afb434bd50ff8

Cleanup: Use enum instead of char codes, naming

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

M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_utils.c
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/editors/object/object_data_transfer.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/screen/screendump.c
M	source/blender/editors/sound/sound_ops.c
M	source/blender/editors/space_clip/clip_toolbar.c
M	source/blender/editors/space_file/file_panels.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_sequencer/sequencer_add.c
M	source/blender/makesrna/intern/rna_ui_api.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 314826b0110..79b60d732fd 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -93,7 +93,7 @@ class TOPBAR_HT_lower_bar(Header):
         elif region.alignment == 'RIGHT':
             self.draw_right(context)
         else:
-            layout.template_operator_redo()
+            layout.template_operator_redo_props()
 
     def draw_left(self, context):
         layout = self.layout
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 7da472c6573..9107a5c3514 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1447,7 +1447,7 @@ static void gp_convert_ui(bContext *C, wmOperator *op)
 	RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
 	
 	/* Main auto-draw call */
-	uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, '\0', false);
+	uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
 }
 
 void GPENCIL_OT_convert(wmOperatorType *ot)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index c3e93df2b3a..0aa5c9a3fe6 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -688,11 +688,22 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, struct IDP
                            void *arg, int retval, int icon, int maxlen, int x, int y,
                            short width, short height, float a1, float a2, const char *tip);
 
+
+/* For uiDefAutoButsRNA */
+typedef enum {
+	/* Keep current layout for aligning label with property button. */
+	UI_BUT_LABEL_ALIGN_NONE,
+	/* Align label and property button vertically. */
+	UI_BUT_LABEL_ALIGN_COLUMN,
+	/* Split layout into a column for the label and one for property button. */
+	UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+} eButLabelAlign;
+
 uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2);
 int uiDefAutoButsRNA(
         uiLayout *layout, struct PointerRNA *ptr,
         bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
-        const char label_align, const bool compact);
+        eButLabelAlign label_align, const bool compact);
 
 /* Links
  *
@@ -956,7 +967,7 @@ void uiTemplateSearchPreview(
 void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, 
                            struct PointerRNA *root_ptr, const char *text);
 uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
-void uiTemplateOperatorRedo(uiLayout *layout, struct bContext *C);
+void uiTemplateOperatorRedoProperties(uiLayout *layout, struct bContext *C);
 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
 void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
                        struct MTex *slot, const char *preview_id);
@@ -983,9 +994,10 @@ void uiTemplateImageInfo(uiLayout *layout, struct bContext *C, struct Image *ima
 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
 void UI_but_func_operator_search(uiBut *but);
 void uiTemplateOperatorSearch(uiLayout *layout);
-void uiTemplateOperatorPropertyButs(const struct bContext *C, uiLayout *layout, struct wmOperator *op,
-                                    bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
-                                    const char label_align, const short flag);
+void 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(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/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 8dd39f84615..169964b9ccb 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1421,11 +1421,12 @@ static void template_operator_redo_property_buts_draw(
 		}
 	}
 	else {
-		uiTemplateOperatorPropertyButs(C, layout, op, NULL, '\0', layout_flags);
+		/* Might want to make label_align adjustable somehow. */
+		uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_NONE, layout_flags);
 	}
 }
 
-void uiTemplateOperatorRedo(uiLayout *layout, bContext *C)
+void uiTemplateOperatorRedoProperties(uiLayout *layout, bContext *C)
 {
 	wmOperator *op = WM_operator_last_redo(C);
 	uiBlock *block = uiLayoutGetBlock(layout);
@@ -3803,7 +3804,7 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt,
 void uiTemplateOperatorPropertyButs(
         const bContext *C, uiLayout *layout, wmOperator *op,
         bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
-        const char label_align, const short flag)
+        const eButLabelAlign label_align, const short flag)
 {
 	uiBlock *block = uiLayoutGetBlock(layout);
 
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index d199236af0d..19ebb16d985 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -160,51 +160,55 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
 int uiDefAutoButsRNA(
         uiLayout *layout, PointerRNA *ptr,
         bool (*check_prop)(PointerRNA *, PropertyRNA *),
-        const char label_align, const bool compact)
+        const eButLabelAlign label_align, const bool compact)
 {
 	uiLayout *split, *col;
 	int flag;
 	const char *name;
 	int tot = 0;
 
-	assert(ELEM(label_align, '\0', 'H', 'V'));
-
 	RNA_STRUCT_BEGIN (ptr, prop)
 	{
 		flag = RNA_property_flag(prop);
 		if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop) == 0))
 			continue;
 
-		if (label_align != '\0') {
-			PropertyType type = RNA_property_type(prop);
-			const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
+		switch (label_align) {
+			case UI_BUT_LABEL_ALIGN_COLUMN:
+			case UI_BUT_LABEL_ALIGN_SPLIT_COLUMN:
+			{
+				PropertyType type = RNA_property_type(prop);
+				const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
 
-			name = RNA_property_ui_name(prop);
+				name = RNA_property_ui_name(prop);
 
-			if (label_align == 'V') {
-				col = uiLayoutColumn(layout, true);
+				if (label_align == UI_BUT_LABEL_ALIGN_COLUMN) {
+					col = uiLayoutColumn(layout, true);
 
-				if (!is_boolean)
-					uiItemL(col, name, ICON_NONE);
-			}
-			else {  /* (label_align == 'H') */
-				BLI_assert(label_align == 'H');
-				split = uiLayoutSplit(layout, 0.5f, false);
+					if (!is_boolean)
+						uiItemL(col, name, ICON_NONE);
+				}
+				else {
+					BLI_assert(label_align == UI_BUT_LABEL_ALIGN_SPLIT_COLUMN);
+					split = uiLayoutSplit(layout, 0.5f, false);
 
-				col = uiLayoutColumn(split, false);
-				uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
-				col = uiLayoutColumn(split, false);
-			}
+					col = uiLayoutColumn(split, false);
+					uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
+					col = uiLayoutColumn(split, false);
+				}
 
-			/* may meed to add more cases here.
-			 * don't override enum flag names */
+				/* may meed to add more cases here.
+				 * don't override enum flag names */
 
-			/* name is shown above, empty name for button below */
-			name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
-		}
-		else {
-			col = layout;
-			name = NULL; /* no smart label alignment, show default name with button */
+				/* name is shown above, empty name for button below */
+				name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
+
+				break;
+			}
+			case UI_BUT_LABEL_ALIGN_NONE:
+				col = layout;
+				name = NULL; /* no smart label alignment, show default name with button */
+				break;
 		}
 
 		uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 246acf883b0..99eba96f2f8 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -5147,7 +5147,7 @@ static void edbm_sort_elements_ui(bContext *C, wmOperator *op)
 	RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
 
 	/* Main auto-draw call. */
-	uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, '\0', false);
+	uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
 }
 
 void MESH_OT_sort_elements(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 641a0f3cce6..96f14d182a4 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -531,7 +531,7 @@ static void data_transfer_ui(bContext *C, wmOperator *op)
 	RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
 
 	/* Main auto-draw call */
-	uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, '\0', false);
+	uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
 }
 
 /* transfers weight from active to selected */
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 4c73c882bb4..0ba32095b0b 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -976,7 +976,7 @@ static void parent_set_ui(bContext *C, w

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list