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:
authorJulian Eisel <julian@blender.org>2020-03-17 18:36:34 +0300
committerJulian Eisel <julian@blender.org>2020-03-17 18:36:34 +0300
commit3f114cd2298166c6f02f08ee017605ed3ddc5dba (patch)
treeca35076592cc3182176c112a4fa10033e4b78c7d /release/scripts
parenta7e3b04e7a4f64cd51fda9f1c75cd3273f0e7824 (diff)
Revert changes to generalize 3D View Shading options button layout
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py25
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py259
-rw-r--r--release/scripts/startup/bl_ui/utils.py256
3 files changed, 241 insertions, 299 deletions
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 80a278b1562..fa9778da53b 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -19,13 +19,13 @@
# <pep8 compliant>
from bpy.types import Panel
+from bl_ui.space_view3d import (
+ 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:
@@ -579,7 +579,7 @@ class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
- bl_label = View3DShadingLightingLayout.bl_label
+ bl_label = "Lighting"
COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
@@ -587,12 +587,11 @@ class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
- shading = context.scene.display.shading
- View3DShadingLightingLayout.draw(context, shading, self.layout)
+ VIEW3D_PT_shading_lighting.draw(self, context)
class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
- bl_label = View3DShadingLightingLayout.bl_label
+ bl_label = "Color"
COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
@@ -600,12 +599,11 @@ class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
- shading = context.scene.display.shading
- View3DShadingColorLayout._draw_color_type(shading, self.layout)
+ VIEW3D_PT_shading_color._draw_color_type(self, context)
class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
- bl_label = View3DShadingOptionsLayout.bl_label
+ bl_label = "Options"
COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@classmethod
@@ -613,8 +611,7 @@ class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
- shading = context.scene.display.shading
- View3DShadingOptionsLayout.draw(context, shading, self.layout)
+ VIEW3D_PT_shading_options.draw(self, context)
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 b60df161a40..f8b291c0c5f 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -36,13 +36,6 @@ 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
@@ -5471,59 +5464,263 @@ class VIEW3D_PT_object_type_visibility(Panel):
class VIEW3D_PT_shading(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = View3DShadingLayout.bl_label
+ bl_label = "Shading"
bl_ui_units_x = 12
+ @classmethod
+ def get_shading(cls, context):
+ # 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):
- View3DShadingLayout.draw(self.layout)
+ layout = self.layout
+ layout.label(text="Viewport Shading")
class VIEW3D_PT_shading_lighting(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = View3DShadingLightingLayout.bl_label
+ bl_label = "Lighting"
bl_parent_id = 'VIEW3D_PT_shading'
@classmethod
def poll(cls, context):
- shading = context.space_data.shading
- return View3DShadingLightingLayout.poll(context, shading)
+ shading = VIEW3D_PT_shading.get_shading(context)
+ engine = context.scene.render.engine
+ return shading.type in {'SOLID', 'MATERIAL'} or engine == 'BLENDER_EEVEE' and shading.type == 'RENDERED'
def draw(self, context):
- shading = context.space_data.shading
- View3DShadingLightingLayout.draw(context, shading, self.layout)
+ layout = self.layout
+ shading = VIEW3D_PT_shading.get_shading(context)
+
+ 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
class VIEW3D_PT_shading_color(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = View3DShadingColorLayout.bl_label
+ bl_label = "Color"
bl_parent_id = 'VIEW3D_PT_shading'
@classmethod
def poll(cls, context):
- shading = context.space_data.shading
- return View3DShadingColorLayout.poll(context, shading)
+ shading = VIEW3D_PT_shading.get_shading(context)
+ return shading.type in {'WIREFRAME', 'SOLID'}
+
+ def _draw_color_type(self, context):
+ layout = self.layout
+ shading = VIEW3D_PT_shading.get_shading(context)
+
+ 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="")
+
+ def _draw_background_color(self, context):
+ layout = self.layout
+ shading = VIEW3D_PT_shading.get_shading(context)
+
+ layout.row().label(text="Background")
+ layout.row().prop(shading, "background_type", expand=True)
+ if shading.background_type == 'VIEWPORT':
+ layout.row().prop(shading, "background_color", text="")
def draw(self, context):
- shading = context.space_data.shading
- View3DShadingColorLayout.draw(context, shading, self.layout)
+ shading = VIEW3D_PT_shading.get_shading(context)
+ if shading.type == 'WIREFRAME':
+ self.layout.row().prop(shading, "wireframe_color_type", expand=True)
+ else:
+ self._draw_color_type(context)
+ self.layout.separator()
+ self._draw_background_color(context)
class VIEW3D_PT_shading_options(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = View3DShadingOptionsLayout.bl_label
+ bl_label = "Options"
bl_parent_id = 'VIEW3D_PT_shading'
@classmethod
def poll(cls, context):
- shading = context.space_data.shading
- return View3DShadingOptionsLayout.poll(context, shading)
+ shading = VIEW3D_PT_shading.get_shading(context)
+ return shading.type in {'WIREFRAME', 'SOLID'}
def draw(self, context):
- shading = context.space_data.shading
- View3DShadingOptionsLayout.draw(context, shading, self.layout)
+ layout = self.layout
+
+ shading = VIEW3D_PT_shading.get_shading(context)
+
+ col = layout.column()
+
+ if shading.type == 'SOLID':
+ col.prop(shading, "show_backface_culling")
+
+ row = col.row(align=True)
+
+ if shading.type == 'WIREFRAME':
+ row.prop(shading, "show_xray_wireframe", text="")
+ sub = row.row()
+ sub.active = shading.show_xray_wireframe
+ sub.prop(shading, "xray_alpha_wireframe", text="X-Ray")
+ elif shading.type == 'SOLID':
+ row.prop(shading, "show_xray", text="")
+ sub = row.row()
+ sub.active = shading.show_xray
+ sub.prop(shading, "xray_alpha", text="X-Ray")
+ # X-ray mode is off when alpha is 1.0
+ xray_active = shading.show_xray and shading.xray_alpha != 1
+
+ row = col.row(align=True)
+ row.prop(shading, "show_shadows", text="")
+ row.active = not xray_active
+ sub = row.row(align=True)
+ sub.active = shading.show_shadows
+ sub.prop(shading, "shadow_intensity", text="Shadow")
+ sub.popover(
+ panel="VIEW3D_PT_shading_options_shadow",
+ icon='PREFERENCES',
+ text="",
+ )
+
+ col = layout.column()
+
+ row = col.row()
+ row.active = not xray_active
+ row.prop(shading, "show_cavity")
+
+ if shading.show_cavity and not xray_active:
+ row.prop(shading, "cavity_type", text="Type")
+
+ if shading.cavity_type in {'WORLD', 'BOTH'}:
+ col.label(text="World Space")
+ sub = col.row(align=True)
+ sub.prop(shading, "cavity_ridge_factor", text="Ridge")
+ sub.prop(shading, "cavity_valley_factor", text="Valley")
+ sub.popover(
+ panel="VIEW3D_PT_shading_options_ssao",
+ icon='PREFERENCES',
+ text="",
+ )
+
+ if shading.cavity_type in {'SCREEN', 'BOTH'}:
+ col.label(text="Screen Space")
+ sub = col.row(align=True)
+ sub.prop(shading, "curvature_ridge_factor", text="Ridge")
+ sub.prop(shading, "curvature_valley_factor", text="Valley")
+
+ row = col.row()
+ row.active = not xray_active
+ row.prop(shading, "use_dof", text="Depth Of Field")
+
+ if shading.type in {'WIREFRAME', 'SOLID'}:
+ row = layout.split()
+ row.prop(shading, "show_object_outline")
+ sub = row.row()
+ sub.active = shading.show_object_outline
+ sub.prop(shading, "object_outline_color", text="")
+
+ if shading.type == 'SOLID':
+ col = layout.column()
+ if shading.light in {'STUDIO', 'MATCAP'}:
+ col.active = shading.selected_studio_light.has_specular_highlight_pass
+ col.prop(shading, "show_specular_highlight", text="Specular Lighting")
class VIEW3D_PT_shading_options_shadow(Panel):
@@ -5561,18 +5758,22 @@ class VIEW3D_PT_shading_options_ssao(Panel):
class VIEW3D_PT_shading_render_pass(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = View3DShadingRenderPassLayout.bl_label
+ bl_label = "Render Pass"
bl_parent_id = 'VIEW3D_PT_shading'
+ COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
- shading = context.space_data.shading
- return View3DShadingRenderPassLayout.poll(context, shading)
+ return (
+ (context.space_data.shading.type == 'MATERIAL') or
+ (context.engine in cls.COMPAT_ENGINES and context.space_data.shading.type == 'RENDERED')
+ )
def draw(self, context):
shading = context.space_data.shading
- View3DShadingRenderPassLayout.draw(
- context, shading, self.layout)
+
+ layout = self.layout
+ layout.prop(shading, "render_pass", text="")
class VIEW3D_PT_gizmo_display(Panel):
diff --git a/release/scripts/startup/bl_ui/utils.py b/release/scripts/startup/bl_ui/utils.py
index f9fb2f9bf0d..8c7ceefecb6 100644
--- a/release/scripts/startup/bl_ui/utils.py
+++ b/release/scripts/startup/bl_ui/utils.py
@@ -54,259 +54,3 @@ class PresetPanel:
layout.operator_context = 'EXEC_DEFAULT'
Menu.draw_preset(self, context)
-
-
-class View3DShadingLayout:
- bl_label = "Shading"
-
- @staticmethod
- def draw(layout):
- layout.label(text="Viewport Shading")
-
-
-class View3DShadingLightingLayout:
- bl_label = "Lighting"
-
- @staticmethod
- def poll(context, shading):
- engine = context.scene.render.engine
- return shading.type in {'SOLID', 'MATERIAL'} or engine == 'BLENDER_EEVEE' and shading.type == 'RENDERED'
-
- @staticmethod
- def draw(context, shading, layout, add_world_space_lighting_prop=True):
- 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()
- if add_world_space_lighting_prop:
- 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
-
-
-class View3DShadingColorLayout:
- bl_label = "Color"
-
- @staticmethod
- def poll(context, shading):
- return shading.type in {'WIREFRAME', 'SOLID'}
-
- @staticmethod
- def _draw_color_type(shading, layout):
- 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(shading, layout):
- layout.row().label(text="Background")
- layout.row().prop(shading, "background_type", expand=True)
- if shading.background_type == 'VIEWPORT':
- layout.row().prop(shading, "background_color", text="")
-
- @classmethod
- def draw(cls, context, shading, layout):
- if shading.type == 'WIREFRAME':
- layout.row().prop(shading, "wireframe_color_type", expand=True)
- else:
- cls._draw_color_type(shading, layout)
- layout.separator()
- cls._draw_background_color(shading, layout)
-
-
-class View3DShadingOptionsLayout:
- bl_label = "Options"
-
- @staticmethod
- def poll(context, shading):
- return shading.type in {'WIREFRAME', 'SOLID'}
-
- @staticmethod
- def draw(context, shading, layout):
- col = layout.column()
-
- if shading.type == 'SOLID':
- col.prop(shading, "show_backface_culling")
-
- row = col.row(align=True)
-
- if shading.type == 'WIREFRAME':
- row.prop(shading, "show_xray_wireframe", text="")
- sub = row.row()
- sub.active = shading.show_xray_wireframe
- sub.prop(shading, "xray_alpha_wireframe", text="X-Ray")
- elif shading.type == 'SOLID':
- row.prop(shading, "show_xray", text="")
- sub = row.row()
- sub.active = shading.show_xray
- sub.prop(shading, "xray_alpha", text="X-Ray")
- # X-ray mode is off when alpha is 1.0
- xray_active = shading.show_xray and shading.xray_alpha != 1
-
- row = col.row(align=True)
- row.prop(shading, "show_shadows", text="")
- row.active = not xray_active
- sub = row.row(align=True)
- sub.active = shading.show_shadows
- sub.prop(shading, "shadow_intensity", text="Shadow")
- sub.popover(
- panel="VIEW3D_PT_shading_options_shadow",
- icon='PREFERENCES',
- text="",
- )
-
- col = layout.column()
-
- row = col.row()
- row.active = not xray_active
- row.prop(shading, "show_cavity")
-
- if shading.show_cavity and not xray_active:
- row.prop(shading, "cavity_type", text="Type")
-
- if shading.cavity_type in {'WORLD', 'BOTH'}:
- col.label(text="World Space")
- sub = col.row(align=True)
- sub.prop(shading, "cavity_ridge_factor", text="Ridge")
- sub.prop(shading, "cavity_valley_factor", text="Valley")
- sub.popover(
- panel="VIEW3D_PT_shading_options_ssao",
- icon='PREFERENCES',
- text="",
- )
-
- if shading.cavity_type in {'SCREEN', 'BOTH'}:
- col.label(text="Screen Space")
- sub = col.row(align=True)
- sub.prop(shading, "curvature_ridge_factor", text="Ridge")
- sub.prop(shading, "curvature_valley_factor", text="Valley")
-
- row = col.row()
- row.active = not xray_active
- row.prop(shading, "use_dof", text="Depth Of Field")
-
- if shading.type in {'WIREFRAME', 'SOLID'}:
- row = layout.split()
- row.prop(shading, "show_object_outline")
- sub = row.row()
- sub.active = shading.show_object_outline
- sub.prop(shading, "object_outline_color", text="")
-
- if shading.type == 'SOLID':
- col = layout.column()
- if shading.light in {'STUDIO', 'MATCAP'}:
- col.active = shading.selected_studio_light.has_specular_highlight_pass
- col.prop(shading, "show_specular_highlight",
- text="Specular Lighting")
-
-
-class View3DShadingRenderPassLayout:
- bl_label = "Render Pass"
-
- @staticmethod
- def poll(context, shading):
- return (
- (shading.type == 'MATERIAL') or
- (context.engine in {'BLENDER_EEVEE'}
- and shading.type == 'RENDERED')
- )
-
- @staticmethod
- def draw(context, shading, layout):
- layout.prop(shading, "render_pass", text="")