Blender V5.0
blender::ui::TreeViewItemDropTarget Class Reference

#include <UI_tree_view.hh>

Inherits blender::ui::DropTargetInterface.

Inherited by blender::ed::asset_browser::AssetCatalogDropTarget, blender::ed::object::shapekey::ShapeKeyDropTarget, 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 410 of file UI_tree_view.hh.

Constructor & Destructor Documentation

◆ TreeViewItemDropTarget()

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 443 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::Insert, blender::ui::Into, 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 458 of file UI_tree_view.hh.

References view_item_.

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 413 of file UI_tree_view.hh.

Referenced by choose_drop_location(), and TreeViewItemDropTarget().

◆ view_item_

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

Definition at line 412 of file UI_tree_view.hh.

Referenced by choose_drop_location(), get_view(), and TreeViewItemDropTarget().


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