UI: Allow view items to not be activatable

No user visible changes expected.

In some cases you'd want a view in which no, or not all items can be
activated. Needed for #104831, but makes sense as a general feature for
UI view items.
This commit is contained in:
Julian Eisel
2023-06-13 17:57:31 +02:00
parent b85e8bb7d9
commit 3b78bca592
4 changed files with 14 additions and 0 deletions

View File

@@ -139,6 +139,7 @@ class AbstractViewItem {
* If this wasn't done, the behavior of items is undefined.
*/
AbstractView *view_ = nullptr;
bool is_activatable_ = true;
bool is_interactive_ = true;
bool is_active_ = false;
bool is_renaming_ = false;
@@ -196,6 +197,8 @@ class AbstractViewItem {
void disable_interaction();
bool is_interactive() const;
void disable_activatable();
/**
* Requires the view to have completed reconstruction, see #is_reconstructed(). Otherwise we
* can't be sure about the item state.

View File

@@ -227,6 +227,11 @@ AbstractView &AbstractViewItem::get_view() const
return *view_;
}
void AbstractViewItem::disable_activatable()
{
is_activatable_ = false;
}
void AbstractViewItem::disable_interaction()
{
is_interactive_ = false;

View File

@@ -175,6 +175,9 @@ void AbstractGridViewItem::activate()
BLI_assert_msg(get_view().is_reconstructed(),
"Item activation can't be done until reconstruction is completed");
if (!is_activatable_) {
return;
}
if (is_active()) {
return;
}

View File

@@ -301,6 +301,9 @@ void AbstractTreeViewItem::activate()
BLI_assert_msg(get_tree_view().is_reconstructed(),
"Item activation can't be done until reconstruction is completed");
if (!is_activatable_) {
return;
}
if (is_active()) {
return;
}