2023-08-16 00:20:26 +10:00
|
|
|
# SPDX-FileCopyrightText: 2009-2023 Blender Authors
|
2023-06-15 13:09:04 +10:00
|
|
|
#
|
2022-02-11 09:07:11 +11:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2023-06-15 13:09:04 +10:00
|
|
|
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
from bpy.types import Header, Panel
|
2024-07-30 11:59:54 +02:00
|
|
|
from rna_prop_ui import PropertyPanel
|
2025-05-04 13:26:03 +02:00
|
|
|
from bl_ui import anim
|
2013-06-19 19:37:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class PROPERTIES_HT_header(Header):
|
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
|
|
2025-04-08 18:43:18 +02:00
|
|
|
@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
|
|
|
|
|
)
|
|
|
|
|
|
2020-09-15 09:50:14 -05:00
|
|
|
def draw(self, context):
|
2013-06-19 19:37:17 +00:00
|
|
|
layout = self.layout
|
2020-09-15 09:50:14 -05:00
|
|
|
view = context.space_data
|
2020-10-21 17:11:56 +02:00
|
|
|
region = context.region
|
|
|
|
|
ui_scale = context.preferences.system.ui_scale
|
2013-06-19 19:37:17 +00:00
|
|
|
|
2019-04-21 04:49:19 +10:00
|
|
|
layout.template_header()
|
2018-05-31 21:45:26 +02:00
|
|
|
|
2020-09-15 09:50:14 -05:00
|
|
|
layout.separator_spacer()
|
|
|
|
|
|
2025-04-08 18:43:18 +02:00
|
|
|
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')
|
2020-10-21 17:11:56 +02:00
|
|
|
|
2025-04-08 18:43:18 +02:00
|
|
|
layout.prop(view, "search_filter", icon='VIEWZOOM', text="")
|
2020-09-15 11:25:49 -05:00
|
|
|
|
|
|
|
|
layout.separator_spacer()
|
|
|
|
|
|
2020-12-21 14:27:09 -07:00
|
|
|
layout.popover(panel="PROPERTIES_PT_options", text="")
|
|
|
|
|
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
|
|
|
|
|
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
|
2020-10-13 13:10:41 -05:00
|
|
|
if view.search_filter:
|
2020-12-16 18:02:40 +11:00
|
|
|
layout.prop_tabs_enum(
|
|
|
|
|
view, "context", data_highlight=view,
|
|
|
|
|
property_highlight="tab_search_results", icon_only=True,
|
|
|
|
|
)
|
2020-10-13 13:10:41 -05:00
|
|
|
else:
|
|
|
|
|
layout.prop_tabs_enum(view, "context", icon_only=True)
|
2013-06-19 19:37:17 +00:00
|
|
|
|
|
|
|
|
|
2020-12-21 14:27:09 -07:00
|
|
|
class PROPERTIES_PT_options(Panel):
|
2021-02-16 09:38:42 -05:00
|
|
|
"""Show options for the properties editor"""
|
2020-12-21 14:27:09 -07:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
|
bl_region_type = 'HEADER'
|
2021-02-16 09:38:42 -05:00
|
|
|
bl_label = "Options"
|
2020-12-21 14:27:09 -07:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
space = context.space_data
|
|
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
col.label(text="Sync with Outliner")
|
|
|
|
|
col.row().prop(space, "outliner_sync", expand=True)
|
|
|
|
|
|
2025-04-08 18:43:18 +02:00
|
|
|
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")
|
|
|
|
|
|
2020-12-21 14:27:09 -07:00
|
|
|
|
2024-07-30 11:59:54 +02:00
|
|
|
class PropertiesAnimationMixin:
|
|
|
|
|
"""Mix-in class for Animation panels.
|
|
|
|
|
|
|
|
|
|
This class can be used to show a generic 'Animation' panel for IDs shown in
|
|
|
|
|
the properties editor. Specific ID types need specific subclasses.
|
|
|
|
|
|
|
|
|
|
For an example, see DATA_PT_camera_animation in properties_data_camera.py
|
|
|
|
|
"""
|
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
|
bl_context = "data"
|
|
|
|
|
bl_label = "Animation"
|
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
bl_order = PropertyPanel.bl_order - 1 # Order just above the Custom Properties.
|
|
|
|
|
|
|
|
|
|
_animated_id_context_property = ""
|
|
|
|
|
"""context.{_animatable_id_context_property} is used to find the animated ID."""
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def _animated_id(cls, context):
|
2024-10-02 15:42:47 +10:00
|
|
|
assert cls._animated_id_context_property, "set _animated_id_context_property on {!r}".format(cls)
|
2024-07-30 11:59:54 +02:00
|
|
|
|
|
|
|
|
# If the pinned ID is of a different type, there could still be a an ID
|
|
|
|
|
# for which to show this panel. For example, a camera object can be
|
|
|
|
|
# pinned, and then this panel can be shown for its camera data.
|
|
|
|
|
return getattr(context, cls._animated_id_context_property, None)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
animated_id = cls._animated_id(context)
|
|
|
|
|
return animated_id is not None
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
col = layout.column(align=True)
|
|
|
|
|
col.use_property_split = True
|
2024-09-27 16:29:32 +02:00
|
|
|
col.use_property_decorate = False
|
2024-07-30 11:59:54 +02:00
|
|
|
self.draw_action_and_slot_selector(context, col, self._animated_id(context))
|
|
|
|
|
|
2024-09-05 12:11:35 +02:00
|
|
|
@classmethod
|
|
|
|
|
def draw_action_and_slot_selector(cls, context, layout, animated_id):
|
|
|
|
|
if not animated_id:
|
|
|
|
|
class_list = [c.__name__ for c in cls.mro()]
|
|
|
|
|
print("PropertiesAnimationMixin: no animatable data-block, this is a bug "
|
2024-10-01 10:13:40 +10:00
|
|
|
"in one of these classes: {!r}".format(class_list))
|
2024-10-16 14:45:08 +11:00
|
|
|
layout.label(text="No animatable data-block, please report as bug", icon='ERROR')
|
2024-09-05 12:11:35 +02:00
|
|
|
return
|
|
|
|
|
|
2025-01-21 15:12:59 +01:00
|
|
|
anim.draw_action_and_slot_selector_for_id(layout, animated_id)
|
2024-07-30 11:59:54 +02:00
|
|
|
|
|
|
|
|
|
2017-03-18 20:03:24 +11:00
|
|
|
classes = (
|
|
|
|
|
PROPERTIES_HT_header,
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
PROPERTIES_PT_navigation_bar,
|
2020-12-21 14:27:09 -07:00
|
|
|
PROPERTIES_PT_options,
|
2017-03-18 20:03:24 +11:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|