Blender  V3.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
blender::ui::AbstractViewItem Class Referenceabstract

#include <UI_abstract_view.hh>

Inheritance diagram for blender::ui::AbstractViewItem:
blender::ui::AbstractGridViewItem blender::ui::AbstractTreeViewItem blender::ui::PreviewGridItem blender::ed::spreadsheet::GeometryDataSetTreeViewItem blender::ui::BasicTreeViewItem blender::ed::asset_browser::AssetCatalogTreeViewAllItem blender::ed::asset_browser::AssetCatalogTreeViewItem blender::ed::asset_browser::AssetCatalogTreeViewUnassignedItem

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< AbstractViewItemDragControllercreate_drag_controller () const
 
virtual std::unique_ptr< AbstractViewItemDropControllercreate_drop_controller () const
 
General Getters & Setters
AbstractViewget_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

AbstractViewview_ = 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)
 

Detailed Description

Definition at line 94 of file UI_abstract_view.hh.

Constructor & Destructor Documentation

◆ ~AbstractViewItem()

virtual blender::ui::AbstractViewItem::~AbstractViewItem ( )
virtualdefault

◆ AbstractViewItem()

blender::ui::AbstractViewItem::AbstractViewItem ( )
protecteddefault

Member Function Documentation

◆ add_rename_button()

void blender::ui::AbstractViewItem::add_rename_button ( uiBlock block)
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 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.

◆ begin_renaming()

void blender::ui::AbstractViewItem::begin_renaming ( )

◆ build_context_menu()

void blender::ui::AbstractViewItem::build_context_menu ( bContext C,
uiLayout column 
) const
virtual

◆ create_drag_controller()

std::unique_ptr< AbstractViewItemDragController > blender::ui::AbstractViewItem::create_drag_controller ( ) const
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().

◆ create_drop_controller()

std::unique_ptr< AbstractViewItemDropController > blender::ui::AbstractViewItem::create_drop_controller ( ) const
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.

Note
This drop controller may be requested for each event. The view doesn't keep a drop controller around currently. So it can not contain persistent state.

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().

◆ end_renaming()

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().

◆ from_item_handle()

template<typename ToType >
ToType * blender::ui::AbstractViewItem::from_item_handle ( uiViewItemHandle handle)
static

Definition at line 191 of file UI_abstract_view.hh.

◆ get_rename_string()

StringRef blender::ui::AbstractViewItem::get_rename_string ( ) const
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().

◆ get_view()

AbstractView & blender::ui::AbstractViewItem::get_view ( ) const

◆ is_active()

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().

◆ is_renaming()

bool blender::ui::AbstractViewItem::is_renaming ( ) const

◆ matches()

virtual bool blender::ui::AbstractViewItem::matches ( const AbstractViewItem other) const
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.

◆ rename()

bool blender::ui::AbstractViewItem::rename ( StringRefNull  new_name)
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.

Returns
True if the renaming was successful.

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().

◆ 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().

◆ supports_renaming()

bool blender::ui::AbstractViewItem::supports_renaming ( ) const
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().

◆ update_from_old()

void blender::ui::AbstractViewItem::update_from_old ( const AbstractViewItem old)
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.

Note
Always call the base class implementation when overriding this!

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().

Friends And Related Function Documentation

◆ AbstractView

friend class AbstractView
friend

Definition at line 95 of file UI_abstract_view.hh.

◆ ViewItemAPIWrapper

friend class ViewItemAPIWrapper
friend

Definition at line 96 of file UI_abstract_view.hh.

Member Data Documentation

◆ is_active_

bool blender::ui::AbstractViewItem::is_active_ = false
protected

◆ is_renaming_

bool blender::ui::AbstractViewItem::is_renaming_ = false
protected

Definition at line 105 of file UI_abstract_view.hh.

Referenced by begin_renaming(), end_renaming(), is_renaming(), and update_from_old().

◆ view_

AbstractView* blender::ui::AbstractViewItem::view_ = nullptr
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().


The documentation for this class was generated from the following files: