diff --git a/source/blender/editors/include/UI_abstract_view.hh b/source/blender/editors/include/UI_abstract_view.hh index b5874199ae7..b981969783c 100644 --- a/source/blender/editors/include/UI_abstract_view.hh +++ b/source/blender/editors/include/UI_abstract_view.hh @@ -188,7 +188,7 @@ class AbstractViewItem { * * \return True if the renaming was successful. */ - virtual bool rename(StringRefNull new_name); + virtual bool rename(const bContext &C, StringRefNull new_name); /** * Get the string that should be used for renaming, typically the item's label. This string will * not be modified, but if the renaming is canceled, the value will be reset to this. @@ -249,7 +249,7 @@ class AbstractViewItem { bool is_renaming() const; void begin_renaming(); void end_renaming(); - void rename_apply(); + void rename_apply(const bContext &C); template static ToType *from_item_handle(uiViewItemHandle *handle); diff --git a/source/blender/editors/include/UI_tree_view.hh b/source/blender/editors/include/UI_tree_view.hh index 7d5690d33af..c0c85e7a985 100644 --- a/source/blender/editors/include/UI_tree_view.hh +++ b/source/blender/editors/include/UI_tree_view.hh @@ -207,7 +207,7 @@ class AbstractTreeViewItem : public AbstractViewItem, public TreeViewItemContain /** See AbstractViewItem::get_rename_string(). */ /* virtual */ StringRef get_rename_string() const override; /** See AbstractViewItem::rename(). */ - /* virtual */ bool rename(StringRefNull new_name) override; + /* virtual */ bool rename(const bContext &C, StringRefNull new_name) override; /** * Return whether the item can be collapsed. Used to disable collapsing for items with children. diff --git a/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc index fca714d4660..226e65d8b44 100644 --- a/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc +++ b/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc @@ -200,7 +200,7 @@ class LayerViewItem : public AbstractTreeViewItem { return true; } - bool rename(StringRefNull new_name) override + bool rename(const bContext & /*C*/, StringRefNull new_name) override { grease_pencil_.rename_node(layer_.as_node(), new_name); return true; @@ -309,7 +309,7 @@ class LayerGroupViewItem : public AbstractTreeViewItem { return true; } - bool rename(StringRefNull new_name) override + bool rename(const bContext & /*C*/, StringRefNull new_name) override { grease_pencil_.rename_node(group_.as_node(), new_name); return true; diff --git a/source/blender/editors/interface/views/abstract_view_item.cc b/source/blender/editors/interface/views/abstract_view_item.cc index 061414d9adf..0e9759f606f 100644 --- a/source/blender/editors/interface/views/abstract_view_item.cc +++ b/source/blender/editors/interface/views/abstract_view_item.cc @@ -106,7 +106,7 @@ bool AbstractViewItem::supports_renaming() const /* No renaming by default. */ return false; } -bool AbstractViewItem::rename(StringRefNull /*new_name*/) +bool AbstractViewItem::rename(const bContext & /*C*/, StringRefNull /*new_name*/) { /* No renaming by default. */ return false; @@ -138,10 +138,10 @@ void AbstractViewItem::begin_renaming() std::copy(std::begin(initial_str), std::end(initial_str), std::begin(view.get_rename_buffer())); } -void AbstractViewItem::rename_apply() +void AbstractViewItem::rename_apply(const bContext &C) { const AbstractView &view = get_view(); - rename(view.get_rename_buffer().data()); + rename(C, view.get_rename_buffer().data()); end_renaming(); } @@ -179,12 +179,12 @@ static AbstractViewItem *find_item_from_rename_button(const uiBut &rename_but) return nullptr; } -static void rename_button_fn(bContext * /*C*/, void *arg, char * /*origstr*/) +static void rename_button_fn(bContext *C, void *arg, char * /*origstr*/) { const uiBut *rename_but = static_cast(arg); AbstractViewItem *item = find_item_from_rename_button(*rename_but); BLI_assert(item); - item->rename_apply(); + item->rename_apply(*C); } void AbstractViewItem::add_rename_button(uiBlock &block) diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index fc33f7bff68..f0bc5a246fd 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -410,7 +410,7 @@ StringRef AbstractTreeViewItem::get_rename_string() const return label_; } -bool AbstractTreeViewItem::rename(StringRefNull new_name) +bool AbstractTreeViewItem::rename(const bContext & /*C*/, StringRefNull new_name) { /* It is important to update the label after renaming, so #AbstractTreeViewItem::matches_single() * recognizes the item. (It only compares labels by default.) */ diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc index ac2e1e92678..c251cafd53b 100644 --- a/source/blender/editors/space_file/asset_catalog_tree_view.cc +++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc @@ -87,7 +87,7 @@ class AssetCatalogTreeViewItem : public ui::BasicTreeViewItem { void build_context_menu(bContext &C, uiLayout &column) const override; bool supports_renaming() const override; - bool rename(StringRefNull new_name) override; + bool rename(const bContext &C, StringRefNull new_name) override; /** Add drag support for catalog items. */ std::unique_ptr create_drag_controller() const override; @@ -330,10 +330,10 @@ bool AssetCatalogTreeViewItem::supports_renaming() const return !ED_asset_catalogs_read_only(*tree_view.asset_library_); } -bool AssetCatalogTreeViewItem::rename(StringRefNull new_name) +bool AssetCatalogTreeViewItem::rename(const bContext &C, StringRefNull new_name) { /* Important to keep state. */ - BasicTreeViewItem::rename(new_name); + BasicTreeViewItem::rename(C, new_name); const AssetCatalogTreeView &tree_view = static_cast( get_tree_view());