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:
-rw-r--r--release/scripts/startup/bl_ui/space_userpref_keymap.py17
-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
4 files changed, 64 insertions, 16 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py
index 25f955085f6..c2e3a145f36 100644
--- a/release/scripts/startup/bl_ui/space_userpref_keymap.py
+++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py
@@ -121,19 +121,6 @@ class InputKeyMapPanel:
for entry in children:
self.draw_entry(display_keymaps, entry, col, level + 1)
- @staticmethod
- def draw_kmi_properties(box, properties, title=None):
- box.separator()
- if title:
- box.label(text=title)
- flow = box.column_flow(columns=2)
- for pname, value in properties.bl_rna.properties.items():
- if pname != "rna_type" and not properties.is_property_hidden(pname):
- if isinstance(value, OperatorProperties):
- InputKeyMapPanel.draw_kmi_properties(box, value, title=pname)
- else:
- flow.prop(properties, pname)
-
def draw_kmi(self, display_keymaps, kc, km, kmi, layout, level):
map_type = kmi.map_type
@@ -218,9 +205,7 @@ class InputKeyMapPanel:
subrow.prop(kmi, "key_modifier", text="", event=True)
# Operator properties
- props = kmi.properties
- if props is not None:
- InputKeyMapPanel.draw_kmi_properties(box, props)
+ box.template_keymap_item_properties(kmi)
# Modal key maps attached to this operator
if not km.is_modal:
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);