UI: Filter visible tabs in Properties Editor

This commit allows to specialize or optimize properties editor for
particular workflows by hiding individual tabs. The filtering is done on
editor level, currently in editor options popover panel.

Primary motivation was to allow strip properties to be moved to
properties editor. The filtering is beneficial, as usually it does not
make sense to show strip propeties in modelling workspace and in video
editing workspace other properties would introduce quite a bit of noise.

Ref. #115626

Pull Request: https://projects.blender.org/blender/blender/pulls/115624
This commit is contained in:
Richard Antalik
2025-04-08 18:43:18 +02:00
committed by Richard Antalik
parent 796e7edfce
commit bf18e8f814
10 changed files with 313 additions and 131 deletions

View File

@@ -10,6 +10,28 @@ from . import anim
class PROPERTIES_HT_header(Header):
bl_space_type = 'PROPERTIES'
@staticmethod
def _search_poll(space):
return (space.show_properties_tool or
space.show_properties_render or
space.show_properties_output or
space.show_properties_view_layer or
space.show_properties_scene or
space.show_properties_world or
space.show_properties_collection or
space.show_properties_object or
space.show_properties_modifiers or
space.show_properties_effects or
space.show_properties_particles or
space.show_properties_physics or
space.show_properties_constraints or
space.show_properties_data or
space.show_properties_bone or
space.show_properties_bone_constraints or
space.show_properties_material or
space.show_properties_texture
)
def draw(self, context):
layout = self.layout
view = context.space_data
@@ -20,16 +42,17 @@ class PROPERTIES_HT_header(Header):
layout.separator_spacer()
# The following is an ugly attempt to make the search button center-align better visually.
# A dummy icon is inserted that has to be scaled as the available width changes.
content_size_est = 160 * ui_scale
layout_scale = min(1, max(0, (region.width / content_size_est) - 1))
if layout_scale > 0:
row = layout.row()
row.scale_x = layout_scale
row.label(icon='BLANK1')
if self._search_poll(context.space_data):
# The following is an ugly attempt to make the search button center-align better visually.
# A dummy icon is inserted that has to be scaled as the available width changes.
content_size_est = 160 * ui_scale
layout_scale = min(1, max(0, (region.width / content_size_est) - 1))
if layout_scale > 0:
row = layout.row()
row.scale_x = layout_scale
row.label(icon='BLANK1')
layout.prop(view, "search_filter", icon='VIEWZOOM', text="")
layout.prop(view, "search_filter", icon='VIEWZOOM', text="")
layout.separator_spacer()
@@ -73,6 +96,30 @@ class PROPERTIES_PT_options(Panel):
col.label(text="Sync with Outliner")
col.row().prop(space, "outliner_sync", expand=True)
layout.separator()
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column(heading="Visible Tabs", align=True)
col.prop(space, "show_properties_tool")
col.prop(space, "show_properties_render")
col.prop(space, "show_properties_output")
col.prop(space, "show_properties_view_layer")
col.prop(space, "show_properties_scene")
col.prop(space, "show_properties_world")
col.prop(space, "show_properties_collection")
col.prop(space, "show_properties_object")
col.prop(space, "show_properties_modifiers")
col.prop(space, "show_properties_effects")
col.prop(space, "show_properties_particles")
col.prop(space, "show_properties_physics")
col.prop(space, "show_properties_constraints")
col.prop(space, "show_properties_data")
col.prop(space, "show_properties_bone")
col.prop(space, "show_properties_bone_constraints")
col.prop(space, "show_properties_material")
col.prop(space, "show_properties_texture")
class PropertiesAnimationMixin:
"""Mix-in class for Animation panels.

View File

@@ -27,7 +27,7 @@
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 18
#define BLENDER_FILE_SUBVERSION 19
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@@ -33,6 +33,7 @@
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_space_types.h"
#include "DNA_workspace_types.h"
#include "DNA_world_types.h"
@@ -6697,6 +6698,20 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 405, 19)) {
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_PROPERTIES) {
SpaceProperties *sbuts = reinterpret_cast<SpaceProperties *>(sl);
/* Translates to 0xFFFFFFFF, so other tabs can be added without versioning. */
sbuts->visible_tabs = uint(-1);
}
}
}
}
}
/* Always run this versioning; meshes are written with the legacy format which always needs to
* be converted to the new format on file load. Can be moved to a subversion check in a larger
* breaking release. */

View File

@@ -8,17 +8,24 @@
#pragma once
#include "BLI_vector.hh"
#include "DNA_space_types.h"
struct ScrArea;
struct SpaceProperties;
struct bContext;
struct PointerRNA;
struct uiLayout;
/**
* Fills an array with the tab context values for the properties editor. -1 signals a separator.
*
* \return The total number of items in the array returned.
*/
int ED_buttons_tabs_list(SpaceProperties *sbuts, short *context_tabs_array);
blender::Vector<eSpaceButtons_Context> ED_buttons_tabs_list(const SpaceProperties *sbuts,
bool apply_filter = true);
void ED_buttons_visible_tabs_menu(bContext *C, uiLayout *layout, void * /*arg*/);
bool ED_buttons_tab_has_search_result(SpaceProperties *sbuts, int index);
void ED_buttons_search_string_set(SpaceProperties *sbuts, const char *value);

View File

@@ -26,6 +26,7 @@
#include "BKE_screen.hh"
#include "ED_asset.hh"
#include "ED_buttons.hh"
#include "ED_keyframing.hh"
#include "ED_screen.hh"
@@ -1377,6 +1378,11 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
ICON_NONE,
ED_screens_region_flip_menu_create,
nullptr);
const ScrArea *area = CTX_wm_area(C);
if (area && area->spacetype == SPACE_PROPERTIES) {
uiItemMenuF(
layout, IFACE_("Visible Tabs"), ICON_NONE, ED_buttons_visible_tabs_menu, nullptr);
}
}
else if (region->regiontype == RGN_TYPE_FOOTER) {
uiItemMenuF(

View File

@@ -955,6 +955,11 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
const int start_size = block->buttons.size();
ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, icon_only);
if (block->buttons.is_empty()) {
return;
}
BLI_assert(start_size != block->buttons.size());
for (int i = start_size; i < block->buttons.size(); i++) {

View File

@@ -56,6 +56,7 @@
#include "ED_anim_api.hh"
#include "ED_armature.hh"
#include "ED_buttons.hh"
#include "ED_fileselect.hh"
#include "ED_image.hh"
#include "ED_keyframes_keylist.hh"
@@ -5243,6 +5244,11 @@ static wmOperatorStatus screen_context_menu_invoke(bContext *C,
uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Navigation Bar"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
ED_screens_region_flip_menu_create(C, layout, nullptr);
const ScrArea *area = CTX_wm_area(C);
if (area && area->spacetype == SPACE_PROPERTIES) {
uiItemMenuF(
layout, IFACE_("Visible Tabs"), ICON_NONE, ED_buttons_visible_tabs_menu, nullptr);
}
UI_popup_menu_end(C, pup);
}
}

View File

@@ -10,9 +10,15 @@
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_view2d_types.h"
#include "BLI_bitmap.h"
#include "BLI_listbase.h"
#include "BLI_span.hh"
#include "BLI_string.h"
#include "BLI_string_ref.hh"
#include "BLI_utildefines.h"
#include "BKE_context.hh"
@@ -32,8 +38,11 @@
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.hh"
#include "UI_interface.hh"
#include "UI_interface_c.hh"
#include "UI_view2d.hh"
#include "BLO_read_write.hh"
@@ -155,99 +164,88 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *region)
/** \name Property Editor Layout
* \{ */
int ED_buttons_tabs_list(SpaceProperties *sbuts, short *context_tabs_array)
void ED_buttons_visible_tabs_menu(bContext *C, uiLayout *layout, void * /*arg*/)
{
int length = 0;
if (sbuts->pathflag & (1 << BCONTEXT_TOOL)) {
context_tabs_array[length] = BCONTEXT_TOOL;
length++;
}
if (length != 0) {
context_tabs_array[length] = -1;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) {
context_tabs_array[length] = BCONTEXT_RENDER;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_OUTPUT)) {
context_tabs_array[length] = BCONTEXT_OUTPUT;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_VIEW_LAYER)) {
context_tabs_array[length] = BCONTEXT_VIEW_LAYER;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_SCENE)) {
context_tabs_array[length] = BCONTEXT_SCENE;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) {
context_tabs_array[length] = BCONTEXT_WORLD;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) {
if (length != 0) {
context_tabs_array[length] = -1;
length++;
}
context_tabs_array[length] = BCONTEXT_COLLECTION;
length++;
}
if (length != 0) {
context_tabs_array[length] = -1;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) {
context_tabs_array[length] = BCONTEXT_OBJECT;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_MODIFIER)) {
context_tabs_array[length] = BCONTEXT_MODIFIER;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_SHADERFX)) {
context_tabs_array[length] = BCONTEXT_SHADERFX;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_PARTICLE)) {
context_tabs_array[length] = BCONTEXT_PARTICLE;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_PHYSICS)) {
context_tabs_array[length] = BCONTEXT_PHYSICS;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_CONSTRAINT)) {
context_tabs_array[length] = BCONTEXT_CONSTRAINT;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_DATA)) {
context_tabs_array[length] = BCONTEXT_DATA;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_BONE)) {
context_tabs_array[length] = BCONTEXT_BONE;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_BONE_CONSTRAINT)) {
context_tabs_array[length] = BCONTEXT_BONE_CONSTRAINT;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_MATERIAL)) {
context_tabs_array[length] = BCONTEXT_MATERIAL;
length++;
}
if (length != 0) {
context_tabs_array[length] = -1;
length++;
}
if (sbuts->pathflag & (1 << BCONTEXT_TEXTURE)) {
context_tabs_array[length] = BCONTEXT_TEXTURE;
length++;
}
PointerRNA ptr = RNA_pointer_create_discrete(
reinterpret_cast<ID *>(CTX_wm_screen(C)), &RNA_SpaceProperties, CTX_wm_space_properties(C));
return length;
/* These can be reordered freely. */
constexpr std::array<blender::StringRefNull, BCONTEXT_TOT> filter_items = {
"show_properties_tool",
"show_properties_render",
"show_properties_output",
"show_properties_view_layer",
"show_properties_scene",
"show_properties_world",
"show_properties_collection",
"show_properties_object",
"show_properties_modifiers",
"show_properties_effects",
"show_properties_particles",
"show_properties_physics",
"show_properties_constraints",
"show_properties_data",
"show_properties_bone",
"show_properties_bone_constraints",
"show_properties_material",
"show_properties_texture",
};
for (blender::StringRefNull item : filter_items) {
uiItemR(layout, &ptr, item, UI_ITEM_R_TOGGLE, std::nullopt, ICON_NONE);
}
}
blender::Vector<eSpaceButtons_Context> ED_buttons_tabs_list(const SpaceProperties *sbuts,
bool apply_filter)
{
blender::Vector<eSpaceButtons_Context> tabs;
const int filter = sbuts->visible_tabs;
auto add_spacer = [&]() {
if (!tabs.is_empty() && tabs.last() != BCONTEXT_SEPARATOR) {
tabs.append(BCONTEXT_SEPARATOR);
}
};
auto add_tab = [&](eSpaceButtons_Context tab) {
if (sbuts->pathflag & (1 << tab) && (!apply_filter || filter & (1 << tab))) {
tabs.append(tab);
}
};
add_tab(BCONTEXT_TOOL);
add_spacer();
add_tab(BCONTEXT_RENDER);
add_tab(BCONTEXT_OUTPUT);
add_tab(BCONTEXT_VIEW_LAYER);
add_tab(BCONTEXT_SCENE);
add_tab(BCONTEXT_WORLD);
add_spacer();
add_tab(BCONTEXT_COLLECTION);
add_spacer();
add_tab(BCONTEXT_OBJECT);
add_tab(BCONTEXT_MODIFIER);
add_tab(BCONTEXT_SHADERFX);
add_tab(BCONTEXT_PARTICLE);
add_tab(BCONTEXT_PHYSICS);
add_tab(BCONTEXT_CONSTRAINT);
add_tab(BCONTEXT_DATA);
add_tab(BCONTEXT_BONE);
add_tab(BCONTEXT_BONE_CONSTRAINT);
add_tab(BCONTEXT_MATERIAL);
add_spacer();
add_tab(BCONTEXT_TEXTURE);
return tabs;
}
static const char *buttons_main_region_context_string(const short mainb)
@@ -355,14 +353,12 @@ static bool property_search_for_context(const bContext *C, ARegion *region, Spac
return false;
}
buttons_context_compute(C, sbuts);
return ED_region_property_search(
C, region, &region->runtime->type->paneltypes, contexts, nullptr);
}
static void property_search_move_to_next_tab_with_results(SpaceProperties *sbuts,
const short *context_tabs_array,
const int tabs_len)
static void property_search_move_to_next_tab_with_results(
SpaceProperties *sbuts, blender::Span<eSpaceButtons_Context> context_tabs_array)
{
/* As long as all-tab search in the tool is disabled in the tool context, don't move from it. */
if (sbuts->mainb == BCONTEXT_TOOL) {
@@ -370,7 +366,7 @@ static void property_search_move_to_next_tab_with_results(SpaceProperties *sbuts
}
int current_tab_index = 0;
for (int i = 0; i < tabs_len; i++) {
for (int i = 0; i < context_tabs_array.size(); i++) {
if (sbuts->mainb == context_tabs_array[i]) {
current_tab_index = i;
break;
@@ -378,7 +374,7 @@ static void property_search_move_to_next_tab_with_results(SpaceProperties *sbuts
}
/* Try the tabs after the current tab. */
for (int i = current_tab_index; i < tabs_len; i++) {
for (int i = current_tab_index; i < context_tabs_array.size(); i++) {
if (BLI_BITMAP_TEST(sbuts->runtime->tab_search_results, i)) {
sbuts->mainbuser = context_tabs_array[i];
return;
@@ -397,8 +393,7 @@ static void property_search_move_to_next_tab_with_results(SpaceProperties *sbuts
static void property_search_all_tabs(const bContext *C,
SpaceProperties *sbuts,
ARegion *region_original,
const short *context_tabs_array,
const int tabs_len)
blender::Span<eSpaceButtons_Context> context_tabs_array)
{
/* Use local copies of the area and duplicate the region as a mainly-paranoid protection
* against changing any of the space / region data while running the search. */
@@ -420,7 +415,7 @@ static void property_search_all_tabs(const bContext *C,
BLI_addtail(&area_copy.spacedata, &sbuts_copy);
/* Loop through the tabs added to the properties editor. */
for (int i = 0; i < tabs_len; i++) {
for (int i = 0; i < context_tabs_array.size(); i++) {
/* -1 corresponds to a spacer. */
if (context_tabs_array[i] == -1) {
continue;
@@ -458,10 +453,9 @@ static void buttons_main_region_property_search(const bContext *C,
ARegion *region)
{
/* Theoretical maximum of every context shown with a spacer between every tab. */
short context_tabs_array[BCONTEXT_TOT * 2];
int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
const blender::Vector<eSpaceButtons_Context> context_tabs_array = ED_buttons_tabs_list(sbuts);
property_search_all_tabs(C, sbuts, region, context_tabs_array, tabs_len);
property_search_all_tabs(C, sbuts, region, context_tabs_array);
/* Check whether the current tab has a search match. */
bool current_tab_has_search_match = false;
@@ -473,7 +467,7 @@ static void buttons_main_region_property_search(const bContext *C,
/* Find which index in the list the current tab corresponds to. */
int current_tab_index = -1;
for (int i = 0; i < tabs_len; i++) {
for (const int i : context_tabs_array.index_range()) {
if (context_tabs_array[i] == sbuts->mainb) {
current_tab_index = i;
}
@@ -487,7 +481,7 @@ static void buttons_main_region_property_search(const bContext *C,
/* Move to the next tab with a result */
if (!current_tab_has_search_match) {
if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
property_search_move_to_next_tab_with_results(sbuts, context_tabs_array, tabs_len);
property_search_move_to_next_tab_with_results(sbuts, context_tabs_array);
}
}
}
@@ -498,11 +492,74 @@ static void buttons_main_region_property_search(const bContext *C,
/** \name Main Region Layout and Listener
* \{ */
static eSpaceButtons_Context find_new_properties_tab(const SpaceProperties *sbuts, int iter_step)
{
using namespace blender;
const Vector<eSpaceButtons_Context> tabs_array_no_filter = ED_buttons_tabs_list(sbuts, false);
const Vector<eSpaceButtons_Context> tabs_array = ED_buttons_tabs_list(sbuts);
const int old_index = tabs_array_no_filter.first_index_of(eSpaceButtons_Context(sbuts->mainb));
/* Try to find next tab to switch to. */
eSpaceButtons_Context new_tab = BCONTEXT_SEPARATOR;
for (int i = old_index; i < tabs_array_no_filter.size(); i += iter_step) {
const eSpaceButtons_Context candidate_tab = tabs_array_no_filter[i];
if (candidate_tab == BCONTEXT_SEPARATOR) {
continue;
}
const int found_tab_index = tabs_array.first_index_of_try(candidate_tab);
if (found_tab_index != -1) {
new_tab = tabs_array[found_tab_index];
break;
}
}
return new_tab;
}
/* Change active tab, if it was hidden. */
static void buttons_apply_filter(SpaceProperties *sbuts)
{
const bool tab_was_hidden = ((1 << sbuts->mainb) & sbuts->visible_tabs) == 0;
if (!tab_was_hidden) {
return;
}
eSpaceButtons_Context new_tab = find_new_properties_tab(sbuts, +1);
/* Try to find previous tab to switch to. */
if (int(new_tab) == -1) {
new_tab = find_new_properties_tab(sbuts, -1);
}
if (int(new_tab) == -1) {
new_tab = eSpaceButtons_Context(1 << BCONTEXT_TOOL);
BLI_assert_unreachable();
}
sbuts->mainb = new_tab;
sbuts->mainbuser = new_tab;
}
static void buttons_main_region_layout(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */
SpaceProperties *sbuts = CTX_wm_space_properties(C);
/* Needed for RNA to get the good values! */
buttons_context_compute(C, sbuts);
if (ED_buttons_tabs_list(sbuts).is_empty()) {
View2D *v2d = UI_view2d_fromcontext(C);
v2d->scroll &= ~V2D_SCROLL_VERTICAL;
return;
}
buttons_apply_filter(sbuts);
if (sbuts->mainb == BCONTEXT_TOOL) {
ED_view3d_buttons_region_layout_ex(C, region, "Tool");
}

View File

@@ -182,9 +182,9 @@ typedef struct SpaceProperties {
/** Context tabs. */
short mainb, mainbo, mainbuser;
uint32_t visible_tabs;
/** Preview is signal to refresh. */
short preview;
char _pad[4];
char flag;
/* eSpaceButtons_OutlinerSync */
@@ -238,6 +238,7 @@ enum {
/** #SpaceProperties.mainb new */
typedef enum eSpaceButtons_Context {
BCONTEXT_SEPARATOR = -1,
BCONTEXT_RENDER = 0,
BCONTEXT_SCENE = 1,
BCONTEXT_WORLD = 2,

View File

@@ -9,6 +9,7 @@
#include <cstdlib>
#include <cstring>
#include "BLI_string_ref.hh"
#include "BLT_translation.hh"
#include "BKE_context.hh"
@@ -16,6 +17,7 @@
#include "BKE_movieclip.h"
#include "ED_asset.hh"
#include "ED_buttons.hh"
#include "BLI_string.h"
#include "BLI_sys_types.h"
@@ -468,7 +470,7 @@ const EnumPropertyItem rna_enum_clip_editor_mode_items[] = {
/* Actually populated dynamically through a function,
* but helps for context-less access (e.g. doc, i18n...). */
static const EnumPropertyItem buttons_context_items[] = {
const EnumPropertyItem buttons_context_items[] = {
{BCONTEXT_TOOL, "TOOL", ICON_TOOL_SETTINGS, "Tool", "Active Tool and Workspace settings"},
{BCONTEXT_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", "Scene Properties"},
{BCONTEXT_RENDER, "RENDER", ICON_SCENE, "Render", "Render Properties"},
@@ -548,6 +550,7 @@ static const EnumPropertyItem rna_enum_curve_display_handle_items[] = {
# include "DNA_sequence_types.h"
# include "DNA_userdef_types.h"
# include "BLI_index_range.hh"
# include "BLI_math_matrix.h"
# include "BLI_math_rotation.h"
# include "BLI_math_vector.h"
@@ -2076,14 +2079,12 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext * /*C*
/* Although it would never reach this amount, a theoretical maximum number of tabs
* is BCONTEXT_TOT * 2, with every tab displayed and a spacer in every other item. */
short context_tabs_array[BCONTEXT_TOT * 2];
int totitem = ED_buttons_tabs_list(sbuts, context_tabs_array);
BLI_assert(totitem <= ARRAY_SIZE(context_tabs_array));
const blender::Vector<eSpaceButtons_Context> context_tabs_array = ED_buttons_tabs_list(sbuts);
int totitem_added = 0;
bool add_separator = true;
for (int i = 0; i < totitem; i++) {
if (context_tabs_array[i] == -1) {
for (const eSpaceButtons_Context tab : context_tabs_array) {
if (tab == -1) {
if (add_separator) {
RNA_enum_item_add_separator(&item, &totitem_added);
add_separator = false;
@@ -2091,11 +2092,11 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext * /*C*
continue;
}
RNA_enum_items_add_value(&item, &totitem_added, buttons_context_items, context_tabs_array[i]);
RNA_enum_items_add_value(&item, &totitem_added, buttons_context_items, tab);
add_separator = true;
/* Add the object data icon dynamically for the data tab. */
if (context_tabs_array[i] == BCONTEXT_DATA) {
if (tab == BCONTEXT_DATA) {
(item + totitem_added - 1)->icon = sbuts->dataicon;
}
}
@@ -2122,10 +2123,9 @@ static int rna_SpaceProperties_tab_search_results_getlength(const PointerRNA *pt
{
SpaceProperties *sbuts = static_cast<SpaceProperties *>(ptr->data);
short context_tabs_array[BCONTEXT_TOT * 2]; /* Dummy variable. */
const int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
const blender::Vector<eSpaceButtons_Context> context_tabs_array = ED_buttons_tabs_list(sbuts);
length[0] = tabs_len;
length[0] = context_tabs_array.size();
return length[0];
}
@@ -2134,10 +2134,9 @@ static void rna_SpaceProperties_tab_search_results_get(PointerRNA *ptr, bool *va
{
SpaceProperties *sbuts = static_cast<SpaceProperties *>(ptr->data);
short context_tabs_array[BCONTEXT_TOT * 2]; /* Dummy variable. */
const int tabs_len = ED_buttons_tabs_list(sbuts, context_tabs_array);
const blender::Vector<eSpaceButtons_Context> context_tabs_array = ED_buttons_tabs_list(sbuts);
for (int i = 0; i < tabs_len; i++) {
for (const int i : context_tabs_array.index_range()) {
values[i] = ED_buttons_tab_has_search_result(sbuts, i);
}
}
@@ -5664,6 +5663,43 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_api_region_view3d(srna);
}
static void rna_def_space_properties_filter(StructRNA *srna)
{
/* Order must follow `buttons_context_items`. */
constexpr std::array<blender::StringRefNull, BCONTEXT_TOT> filter_items = {
"show_properties_tool",
"show_properties_scene",
"show_properties_render",
"show_properties_output",
"show_properties_view_layer",
"show_properties_world",
"show_properties_collection",
"show_properties_object",
"show_properties_constraints",
"show_properties_modifiers",
"show_properties_data",
"show_properties_bone",
"show_properties_bone_constraints",
"show_properties_material",
"show_properties_texture",
"show_properties_particles",
"show_properties_physics",
"show_properties_effects",
};
for (const int i : blender::IndexRange(BCONTEXT_TOT)) {
EnumPropertyItem item = buttons_context_items[i];
const int value = (1 << item.value);
blender::StringRefNull prop_name = filter_items[i];
PropertyRNA *prop = RNA_def_property(srna, prop_name.c_str(), PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "visible_tabs", value);
RNA_def_property_ui_text(prop, item.name, "");
RNA_def_property_update(
prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_context_update");
}
}
static void rna_def_space_properties(BlenderRNA *brna)
{
StructRNA *srna;
@@ -5702,6 +5738,8 @@ static void rna_def_space_properties(BlenderRNA *brna)
RNA_def_property_update(
prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_SpaceProperties_context_update");
rna_def_space_properties_filter(srna);
/* pinned data */
prop = RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, nullptr, "pinid");