This commit adds low-level logic in BKE to support three behaviors in case of name conflict when renaming an ID: 1. Always tweak new name of the renamed ID (never modify the other ID name). 2. Always set requested name in renamed ID, modifying as needed the other ID name. 3. Only modify the other ID name if it shares the same root name with the current renamed ID's name. It also adds quite some changes to IDTemplate, Outliner code, and RNA-defined UILayout code, and the lower-level UI button API, to allow for the new behavior defined in the design (i.e. option three from above list). When renaming from the UI either 'fails' (falls back to adjusted name) or forces renaming another ID, an INFO report is displayed. This commit also fixes several issues in existing code, especially regarding undo handling in rename operations (which could lead to saving the wrong name in undo step, and/or over-generating undo steps). API wise, the bahavior when directly assigning a name to the `ID.name` property remains unchanged (option one from the list above). But a new API call `ID.rename` has been added, which offers all three behaviors. Unittests were added to cover the new implemented behaviors (both at BKE level, and the RNA/Py API). This commit implements #119139 design. Pull Request: https://projects.blender.org/blender/blender/pulls/126996
19 lines
398 B
C++
19 lines
398 B
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup editors
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_compiler_attrs.h"
|
|
#include "BLI_string_ref.hh"
|
|
|
|
struct ID;
|
|
struct Main;
|
|
|
|
/** Handle complex user-facing ID renaming behavior, including user feedback (reporting). */
|
|
bool ED_id_rename(Main &bmain, ID &id, blender::StringRefNull name);
|