61 if ((fmval[1] > te->
ys) && (fmval[1] < (te->
ys +
UI_UNIT_Y))) {
139 const float margin =
UI_UNIT_Y * (1.0f / 4);
141 if (view_mval[1] < (te_hovered->
ys + margin)) {
156 if (view_mval[1] > (te_hovered->
ys + (3 * margin))) {
169 if (view_mval[1] < last->
ys) {
187 while (te !=
nullptr) {
188 if (check_type(te)) {
224 if (!collection_te) {
236 if (collection_te != te) {
245 return collection_te;
256 drop_te = drop_te->
prev;
261 drop_te = drop_te->
next;
265 if (drop_te ==
nullptr) {
287 if (potential_parent == potential_child) {
293 if (potential_parent == potential_child->
parent) {
337 if (!potential_child) {
366 const bool keep_transform)
374 if (scene ==
nullptr) {
383 bool parent_set =
false;
384 bool linked_objects =
false;
386 for (
wmDragID *drag_id = drag; drag_id; drag_id = drag_id->
next) {
387 if (
GS(drag_id->id->name) ==
ID_OB) {
392 linked_objects =
true;
397 reports,
C, scene,
object, parent, parent_type,
false, keep_transform,
nullptr))
404 if (linked_objects) {
427 if (
ELEM(
nullptr, ob, par)) {
454 ot->name =
"Drop to Set Parent (hold Alt to keep transforms)";
455 ot->description =
"Drag to parent in Outliner";
456 ot->idname =
"OUTLINER_OT_parent_drop";
525 if (
GS(drag_id->id->name) ==
ID_OB) {
543 ot->name =
"Drop to Clear Parent (hold Alt to keep transforms)";
544 ot->description =
"Drag to clear parent in Outliner";
545 ot->idname =
"OUTLINER_OT_parent_clear";
614 ot->name =
"Drop Object to Scene";
615 ot->description =
"Drag object to scene in Outliner";
616 ot->idname =
"OUTLINER_OT_scene_drop";
671 ot->name =
"Drop Material on Object";
672 ot->description =
"Drag material to object in Outliner";
673 ot->idname =
"OUTLINER_OT_material_drop";
731 drag->
poin = drop_data;
791 else if (ob && ob != drop_data->
ob_parent) {
792 drop_data->
drop_te = object_te;
799 else if (ob || pchan) {
807 else if (ob && ob != drop_data->
ob_parent) {
810 drop_data->
drop_te = object_te;
818 drop_data->
drop_te = te_target;
916 return TIP_(
"Reorder");
919 return TIP_(
"Copy to bone");
921 return TIP_(
"Copy to object");
925 return TIP_(
"Link all to bone");
927 return TIP_(
"Link all to object");
1087 ot->name =
"Data Stack Drop";
1088 ot->description =
"Copy or reorder modifiers, constraints, and effects";
1089 ot->idname =
"OUTLINER_OT_datastack_drop";
1123 return ((
Scene *)
id)->master_collection;
1154 if (drag_id ==
nullptr) {
1158 ID *
id = drag_id->
id;
1174 if (
id == &to_collection->
id) {
1189 data->from = from_collection;
1190 data->to = to_collection;
1192 data->insert_type = insert_type;
1207 switch (
data.insert_type) {
1243 const bool is_link = !
data.from || (
event->modifier &
KM_CTRL);
1246 bool same_level =
false;
1248 if (
data.from == parent->collection) {
1255 const bool tooltip_link = (is_link && !same_level);
1256 const char *tooltip_before = tooltip_link ?
TIP_(
"Link before collection") :
1257 TIP_(
"Move before collection");
1258 const char *tooltip_between = tooltip_link ?
TIP_(
"Link between collections") :
1259 TIP_(
"Move between collections");
1260 const char *tooltip_after = tooltip_link ?
TIP_(
"Link after collection") :
1261 TIP_(
"Move after collection");
1264 switch (
data.insert_type) {
1267 return tooltip_between;
1269 return tooltip_before;
1272 return tooltip_between;
1274 return tooltip_after;
1277 return TIP_(
"Link inside collection");
1286 return TIP_(
"Move inside collection (Ctrl to link, Shift to parent)");
1288 return TIP_(
"Move inside collection (Ctrl to link)");
1316 bool relative_after =
false;
1336 if (relative_after) {
1346 if (
GS(drag_id->id->name) ==
ID_OB) {
1357 else if (
GS(drag_id->id->name) ==
ID_GR) {
1361 if (collection != from) {
1383 ot->name =
"Move to Collection";
1384 ot->description =
"Drag to move to collection in Outliner";
1385 ot->idname =
"OUTLINER_OT_collection_drop";
1401#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD 7
1433 if (!
data.drag_id) {
1457 const bool use_datastack_drag =
ELEM(tselem->
type,
1468 if (use_datastack_drag) {
1487 &space_outliner->
tree,
1495 &space_outliner->
tree,
1511 bool parent_selected =
false;
1513 te_parent = te_parent->
parent)
1517 parent_selected =
true;
1523 if (parent_selected) {
1533 if (te_selected->
parent) {
1535 te_parent = te_parent->
parent)
1571 ot->name =
"Drag and Drop";
1572 ot->idname =
"OUTLINER_OT_item_drag_drop";
1573 ot->description =
"Drag and drop element to another place";
1579#undef OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
1596 "OUTLINER_OT_datastack_drop",
1602 "OUTLINER_OT_collection_drop",
bool BKE_collection_is_empty(const Collection *collection)
bool BKE_collection_move(Main *bmain, Collection *to_parent, Collection *from_parent, Collection *relative, bool relative_after, Collection *collection)
void BKE_collection_object_move(Main *bmain, Scene *scene, Collection *collection_dst, Collection *collection_src, Object *ob)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
ReportList * CTX_wm_reports(const bContext *C)
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
Collection * CTX_data_collection(const bContext *C)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
bool BKE_scene_has_object(Scene *scene, Object *ob)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
General operations, lookup, etc. for materials.
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
@ BKE_MAT_ASSIGN_USERPREF
General operations, lookup, etc. for blender objects.
bool BKE_object_is_child_recursive(const Object *ob_parent, const Object *ob_child)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void void void void void void void BLI_listbase_reverse(ListBase *lb) ATTR_NONNULL(1)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
struct Collection Collection
Object is a sort of wrapper for general info.
@ TSE_LIBRARY_OVERRIDE_BASE
@ TSE_GPENCIL_EFFECT_BASE
@ SO_FILTER_NO_COLLECTION
void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *space_outliner)
bool ED_operator_region_outliner_active(bContext *C)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
void ED_region_tag_redraw(ARegion *region)
bool ED_operator_outliner_active(bContext *C)
Read Guarded memory(de)allocation.
float UI_view2d_region_to_view_y(const View2D *v2d, float y)
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
BMesh const char void * data
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
void * MEM_callocN(size_t len, const char *str)
@ CLEAR_PARENT_KEEP_TRANSFORM
void constraint_link(Main *bmain, Object *ob_dst, ListBase *dst, ListBase *src)
void constraint_copy_for_object(Main *bmain, Object *ob_dst, bConstraint *con)
bool modifier_copy_to_object(Main *bmain, const Scene *scene, const Object *ob_src, const ModifierData *md, Object *ob_dst, ReportList *reports)
void constraint_copy_for_pose(Main *bmain, Object *ob_dst, bPoseChannel *pchan, bConstraint *con)
void base_select(Base *base, eObjectSelect_Mode mode)
void parent_clear(Object *ob, int type)
bool parent_set(ReportList *reports, const bContext *C, Scene *scene, Object *const ob, Object *const par, int partype, bool xmirror, bool keep_transform, const int vert_par[3])
void shaderfx_copy(Object *dst, ShaderFxData *fx)
bool constraint_move_to_index(Object *ob, bConstraint *con, int index)
bool modifier_move_to_index(ReportList *reports, eReportType error_type, Object *ob, ModifierData *md, int index, bool allow_partial)
bool shaderfx_move_to_index(ReportList *reports, Object *ob, ShaderFxData *fx, int index)
void modifier_link(bContext *C, Object *ob_dst, Object *ob_src)
void shaderfx_link(Object *dst, Object *src)
static bool scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x)
static bool collection_drop_init(bContext *C, wmDrag *drag, const int xy[2], CollectionDrop *data)
static bool is_pchan_element(TreeElement *te)
static void datastack_drop_link(bContext *C, StackDropData *drop_data)
bool(*)(TreeElement *te) CheckTypeFn
static wmOperatorStatus outliner_item_drag_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static TreeElement * outliner_drop_find(bContext *C, const wmEvent *event)
static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
static std::string datastack_drop_tooltip(bContext *, wmDrag *drag, const int[2], wmDropBox *)
bool outliner_is_collection_tree_element(const TreeElement *te)
static std::string collection_drop_tooltip(bContext *C, wmDrag *drag, const int xy[2], wmDropBox *)
static ID * outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode)
TreeElement * outliner_find_id(SpaceOutliner *space_outliner, ListBase *lb, const ID *id)
static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static wmOperatorStatus scene_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static bool datastack_drop_are_types_valid(StackDropData *drop_data)
static void datastack_drop_reorder(bContext *C, ReportList *reports, StackDropData *drop_data)
static wmOperatorStatus datastack_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool outliner_flag_set(const SpaceOutliner &space_outliner, const short flag, const short set)
static bool datastack_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
void OUTLINER_OT_collection_drop(wmOperatorType *ot)
TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
TreeElement * outliner_find_item_at_y(const SpaceOutliner *space_outliner, const ListBase *tree, float view_co_y)
static TreeElement * outliner_drop_insert_collection_find(bContext *C, const int xy[2], TreeElementInsertType *r_insert_type)
@ DATA_STACK_DROP_REORDER
bPoseChannel * outliner_find_parent_bone(TreeElement *te, TreeElement **r_bone_te)
void OUTLINER_OT_datastack_drop(wmOperatorType *ot)
static TreeElement * outliner_drop_insert_find(bContext *C, const int xy[2], TreeElementInsertType *r_insert_type)
static void datastack_drop_data_init(wmDrag *drag, Object *ob, bPoseChannel *pchan, TreeElement *te, TreeStoreElem *tselem, void *directdata)
static int outliner_get_insert_index(TreeElement *drag_te, TreeElement *drop_te, TreeElementInsertType insert_type, ListBase *listbase)
TreeTraversalAction outliner_collect_selected_objects(TreeElement *te, void *customdata)
Collection * outliner_collection_from_tree_element(const TreeElement *te)
static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2])
void OUTLINER_OT_material_drop(wmOperatorType *ot)
void OUTLINER_OT_scene_drop(wmOperatorType *ot)
static TreeElement * outliner_dropzone_find(const SpaceOutliner *space_outliner, const float fmval[2], const bool children)
static wmOperatorStatus material_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static TreeElement * outliner_item_drag_element_find(SpaceOutliner *space_outliner, ARegion *region, const wmEvent *event)
void OUTLINER_OT_parent_drop(wmOperatorType *ot)
bool outliner_tree_traverse(const SpaceOutliner *space_outliner, ListBase *tree, int filter_te_flag, int filter_tselem_flag, TreeTraversalFunc func, void *customdata)
ID * outliner_search_back(TreeElement *te, short idcode)
static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData *drop_data)
static bool allow_parenting_without_modifier_key(SpaceOutliner *space_outliner)
static void parent_drop_set_parents(bContext *C, ReportList *reports, wmDragID *drag, Object *parent, short parent_type, const bool keep_transform)
TreeElement * outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem)
TreeElement * outliner_find_parent_element(ListBase *lb, TreeElement *parent_te, const TreeElement *child_te)
static wmOperatorStatus parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool is_object_element(TreeElement *te)
static void datastack_drop_copy(bContext *C, StackDropData *drop_data)
static wmOperatorStatus collection_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static bool is_collection_element(TreeElement *te)
static TreeElement * outliner_data_from_tree_element_and_parents(CheckTypeFn check_type, TreeElement *te)
static Collection * collection_parent_from_ID(ID *id)
void OUTLINER_OT_parent_clear(wmOperatorType *ot)
static TreeElement * outliner_dropzone_element(TreeElement *te, const float fmval[2], const bool children)
static wmOperatorStatus parent_clear_invoke(bContext *C, wmOperator *, const wmEvent *event)
TreeTraversalAction outliner_collect_selected_collections(TreeElement *te, void *customdata)
static bool material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
void OUTLINER_OT_item_drag_drop(wmOperatorType *ot)
void outliner_dropboxes()
static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
#define TSELEM_OPEN(telm, sv)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
struct MaterialGPencilStyle * gp_style
struct Collection * master_collection
TreeElementInsertType insert_type
eDataStackDropAction drop_action
TreeStoreElem * drag_tselem
TreeElementInsertType insert_type
bPoseChannel * pchan_parent
wmEventModifierFlag modifier
struct ReportList * reports
struct wmEvent * eventstate
wmDropBox * WM_dropbox_add(ListBase *lb, const char *idname, bool(*poll)(bContext *C, wmDrag *drag, const wmEvent *event), void(*copy)(bContext *C, wmDrag *drag, wmDropBox *drop), void(*cancel)(Main *bmain, wmDrag *drag, wmDropBox *drop), WMDropboxTooltipFunc tooltip)
void WM_event_start_prepared_drag(bContext *C, wmDrag *drag)
wmDrag * WM_drag_data_create(bContext *C, int icon, eWM_DragDataType type, void *poin, uint flags)
ID * WM_drag_get_local_ID_from_event(const wmEvent *event, short idcode)
ListBase * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
void WM_drag_add_local_ID(wmDrag *drag, ID *id, ID *from_parent)
ID * WM_drag_get_local_ID(const wmDrag *drag, short idcode)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void WM_main_add_notifier(uint type, void *reference)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)