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:
-rw-r--r--intern/cycles/blender/addon/ui.py22
-rw-r--r--source/blender/blenkernel/BKE_layer.h3
-rw-r--r--source/blender/blenkernel/intern/layer.c10
-rw-r--r--source/blender/editors/include/UI_interface.h3
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_layout.c19
-rw-r--r--source/blender/editors/interface/interface_utils.cc2
-rw-r--r--source/blender/editors/render/render_shading.cc25
-rw-r--r--source/blender/makesrna/intern/rna_scene.c1
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c8
10 files changed, 76 insertions, 20 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):
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 4a3917dafee..cad6f6d6645 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -582,7 +582,8 @@ bool BKE_view_layer_has_valid_aov(struct ViewLayer *view_layer);
struct ViewLayer *BKE_view_layer_find_with_aov(struct Scene *scene,
struct ViewLayerAOV *view_layer_aov);
-struct ViewLayerLightgroup *BKE_view_layer_add_lightgroup(struct ViewLayer *view_layer);
+struct ViewLayerLightgroup *BKE_view_layer_add_lightgroup(struct ViewLayer *view_layer,
+ const char *name);
void BKE_view_layer_remove_lightgroup(struct ViewLayer *view_layer,
struct ViewLayerLightgroup *lightgroup);
void BKE_view_layer_set_active_lightgroup(struct ViewLayer *view_layer,
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index c99bf885074..1cc1839d2d0 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -2535,11 +2535,17 @@ static void viewlayer_lightgroup_active_set(ViewLayer *view_layer, ViewLayerLigh
}
}
-struct ViewLayerLightgroup *BKE_view_layer_add_lightgroup(struct ViewLayer *view_layer)
+struct ViewLayerLightgroup *BKE_view_layer_add_lightgroup(struct ViewLayer *view_layer,
+ const char *name)
{
ViewLayerLightgroup *lightgroup;
lightgroup = MEM_callocN(sizeof(ViewLayerLightgroup), __func__);
- BLI_strncpy(lightgroup->name, DATA_("Lightgroup"), sizeof(lightgroup->name));
+ if (name && name[0]) {
+ BLI_strncpy(lightgroup->name, name, sizeof(lightgroup->name));
+ }
+ else {
+ BLI_strncpy(lightgroup->name, DATA_("Lightgroup"), sizeof(lightgroup->name));
+ }
BLI_addtail(&view_layer->lightgroups, lightgroup);
viewlayer_lightgroup_active_set(view_layer, lightgroup);
viewlayer_lightgroup_make_name_unique(view_layer, lightgroup);
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 4649fb06374..c14cce28052 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2712,7 +2712,8 @@ void uiItemPointerR_prop(uiLayout *layout,
struct PointerRNA *searchptr,
struct PropertyRNA *searchprop,
const char *name,
- int icon);
+ int icon,
+ bool results_are_suggestions);
void uiItemPointerR(uiLayout *layout,
struct PointerRNA *ptr,
const char *propname,
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 8bbf95e9e20..ad5aeb1c29f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -1283,7 +1283,8 @@ uiBut *ui_but_add_search(uiBut *but,
PointerRNA *ptr,
PropertyRNA *prop,
PointerRNA *searchptr,
- PropertyRNA *searchprop);
+ PropertyRNA *searchprop,
+ bool results_are_suggestions);
/**
* Check all buttons defined in this layout,
* and set any button flagged as UI_BUT_LIST_ITEM as active/selected.
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index cbc21bd481f..ac807f06891 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2332,7 +2332,7 @@ void uiItemFullR(uiLayout *layout,
/* property with separate label */
else if (ELEM(type, PROP_ENUM, PROP_STRING, PROP_POINTER)) {
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
- but = ui_but_add_search(but, ptr, prop, NULL, NULL);
+ but = ui_but_add_search(but, ptr, prop, NULL, NULL, false);
if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
@@ -2700,8 +2700,12 @@ static void ui_rna_collection_search_arg_free_fn(void *ptr)
MEM_freeN(ptr);
}
-uiBut *ui_but_add_search(
- uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop)
+uiBut *ui_but_add_search(uiBut *but,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ PointerRNA *searchptr,
+ PropertyRNA *searchprop,
+ bool results_are_suggestions)
{
/* for ID's we do automatic lookup */
PointerRNA sptr;
@@ -2743,6 +2747,8 @@ uiBut *ui_but_add_search(
but->str[0] = 0;
}
+ UI_but_func_search_set_results_are_suggestions(but, results_are_suggestions);
+
UI_but_func_search_set(but,
ui_searchbox_create_generic,
ui_rna_collection_search_update_fn,
@@ -2771,7 +2777,8 @@ void uiItemPointerR_prop(uiLayout *layout,
PointerRNA *searchptr,
PropertyRNA *searchprop,
const char *name,
- int icon)
+ int icon,
+ bool results_are_suggestions)
{
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
@@ -2820,7 +2827,7 @@ void uiItemPointerR_prop(uiLayout *layout,
w += UI_UNIT_X; /* X icon needs more space */
uiBut *but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
- ui_but_add_search(but, ptr, prop, searchptr, searchprop);
+ but = ui_but_add_search(but, ptr, prop, searchptr, searchprop, results_are_suggestions);
}
void uiItemPointerR(uiLayout *layout,
@@ -2845,7 +2852,7 @@ void uiItemPointerR(uiLayout *layout,
return;
}
- uiItemPointerR_prop(layout, ptr, prop, searchptr, searchprop, name, icon);
+ uiItemPointerR_prop(layout, ptr, prop, searchptr, searchprop, name, icon, false);
}
void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc
index 56d80b8e557..c59863f462a 100644
--- a/source/blender/editors/interface/interface_utils.cc
+++ b/source/blender/editors/interface/interface_utils.cc
@@ -333,7 +333,7 @@ uiBut *uiDefAutoButR(uiBlock *block,
-1,
-1,
nullptr);
- ui_but_add_search(but, ptr, prop, nullptr, nullptr);
+ ui_but_add_search(but, ptr, prop, nullptr, nullptr, false);
break;
}
case PROP_COLLECTION: {
diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc
index 07a07b462ef..d9929025c28 100644
--- a/source/blender/editors/render/render_shading.cc
+++ b/source/blender/editors/render/render_shading.cc
@@ -1118,12 +1118,25 @@ void SCENE_OT_view_layer_remove_aov(wmOperatorType *ot)
/** \name View Layer Add Lightgroup Operator
* \{ */
-static int view_layer_add_lightgroup_exec(bContext *C, wmOperator *UNUSED(op))
+static int view_layer_add_lightgroup_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_view_layer_add_lightgroup(view_layer);
+ char name[MAX_NAME];
+ RNA_string_get(op->ptr, "name", name);
+ /* If a name is provided, ensure that it is unique. */
+ if (name[0]) {
+ /* Ensure that there are no dots in the name. */
+ BLI_str_replace_char(name, '.', '_');
+ LISTBASE_FOREACH (ViewLayerLightgroup *, lightgroup, &view_layer->lightgroups) {
+ if (strcmp(lightgroup->name, name) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+ }
+ }
+
+ BKE_view_layer_add_lightgroup(view_layer, name);
if (scene->nodetree) {
ntreeCompositUpdateRLayers(scene->nodetree);
@@ -1148,6 +1161,14 @@ void SCENE_OT_view_layer_add_lightgroup(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
+
+ /* properties */
+ ot->prop = RNA_def_string(ot->srna,
+ "name",
+ nullptr,
+ sizeof(((ViewLayerLightgroup *)NULL)->name),
+ "Name",
+ "Name of newly created lightgroup");
}
/** \} */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 050e08348a0..fa34e7a40c0 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -4219,6 +4219,7 @@ static void rna_def_view_layer_lightgroups(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "add", "BKE_view_layer_add_lightgroup");
parm = RNA_def_pointer(func, "lightgroup", "Lightgroup", "", "Newly created Lightgroup");
RNA_def_function_return(func, parm);
+ parm = RNA_def_string(func, "name", NULL, 0, "Name", "Name of newly created lightgroup");
}
static void rna_def_view_layer_lightgroup(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index c4396719bb9..1b416e4b6e5 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -278,7 +278,8 @@ static void rna_uiItemPointerR(uiLayout *layout,
const char *name,
const char *text_ctxt,
bool translate,
- int icon)
+ int icon,
+ const bool results_are_suggestions)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -295,7 +296,8 @@ static void rna_uiItemPointerR(uiLayout *layout,
/* Get translated name (label). */
name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
- uiItemPointerR_prop(layout, ptr, prop, searchptr, searchprop, name, icon);
+ uiItemPointerR_prop(
+ layout, ptr, prop, searchptr, searchprop, name, icon, results_are_suggestions);
}
static PointerRNA rna_uiItemO(uiLayout *layout,
@@ -1142,6 +1144,8 @@ void RNA_api_ui_layout(StructRNA *srna)
func, "search_property", NULL, 0, "", "Identifier of search collection property");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
api_ui_item_common(func);
+ RNA_def_boolean(
+ func, "results_are_suggestions", false, "", "Accept inputs that do not match any item");
func = RNA_def_function(srna, "prop_decorator", "uiItemDecoratorR");
api_ui_item_rna_common(func);