[Bf-blender-cvs] [90e354fd7a6] master: Revert/Redo ugly rBd12b3767f81d commit (i.e. add locked sorting option to UIList).

Bastien Montagne noreply at git.blender.org
Wed Jan 9 15:52:20 CET 2019


Commit: 90e354fd7a6989f6d93309a2af68b8bdb60434fc
Author: Bastien Montagne
Date:   Wed Jan 9 15:48:09 2019 +0100
Branches: master
https://developer.blender.org/rB90e354fd7a6989f6d93309a2af68b8bdb60434fc

Revert/Redo ugly rBd12b3767f81d commit (i.e. add locked sorting option to UIList).

Too many things done wrong in original rBd12b3767f81d to list them all
here, hopefully nothing bad sneaked in again this time :|

Also cleaned up a little the 'sort by name', even though (since we only
have two options by default, sort by index and by name) we can abuse it
as a binary option for now, this is not a bitflag...

===================================================================

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/blenkernel/BKE_screen.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_node/node_buttons.c
M	source/blender/makesdna/DNA_screen_types.h
M	source/blender/makesrna/intern/rna_ui.c
M	source/blender/makesrna/intern/rna_ui_api.c

===================================================================

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 --g

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list