diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2022-04-04 04:50:55 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2022-04-08 02:08:03 +0300 |
commit | 3214028ae822d6b9b1622589d27dd9b9746f2aa8 (patch) | |
tree | 08cb475db64f13d6507cd723c537f8dba568e39f /intern/cycles/blender/addon | |
parent | 5dd855102130bfbc140cbe334a8f79c309e4a5c5 (diff) |
Cycles: Support adding Lightgroups from the object/world properties
Currently, only Lightgroups that exist in the current view layer can be
selected from object or world properties.
The internal UI code already has support for search fields that accept
unknown input, so I just added that to the API and use it for lightgroups.
When a lightgroup is entered that does not exist in the current view layer
(e.g. because it's completely new, because the view layer was switched or
because it was deleted earlier), a new button next to it becomes active and
adds it to the view layer when pressed.
Differential Revision: https://developer.blender.org/D14540
Diffstat (limited to 'intern/cycles/blender/addon')
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index b7fd3e46669..2c6788b867b 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1174,8 +1174,15 @@ class CYCLES_OBJECT_PT_lightgroup(CyclesButtonsPanel, Panel): view_layer = context.view_layer - col = layout.column(align=True) - col.prop_search(ob, "lightgroup", view_layer, "lightgroups", text="Light Group") + row = layout.row(align=True) + row.use_property_decorate = False + + sub = row.column(align=True) + sub.prop_search(ob, "lightgroup", view_layer, "lightgroups", text="Light Group", results_are_suggestions=True) + + sub = row.column(align=True) + sub.active = bool(ob.lightgroup) and not any(lg.name == ob.lightgroup for lg in view_layer.lightgroups) + sub.operator("scene.view_layer_add_lightgroup", icon='ADD', text="").name = ob.lightgroup class CYCLES_OBJECT_PT_visibility(CyclesButtonsPanel, Panel): @@ -1435,8 +1442,15 @@ class CYCLES_WORLD_PT_surface(CyclesButtonsPanel, Panel): if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'): layout.prop(world, "color") - col = layout.column(align=True) - col.prop_search(world, "lightgroup", view_layer, "lightgroups", text="Light Group") + row = layout.row(align=True) + row.use_property_decorate = False + + sub = row.column(align=True) + sub.prop_search(world, "lightgroup", view_layer, "lightgroups", text="Light Group", results_are_suggestions=True) + + sub = row.column(align=True) + sub.active = bool(world.lightgroup) and not any(lg.name == world.lightgroup for lg in view_layer.lightgroups) + sub.operator("scene.view_layer_add_lightgroup", icon='ADD', text="").name = world.lightgroup class CYCLES_WORLD_PT_volume(CyclesButtonsPanel, Panel): |