Blender V4.3
blender::ui::TreeViewItemDropTarget Class Reference

#include <UI_tree_view.hh>

Inherits blender::ui::DropTargetInterface.

Inherited by blender::ed::asset_browser::AssetCatalogDropTarget, blender::ui::bonecollections::BoneCollectionDropTarget, and blender::ui::greasepencil::LayerNodeDropTarget.

Public Member Functions

 TreeViewItemDropTarget (AbstractTreeViewItem &view_item, DropBehavior behavior=DropBehavior::Insert)
 
std::optional< DropLocationchoose_drop_location (const ARegion &region, const wmEvent &event) const override
 
template<class ViewType >
ViewType & get_view () const
 
- Public Member Functions inherited from blender::ui::DropTargetInterface
 DropTargetInterface ()=default
 
virtual ~DropTargetInterface ()=default
 
virtual bool can_drop (const wmDrag &drag, const char **r_disabled_hint) const =0
 
virtual std::string drop_tooltip (const DragInfo &drag) const =0
 
virtual bool on_drop (bContext *C, const DragInfo &drag) const =0
 

Protected Attributes

AbstractTreeViewItemview_item_
 
const DropBehavior behavior_
 

Detailed Description

Class to define the behavior when dropping something onto/into a view item, plus the behavior when dragging over this item. An item can return a drop target for itself via a custom implementation of AbstractTreeViewItem::create_drop_target().

By default the drop target only supports dropping into/onto itself. To support inserting/reordering behavior, where dropping before or after the drop-target is supported, pass a different DropBehavior to the constructor.

Definition at line 382 of file UI_tree_view.hh.

Constructor & Destructor Documentation

◆ TreeViewItemDropTarget()

blender::ui::TreeViewItemDropTarget::TreeViewItemDropTarget ( AbstractTreeViewItem & view_item,
DropBehavior behavior = DropBehavior::Insert )

Definition at line 343 of file tree_view.cc.

Member Function Documentation

◆ choose_drop_location()

std::optional< DropLocation > blender::ui::TreeViewItemDropTarget::choose_drop_location ( const ARegion & region,
const wmEvent & event ) const
overridevirtual

Once the drop target validated that it can receive the dragged data using can_drop(), this method can determine where/how the data should be dropped exactly: before, after or into the drop target. Additional feedback can be drawn then while dragging, and the on_drop() function should operate accordingly. Implementations of this function may want to use DropBehavior to control which locations may be returned here.

If the returned optional is unset, dropping will be disabled. The default implementation returns DropLocation::Into.

Reimplemented from blender::ui::DropTargetInterface.

Definition at line 349 of file tree_view.cc.

References blender::ui::After, blender::ui::Before, behavior_, BLI_assert, BLI_assert_unreachable, BLI_rctf_size_y(), ELEM, blender::ui::AbstractTreeViewItem::get_win_rect(), blender::ui::Insert, blender::ui::Into, blender::ui::AbstractTreeViewItem::is_collapsed(), blender::ui::AbstractTreeViewItem::is_collapsible(), blender::ui::Reorder, blender::ui::ReorderAndInsert, view_item_, and wmEvent::xy.

◆ get_view()

template<class ViewType >
ViewType & blender::ui::TreeViewItemDropTarget::get_view ( ) const
inline

Request the view the item is registered for as type #ViewType. Throws a std::bad_cast exception if the view is not of the requested type.

Definition at line 430 of file UI_tree_view.hh.

Referenced by blender::ed::asset_browser::AssetCatalogDropTarget::get_asset_library(), and blender::ed::asset_browser::AssetCatalogDropTarget::on_drop().

Member Data Documentation

◆ behavior_

const DropBehavior blender::ui::TreeViewItemDropTarget::behavior_
protected

Definition at line 385 of file UI_tree_view.hh.

Referenced by choose_drop_location().

◆ view_item_

AbstractTreeViewItem& blender::ui::TreeViewItemDropTarget::view_item_
protected

Definition at line 384 of file UI_tree_view.hh.

Referenced by choose_drop_location().


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