Files
blender/release/scripts/startup/bl_ui/properties_data_empty.py

113 lines
3.5 KiB
Python
Raw Normal View History

# ##### 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,
2010-02-12 13:34:04 +00:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
from bpy.types import Panel
2011-09-20 18:29:19 +00:00
class DataButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
@classmethod
def poll(cls, context):
ob = context.object
return (ob and ob.type == 'EMPTY')
class DATA_PT_empty(DataButtonsPanel, Panel):
bl_label = "Empty"
def draw(self, context):
layout = self.layout
layout.use_property_split = True
ob = context.object
layout.prop(ob, "empty_display_type", text="Display As")
layout.prop(ob, "empty_display_size", text="Size")
if ob.empty_display_type == 'IMAGE':
2018-07-06 10:01:05 +02:00
col = layout.column(align=True)
col.prop(ob, "empty_image_offset", text="Offset X", index=0)
col.prop(ob, "empty_image_offset", text="Y", index=1)
col = layout.column()
depth_row = col.row()
depth_row.enabled = not ob.show_in_front
depth_row.prop(ob, "empty_image_depth", text="Depth", expand=True)
col.row().prop(ob, "empty_image_side", text="Side", expand=True)
UI: Layout changes for new checkbox layout possibilities Follow-up to previous commit. Some examples: {F8473507} {F8473508} {F8473509} {F8473510} For more screenshots, please see D7430. We use column or row headings here to bring more structure, and to give the eye visual anchors which aid eye-scanning. The left-aligned checkboxes likewise help with this. And we keep the adherence to the center line, so the alignment matches up between the various buttons and controls. * Changes the property split percentage from 50/50% to 40/60%. This is needed to give enough space for the checkboxes. But in most cases this looks better anyway - see Transform panel. In some cases it simply fills out the available space more efficently. * Fix various hacks where we previously used manually defined splits. When we did this, the alignment was never quite right, and the layout code was a mess. * Adds column headings to many places where a list of checkboxes all share a common purpose or leading text. * Add checkbox + value configurations various places where a checkbox only serves to enable the value slider * Removes most uses of grid flow layout. The grid flow layouts combine poorly with column headings, and also they would mess alignment up badly. The grid flow layouts also often made buttons and controls jump around on the screen if you would just resize editors slightly, causing visual confusion, making users lose their place. The logic for at what time the list of items would re-flow was often flawed, jumping to multiple columns too fast or too late - and frankly, the grid flow layouts would often just look bad. Maniphest Task: https://developer.blender.org/T65965 Differential Revision: https://developer.blender.org/D7430 Reviewed by: Brecht Van Lommel, Pablo Vazquez. Most work here by William Reynish, few changes by Julian Eisel.
2020-04-17 16:54:03 +02:00
col = layout.column(heading="Show in", align=True)
col.prop(ob, "show_empty_image_orthographic", text="Orthographic")
col.prop(ob, "show_empty_image_perspective", text="Perspective")
col.prop(ob, "show_empty_image_only_axis_aligned", text="Only Axis Aligned")
class DATA_PT_empty_alpha(DataButtonsPanel, Panel):
bl_label = "Transparency"
bl_parent_id = "DATA_PT_empty"
@classmethod
def poll(cls, context):
ob = context.object
return (ob and ob.type == 'EMPTY' and ob.empty_display_type == 'IMAGE')
def draw_header(self, context):
ob = context.object
self.layout.prop(ob, "use_empty_image_alpha", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
ob = context.object
layout.active = ob.use_empty_image_alpha
layout.prop(ob, "color", text="Opacity", index=3, slider=True)
class DATA_PT_empty_image(DataButtonsPanel, Panel):
bl_label = "Image"
@classmethod
def poll(cls, context):
ob = context.object
return (ob and ob.type == 'EMPTY' and ob.empty_display_type == 'IMAGE')
def draw(self, context):
layout = self.layout
ob = context.object
2020-01-29 11:11:09 +11:00
layout.template_ID(ob, "data", open="image.open", unlink="object.unlink_data")
2019-05-22 00:27:01 +10:00
layout.separator()
layout.template_image(ob, "data", ob.image_user, compact=True)
classes = (
DATA_PT_empty,
DATA_PT_empty_alpha,
DATA_PT_empty_image,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)