Merge branch 'blender-v4.3-release'

This commit is contained in:
Falk David 2024-11-14 18:37:12 +01:00
commit 19f14aa7aa
3 changed files with 16 additions and 9 deletions

View file

@ -3368,20 +3368,19 @@ static void unique_node_name_ex(VectorSet<blender::StringRefNull> &names,
static std::string unique_node_name(const GreasePencil &grease_pencil,
const char *default_name,
blender::StringRefNull name)
blender::StringRef name)
{
using namespace blender;
char unique_name[MAX_NAME];
STRNCPY(unique_name, name.c_str());
STRNCPY(unique_name, name.data());
VectorSet<StringRefNull> names = get_node_names(grease_pencil);
unique_node_name_ex(names, default_name, unique_name);
return unique_name;
}
static std::string unique_layer_name(const GreasePencil &grease_pencil,
blender::StringRefNull name)
std::string GreasePencil::unique_layer_name(blender::StringRef name)
{
return unique_node_name(grease_pencil, DATA_("Layer"), name);
return unique_node_name(*this, DATA_("Layer"), name);
}
static std::string unique_layer_group_name(const GreasePencil &grease_pencil,
@ -3394,7 +3393,7 @@ blender::bke::greasepencil::Layer &GreasePencil::add_layer(const blender::String
const bool check_name_is_unique)
{
using namespace blender;
std::string unique_name = check_name_is_unique ? unique_layer_name(*this, name) : name.c_str();
std::string unique_name = check_name_is_unique ? unique_layer_name(name) : name.c_str();
const int numLayers = layers().size();
CustomData_realloc(&layers_data, numLayers, numLayers + 1, CD_SET_DEFAULT);
bke::greasepencil::Layer *new_layer = MEM_new<bke::greasepencil::Layer>(__func__, unique_name);
@ -3440,7 +3439,7 @@ blender::bke::greasepencil::Layer &GreasePencil::duplicate_layer(
const blender::bke::greasepencil::Layer &duplicate_layer)
{
using namespace blender;
std::string unique_name = unique_layer_name(*this, duplicate_layer.name());
std::string unique_name = unique_layer_name(duplicate_layer.name());
std::optional<int> duplicate_layer_idx = get_layer_index(duplicate_layer);
const int numLayers = layers().size();
CustomData_realloc(&layers_data, numLayers, numLayers + 1);
@ -3773,7 +3772,7 @@ void GreasePencil::rename_node(Main &bmain,
/* Rename the node. */
std::string old_name = node.name();
if (node.is_layer()) {
node.set_name(unique_layer_name(*this, new_name));
node.set_name(unique_layer_name(new_name));
}
else if (node.is_group()) {
node.set_name(unique_layer_group_name(*this, new_name));

View file

@ -1786,6 +1786,12 @@ static int grease_pencil_move_to_layer_invoke(bContext *C, wmOperator *op, const
{
const bool add_new_layer = RNA_boolean_get(op->ptr, "add_new_layer");
if (add_new_layer) {
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
const std::string unique_name = grease_pencil.unique_layer_name("Layer");
RNA_string_set(op->ptr, "target_layer_name", unique_name.c_str());
return WM_operator_props_popup_confirm_ex(
C, op, event, IFACE_("Move to New Layer"), IFACE_("Create"));
}
@ -1807,7 +1813,7 @@ static void GREASE_PENCIL_OT_move_to_layer(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_string(
ot->srna, "target_layer_name", "Layer", INT16_MAX, "Name", "Target Grease Pencil Layer");
ot->srna, "target_layer_name", nullptr, INT16_MAX, "Name", "Target Grease Pencil Layer");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
ot->srna, "add_new_layer", false, "New Layer", "Move selection to a new layer");

View file

@ -597,6 +597,8 @@ typedef struct GreasePencil {
void remove_layer(blender::bke::greasepencil::Layer &layer);
void remove_group(blender::bke::greasepencil::LayerGroup &group, bool keep_children = false);
std::string unique_layer_name(blender::StringRef name);
/* Frames API functions. */
/**