[Bf-blender-cvs] [5ea28551cb3] vr_scene_inspection: Refactor sharing of 3D View Shading layout
Julian Eisel
noreply at git.blender.org
Fri Mar 13 12:29:04 CET 2020
Commit: 5ea28551cb3750cebc1e343577343a8e6ecb9675
Author: Julian Eisel
Date: Fri Mar 13 12:19:05 2020 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB5ea28551cb3750cebc1e343577343a8e6ecb9675
Refactor sharing of 3D View Shading layout
===================================================================
M release/scripts/startup/bl_ui/properties_render.py
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/utils.py
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index faf42805f93..80a278b1562 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -19,14 +19,13 @@
# <pep8 compliant>
from bpy.types import Panel
-from bl_ui.space_view3d import (
- VIEW3D_PT_shading,
- VIEW3D_PT_shading_lighting,
- VIEW3D_PT_shading_color,
- VIEW3D_PT_shading_options,
-)
from bl_ui.properties_grease_pencil_common import GreasePencilSimplifyPanel
+from bl_ui.utils import (
+ View3DShadingLightingLayout,
+ View3DShadingColorLayout,
+ View3DShadingOptionsLayout,
+)
class RenderButtonsPanel:
@@ -580,7 +579,7 @@ class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
- bl_label = "Lighting"
+ bl_label = View3DShadingLightingLayout.bl_label
COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
@@ -588,11 +587,12 @@ class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
- VIEW3D_PT_shading_lighting.draw(self, context)
+ shading = context.scene.display.shading
+ View3DShadingLightingLayout.draw(context, shading, self.layout)
class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
- bl_label = "Color"
+ bl_label = View3DShadingLightingLayout.bl_label
COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
@@ -600,12 +600,12 @@ class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
- shading = VIEW3D_PT_shading.get_shading(context)
- VIEW3D_PT_shading_color._draw_color_type(self.layout, shading)
+ shading = context.scene.display.shading
+ View3DShadingColorLayout._draw_color_type(shading, self.layout)
class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
- bl_label = "Options"
+ bl_label = View3DShadingOptionsLayout.bl_label
COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
@@ -613,7 +613,8 @@ class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
- VIEW3D_PT_shading_options.draw(self, context)
+ shading = context.scene.display.shading
+ View3DShadingOptionsLayout.draw(context, shading, self.layout)
class RENDER_PT_simplify(RenderButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 7e20231bf29..f168320fe72 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -36,6 +36,13 @@ from bl_ui.properties_grease_pencil_common import (
from bl_ui.space_toolsystem_common import (
ToolActivePanelHelper,
)
+from bl_ui.utils import (
+ View3DShadingLayout,
+ View3DShadingLightingLayout,
+ View3DShadingColorLayout,
+ View3DShadingOptionsLayout,
+ View3DShadingRenderPassLayout,
+)
from bpy.app.translations import contexts as i18n_contexts
@@ -5461,286 +5468,59 @@ class VIEW3D_PT_object_type_visibility(Panel):
class VIEW3D_PT_shading(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = "Shading"
+ bl_label = View3DShadingLayout.bl_label
bl_ui_units_x = 12
- @classmethod
- def get_shading(cls, context, shading=None):
- if shading:
- return shading
-
- # Get settings from 3D viewport or OpenGL render engine
- view = context.space_data
- if view.type == 'VIEW_3D':
- return view.shading
- else:
- return context.scene.display.shading
-
def draw(self, _context):
- layout = self.layout
- layout.label(text="Viewport Shading")
+ View3DShadingLayout.draw(self.layout)
class VIEW3D_PT_shading_lighting(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = "Lighting"
+ bl_label = View3DShadingLightingLayout.bl_label
bl_parent_id = 'VIEW3D_PT_shading'
@classmethod
def poll(cls, context):
- return cls.poll_ex(context)
+ shading = context.space_data.shading
+ return View3DShadingLightingLayout.poll(context, shading)
def draw(self, context):
- VIEW3D_PT_shading_lighting.draw_ex(self, context)
-
- @classmethod
- def poll_ex(cls, context, opt_shading=None):
- shading = VIEW3D_PT_shading.get_shading(context, opt_shading)
- engine = context.scene.render.engine
- return shading.type in {'SOLID', 'MATERIAL'} or engine == 'BLENDER_EEVEE' and shading.type == 'RENDERED'
-
- @staticmethod
- def draw_ex(self, context, opt_shading=None):
- layout = self.layout
- shading = VIEW3D_PT_shading.get_shading(context, opt_shading)
-
- col = layout.column()
- split = col.split(factor=0.9)
-
- if shading.type == 'SOLID':
- split.row().prop(shading, "light", expand=True)
- col = split.column()
-
- split = layout.split(factor=0.9)
- col = split.column()
- sub = col.row()
-
- if shading.light == 'STUDIO':
- prefs = context.preferences
- system = prefs.system
-
- if not system.use_studio_light_edit:
- sub.scale_y = 0.6 # smaller studiolight preview
- sub.template_icon_view(shading, "studio_light", scale_popup=3.0)
- else:
- sub.prop(
- system,
- "use_studio_light_edit",
- text="Disable Studio Light Edit",
- icon='NONE',
- toggle=True,
- )
-
- col = split.column()
- col.operator("preferences.studiolight_show", emboss=False, text="", icon='PREFERENCES')
-
- split = layout.split(factor=0.9)
- col = split.column()
-
- row = col.row()
- row.prop(shading, "use_world_space_lighting", text="", icon='WORLD', toggle=True)
- row = row.row()
- row.active = shading.use_world_space_lighting
- row.prop(shading, "studiolight_rotate_z", text="Rotation")
- col = split.column() # to align properly with above
-
- elif shading.light == 'MATCAP':
- sub.scale_y = 0.6 # smaller matcap preview
- sub.template_icon_view(shading, "studio_light", scale_popup=3.0)
-
- col = split.column()
- col.operator("preferences.studiolight_show", emboss=False, text="", icon='PREFERENCES')
- col.operator("view3d.toggle_matcap_flip", emboss=False, text="", icon='ARROW_LEFTRIGHT')
-
- elif shading.type == 'MATERIAL':
- col.prop(shading, "use_scene_lights")
- col.prop(shading, "use_scene_world")
- col = layout.column()
- split = col.split(factor=0.9)
-
- if not shading.use_scene_world:
- col = split.column()
- sub = col.row()
- sub.scale_y = 0.6
- sub.template_icon_view(shading, "studio_light", scale_popup=3)
-
- col = split.column()
- col.operator("preferences.studiolight_show", emboss=False, text="", icon='PREFERENCES')
-
- split = layout.split(factor=0.9)
- col = split.column()
- col.prop(shading, "studiolight_rotate_z", text="Rotation")
- col.prop(shading, "studiolight_intensity")
- col.prop(shading, "studiolight_background_alpha")
- col.prop(shading, "studiolight_background_blur")
- col = split.column() # to align properly with above
-
- elif shading.type == 'RENDERED':
- col.prop(shading, "use_scene_lights_render")
- col.prop(shading, "use_scene_world_render")
-
- if not shading.use_scene_world_render:
- col = layout.column()
- split = col.split(factor=0.9)
-
- col = split.column()
- sub = col.row()
- sub.scale_y = 0.6
- sub.template_icon_view(shading, "studio_light", scale_popup=3)
-
- col = split.column()
- col.operator("preferences.studiolight_show", emboss=False, text="", icon='PREFERENCES')
-
- split = layout.split(factor=0.9)
- col = split.column()
- col.prop(shading, "studiolight_rotate_z", text="Rotation")
- col.prop(shading, "studiolight_intensity")
- col.prop(shading, "studiolight_background_alpha")
- col.prop(shading, "studiolight_background_blur")
- col = split.column() # to align properly with above
+ shading = context.space_data.shading
+ View3DShadingLightingLayout.draw(context, shading, self.layout)
class VIEW3D_PT_shading_color(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = "Color"
+ bl_label = View3DShadingColorLayout.bl_label
bl_parent_id = 'VIEW3D_PT_shading'
@classmethod
def poll(cls, context):
- return cls.poll_ex(context)
+ shading = context.space_data.shading
+ return View3DShadingColorLayout.poll(context, shading)
def draw(self, context):
- self.draw_ex(context)
-
- @classmethod
- def poll_ex(cls, context, shading=None):
- shading = VIEW3D_PT_shading.get_shading(context, shading)
- return shading.type in {'WIREFRAME', 'SOLID'}
-
- @staticmethod
- def _draw_color_type(layout, shading):
- layout.grid_flow(columns=3, align=True).prop(shading, "color_type", expand=True)
- if shading.color_type == 'SINGLE':
- layout.row().prop(shading, "single_color", text="")
-
- @staticmethod
- def _draw_background_color(layout, shading):
- layout
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list