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:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user