This patch enables property search for all tabs in the property editor. To make interaction faster, if the editor's current tab doesn't have a result, the current tab changes to the next tab that has a match. This patch implements basic code that only searches panels. While we could run the existing "single tab" property search for every tab, that would also do everything else related to the layout pass, which would be less efficient, and maybe more complicated to maintain. The search match status for every current tab of the property editor is stored in a runtime bitfield and them displayed later by dimming icons in the tab selector panel to the left. Using `BLI_bitmap` properly in the runtime struct required moving it to `buttons_intern.h` and adding a small API to access the search filter instead. To make sure the editor isn't influenced by anything that happens while building the layout for other tabs, most of the context is duplicated and the new search is run in the duplicated editor. Note that the tool settings tab works slightly different than the other tabs, so I've disabled searching it for this commit. That would be a relatively simple improvement, but would just require a bit of refactoring of existing code. Differential Revision: https://developer.blender.org/D8859
72 lines
2.1 KiB
Python
72 lines
2.1 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
|
|
if view.search_filter:
|
|
layout.prop_tabs_enum(view, "context", data_highlight=view,
|
|
property_highlight="tab_search_results", icon_only=True)
|
|
else:
|
|
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)
|