Files
blender/release/scripts/startup/bl_ui/space_properties.py
Hans Goudey 8bcdcab659 UI: Single tab property search
This adds a search bar to the properties editor. The full search for
every tab isn't included in this patch, but the interaction with
panels, searching behavior, UI, region level, and DNA changes are
included here.

The block-level search works by iterating over the block's button
groups and checking whether they match the search. If they do, they
are tagged with a flag, and the block's panel is tagged too. For
every update (text edit), the panel's expansion is set to whether
the panel has a result or not. The search also checks for matching
strings inside enums and in panel labels.

One complication to this that isn't immediately apparent is that
closed panel's subpanels have to be searched too. This adds some
complexity to the area-level panel layout code.

Possible Future Improvements:
 - Use the new fuzzy search in BLI
 - Reset panels to their expansion before the search started if
   the user escape out of the text box.
 - Open all child panels of a panel with expansion.

Differential Revision: https://developer.blender.org/D8856
2020-09-15 11:25:49 -05:00

68 lines
1.9 KiB
Python

# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
from bpy.types import Header, Panel
class PROPERTIES_HT_header(Header):
bl_space_type = 'PROPERTIES'
def draw(self, context):
layout = self.layout
view = context.space_data
layout.template_header()
layout.separator_spacer()
layout.prop(view, "search_filter", icon='VIEWZOOM', text="")
layout.separator_spacer()
row = layout.row()
row.emboss = 'NONE'
row.operator("buttons.toggle_pin", icon=('PINNED' if view.use_pin_id else 'UNPINNED'), text="")
class PROPERTIES_PT_navigation_bar(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'NAVIGATION_BAR'
bl_label = "Navigation Bar"
bl_options = {'HIDE_HEADER'}
def draw(self, context):
layout = self.layout
view = context.space_data
layout.scale_x = 1.4
layout.scale_y = 1.4
layout.prop_tabs_enum(view, "context", icon_only=True)
classes = (
PROPERTIES_HT_header,
PROPERTIES_PT_navigation_bar,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)