diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-08 16:34:13 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-08 16:34:46 +0300 |
commit | 70b3fb37819e5bb36de7d5e1f2c61db107dd23b0 (patch) | |
tree | a62df84f312fd00066c99ddf733a27ec7c7d87cf | |
parent | 6739bb195ea332cb067311c9162a9439204b9485 (diff) |
Workbench: Custom StudioLight UI
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 46 |
1 files changed, 24 insertions, 22 deletions
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' |