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) {
229 if (collection_te != te) {
238 return collection_te;
249 drop_te = drop_te->
prev;
254 drop_te = drop_te->
next;
258 if (drop_te ==
nullptr) {
280 if (potential_parent == potential_child) {
286 if (potential_parent == potential_child->
parent) {
330 if (!potential_child) {
359 const bool keep_transform)
367 if (scene ==
nullptr) {
376 bool parent_set =
false;
377 bool linked_objects =
false;
379 for (
wmDragID *drag_id = drag; drag_id; drag_id = drag_id->
next) {
380 if (
GS(drag_id->id->name) ==
ID_OB) {
385 linked_objects =
true;
390 reports,
C, scene,
object, parent, parent_type,
false, keep_transform,
nullptr))
397 if (linked_objects) {
398 BKE_report(reports,
RPT_INFO,
"Cannot edit library linked or non-editable override object(s)");
420 if (
ELEM(
nullptr, ob, par)) {
447 ot->name =
"Drop to Set Parent (hold Alt to not keep transforms)";
448 ot->description =
"Drag to parent in Outliner";
449 ot->idname =
"OUTLINER_OT_parent_drop";
518 if (
GS(drag_id->id->name) ==
ID_OB) {
536 ot->name =
"Drop to Clear Parent (hold Alt to not keep transforms)";
537 ot->description =
"Drag to clear parent in Outliner";
538 ot->idname =
"OUTLINER_OT_parent_clear";
607 ot->name =
"Drop Object to Scene";
608 ot->description =
"Drag object to scene in Outliner";
609 ot->idname =
"OUTLINER_OT_scene_drop";
664 ot->name =
"Drop Material on Object";
665 ot->description =
"Drag material to object in Outliner";
666 ot->idname =
"OUTLINER_OT_material_drop";
724 drag->
poin = drop_data;
784 else if (ob && ob != drop_data->
ob_parent) {
785 drop_data->
drop_te = object_te;
792 else if (ob || pchan) {
800 else if (ob && ob != drop_data->
ob_parent) {
803 drop_data->
drop_te = object_te;
811 drop_data->
drop_te = te_target;
909 return TIP_(
"Reorder");
912 return TIP_(
"Copy to bone");
914 return TIP_(
"Copy to object");
918 return TIP_(
"Link all to bone");
920 return TIP_(
"Link all to object");
1080 ot->name =
"Data Stack Drop";
1081 ot->description =
"Copy or reorder modifiers, constraints, and effects";
1082 ot->idname =
"OUTLINER_OT_datastack_drop";
1116 return ((
Scene *)
id)->master_collection;
1147 if (drag_id ==
nullptr) {
1151 ID *
id = drag_id->
id;
1167 if (
id == &to_collection->
id) {
1182 data->from = from_collection;
1183 data->to = to_collection;
1185 data->insert_type = insert_type;
1200 switch (
data.insert_type) {
1236 const bool is_link = !
data.from || (
event->modifier &
KM_CTRL);
1239 bool same_level =
false;
1241 if (
data.from == parent->collection) {
1248 const bool tooltip_link = (is_link && !same_level);
1249 const char *tooltip_before = tooltip_link ?
TIP_(
"Link before collection") :
1250 TIP_(
"Move before collection");
1251 const char *tooltip_between = tooltip_link ?
TIP_(
"Link between collections") :
1252 TIP_(
"Move between collections");
1253 const char *tooltip_after = tooltip_link ?
TIP_(
"Link after collection") :
1254 TIP_(
"Move after collection");
1257 switch (
data.insert_type) {
1260 return tooltip_between;
1262 return tooltip_before;
1265 return tooltip_between;
1267 return tooltip_after;
1270 return TIP_(
"Link inside collection");
1279 return TIP_(
"Move inside collection (Ctrl to link, Shift to parent)");
1281 return TIP_(
"Move inside collection (Ctrl to link)");
1309 bool relative_after =
false;
1335 if (
GS(drag_id->id->name) ==
ID_OB) {
1346 else if (
GS(drag_id->id->name) ==
ID_GR) {
1350 if (collection != from) {
1372 ot->name =
"Move to Collection";
1373 ot->description =
"Drag to move to collection in Outliner";
1374 ot->idname =
"OUTLINER_OT_collection_drop";
1390#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD 7
1422 if (!
data.drag_id) {
1446 const bool use_datastack_drag =
ELEM(tselem->
type,
1457 if (use_datastack_drag) {
1476 &space_outliner->
tree,
1484 &space_outliner->
tree,
1500 bool parent_selected =
false;
1502 te_parent = te_parent->
parent)
1506 parent_selected =
true;
1512 if (parent_selected) {
1522 if (te_selected->
parent) {
1524 te_parent = te_parent->
parent)
1560 ot->name =
"Drag and Drop";
1561 ot->idname =
"OUTLINER_OT_item_drag_drop";
1562 ot->description =
"Drag and drop element to another place";
1568#undef OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
1585 "OUTLINER_OT_datastack_drop",
1591 "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.
@ BKE_MAT_ASSIGN_USERPREF
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
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 DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
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
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])
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, blender::wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_main_add_notifier(uint type, void *reference)
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)