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/properties_data_gpencil.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py2
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py2
-rw-r--r--source/blender/blenkernel/BKE_screen.h2
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_templates.c31
-rw-r--r--source/blender/editors/space_node/drawnode.c4
-rw-r--r--source/blender/editors/space_node/node_buttons.c4
-rw-r--r--source/blender/makesdna/DNA_screen_types.h12
-rw-r--r--source/blender/makesrna/intern/rna_ui.c16
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c3
11 files changed, 43 insertions, 37 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index b6347afb13f..59e54a4c62d 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -133,7 +133,7 @@ class DATA_PT_gpencil_datapanel(Panel):
col = row.column()
layer_rows = 7
col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, "active_index",
- rows=layer_rows, reverse=True)
+ rows=layer_rows, sort_reverse=True, sort_lock=True)
gpl = context.active_gpencil_layer
if gpl:
diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index cefe6ca1a34..8a93014670a 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -728,7 +728,7 @@ class AnnotationDataPanel:
else:
layer_rows = 3
col.template_list("GPENCIL_UL_annotation_layer", "", gpd, "layers", gpd.layers, "active_index",
- rows=layer_rows, reverse=True)
+ rows=layer_rows, sort_reverse=True, sort_lock=True)
col = row.column()
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 75a6b6532e5..94965e5d03d 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -491,7 +491,7 @@ class TOPBAR_PT_gpencil_layers(Panel):
col = row.column()
layer_rows = 10
col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, "active_index",
- rows=layer_rows, reverse=True)
+ rows=layer_rows, sort_reverse=True, sort_lock=True)
gpl = context.active_gpencil_layer
if gpl:
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 75d2ed0d0bc..6b96703a344 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -238,7 +238,7 @@ typedef void (*uiListDrawItemFunc)(
/* Draw the filtering part of an uiList */
typedef void (*uiListDrawFilterFunc)(
- struct uiList *ui_list, struct bContext *C, struct uiLayout *layout, bool reverse);
+ struct uiList *ui_list, struct bContext *C, struct uiLayout *layout);
/* Filter items of an uiList */
typedef void (*uiListFilterItemsFunc)(
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 2e31a1a9ae5..d4d2adadbac 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1133,7 +1133,7 @@ void uiTemplateList(
uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id,
struct PointerRNA *dataptr, const char *propname, struct PointerRNA *active_dataptr,
const char *active_propname, const char *item_dyntip_propname,
- int rows, int maxrows, int layout_type, int columns, bool reverse);
+ int rows, int maxrows, int layout_type, int columns, bool sort_reverse, bool sort_lock);
void uiTemplateNodeLink(uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index f77a7dcdeb2..8b6339c73ca 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3573,7 +3573,7 @@ static void uilist_draw_item_default(
}
}
-static void uilist_draw_filter_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout, bool reverse)
+static void uilist_draw_filter_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout)
{
PointerRNA listptr;
uiLayout *row, *subrow;
@@ -3587,8 +3587,7 @@ static void uilist_draw_filter_default(struct uiList *ui_list, struct bContext *
uiItemR(subrow, &listptr, "use_filter_invert", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "",
(ui_list->filter_flag & UILST_FLT_EXCLUDE) ? ICON_ZOOM_OUT : ICON_ZOOM_IN);
- /* a reverse list, cannot sort or invert order in filter */
- if (!reverse) {
+ if ((ui_list->filter_sort_flag & UILST_FLT_SORT_LOCK) == 0) {
subrow = uiLayoutRow(row, true);
uiItemR(subrow, &listptr, "use_filter_sort_alpha", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
uiItemR(subrow, &listptr, "use_filter_sort_reverse", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "",
@@ -3617,7 +3616,7 @@ static void uilist_filter_items_default(
const char *filter_raw = ui_list->filter_byname;
char *filter = (char *)filter_raw, filter_buff[32], *filter_dyn = NULL;
const bool filter_exclude = (ui_list->filter_flag & UILST_FLT_EXCLUDE) != 0;
- const bool order_by_name = (ui_list->filter_sort_flag & UILST_FLT_SORT_ALPHA) != 0;
+ const bool order_by_name = (ui_list->filter_sort_flag & UILST_FLT_SORT_MASK) == UILST_FLT_SORT_ALPHA;
int len = RNA_property_collection_length(dataptr, prop);
dyn_data->items_shown = dyn_data->items_len = len;
@@ -3816,7 +3815,8 @@ static char *uilist_item_tooltip_func(bContext *UNUSED(C), void *argN, const cha
void uiTemplateList(
uiLayout *layout, bContext *C, const char *listtype_name, const char *list_id,
PointerRNA *dataptr, const char *propname, PointerRNA *active_dataptr, const char *active_propname,
- const char *item_dyntip_propname, int rows, int maxrows, int layout_type, int columns, bool reverse)
+ const char *item_dyntip_propname, int rows, int maxrows, int layout_type, int columns,
+ bool sort_reverse, bool sort_lock)
{
uiListType *ui_list_type;
uiList *ui_list = NULL;
@@ -3921,6 +3921,12 @@ void uiTemplateList(
BLI_strncpy(ui_list->list_id, ui_list_id, sizeof(ui_list->list_id));
BLI_addtail(&ar->ui_lists, ui_list);
ui_list->list_grip = -UI_LIST_AUTO_SIZE_THRESHOLD; /* Force auto size by default. */
+ if (sort_reverse) {
+ ui_list->filter_sort_flag |= UILST_FLT_SORT_REVERSE;
+ }
+ if (sort_lock) {
+ ui_list->filter_sort_flag |= UILST_FLT_SORT_LOCK;
+ }
}
if (!ui_list->dyn_data) {
@@ -3937,19 +3943,6 @@ void uiTemplateList(
MEM_SAFE_FREE(dyn_data->items_filter_neworder);
dyn_data->items_len = dyn_data->items_shown = -1;
- /* if reverse, enable reverse and forced flag */
- if (reverse) {
- ui_list->filter_sort_flag |= UILST_FLT_SORT_REVERSE;
- ui_list->filter_sort_flag |= UILST_FLT_FORCED_REVERSE;
- }
- else {
- /* if it was forced, disable forced flag to restore all normal behavior */
- if (ui_list->filter_sort_flag & UILST_FLT_FORCED_REVERSE) {
- ui_list->filter_sort_flag &= ~UILST_FLT_SORT_REVERSE;
- ui_list->filter_sort_flag &= ~UILST_FLT_FORCED_REVERSE;
- }
- }
-
/* When active item changed since last draw, scroll to it. */
if (activei != ui_list->list_last_activei) {
ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM;
@@ -4227,7 +4220,7 @@ void uiTemplateList(
subblock = uiLayoutGetBlock(col);
uiDefBut(subblock, UI_BTYPE_SEPR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y * 0.05f, NULL, 0.0, 0.0, 0, 0, "");
- draw_filter(ui_list, C, col, reverse);
+ draw_filter(ui_list, C, col);
}
else {
but = uiDefIconButBitI(subblock, UI_BTYPE_TOGGLE, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_RIGHT, 0, 0,
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index ec47d140193..38714c6bd4b 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -1795,13 +1795,13 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
/* using different collection properties if multilayer format is enabled */
if (multilayer) {
uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "layer_slots", ptr, "active_input_index",
- NULL, 0, 0, 0, 0, false);
+ NULL, 0, 0, 0, 0, false, false);
RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"),
active_index, &active_input_ptr);
}
else {
uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "file_slots", ptr, "active_input_index",
- NULL, 0, 0, 0, 0, false);
+ NULL, 0, 0, 0, 0, false, false);
RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"),
active_index, &active_input_ptr);
}
diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c
index 0a913bcbea8..59c5ced1cfd 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -150,14 +150,14 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa)
ot = WM_operatortype_find("NODE_OT_tree_socket_add", false);
uiItemL(col, IFACE_("Inputs:"), ICON_NONE);
uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "inputs", &ptr, "inputs", &ptr, "active_input",
- NULL, 0, 0, 0, 0, false);
+ NULL, 0, 0, 0, 0, false, false);
uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr);
RNA_enum_set(&opptr, "in_out", SOCK_IN);
col = uiLayoutColumn(split, true);
uiItemL(col, IFACE_("Outputs:"), ICON_NONE);
uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "outputs", &ptr, "outputs", &ptr, "active_output",
- NULL, 0, 0, 0, 0, false);
+ NULL, 0, 0, 0, 0, false, false);
uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr);
RNA_enum_set(&opptr, "in_out", SOCK_OUT);
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 85be6cac383..869f8c029a3 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -551,14 +551,18 @@ enum {
UILST_FLT_EXCLUDE = UILST_FLT_ITEM, /* Exclude filtered items, *must* use this same value. */
};
-/* uiList filter orderby type */
+/* uiList filter sort type */
enum {
- UILST_FLT_SORT_ALPHA = 1 << 0,
- UILST_FLT_FORCED_REVERSE = 1 << 1, /* Special flag to indicate reverse was set by external parameter */
+ /* Plain values (only one is valid at a time, once masked with UILST_FLT_SORT_MASK. */
+ UILST_FLT_SORT_INDEX = 0, /* Just for sake of consistency. */
+ UILST_FLT_SORT_ALPHA = 1,
+
+ /* Bitflags affecting behavior of any kind of sorting. */
+ UILST_FLT_SORT_LOCK = 1u << 30, /* Special flag to indicate that order is locked (not user-changeable). */
UILST_FLT_SORT_REVERSE = 1u << 31 /* Special value, bitflag used to reverse order! */
};
-#define UILST_FLT_SORT_MASK (((unsigned int)UILST_FLT_SORT_REVERSE) - 1)
+#define UILST_FLT_SORT_MASK (((unsigned int)(UILST_FLT_SORT_REVERSE | UILST_FLT_SORT_LOCK)) - 1)
/* regiontype, first two are the default set */
/* Do NOT change order, append on end. Types are hardcoded needed */
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index f51aad43f69..46b6fcf67d0 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -394,7 +394,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, bool reverse)
+static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout)
{
extern FunctionRNA rna_UIList_draw_filter_func;
@@ -408,7 +408,6 @@ static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout, b
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);
@@ -1297,6 +1296,12 @@ static void rna_def_uilist(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", UILST_FLT_EXCLUDE);
RNA_def_property_ui_text(prop, "Invert", "Invert filtering (show hidden items, and vice-versa)");
+ /* WARNING: This is sort of an abuse, sort-by-alpha is actually a value, should even be an enum in full logic
+ * (of two values, sort by index and sort by name).
+ * But for default UIList, it's nicer (better UI-wise) to show this as a boolean bit-flag option,
+ * avoids having to define custom setters/getters using UILST_FLT_SORT_MASK to mask out
+ * actual bitflags on same var, etc.
+ */
prop = RNA_def_property(srna, "use_filter_sort_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_ALPHA);
RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
@@ -1304,7 +1309,11 @@ static void rna_def_uilist(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_filter_sort_reverse", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_REVERSE);
- RNA_def_property_ui_text(prop, "Invert", "Invert the order of shown items");
+ RNA_def_property_ui_text(prop, "Reverse", "Reverse the order of shown items");
+
+ prop = RNA_def_property(srna, "use_filter_sort_lock", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_LOCK);
+ RNA_def_property_ui_text(prop, "Lock Order", "Lock the order of shown items (user cannot change it)");
/* draw_item */
func = RNA_def_function(srna, "draw_item", NULL);
@@ -1341,7 +1350,6 @@ 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);
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 0db0408d09f..4ab144996eb 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -1064,7 +1064,8 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Default maximum number of rows to display", 0, INT_MAX);
RNA_def_enum(func, "type", rna_enum_uilist_layout_type_items, UILST_LAYOUT_DEFAULT, "Type", "Type of layout to use");
RNA_def_int(func, "columns", 9, 0, INT_MAX, "", "Number of items to display per row, for GRID layout", 0, INT_MAX);
- RNA_def_boolean(func, "reverse", false, "", "Display items in reverse order");
+ RNA_def_boolean(func, "sort_reverse", false, "", "Display items in reverse order by default");
+ RNA_def_boolean(func, "sort_lock", false, "", "Lock display order to default value");
func = RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);