|
Blender V4.3
|
#include <UI_abstract_view.hh>
Inherited by blender::ui::AbstractGridViewItem, and blender::ui::AbstractTreeViewItem.
Public Member Functions | |
| virtual | ~AbstractViewItem ()=default |
Context Menu | |
| virtual void | build_context_menu (bContext &C, uiLayout &column) const |
Drag 'n Drop | |
| virtual std::unique_ptr< AbstractViewItemDragController > | create_drag_controller () const |
| virtual std::unique_ptr< DropTargetInterface > | create_item_drop_target () |
| virtual std::optional< std::string > | debug_name () const |
General Getters & Setters | |
| AbstractView & | get_view () const |
| uiButViewItem * | view_item_button () const |
| void | disable_interaction () |
| bool | is_interactive () const |
| void | disable_activatable () |
| bool | is_active () const |
| bool | is_search_highlight () const |
Protected Member Functions | |
| AbstractViewItem ()=default | |
| virtual bool | matches (const AbstractViewItem &other) const =0 |
View Reconstruction | |
| virtual void | update_from_old (const AbstractViewItem &old) |
General State Management | |
| virtual void | change_state_delayed () |
Protected Attributes | |
| AbstractView * | view_ = nullptr |
| uiButViewItem * | view_item_but_ = nullptr |
| bool | is_activatable_ = true |
| bool | is_interactive_ = true |
| bool | is_active_ = false |
| bool | is_renaming_ = false |
| bool | is_highlighted_search_ = false |
| bool | is_filtered_visible_ = true |
Friends | |
| class | AbstractView |
| class | ViewItemAPIWrapper |
Active Item State | |
| virtual void | on_activate (bContext &C) |
| virtual std::optional< bool > | should_be_active () const |
| void | activate (bContext &C) |
| void | deactivate () |
| virtual bool | set_state_active () |
Renaming | |
| virtual bool | supports_renaming () const |
| virtual bool | rename (const bContext &C, StringRefNull new_name) |
| virtual StringRef | get_rename_string () const |
| bool | is_renaming () const |
| void | begin_renaming () |
| void | end_renaming () |
| void | rename_apply (const bContext &C) |
| void | add_rename_button (uiBlock &block) |
Filtering | |
| bool | is_filtered_visible () const |
| virtual bool | should_be_filtered_visible (StringRefNull filter_string) const |
Definition at line 166 of file UI_abstract_view.hh.
|
virtualdefault |
|
protecteddefault |
| void blender::ui::AbstractViewItem::activate | ( | bContext & | C | ) |
Activates this item, deactivates other items, and calls the AbstractViewItem::on_activate() function. Should only be called when the item was activated through the view (e.g. through a click), not if the view reflects an external change (e.g. AbstractViewItem::should_be_active() changes from returning false to returning true).
Requires the view to have completed reconstruction, see #is_reconstructed(). Otherwise the actual item state is unknown, possibly calling state-change update functions incorrectly.
Definition at line 70 of file abstract_view_item.cc.
References on_activate(), and set_state_active().
Referenced by ui_do_button().
|
protected |
Add a text button for renaming the item to block. This must be used for the built-in renaming to work. This button is meant to appear temporarily. It is removed when renaming is done.
Definition at line 194 of file abstract_view_item.cc.
References CTX_wm_region(), end_renaming(), uiBlock::evil_C, get_view(), blender::ui::rename_button_fn(), UI_BTYPE_TEXT, UI_but_active_only(), UI_but_flag_disable(), UI_but_func_rename_set(), UI_BUT_UNDO, UI_UNIT_X, UI_UNIT_Y, and uiDefBut().
| void blender::ui::AbstractViewItem::begin_renaming | ( | ) |
Definition at line 130 of file abstract_view_item.cc.
References get_rename_string(), get_view(), blender::ui::AbstractView::is_renaming(), is_renaming_, and supports_renaming().
Referenced by UI_view_item_begin_rename().
|
virtual |
Reimplemented in blender::ed::asset::shelf::AssetViewItem, blender::ed::asset_browser::AssetCatalogTreeViewItem, blender::ui::bonecollections::BoneCollectionItem, and blender::ui::greasepencil::LayerGroupViewItem.
Definition at line 229 of file abstract_view_item.cc.
Referenced by ui_popup_context_menu_for_button().
|
protectedvirtual |
See AbstractView::change_state_delayed(). Overrides should call the base class implementation.
Reimplemented in blender::ui::AbstractTreeViewItem.
Definition at line 88 of file abstract_view_item.cc.
References is_active_, set_state_active(), and should_be_active().
Referenced by blender::ui::AbstractTreeViewItem::change_state_delayed(), and blender::ui::AbstractView::change_state_delayed().
|
virtual |
If an item wants to support being dragged, it has to return a drag controller here. That is an object implementing #AbstractViewItemDragController.
Reimplemented in blender::ed::asset::shelf::AssetViewItem, blender::ed::asset_browser::AssetCatalogTreeViewItem, blender::ui::bonecollections::BoneCollectionItem, blender::ui::greasepencil::LayerGroupViewItem, and blender::ui::greasepencil::LayerViewItem.
Definition at line 257 of file abstract_view_item.cc.
Referenced by UI_view_item_drag_start(), and UI_view_item_supports_drag().
|
virtual |
If an item wants to support dropping data into it, it has to return a drop target here. That is an object implementing #DropTargetInterface.
Reimplemented in blender::ui::AbstractGridViewItem, and blender::ui::AbstractTreeViewItem.
Definition at line 263 of file abstract_view_item.cc.
| void blender::ui::AbstractViewItem::deactivate | ( | ) |
Definition at line 77 of file abstract_view_item.cc.
References is_active_.
|
virtual |
View types should implement this to return some name or identifier of the item, which is helpful for debugging (there's nothing to identify the item just from the AbstractViewItem otherwise).
Reimplemented in blender::ui::AbstractGridViewItem, and blender::ui::AbstractTreeViewItem.
Definition at line 269 of file abstract_view_item.cc.
| void blender::ui::AbstractViewItem::disable_activatable | ( | ) |
Definition at line 301 of file abstract_view_item.cc.
References is_activatable_.
Referenced by blender::ed::asset::shelf::AssetCatalogSelectorTree::Item::Item().
| void blender::ui::AbstractViewItem::disable_interaction | ( | ) |
Disable the interacting with this item, meaning the buttons drawn will be disabled and there will be no mouse hover feedback for the view row.
Definition at line 306 of file abstract_view_item.cc.
References is_interactive_.
| void blender::ui::AbstractViewItem::end_renaming | ( | ) |
Definition at line 152 of file abstract_view_item.cc.
References blender::ui::AbstractView::end_renaming(), get_view(), is_renaming(), and is_renaming_.
Referenced by add_rename_button(), and rename_apply().
|
virtual |
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.
Reimplemented in blender::ui::AbstractTreeViewItem, blender::ui::bonecollections::BoneCollectionItem, blender::ui::greasepencil::LayerGroupViewItem, and blender::ui::greasepencil::LayerViewItem.
Definition at line 119 of file abstract_view_item.cc.
Referenced by begin_renaming().
| AbstractView & blender::ui::AbstractViewItem::get_view | ( | ) | const |
Get the view this item is registered for using AbstractView::register_item().
Definition at line 287 of file abstract_view_item.cc.
References UNLIKELY, and view_.
Referenced by add_rename_button(), begin_renaming(), end_renaming(), blender::ui::find_first_view_item_but(), blender::ui::find_item_from_rename_button(), blender::ui::AbstractTreeViewItem::get_tree_view(), is_active(), is_filtered_visible(), rename_apply(), set_state_active(), ui_block_view_find_matching_view_item_but_in_old_block(), UI_but_context_menu_title_from_button(), UI_view_item_can_rename(), UI_view_item_popup_keep_open(), and ViewLink::views_bounds_calc().
| bool blender::ui::AbstractViewItem::is_active | ( | ) | const |
Requires the view to have completed reconstruction, see #is_reconstructed(). Otherwise we can't be sure about the item state.
Definition at line 316 of file abstract_view_item.cc.
References BLI_assert_msg, get_view(), and is_active_.
Referenced by set_state_active(), ui_but_is_active_view_item(), and ui_but_is_pushed_ex().
| bool blender::ui::AbstractViewItem::is_filtered_visible | ( | ) | const |
Definition at line 245 of file abstract_view_item.cc.
References BLI_assert, get_view(), and is_filtered_visible_.
Referenced by blender::ui::find_filtered_item_index().
| bool blender::ui::AbstractViewItem::is_interactive | ( | ) | const |
Definition at line 311 of file abstract_view_item.cc.
References is_interactive_.
Referenced by ui_but_is_interactive_ex().
| bool blender::ui::AbstractViewItem::is_renaming | ( | ) | const |
Definition at line 125 of file abstract_view_item.cc.
References is_renaming_.
Referenced by blender::ui::TreeViewLayoutBuilder::build_row(), end_renaming(), and blender::ui::find_item_from_rename_button().
| bool blender::ui::AbstractViewItem::is_search_highlight | ( | ) | const |
Should this item be highlighted as matching search result? Only one item should be highlighted this way at a time. Pressing enter will activate it.
Definition at line 323 of file abstract_view_item.cc.
References is_highlighted_search_.
Referenced by blender::ui::AbstractView::search_highlight_item().
|
protectedpure virtual |
Compare this item's identity to other to check if they represent the same data. Implementations can assume that the types match already (caller must check).
Used to recognize an item from a previous redraw, to be able to keep its state (e.g. active, renaming, etc.).
Implemented in blender::ui::AbstractGridViewItem, and blender::ui::AbstractTreeViewItem.
|
virtual |
Called when the view changes an item's state from inactive to active. Will only be called if the state change is triggered through the view, not through external changes. E.g. a click on an item calls it, a change in the value returned by should_be_active() to reflect an external state change does not.
Reimplemented in blender::ed::asset::shelf::AssetViewItem, blender::ed::asset_browser::AssetCatalogTreeViewItem, blender::ed::spreadsheet::DataSetViewItem, blender::ed::spreadsheet::InstancesTreeViewItem, blender::ui::bonecollections::BoneCollectionItem, blender::ui::greasepencil::LayerGroupViewItem, and blender::ui::greasepencil::LayerViewItem.
Definition at line 41 of file abstract_view_item.cc.
Referenced by activate().
|
virtual |
Try renaming the item, or the data it represents. Can assume AbstractViewItem::supports_renaming() returned true. Sub-classes that override this should usually call this, unless they have a custom AbstractViewItem.matches() implementation.
Reimplemented in blender::ed::asset_browser::AssetCatalogTreeViewItem, blender::ui::AbstractTreeViewItem, blender::ui::bonecollections::BoneCollectionItem, blender::ui::greasepencil::LayerGroupViewItem, and blender::ui::greasepencil::LayerViewItem.
Definition at line 113 of file abstract_view_item.cc.
Referenced by rename_apply().
| void blender::ui::AbstractViewItem::rename_apply | ( | const bContext & | C | ) |
Definition at line 145 of file abstract_view_item.cc.
References bContext::data, end_renaming(), get_view(), and rename().
Referenced by blender::ui::rename_button_fn().
|
protectedvirtual |
Like activate() but does not call on_activate(). Use it to reflect changes in the active state that happened externally. Can be overridden to customize behavior but should always call the base class implementation.
Definition at line 51 of file abstract_view_item.cc.
References BLI_assert_msg, blender::ui::AbstractView::foreach_view_item(), get_view(), is_activatable_, is_active(), and is_active_.
Referenced by activate(), and change_state_delayed().
|
virtual |
If the result is not empty, it controls whether the item should be active or not, usually depending on the data that the view represents. Note that since this is meant to reflect externally managed state changes, on_activate() will never be called if this returns true.
Reimplemented in blender::ed::asset::shelf::AssetViewItem, blender::ed::spreadsheet::DataSetViewItem, blender::ed::spreadsheet::InstancesTreeViewItem, blender::ui::bonecollections::BoneCollectionItem, blender::ui::greasepencil::LayerGroupViewItem, and blender::ui::greasepencil::LayerViewItem.
Definition at line 46 of file abstract_view_item.cc.
Referenced by blender::ui::AbstractView::change_state_delayed(), and change_state_delayed().
|
protectedvirtual |
Reimplemented in blender::ed::asset::shelf::AssetViewItem.
Definition at line 240 of file abstract_view_item.cc.
Referenced by blender::ui::AbstractView::filter().
|
virtual |
Queries if the view item supports renaming in principle. Renaming may still fail, e.g. if another item is already being renamed.
Reimplemented in blender::ed::asset_browser::AssetCatalogTreeViewItem, blender::ui::bonecollections::BoneCollectionItem, blender::ui::greasepencil::LayerGroupViewItem, and blender::ui::greasepencil::LayerViewItem.
Definition at line 108 of file abstract_view_item.cc.
Referenced by begin_renaming(), and UI_view_item_can_rename().
|
protectedvirtual |
Copy persistent state (e.g. active, selection, etc.) from a matching item of the last redraw to this item. If sub-classes introduce more advanced state they should override this and make it update their state accordingly.
Reimplemented in blender::ui::AbstractTreeViewItem.
Definition at line 28 of file abstract_view_item.cc.
References is_active_, is_highlighted_search_, and is_renaming_.
Referenced by blender::ui::AbstractTreeViewItem::update_from_old().
| uiButViewItem * blender::ui::AbstractViewItem::view_item_button | ( | ) | const |
Get the view item button (button of type UI_BTYPE_VIEW_ITEM) created for this item. Every visible item gets one during the layout building. Items that are not visible may not have one, so null is a valid return value.
Definition at line 296 of file abstract_view_item.cc.
References view_item_but_.
Referenced by blender::ed::asset::shelf::AssetViewItem::build_grid_tile(), blender::ui::PreviewGridItem::build_grid_tile_button(), blender::ed::asset_browser::AssetCatalogTreeViewItem::build_row(), blender::ed::spreadsheet::draw_row_suffix(), and blender::ui::AbstractTreeViewItem::get_win_rect().
|
friend |
Definition at line 167 of file UI_abstract_view.hh.
|
friend |
Definition at line 168 of file UI_abstract_view.hh.
|
protected |
Definition at line 178 of file UI_abstract_view.hh.
Referenced by disable_activatable(), and set_state_active().
|
protected |
Definition at line 180 of file UI_abstract_view.hh.
Referenced by change_state_delayed(), deactivate(), is_active(), set_state_active(), and update_from_old().
|
protected |
Cache filtered state here to avoid having to re-query.
Definition at line 186 of file UI_abstract_view.hh.
Referenced by blender::ui::AbstractView::filter(), and is_filtered_visible().
|
protected |
Definition at line 183 of file UI_abstract_view.hh.
Referenced by blender::ui::AbstractView::clear_search_highlight(), blender::ui::AbstractView::filter(), is_search_highlight(), and update_from_old().
|
protected |
Definition at line 179 of file UI_abstract_view.hh.
Referenced by blender::ui::TreeViewLayoutBuilder::build_row(), disable_interaction(), and is_interactive().
|
protected |
Definition at line 181 of file UI_abstract_view.hh.
Referenced by begin_renaming(), end_renaming(), is_renaming(), and update_from_old().
|
protected |
The view this item is a part of, and was registered for using AbstractView::register_item(). If this wasn't done, the behavior of items is undefined.
Definition at line 175 of file UI_abstract_view.hh.
Referenced by blender::ui::AbstractGridViewItem::get_view(), get_view(), blender::ui::GridViewItemDropTarget::get_view(), and blender::ui::AbstractView::register_item().
|
protected |
Definition at line 177 of file UI_abstract_view.hh.
Referenced by blender::ed::asset::shelf::AssetViewItem::build_grid_tile(), blender::ui::AbstractTreeViewItem::is_hovered(), and view_item_button().