[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20746] branches/blender2.5/blender: added layout attribute for setting the operator execution context.
Campbell Barton
ideasman42 at gmail.com
Tue Jun 9 12:30:12 CEST 2009
Revision: 20746
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20746
Author: campbellbarton
Date: 2009-06-09 12:30:11 +0200 (Tue, 09 Jun 2009)
Log Message:
-----------
added layout attribute for setting the operator execution context.
eg, layout.operator_context = 'INVOKE_REGION_WIN'
Needed to set the context that menu item operators are executed in.
fixed missing NULL check with anim system debug printing.
Modified Paths:
--------------
branches/blender2.5/blender/release/ui/space_sequencer.py
branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui.c
branches/blender2.5/blender/source/blender/windowmanager/WM_types.h
Modified: branches/blender2.5/blender/release/ui/space_sequencer.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_sequencer.py 2009-06-09 07:28:15 UTC (rev 20745)
+++ branches/blender2.5/blender/release/ui/space_sequencer.py 2009-06-09 10:30:11 UTC (rev 20746)
@@ -188,7 +188,7 @@
layout = self.layout
st = context.space_data
- # uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
+ layout.operator_context = 'INVOKE_REGION_WIN'
layout.column()
layout.item_enumO("TFM_OT_transform", "mode", 'TRANSLATION', text="Grab/Move")
Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-06-09 07:28:15 UTC (rev 20745)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-06-09 10:30:11 UTC (rev 20746)
@@ -1249,7 +1249,10 @@
}
else if (G.f & G_DEBUG) {
printf("ptr.data = %p, prop = %p,", ptr.data, prop);
- printf("animateable = %d \n", RNA_property_animateable(&ptr, prop));
+ if(prop)
+ printf("animateable = %d \n", RNA_property_animateable(&ptr, prop));
+ else
+ printf("animateable = NULL \n");
}
if (success) {
Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-06-09 07:28:15 UTC (rev 20745)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-06-09 10:30:11 UTC (rev 20746)
@@ -581,6 +581,8 @@
void uiLayoutSetScaleX(uiLayout *layout, float scale);
void uiLayoutSetScaleY(uiLayout *layout, float scale);
+
+int uiLayoutGetOperatorContext(uiLayout *layout);
int uiLayoutGetActive(uiLayout *layout);
int uiLayoutGetEnabled(uiLayout *layout);
int uiLayoutGetRedAlert(uiLayout *layout);
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-06-09 07:28:15 UTC (rev 20745)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-06-09 10:30:11 UTC (rev 20746)
@@ -1951,6 +1951,12 @@
return layout->root->block;
}
+int uiLayoutGetOperatorContext(uiLayout *layout)
+{
+ return layout->root->opcontext;
+}
+
+
void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout)
{
block->curlayout= layout;
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui.c 2009-06-09 07:28:15 UTC (rev 20745)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui.c 2009-06-09 10:30:11 UTC (rev 20746)
@@ -32,6 +32,8 @@
#include "UI_interface.h"
+#include "WM_types.h"
+
#ifdef RNA_RUNTIME
#include "MEM_guardedalloc.h"
@@ -47,7 +49,6 @@
#include "BKE_screen.h"
#include "WM_api.h"
-#include "WM_types.h"
static ARegionType *region_type_find(ReportList *reports, int space_type, int region_type)
{
@@ -418,6 +419,16 @@
return uiLayoutSetActive(ptr->data, value);
}
+static void rna_UILayout_op_context_set(struct PointerRNA *ptr, int value)
+{
+ return uiLayoutSetOperatorContext(ptr->data, value);
+}
+
+static int rna_UILayout_op_context_get(struct PointerRNA *ptr)
+{
+ return uiLayoutGetOperatorContext(ptr->data);
+}
+
static int rna_UILayout_enabled_get(struct PointerRNA *ptr)
{
return uiLayoutGetEnabled(ptr->data);
@@ -478,7 +489,7 @@
return uiLayoutSetScaleY(ptr->data, value);
}
-#else
+#else // RNA_RUNTIME
static void rna_def_ui_layout(BlenderRNA *brna)
{
@@ -491,6 +502,18 @@
{UI_LAYOUT_ALIGN_CENTER, "CENTER", "Center", ""},
{UI_LAYOUT_ALIGN_RIGHT, "RIGHT", "RIght", ""},
{0, NULL, NULL, NULL}};
+
+ /* see WM_types.h */
+ static EnumPropertyItem operator_context_items[] = {
+ {WM_OP_INVOKE_DEFAULT, "INVOKE_DEFAULT", "Invoke Default", ""},
+ {WM_OP_INVOKE_REGION_WIN, "INVOKE_REGION_WIN", "Invoke Region Window", ""},
+ {WM_OP_INVOKE_AREA, "INVOKE_AREA", "Invoke Area", ""},
+ {WM_OP_INVOKE_SCREEN, "INVOKE_SCREEN", "Invoke Screen", ""},
+ {WM_OP_EXEC_DEFAULT, "EXEC_DEFAULT", "Exec Default", ""},
+ {WM_OP_EXEC_REGION_WIN, "EXEC_REGION_WIN", "Exec Region Window", ""},
+ {WM_OP_EXEC_AREA, "EXEC_AREA", "Exec Area", ""},
+ {WM_OP_EXEC_SCREEN, "EXEC_SCREEN", "Exec Screen", ""},
+ {0, NULL, NULL, NULL}};
srna= RNA_def_struct(brna, "UILayout", NULL);
RNA_def_struct_sdna(srna, "uiLayout");
@@ -498,6 +521,10 @@
prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_active_get", "rna_UILayout_active_set");
+
+ prop= RNA_def_property(srna, "operator_context", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, operator_context_items);
+ RNA_def_property_enum_funcs(prop, "rna_UILayout_op_context_get", "rna_UILayout_op_context_set", NULL);
prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set");
@@ -661,5 +688,5 @@
rna_def_menu(brna);
}
-#endif
+#endif // RNA_RUNTIME
Modified: branches/blender2.5/blender/source/blender/windowmanager/WM_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/windowmanager/WM_types.h 2009-06-09 07:28:15 UTC (rev 20745)
+++ branches/blender2.5/blender/source/blender/windowmanager/WM_types.h 2009-06-09 10:30:11 UTC (rev 20746)
@@ -44,6 +44,7 @@
#define OPTYPE_UNDO 2
/* context to call operator in for WM_operator_name_call */
+/* rna_ui.c contains EnumPropertyItem's of these, keep in sync */
enum {
/* if there's invoke, call it, otherwise exec */
WM_OP_INVOKE_DEFAULT,
More information about the Bf-blender-cvs
mailing list