61 if ((fmval[1] > te->
ys) && (fmval[1] < (te->
ys +
UI_UNIT_Y))) {
130 mval[0] =
xy[0] - region->winrct.xmin;
131 mval[1] =
xy[1] - region->winrct.ymin;
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,
"Can't 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 keep transforms)";
449 ot->
idname =
"OUTLINER_OT_parent_drop";
492 switch (
GS(id->name)) {
518 if (
GS(drag_id->id->name) ==
ID_OB) {
536 ot->
name =
"Drop to Clear Parent (hold Alt to keep transforms)";
538 ot->
idname =
"OUTLINER_OT_parent_clear";
579 collection = scene->master_collection;
606 ot->
name =
"Drop Object to Scene";
608 ot->
idname =
"OUTLINER_OT_scene_drop";
661 ot->
name =
"Drop Material on Object";
663 ot->
idname =
"OUTLINER_OT_material_drop";
713 StackDropData *drop_data = MEM_cnew<StackDropData>(
"datastack drop data");
721 drag->
poin = drop_data;
781 else if (ob && ob != drop_data->
ob_parent) {
782 drop_data->
drop_te = object_te;
789 else if (ob || pchan) {
797 else if (ob && ob != drop_data->
ob_parent) {
800 drop_data->
drop_te = object_te;
808 drop_data->
drop_te = te_target;
906 return TIP_(
"Reorder");
909 return TIP_(
"Copy to bone");
911 return TIP_(
"Copy to object");
915 return TIP_(
"Link all to bone");
917 return TIP_(
"Link all to object");
1077 ot->
name =
"Data Stack Drop";
1078 ot->
description =
"Copy or reorder modifiers, constraints, and effects";
1079 ot->
idname =
"OUTLINER_OT_datastack_drop";
1113 return ((
Scene *)
id)->master_collection;
1142 if (drag_id ==
nullptr) {
1146 ID *
id = drag_id->
id;
1162 if (
id == &to_collection->
id) {
1177 data->from = from_collection;
1178 data->to = to_collection;
1180 data->insert_type = insert_type;
1195 switch (data.insert_type) {
1231 const bool is_link = !data.
from || (
event->modifier &
KM_CTRL);
1234 bool same_level =
false;
1236 if (data.from == parent->collection) {
1243 const bool tooltip_link = (is_link && !same_level);
1244 const char *tooltip_before = tooltip_link ?
TIP_(
"Link before collection") :
1245 TIP_(
"Move before collection");
1246 const char *tooltip_between = tooltip_link ?
TIP_(
"Link between collections") :
1247 TIP_(
"Move between collections");
1248 const char *tooltip_after = tooltip_link ?
TIP_(
"Link after collection") :
1249 TIP_(
"Move after collection");
1252 switch (data.insert_type) {
1255 return tooltip_between;
1257 return tooltip_before;
1260 return tooltip_between;
1262 return tooltip_after;
1265 return TIP_(
"Link inside collection");
1274 return TIP_(
"Move inside collection (Ctrl to link, Shift to parent)");
1276 return TIP_(
"Move inside collection (Ctrl to link)");
1302 bool relative_after =
false;
1328 if (
GS(drag_id->id->name) ==
ID_OB) {
1339 else if (
GS(drag_id->id->name) ==
ID_GR) {
1343 if (collection != from) {
1365 ot->
name =
"Move to Collection";
1367 ot->
idname =
"OUTLINER_OT_collection_drop";
1383#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD 7
1413 if (!data.drag_id) {
1437 const bool use_datastack_drag =
ELEM(tselem->
type,
1448 if (use_datastack_drag) {
1465 if (
GS(data.drag_id->name) ==
ID_OB) {
1467 &space_outliner->
tree,
1475 &space_outliner->
tree,
1486 if (
GS(data.drag_id->name) ==
ID_OB) {
1491 bool parent_selected =
false;
1493 te_parent = te_parent->parent)
1497 parent_selected =
true;
1503 if (parent_selected) {
1513 if (te_selected->
parent) {
1515 te_parent = te_parent->parent)
1525 parent = scene->master_collection;
1551 ot->
name =
"Drag and Drop";
1552 ot->
idname =
"OUTLINER_OT_item_drag_drop";
1559#undef OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
1576 "OUTLINER_OT_datastack_drop",
1582 "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(struct Main *bmain, struct Object *ob, struct 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()
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT 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.
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)
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()
@ 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 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 bool datastack_drop_are_types_valid(StackDropData *drop_data)
static int scene_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static void datastack_drop_reorder(bContext *C, ReportList *reports, StackDropData *drop_data)
static int 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
static int material_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
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])
static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
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 int parent_clear_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 bool is_object_element(TreeElement *te)
static void datastack_drop_copy(bContext *C, StackDropData *drop_data)
static bool is_collection_element(TreeElement *te)
static TreeElement * outliner_data_from_tree_element_and_parents(CheckTypeFn check_type, TreeElement *te)
static int collection_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
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)
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)
static int parent_drop_invoke(bContext *C, wmOperator *op, 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
TreeElementInsertType insert_type
eDataStackDropAction drop_action
TreeStoreElem * drag_tselem
TreeElementInsertType insert_type
bPoseChannel * pchan_parent
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
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)
int 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)