Blender
V3.3
|
#include <UI_abstract_view.hh>
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< AbstractViewItemDropController > | create_drop_controller () const |
General Getters & Setters | |
AbstractView & | get_view () const |
bool | is_active () const |
Static Public Member Functions | |
template<typename ToType = AbstractViewItem> | |
static ToType * | from_item_handle (uiViewItemHandle *handle) |
Protected Member Functions | |
AbstractViewItem ()=default | |
virtual bool | matches (const AbstractViewItem &other) const =0 |
View Reconstruction | |
virtual void | update_from_old (const AbstractViewItem &old) |
Protected Attributes | |
AbstractView * | view_ = nullptr |
bool | is_active_ = false |
bool | is_renaming_ = false |
Friends | |
class | AbstractView |
class | ViewItemAPIWrapper |
Renaming | |
virtual bool | supports_renaming () const |
virtual bool | rename (StringRefNull new_name) |
virtual StringRef | get_rename_string () const |
bool | is_renaming () const |
void | begin_renaming () |
void | end_renaming () |
void | rename_apply () |
void | add_rename_button (uiBlock &block) |
Definition at line 94 of file UI_abstract_view.hh.
|
virtualdefault |
|
protecteddefault |
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 123 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, uiDefBut(), and view.
void blender::ui::AbstractViewItem::begin_renaming | ( | ) |
Definition at line 59 of file abstract_view_item.cc.
References copy(), get_rename_string(), get_view(), is_renaming_, supports_renaming(), and view.
Referenced by UI_view_item_begin_rename().
|
virtual |
Reimplemented in blender::ed::asset_browser::AssetCatalogTreeViewItem.
Definition at line 160 of file abstract_view_item.cc.
Referenced by UI_view_item_context_menu_build().
|
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_browser::AssetCatalogTreeViewItem.
Definition at line 171 of file abstract_view_item.cc.
Referenced by blender::ui::ViewItemAPIWrapper::drag_start().
|
virtual |
If an item wants to support dropping data into it, it has to return a drop controller here. That is an object implementing #AbstractViewItemDropController.
Reimplemented in blender::ed::asset_browser::AssetCatalogTreeViewItem.
Definition at line 177 of file abstract_view_item.cc.
Referenced by blender::ui::ViewItemAPIWrapper::can_drop(), blender::ui::ViewItemAPIWrapper::drop_handle(), and blender::ui::ViewItemAPIWrapper::drop_tooltip().
void blender::ui::AbstractViewItem::end_renaming | ( | ) |
Definition at line 81 of file abstract_view_item.cc.
References get_view(), is_renaming(), is_renaming_, and view.
Referenced by add_rename_button(), and rename_apply().
|
static |
Definition at line 191 of file UI_abstract_view.hh.
|
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.
Definition at line 48 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 202 of file abstract_view_item.cc.
References UNLIKELY, and view_.
Referenced by add_rename_button(), begin_renaming(), blender::ui::ViewItemAPIWrapper::can_rename(), end_renaming(), blender::ui::find_item_from_rename_button(), blender::ui::AbstractTreeViewItem::get_tree_view(), is_active(), rename_apply(), and ui_block_view_find_matching_view_item_but_in_old_block().
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 211 of file abstract_view_item.cc.
References BLI_assert_msg, get_view(), and is_active_.
Referenced by blender::ui::AbstractGridViewItem::activate(), blender::ui::AbstractTreeViewItem::activate(), and UI_view_item_is_active().
bool blender::ui::AbstractViewItem::is_renaming | ( | ) | const |
Definition at line 54 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().
|
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::AbstractTreeViewItem, and blender::ui::AbstractGridViewItem.
|
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, and blender::ui::AbstractTreeViewItem.
Definition at line 42 of file abstract_view_item.cc.
Referenced by rename_apply().
void blender::ui::AbstractViewItem::rename_apply | ( | ) |
Definition at line 74 of file abstract_view_item.cc.
References end_renaming(), get_view(), rename(), and view.
Referenced by blender::ui::rename_button_fn().
|
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.
Definition at line 37 of file abstract_view_item.cc.
Referenced by begin_renaming(), and blender::ui::ViewItemAPIWrapper::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 25 of file abstract_view_item.cc.
References is_active_, and is_renaming_.
Referenced by blender::ui::AbstractTreeViewItem::update_from_old().
|
friend |
Definition at line 95 of file UI_abstract_view.hh.
|
friend |
Definition at line 96 of file UI_abstract_view.hh.
|
protected |
Definition at line 104 of file UI_abstract_view.hh.
Referenced by blender::ui::AbstractGridViewItem::activate(), blender::ui::AbstractTreeViewItem::activate(), blender::ui::AbstractGridViewItem::deactivate(), blender::ui::AbstractTreeViewItem::deactivate(), is_active(), and update_from_old().
|
protected |
Definition at line 105 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 103 of file UI_abstract_view.hh.
Referenced by get_view(), blender::ui::AbstractGridViewItem::get_view(), and blender::ui::AbstractView::register_item().