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:
authorCampbell Barton <ideasman42@gmail.com>2009-12-25 00:17:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-25 00:17:14 +0300
commit5f4e24d5990a7ecd6198ee394da8b7c07277cd91 (patch)
tree9a1909d90276f0243d50c6624da43c794cc52dad /source/blender
parent4b8bc301c62784d111f2cffcbc35cf9c6189e37b (diff)
operator draw function working again. needed to add layout to the operator to give access to "self.layout" - like panels, headers and manu's have
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_file/file_panels.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c7
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_wm.c21
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c12
-rw-r--r--source/blender/windowmanager/WM_types.h2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c21
7 files changed, 54 insertions, 14 deletions
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index fb52a36cdcf..4e731cda5f3 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -175,7 +175,9 @@ static void file_panel_operator(const bContext *C, Panel *pa)
int empty= 1, flag;
if(op->type->ui) {
- op->type->ui((bContext*)C, op, pa->layout);
+ op->layout= pa->layout;
+ op->type->ui((bContext*)C, op);
+ op->layout= NULL;
}
else {
RNA_STRUCT_BEGIN(op->ptr, prop) {
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index 5dbc6cc232c..0384a23579e 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -142,8 +142,11 @@ static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOper
}
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
- if(op->type->ui)
- op->type->ui((bContext*)C, op, pa->layout);
+ if(op->type->ui) {
+ op->layout= pa->layout;
+ op->type->ui((bContext*)C, op);
+ op->layout= NULL;
+ }
else
uiDefAutoButsRNA(C, pa->layout, &ptr, 1);
}
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 66b50fbad04..48d67714f15 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -279,6 +279,7 @@ typedef struct wmOperator {
ListBase macro; /* list of operators, can be a tree */
struct wmOperator *opm; /* current running macro, not saved */
+ struct uiLayout *layout; /* runtime for drawing */
short flag, pad[3];
} wmOperator;
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 51cd9d5d3ac..7abba3c004a 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -675,6 +675,21 @@ static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event)
return result;
}
+static void operator_draw(bContext *C, wmOperator *op)
+{
+ PointerRNA opr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
+ func= RNA_struct_find_function(&opr, "draw");
+
+ RNA_parameter_list_create(&list, &opr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ op->type->ext.call(&opr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
void operator_wrapper(wmOperatorType *ot, void *userdata);
@@ -686,7 +701,7 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
wmOperatorType dummyot = {0};
wmOperator dummyop= {0};
PointerRNA dummyotr;
- int have_function[3];
+ int have_function[4];
/* setup dummy operator & operator type to store static properties in */
dummyop.type= &dummyot;
@@ -737,6 +752,7 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
dummyot.pyop_poll= (have_function[0])? operator_poll: NULL;
dummyot.exec= (have_function[1])? operator_exec: NULL;
dummyot.invoke= (have_function[2])? operator_invoke: NULL;
+ dummyot.ui= (have_function[3])? operator_draw: NULL;
WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot);
@@ -778,6 +794,9 @@ static void rna_def_operator(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Properties", "");
RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL);
+ prop= RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "UILayout");
+
/* Registration */
prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "type->idname");
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index dcaff1a7c07..1afedf1c6a6 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -205,14 +205,14 @@ void RNA_api_operator(StructRNA *srna)
/* poll */
func= RNA_def_function(srna, "poll", NULL);
RNA_def_function_ui_description(func, "Test if the operator can be called or not.");
- RNA_def_function_flag(func, FUNC_REGISTER|FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
RNA_def_pointer(func, "context", "Context", "", "");
/* exec */
func= RNA_def_function(srna, "execute", NULL);
RNA_def_function_ui_description(func, "Execute the operator.");
- RNA_def_function_flag(func, FUNC_REGISTER);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
RNA_def_pointer(func, "context", "Context", "", "");
parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); // better name?
@@ -222,13 +222,19 @@ void RNA_api_operator(StructRNA *srna)
/* invoke */
func= RNA_def_function(srna, "invoke", NULL);
RNA_def_function_ui_description(func, "Invoke the operator.");
- RNA_def_function_flag(func, FUNC_REGISTER);
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
RNA_def_pointer(func, "context", "Context", "", "");
RNA_def_pointer(func, "event", "Event", "", "");
parm= RNA_def_enum(func, "result", operator_return_items, 0, "result", ""); // better name?
RNA_def_property_flag(parm, PROP_ENUM_FLAG);
RNA_def_function_return(func, parm);
+
+ /* draw */
+ func= RNA_def_function(srna, "draw", NULL);
+ RNA_def_function_ui_description(func, "Draw function for the operator.");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_pointer(func, "context", "Context", "", "");
}
void RNA_api_keyconfig(StructRNA *srna)
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index f0ccbed06c3..78125954816 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -383,7 +383,7 @@ typedef struct wmOperatorType {
int (*poll)(struct bContext *);
/* optional panel for redo and repeat, autogenerated if not set */
- void (*ui)(struct bContext *, struct wmOperator *, struct uiLayout *);
+ void (*ui)(struct bContext *, struct wmOperator *);
/* rna for properties */
struct StructRNA *srna;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 6d008d5cbb3..8a9fb1fa5b5 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -774,8 +774,11 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, 20, style);
uiItemL(layout, op->type->name, 0);
- if(op->type->ui)
- op->type->ui((bContext*)C, op, layout);
+ if(op->type->ui) {
+ op->layout= layout;
+ op->type->ui((bContext*)C, op);
+ op->layout= NULL;
+ }
else
uiDefAutoButsRNA(C, layout, &ptr, columns);
@@ -808,8 +811,11 @@ static uiBlock *wm_operator_create_ui(bContext *C, ARegion *ar, void *userData)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style);
- if(op->type->ui)
- op->type->ui((bContext*)C, op, layout);
+ if(op->type->ui) {
+ op->layout= layout;
+ op->type->ui((bContext*)C, op);
+ op->layout= NULL;
+ }
uiPopupBoundsBlock(block, 4.0f, 0, 0);
uiEndBlock(C, block);
@@ -862,8 +868,11 @@ static uiBlock *wm_block_create_menu(bContext *C, ARegion *ar, void *arg_op)
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style);
uiItemL(layout, op->type->name, 0);
- if(op->type->ui)
- op->type->ui(C, op, layout);
+ if(op->type->ui) {
+ op->layout= layout;
+ op->type->ui(C, op);
+ op->layout= NULL;
+ }
else
uiDefAutoButsRNA(C, layout, op->ptr, 2);