Nodes: improve handling of deprecated nodes
In 4.1 we deprecate the `Rotate Euler` node in favor of the `Rotate Rotation` node which uses the new rotation socket type. The node is not removed (for now) because that would come with compatibility issues. More generally, we'll likely run into the situation where nodes are deprecated more often in the future, without actually removing them to keep compatibility. This patch improves how such nodes are handled in the UI. The patch does three things: * Adds a new `Utilities > Deprecated` entry in the add node menu in geometry nodes. * Moves search items which are deprecated to the bottom in the search results (currently, this only works in English, can be fixed in bcon3). * Adds a new `bNodeType->deprecation_notice` that will result in a deprecation warning when the node is used. Pull Request: https://projects.blender.org/blender/blender/pulls/117905
This commit is contained in:
parent
d9266853c2
commit
e1ee422d12
@ -542,6 +542,7 @@ class NODE_MT_category_GEO_UTILITIES(Menu):
|
||||
layout.menu("NODE_MT_category_GEO_UTILITIES_FIELD")
|
||||
layout.menu("NODE_MT_category_GEO_UTILITIES_MATH")
|
||||
layout.menu("NODE_MT_category_GEO_UTILITIES_ROTATION")
|
||||
layout.menu("NODE_MT_category_GEO_UTILITIES_DEPRECATED")
|
||||
layout.separator()
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeIndexSwitch")
|
||||
node_add_menu.add_node_type(layout, "GeometryNodeMenuSwitch")
|
||||
@ -551,6 +552,15 @@ class NODE_MT_category_GEO_UTILITIES(Menu):
|
||||
node_add_menu.draw_assets_for_catalog(layout, self.bl_label)
|
||||
|
||||
|
||||
class NODE_MT_category_GEO_UTILITIES_DEPRECATED(Menu):
|
||||
bl_idname = "NODE_MT_category_GEO_UTILITIES_DEPRECATED"
|
||||
bl_label = "Deprecated"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
node_add_menu.add_node_type(layout, "FunctionNodeRotateEuler")
|
||||
|
||||
|
||||
class NODE_MT_category_GEO_UTILITIES_FIELD(Menu):
|
||||
bl_idname = "NODE_MT_category_GEO_UTILITIES_FIELD"
|
||||
bl_label = "Field"
|
||||
@ -769,6 +779,7 @@ classes = (
|
||||
NODE_MT_category_GEO_UTILITIES_FIELD,
|
||||
NODE_MT_category_GEO_UTILITIES_MATH,
|
||||
NODE_MT_category_GEO_UTILITIES_ROTATION,
|
||||
NODE_MT_category_GEO_UTILITIES_DEPRECATED,
|
||||
NODE_MT_category_GEO_GROUP,
|
||||
)
|
||||
|
||||
|
@ -396,6 +396,8 @@ typedef struct bNodeType {
|
||||
|
||||
/** True when the node cannot be muted. */
|
||||
bool no_muting;
|
||||
/** True when the node still works but it's usage is discouraged. */
|
||||
const char *deprecation_notice;
|
||||
|
||||
/* RNA integration */
|
||||
ExtensionRNA rna_ext;
|
||||
|
@ -34,6 +34,10 @@ struct SearchItem {
|
||||
* number is not based on an actual clock.
|
||||
*/
|
||||
int recent_time;
|
||||
/**
|
||||
* Deprecated items can still be found via search, but are at the bottom of the list.
|
||||
*/
|
||||
bool is_deprecated;
|
||||
};
|
||||
|
||||
struct RecentCache {
|
||||
|
@ -343,7 +343,7 @@ static std::optional<float> score_query_against_words(Span<StringRef> query_word
|
||||
Array<int, 64> word_match_map(item.normalized_words.size(), unused_word);
|
||||
|
||||
/* Start with some high score, because otherwise the final score might become negative. */
|
||||
float total_match_score = 1000;
|
||||
float total_match_score = item.is_deprecated ? 500 : 1000;
|
||||
|
||||
for (const int query_word_index : query_words.index_range()) {
|
||||
const StringRef query_word = query_words[query_word_index];
|
||||
@ -514,6 +514,9 @@ void StringSearchBase::add_impl(const StringRef str, void *user_data, const int
|
||||
}
|
||||
}
|
||||
|
||||
/* Not checking for the "D" to avoid problems with upper/lower-case. */
|
||||
const bool is_deprecated = str.find("eprecated") != StringRef::not_found;
|
||||
|
||||
items_.append({user_data,
|
||||
allocator_.construct_array_copy(words.as_span()),
|
||||
allocator_.construct_array_copy(word_group_ids.as_span()),
|
||||
@ -521,7 +524,8 @@ void StringSearchBase::add_impl(const StringRef str, void *user_data, const int
|
||||
main_group_length,
|
||||
int(str.size()),
|
||||
weight,
|
||||
recent_time});
|
||||
recent_time,
|
||||
is_deprecated});
|
||||
}
|
||||
|
||||
Vector<void *> StringSearchBase::query_impl(const StringRef query) const
|
||||
|
@ -2615,6 +2615,14 @@ static Vector<NodeExtraInfoRow> node_get_extra_info(const bContext &C,
|
||||
node.typeinfo->get_extra_info(params);
|
||||
}
|
||||
|
||||
if (node.typeinfo->deprecation_notice) {
|
||||
NodeExtraInfoRow row;
|
||||
row.text = IFACE_("Deprecated");
|
||||
row.icon = ICON_INFO;
|
||||
row.tooltip = TIP_(node.typeinfo->deprecation_notice);
|
||||
rows.append(std::move(row));
|
||||
}
|
||||
|
||||
if (!(snode.edittree->type == NTREE_GEOMETRY)) {
|
||||
/* Currently geometry nodes are the only nodes to have extra infos per nodes. */
|
||||
return rows;
|
||||
|
@ -138,7 +138,7 @@ static void node_register()
|
||||
ntype.draw_buttons = node_layout;
|
||||
ntype.updatefunc = node_update;
|
||||
ntype.build_multi_function = node_build_multi_function;
|
||||
ntype.gather_link_search_ops = nullptr;
|
||||
ntype.deprecation_notice = N_("Use the \"Rotate Rotation\" node instead");
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
NOD_REGISTER_NODE(node_register)
|
||||
|
@ -2,6 +2,8 @@
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "BLI_set.hh"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
@ -21,8 +23,10 @@ void GatherLinkSearchOpParams::add_item(std::string socket_name,
|
||||
const int weight)
|
||||
{
|
||||
|
||||
std::string name = std::string(IFACE_(node_type_.ui_name)) + " " + UI_MENU_ARROW_SEP +
|
||||
socket_name;
|
||||
std::string name = fmt::format("{}{} " UI_MENU_ARROW_SEP " {}",
|
||||
IFACE_(node_type_.ui_name),
|
||||
node_type_.deprecation_notice ? IFACE_(" (Deprecated)") : "",
|
||||
socket_name);
|
||||
|
||||
items_.append({std::move(name), std::move(fn), weight});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user