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:
authorBastien Montagne <montagne29@wanadoo.fr>2019-01-09 17:48:09 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-01-09 17:51:46 +0300
commit90e354fd7a6989f6d93309a2af68b8bdb60434fc (patch)
treebfcb60b294a1cf5a9699f16d8171723c63212a05 /source/blender/editors/interface
parent1c42f1c5ca52bedec9b016edcb5fc7ff75754509 (diff)
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...
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_templates.c31
1 files changed, 12 insertions, 19 deletions
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,