forked from bartvdbraak/blender
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.
This commit is contained in:
parent
215ed84779
commit
f618bc5aca
@ -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:
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user