Outliner: Object state filter invert toggle
This adds an invert toggle for the outliner object state filters. There are some cases where we want a filter for invertable states (Selected, Unselected) and having a single toggle to invert the filter reduces the number of separate filter types needed. This removes the "Hidden" filter which can now be replicated with an inverted "Visible" filter. Differential Revision: https://developer.blender.org/D9598
This commit is contained in:
parent
96995b2343
commit
2afdb4ba87
|
@ -372,10 +372,16 @@ class OUTLINER_PT_filter(Panel):
|
|||
row = col.row()
|
||||
row.label(icon='OUTLINER_COLLECTION')
|
||||
row.prop(space, "use_filter_collection", text="Collections")
|
||||
|
||||
row = col.row()
|
||||
row.label(icon='OBJECT_DATAMODE')
|
||||
row.prop(space, "use_filter_object", text="Objects")
|
||||
row = col.row(align=True)
|
||||
row.label(icon="BLANK1")
|
||||
row.prop(space, "filter_state", text="")
|
||||
sub = row.row(align=True)
|
||||
sub.enabled = space.filter_state != 'ALL'
|
||||
sub.prop(space, "filter_invert", text="", icon="ARROW_LEFTRIGHT")
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.active = space.use_filter_object
|
||||
|
|
|
@ -1166,5 +1166,20 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Replace object hidden filter with inverted object visible filter. */
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
|
||||
if (space->spacetype == SPACE_OUTLINER) {
|
||||
SpaceOutliner *space_outliner = (SpaceOutliner *)space;
|
||||
if (space_outliner->filter_state == SO_FILTER_OB_HIDDEN) {
|
||||
space_outliner->filter_state = SO_FILTER_OB_VISIBLE;
|
||||
space_outliner->filter |= SO_FILTER_OB_STATE_INVERSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1913,9 +1913,6 @@ static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner)
|
|||
case SO_FILTER_OB_VISIBLE:
|
||||
exclude_filter |= SO_FILTER_OB_STATE_VISIBLE;
|
||||
break;
|
||||
case SO_FILTER_OB_HIDDEN:
|
||||
exclude_filter |= SO_FILTER_OB_STATE_HIDDEN;
|
||||
break;
|
||||
case SO_FILTER_OB_SELECTED:
|
||||
exclude_filter |= SO_FILTER_OB_STATE_SELECTED;
|
||||
break;
|
||||
|
@ -1992,32 +1989,34 @@ static bool outliner_element_visible_get(ViewLayer *view_layer,
|
|||
}
|
||||
}
|
||||
|
||||
bool is_visible = true;
|
||||
if (exclude_filter & SO_FILTER_OB_STATE_VISIBLE) {
|
||||
if ((base->flag & BASE_VISIBLE_VIEWLAYER) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (exclude_filter & SO_FILTER_OB_STATE_HIDDEN) {
|
||||
if ((base->flag & BASE_VISIBLE_VIEWLAYER) != 0) {
|
||||
return false;
|
||||
is_visible = false;
|
||||
}
|
||||
}
|
||||
else if (exclude_filter & SO_FILTER_OB_STATE_SELECTED) {
|
||||
if ((base->flag & BASE_SELECTED) == 0) {
|
||||
return false;
|
||||
is_visible = false;
|
||||
}
|
||||
}
|
||||
else if (exclude_filter & SO_FILTER_OB_STATE_SELECTABLE) {
|
||||
if ((base->flag & BASE_SELECTABLE) == 0) {
|
||||
return false;
|
||||
is_visible = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLI_assert(exclude_filter & SO_FILTER_OB_STATE_ACTIVE);
|
||||
if (base != BASACT(view_layer)) {
|
||||
return false;
|
||||
is_visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (exclude_filter & SO_FILTER_OB_STATE_INVERSE) {
|
||||
is_visible = !is_visible;
|
||||
}
|
||||
|
||||
return is_visible;
|
||||
}
|
||||
|
||||
if ((te->parent != NULL) && (TREESTORE(te->parent)->type == 0) &&
|
||||
|
|
|
@ -316,9 +316,9 @@ typedef enum eSpaceOutliner_Filter {
|
|||
|
||||
SO_FILTER_OB_STATE_SELECTABLE = (1 << 12), /* Not set via DNA. */
|
||||
SO_FILTER_OB_STATE_VISIBLE = (1 << 13), /* Not set via DNA. */
|
||||
SO_FILTER_OB_STATE_HIDDEN = (1 << 14), /* Not set via DNA. */
|
||||
SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */
|
||||
SO_FILTER_OB_STATE_ACTIVE = (1 << 16), /* Not set via DNA. */
|
||||
SO_FILTER_OB_STATE_INVERSE = (1 << 14),
|
||||
SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */
|
||||
SO_FILTER_OB_STATE_ACTIVE = (1 << 16), /* Not set via DNA. */
|
||||
SO_FILTER_NO_COLLECTION = (1 << 17),
|
||||
|
||||
SO_FILTER_ID_TYPE = (1 << 18),
|
||||
|
@ -329,8 +329,8 @@ typedef enum eSpaceOutliner_Filter {
|
|||
SO_FILTER_NO_OB_LAMP | SO_FILTER_NO_OB_CAMERA | SO_FILTER_NO_OB_OTHERS)
|
||||
|
||||
#define SO_FILTER_OB_STATE \
|
||||
(SO_FILTER_OB_STATE_VISIBLE | SO_FILTER_OB_STATE_HIDDEN | SO_FILTER_OB_STATE_SELECTED | \
|
||||
SO_FILTER_OB_STATE_ACTIVE | SO_FILTER_OB_STATE_SELECTABLE)
|
||||
(SO_FILTER_OB_STATE_VISIBLE | SO_FILTER_OB_STATE_SELECTED | SO_FILTER_OB_STATE_ACTIVE | \
|
||||
SO_FILTER_OB_STATE_SELECTABLE)
|
||||
|
||||
#define SO_FILTER_ANY \
|
||||
(SO_FILTER_NO_OB_CONTENT | SO_FILTER_NO_CHILDREN | SO_FILTER_OB_TYPE | SO_FILTER_OB_STATE | \
|
||||
|
@ -340,7 +340,7 @@ typedef enum eSpaceOutliner_Filter {
|
|||
typedef enum eSpaceOutliner_StateFilter {
|
||||
SO_FILTER_OB_ALL = 0,
|
||||
SO_FILTER_OB_VISIBLE = 1,
|
||||
SO_FILTER_OB_HIDDEN = 2,
|
||||
SO_FILTER_OB_HIDDEN = 2, /* deprecated */
|
||||
SO_FILTER_OB_SELECTED = 3,
|
||||
SO_FILTER_OB_ACTIVE = 4,
|
||||
SO_FILTER_OB_SELECTABLE = 5,
|
||||
|
|
|
@ -3047,7 +3047,6 @@ static void rna_def_space_outliner(BlenderRNA *brna)
|
|||
static const EnumPropertyItem filter_state_items[] = {
|
||||
{SO_FILTER_OB_ALL, "ALL", 0, "All", "Show all objects in the view layer"},
|
||||
{SO_FILTER_OB_VISIBLE, "VISIBLE", 0, "Visible", "Show visible objects"},
|
||||
{SO_FILTER_OB_HIDDEN, "HIDDEN", 0, "Hidden", "Show hidden objects"},
|
||||
{SO_FILTER_OB_SELECTED, "SELECTED", 0, "Selected", "Show selected objects"},
|
||||
{SO_FILTER_OB_ACTIVE, "ACTIVE", 0, "Active", "Show only the active object"},
|
||||
{SO_FILTER_OB_SELECTABLE, "SELECTABLE", 0, "Selectable", "Show only selectable objects"},
|
||||
|
@ -3171,6 +3170,11 @@ static void rna_def_space_outliner(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Object State Filter", "");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "filter_invert", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", SO_FILTER_OB_STATE_INVERSE);
|
||||
RNA_def_property_ui_text(prop, "Invert", "Invert the object state filter");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
|
||||
|
||||
/* Filters object type. */
|
||||
prop = RNA_def_property(srna, "use_filter_object_mesh", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_OB_MESH);
|
||||
|
|
Loading…
Reference in New Issue