From d12b3767f81d62a802411a42037d580a98923349 Mon Sep 17 00:00:00 2001 From: Antonioya Date: Thu, 11 Oct 2018 17:47:46 +0200 Subject: Add new parameter to reverse UIList items Now, it was possible to invert the order of the UIlist using the filter, but it was impossible to know if the list was inverted or not. The problem with this is that any other element depending of this value could not be adjusted. See https://devtalk.blender.org/t/how-to-access-uilist-properties/2268 The new parameter allows to set the reverse order by default. When the list is set as reverse, it cannot be inverted again, so the invert button is removed of the filter. This change is needed to fix a requested feature for Grease Pencil (T56985) and because a lot of 2D softwares use the drawing layers in the inverse order used in Blender. --- source/blender/makesrna/intern/rna_ui.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/makesrna/intern/rna_ui.c') diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 333181b3593..0756d5e39ee 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -378,7 +378,7 @@ static void uilist_draw_item(uiList *ui_list, bContext *C, uiLayout *layout, Poi RNA_parameter_list_free(&list); } -static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout) +static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout, bool reverse) { extern FunctionRNA rna_UIList_draw_filter_func; @@ -392,6 +392,7 @@ static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout) RNA_parameter_list_create(&list, &ul_ptr, func); RNA_parameter_set_lookup(&list, "context", &C); RNA_parameter_set_lookup(&list, "layout", &layout); + RNA_parameter_set_lookup(&list, "reverse", &reverse); ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list); RNA_parameter_list_free(&list); @@ -1307,6 +1308,7 @@ static void rna_def_uilist(BlenderRNA *brna) RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + RNA_def_boolean(func, "reverse", false, "", "Display items in reverse order"); /* filter */ func = RNA_def_function(srna, "filter_items", NULL); -- cgit v1.2.3