Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2012-12-28 13:20:16 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-12-28 13:20:16 +0400
commit7504cf34b470bec3b3fc7239d655738a09ed7624 (patch)
treeb811d07dc2b708163b2944bb7b3c4cc99aa588ed /release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
parent7730ddb3d6211a9c03e4b2eebedefcfb6f709891 (diff)
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels! This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore! To make all this work, other changes were also necessary: * Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox. * DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not. * UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon. * UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews). Note: not sure whether we should add that one to all UILayout's prop funcs? Note: will update addons using template list asap.
Diffstat (limited to 'release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py')
-rw-r--r--release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 1df2936b2d4..b102f1b09d0 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -18,13 +18,35 @@
# <pep8 compliant>
import bpy
-from bpy.types import Panel
+from bpy.types import Panel, UIList
from bl_ui.properties_physics_common import (point_cache_ui,
effector_weights_ui,
)
+class PHYSICS_UL_dynapaint_surfaces(UIList):
+ def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+ if not isinstance(item, bpy.types.DynamicPaintSurface):
+ return
+ surf = item
+ sticon = layout.enum_item_icon(surf, "surface_type", surf.surface_type)
+ if self.layout_type in {'DEFAULT', 'COMPACT'}:
+ row = layout.row(align=True)
+ row.label(text="", icon_value=icon)
+ row.label(text=surf.name, icon_value=sticon)
+ row = layout.row(align=True)
+ if surf.use_color_preview:
+ row.prop(surf, "show_preview", text="", emboss=False,
+ icon='RESTRICT_VIEW_OFF' if surf.show_preview else 'RESTRICT_VIEW_ON')
+ row.prop(surf, "is_active", text="")
+ elif self.layout_type in {'GRID'}:
+ layout.alignment = 'CENTER'
+ row = layout.row(align=True)
+ row.label(text="", icon_value=icon)
+ row.label(text="", icon_value=sticon)
+
+
class PhysicButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
@@ -58,7 +80,8 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
surface = canvas.canvas_surfaces.active
row = layout.row()
- row.template_list(canvas, "canvas_surfaces", canvas.canvas_surfaces, "active_index", rows=2)
+ row.template_list("PHYSICS_UL_dynapaint_surfaces", "", canvas, "canvas_surfaces",
+ canvas.canvas_surfaces, "active_index", rows=2)
col = row.column(align=True)
col.operator("dpaint.surface_slot_add", icon='ZOOMIN', text="")