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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-10-04 17:24:48 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-10-04 17:24:48 +0400
commitf618bc5aca23616cf22c0e9350ae3c2ee23acc5f (patch)
tree27289252456406cf1899c9a9efb545542b40fb65 /source/blender
parent215ed84779da71ab8c1c580766f1771617e4828d (diff)
Fix #28202: (only) modifying keymap item properties did not save properly, the
update signal for this was missing. Problem is that the operator properties RNA update callback doesn't know the associated keymap item, worked around it with UI template now.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/interface/interface_templates.c58
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c4
3 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index a5781ab7267..a06497889d9 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -749,6 +749,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
+void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, int rows, int maxrows, int type);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ff6ef41bfb0..4dcdeab2169 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2542,3 +2542,61 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
}
+/********************************* Keymap *************************************/
+
+static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused))
+{
+ wmKeyMapItem *kmi= (wmKeyMapItem*)kmi_p;
+ WM_keyconfig_update_tag(NULL, kmi);
+}
+
+static void template_keymap_item_properties(uiLayout *layout, const char *title, PointerRNA *ptr)
+{
+ uiLayout *flow;
+
+ uiItemS(layout);
+
+ if(title)
+ uiItemL(layout, title, ICON_NONE);
+
+ flow= uiLayoutColumnFlow(layout, 2, 0);
+
+ RNA_STRUCT_BEGIN(ptr, prop) {
+ int flag= RNA_property_flag(prop);
+
+ if(flag & PROP_HIDDEN)
+ continue;
+
+ /* recurse for nested properties */
+ if(RNA_property_type(prop) == PROP_POINTER) {
+ PointerRNA propptr= RNA_property_pointer_get(ptr, prop);
+ const char *name= RNA_property_ui_name(prop);
+
+ if(propptr.data && RNA_struct_is_a(propptr.type, &RNA_OperatorProperties)) {
+ template_keymap_item_properties(layout, name, &propptr);
+ continue;
+ }
+ }
+
+ /* add property */
+ uiItemR(flow, ptr, RNA_property_identifier(prop), 0, NULL, ICON_NONE);
+ }
+ RNA_STRUCT_END;
+}
+
+void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
+{
+ PointerRNA propptr= RNA_pointer_get(ptr, "properties");
+
+ if(propptr.data) {
+ uiBut *but= uiLayoutGetBlock(layout)->buttons.last;
+
+ template_keymap_item_properties(layout, NULL, &propptr);
+
+ /* attach callbacks to compensate for missing properties update,
+ we don't know which keymap (item) is being modified there */
+ for(; but; but=but->next)
+ uiButSetFunc(but, keymap_item_modified, ptr->data, NULL);
+ }
+}
+
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 85ad6b231aa..9e9e64a480d 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -428,6 +428,10 @@ void RNA_api_ui_layout(StructRNA *srna)
func= RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ func= RNA_def_function(srna, "template_keymap_item_properties", "uiTemplateKeymapItemProperties");
+ parm= RNA_def_pointer(func, "item", "KeyMapItem", "", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
+
func= RNA_def_function(srna, "introspect", "uiLayoutIntrospect");
parm= RNA_def_string(func, "string", "", 1024*1024, "Descr", "DESCR");
RNA_def_function_return(func, parm);