Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_layout.c42
-rw-r--r--source/blender/editors/interface/interface_utils.c46
2 files changed, 73 insertions, 15 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 5d9ebebe89d..a419fcfe40b 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2664,3 +2664,45 @@ const char *uiLayoutIntrospect(uiLayout *layout)
return str;
}
+
+/* this function does not initialize the layout, functions can be called on the layout before and after */
+void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,int (*check_prop)(struct PropertyRNA *), const char label_align, const short flag)
+{
+ if(!op->properties) {
+ IDPropertyTemplate val = {0};
+ op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
+ }
+
+ if(flag & UI_LAYOUT_OP_SHOW_TITLE) {
+ uiItemL(layout, op->type->name, 0);
+ }
+
+ /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
+ * just fails silently */
+ if(!WM_operator_repeat_check(C, op)) {
+ uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator cannot redo");
+ uiItemL(layout, "* Redo Unsupported *", 0); // XXX, could give some nicer feedback or not show redo panel at all?
+ }
+
+ if(op->type->ui) {
+ op->layout= layout;
+ op->type->ui((bContext*)C, op);
+ op->layout= NULL;
+
+ /* UI_LAYOUT_OP_SHOW_EMPTY ignored */
+ }
+ else {
+ wmWindowManager *wm= CTX_wm_manager(C);
+ PointerRNA ptr;
+ int empty;
+
+ RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
+
+ /* main draw call */
+ empty= uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
+
+ if(empty && (flag & UI_LAYOUT_OP_SHOW_EMPTY)) {
+ uiItemL(layout, "No Properties.", 0);
+ }
+ }
+}
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 7d3f186d490..b6afe6f63d4 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "DNA_object_types.h"
@@ -131,35 +132,50 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
return but;
}
-void uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int columns)
+int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(PropertyRNA *), const char label_align)
{
uiLayout *split, *col;
int flag;
- char *name;
+ const char *name;
+ int tot= 0;
+
+ assert(ELEM3(label_align, '\0', 'H', 'V'));
RNA_STRUCT_BEGIN(ptr, prop) {
flag= RNA_property_flag(prop);
- if(flag & PROP_HIDDEN)
+ if(flag & PROP_HIDDEN || (check_prop && check_prop(prop)==FALSE))
continue;
- name= (char*)RNA_property_ui_name(prop);
+ if(label_align != '\0') {
+ name= RNA_property_ui_name(prop);
- if(columns == 1) {
- col= uiLayoutColumn(layout, 1);
- uiItemL(col, name, 0);
- }
- else if(columns == 2) {
- split = uiLayoutSplit(layout, 0.5f, 0);
+ if(label_align=='V') {
+ col= uiLayoutColumn(layout, 1);
+ uiItemL(col, name, 0);
+ }
+ else if(label_align=='H') {
+ split = uiLayoutSplit(layout, 0.5f, 0);
- uiItemL(uiLayoutColumn(split, 0), name, 0);
- col= uiLayoutColumn(split, 0);
+ uiItemL(uiLayoutColumn(split, 0), name, 0);
+ col= uiLayoutColumn(split, 0);
+ }
+ else {
+ col= NULL;
+ }
+
+ name= ""; /* name is shown above, empty name for button below */
+ }
+ else {
+ col= layout;
+ name= NULL; /* no smart label alignment, show default name with button */
}
- else
- col= NULL;
- uiItemFullR(col, ptr, prop, -1, 0, 0, "", 0);
+ uiItemFullR(col, ptr, prop, -1, 0, 0, name, 0);
+ tot++;
}
RNA_STRUCT_END;
+
+ return tot;
}
/***************************** ID Utilities *******************************/