UI: Add title to tree view context menus #120694
|
@ -6438,11 +6438,11 @@ std::string UI_but_string_get_label(uiBut &but)
|
|||
std::string UI_but_context_menu_title_from_button(uiBut &but)
|
||||
|
||||
{
|
||||
if (but.type == UI_BTYPE_VIEW_ITEM) {
|
||||
const uiButViewItem *view_item_but = static_cast<uiButViewItem *>(&but);
|
||||
if (view_item_but == nullptr) {
|
||||
const uiButViewItem &view_item_but = static_cast<const uiButViewItem &>(but);
|
||||
Julian Eisel
commented
```cpp
const uiButViewItem &view_item_but = static_cast<const uiButViewItem &>(but);
```
|
||||
if (view_item_but.view_item == nullptr) {
|
||||
Julian Eisel
commented
`view_item` should be null-checked. Can return an empty string in that case I guess.
|
||||
return "";
|
||||
}
|
||||
blender::ui::AbstractView &tree_view = view_item_but->view_item->get_view();
|
||||
blender::ui::AbstractView &tree_view = view_item_but.view_item->get_view();
|
||||
Julian Eisel
commented
`const`
|
||||
return IFACE_(tree_view.get_context_menu_title().c_str());
|
||||
}
|
||||
return UI_but_string_get_label(but);
|
||||
|
|
Loading…
Reference in New Issue
but
can beconst
.If we do this, we will also need to change "button parameter -> const" of few other functions. Example:
UI_but_string_get_label
,UI_but_string_get_rna_label
,UI_but_operator_ptr_ensure
and possibly few more.Maybe best to do it outside of this PR to avoid the noise? 😅
or use
const_cast
?