[Bf-blender-cvs] [70b3fb37819] blender2.8: Workbench: Custom StudioLight UI
Jeroen Bakker
noreply at git.blender.org
Fri Jun 8 15:35:01 CEST 2018
Commit: 70b3fb37819e5bb36de7d5e1f2c61db107dd23b0
Author: Jeroen Bakker
Date: Fri Jun 8 15:34:13 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB70b3fb37819e5bb36de7d5e1f2c61db107dd23b0
Workbench: Custom StudioLight UI
===================================================================
M release/scripts/startup/bl_ui/space_userpref.py
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 29886d3cd0a..7b009b9b45b 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1584,6 +1584,27 @@ class StudioLightPanelMixin():
userpref = context.user_preferences
return (userpref.active_section == 'LIGHTS')
+ def _get_lights(self, userpref):
+ return [light for light in userpref.studio_lights if light.is_user_defined and light.orientation == self.sl_orientation]
+
+ def draw_header(self, context):
+ layout = self.layout
+ row = layout.row()
+ userpref = context.user_preferences
+ lights = self._get_lights(userpref)
+ row.label("({})".format(len(lights)))
+
+ def draw(self, context):
+ layout = self.layout
+ userpref = context.user_preferences
+ lights = self._get_lights(userpref)
+ if lights:
+ flow = layout.column_flow(4)
+ for studio_light in lights:
+ self.draw_studio_light(flow, studio_light)
+ else:
+ layout.label("No custom {} configured".format(self.bl_label))
+
def draw_studio_light(self, layout, studio_light):
box = layout.box()
row = box.row()
@@ -1595,36 +1616,17 @@ class StudioLightPanelMixin():
class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
bl_label = "MatCaps"
+ sl_orientation = 'MATCAP'
- def draw(self, context):
- layout = self.layout
- flow = layout.column_flow(4)
- userpref = context.user_preferences
- lights = [light for light in userpref.studio_lights if light.is_user_defined]
- for studio_light in filter(lambda x: x.orientation=='MATCAP', lights):
- self.draw_studio_light(flow, studio_light)
class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
bl_label = "World HDRI"
+ sl_orientation = 'WORLD'
- def draw(self, context):
- layout = self.layout
- flow = layout.column_flow(4)
- userpref = context.user_preferences
- lights = [light for light in userpref.studio_lights if light.is_user_defined]
- for studio_light in filter(lambda x: x.orientation=='WORLD', lights):
- self.draw_studio_light(flow, studio_light)
class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin):
bl_label = "Camera HDRI"
-
- def draw(self, context):
- layout = self.layout
- flow = layout.column_flow(4)
- userpref = context.user_preferences
- lights = [light for light in userpref.studio_lights if light.is_user_defined]
- for studio_light in filter(lambda x: x.orientation=='CAMERA', lights):
- self.draw_studio_light(flow, studio_light)
+ sl_orientation = 'CAMERA'
More information about the Bf-blender-cvs
mailing list