[Bf-blender-cvs] [2a3758f305f] blender2.8: Physics Dynamic Paint: Use Grid Flow, sub-panels layout

Vuk Gardaáević noreply at git.blender.org
Fri Aug 17 12:05:54 CEST 2018


Commit: 2a3758f305fdbffd40737a5750539da3afcea5f9
Author: Vuk Gardašević
Date:   Fri Aug 17 12:03:39 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2a3758f305fdbffd40737a5750539da3afcea5f9

Physics Dynamic Paint: Use Grid Flow, sub-panels layout

See D3611

===================================================================

M	release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index 3a475c82f5c..9d52232e10c 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -17,9 +17,12 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
-import bpy
-from bpy.types import Panel, UIList
 
+import bpy
+from bpy.types import (
+    Panel,
+    UIList,
+)
 from .properties_physics_common import (
     point_cache_ui,
     effector_weights_ui,
@@ -31,15 +34,20 @@ class PHYSICS_UL_dynapaint_surfaces(UIList):
         # assert(isinstance(item, bpy.types.DynamicPaintSurface)
         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.prop(surf, "name", text="", emboss=False, 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, "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 == 'GRID':
             layout.alignment = 'CENTER'
             row = layout.row(align=True)
@@ -52,73 +60,148 @@ class PhysicButtonsPanel:
     bl_region_type = 'WINDOW'
     bl_context = "physics"
 
-    @classmethod
-    def poll(cls, context):
+    def poll_dyn_paint(context):
         ob = context.object
-        return (ob and ob.type == 'MESH') and context.engine in cls.COMPAT_ENGINES and context.dynamic_paint
+        return (ob and ob.type == 'MESH') and context.dynamic_paint
+
+    def poll_dyn_canvas(context):
+        if not PhysicButtonsPanel.poll_dyn_paint(context):
+            return False
+
+        md = context.dynamic_paint
+        return (md and md.ui_type == 'CANVAS' and md.canvas_settings and md.canvas_settings.canvas_surfaces.active)
+
+    def poll_dyn_canvas_paint(context):
+        if not PhysicButtonsPanel.poll_dyn_canvas(context):
+            return False
+
+        surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
+        return (surface.surface_type == 'PAINT')
+
+    def poll_dyn_canvas_brush(context):
+        if not PhysicButtonsPanel.poll_dyn_paint(context):
+            return False
+
+        md = context.dynamic_paint
+        return (md and md.ui_type == 'BRUSH' and md.brush_settings)
+
+    def poll_dyn_output(context):
+        if not PhysicButtonsPanel.poll_dyn_canvas(context):
+            return False
+
+        surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
+        return (not (surface.surface_format == 'VERTEX' and (surface.surface_type in {'DISPLACE', 'WAVE'})))
+
+    def poll_dyn_output_maps(context):
+        if not PhysicButtonsPanel.poll_dyn_output(context):
+            return False
+
+        surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
+        return (surface.surface_format == 'IMAGE' and surface.surface_type == 'PAINT')
 
 
 class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel):
     bl_label = "Dynamic Paint"
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
 
+    @classmethod
+    def poll(cls, context):
+        if not PhysicButtonsPanel.poll_dyn_paint(context):
+            return False
+
+        return (context.engine in cls.COMPAT_ENGINES)
+
     def draw(self, context):
         layout = self.layout
+        layout.use_property_split = True
 
         md = context.dynamic_paint
 
-        layout.row().prop(md, "ui_type", expand=True)
+        layout.prop(md, "ui_type")
+
+
+class PHYSICS_PT_dynamic_paint_settings(PhysicButtonsPanel, Panel):
+    bl_label = "Settings"
+    bl_parent_id = 'PHYSICS_PT_dynamic_paint'
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+
+    @classmethod
+    def poll(cls, context):
+        if not PhysicButtonsPanel.poll_dyn_paint(context):
+            return False
+
+        return (context.engine in cls.COMPAT_ENGINES)
+
+    def draw(self, context):
+        layout = self.layout
+
+        md = context.dynamic_paint
 
         if md.ui_type == 'CANVAS':
             canvas = md.canvas_settings
 
             if canvas is None:
                 layout.operator("dpaint.type_toggle", text="Add Canvas").type = 'CANVAS'
-            else:
-                layout.operator("dpaint.type_toggle", text="Remove Canvas", icon='X').type = 'CANVAS'
+                return  # do nothing.
 
-                surface = canvas.canvas_surfaces.active
+            layout.operator("dpaint.type_toggle", text="Remove Canvas", icon='X').type = 'CANVAS'
 
-                row = layout.row()
-                row.template_list("PHYSICS_UL_dynapaint_surfaces", "", canvas, "canvas_surfaces",
-                                  canvas.canvas_surfaces, "active_index", rows=1)
+            surface = canvas.canvas_surfaces.active
+
+            row = layout.row()
+            row.template_list(
+                "PHYSICS_UL_dynapaint_surfaces", "", canvas, "canvas_surfaces",
+                canvas.canvas_surfaces, "active_index", rows=1
+            )
 
-                col = row.column(align=True)
-                col.operator("dpaint.surface_slot_add", icon='ZOOMIN', text="")
-                col.operator("dpaint.surface_slot_remove", icon='ZOOMOUT', text="")
+            col = row.column(align=True)
+            col.operator("dpaint.surface_slot_add", icon='ZOOMIN', text="")
+            col.operator("dpaint.surface_slot_remove", icon='ZOOMOUT', text="")
+
+            layout.separator()
 
-                layout.use_property_split = True
+            layout.use_property_split = True
 
-                if surface:
-                    layout.prop(surface, "surface_format")
+            if surface:
+                flow = layout.grid_flow(
+                    row_major=True, columns=0, even_columns=True, even_rows=False, align=False
+                )
+                col = flow.column()
 
-                    col = layout.column()
-                    if surface.surface_format != 'VERTEX':
-                        col.prop(surface, "image_resolution")
-                    col.prop(surface, "use_antialiasing")
+                col.prop(surface, "surface_format")
 
-                    sub = col.column(align=True)
-                    sub.prop(surface, "frame_start", text="Frame Start")
-                    sub.prop(surface, "frame_end", text="End")
+                if surface.surface_format != 'VERTEX':
+                    col.prop(surface, "image_resolution")
+                col.prop(surface, "use_antialiasing")
 
-                    col.prop(surface, "frame_substeps")
+                col = flow.column(align=True)
+                col.prop(surface, "frame_start", text="Frame Start")
+                col.prop(surface, "frame_end", text="End")
+
+                col.prop(surface, "frame_substeps")
 
         elif md.ui_type == 'BRUSH':
             brush = md.brush_settings
 
             if brush is None:
                 layout.operator("dpaint.type_toggle", text="Add Brush").type = 'BRUSH'
-            else:
-                layout.operator("dpaint.type_toggle", text="Remove Brush", icon='X').type = 'BRUSH'
+                return  # do nothing.
+
+            layout.operator("dpaint.type_toggle", text="Remove Brush", icon='X').type = 'BRUSH'
 
-                layout.use_property_split = True
+            layout.use_property_split = True
 
-                col = layout.column()
-                col.prop(brush, "paint_color")
-                col.prop(brush, "paint_alpha", text="Alpha", slider=True)
-                col.prop(brush, "paint_wetness", text="Wetness", slider=True)
-                col.prop(brush, "use_absolute_alpha")
-                col.prop(brush, "use_paint_erase")
+            flow = layout.grid_flow(
+                row_major=True, columns=0, even_columns=True, even_rows=False, align=False
+            )
+            col = flow.column()
+            col.prop(brush, "paint_color")
+            col.prop(brush, "paint_alpha", text="Alpha", slider=True)
+
+            col = flow.column()
+            col.prop(brush, "paint_wetness", text="Wetness", slider=True)
+            col.prop(brush, "use_absolute_alpha")
+            col.prop(brush, "use_paint_erase")
 
 
 class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
@@ -128,46 +211,59 @@ class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
-        md = context.dynamic_paint
-        return md and md.ui_type == 'CANVAS' and md.canvas_settings and md.canvas_settings.canvas_surfaces.active and context.engine in cls.COMPAT_ENGINES
+        if not PhysicButtonsPanel.poll_dyn_canvas(context):
+            return False
+
+        return (context.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
+        layout.use_property_split = True
 
         canvas = context.dynamic_paint.canvas_settings
         surface = canvas.canvas_surfaces.active
         surface_type = surface.surface_type
 
-        layout.use_property_split = True
-
         layout.prop(surface, "surface_type")
 
         layout.separator()
 
-        col = layout.column()
+        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
 
         # per type settings
         if surface_type == 'DISPLACE':
-            col.prop(surface, "use_incremental_displace")
+            col = flow.column()
+
             if surface.surface_format == 'VERTEX':
                 col.prop(surface, "depth_clamp")
                 col.prop(surface, "displace_factor")
 
+            col.prop(surface, "use_incre

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list