58 if ((fmval[1] > te->
ys) && (fmval[1] < (te->
ys +
UI_UNIT_Y))) {
136 const float margin =
UI_UNIT_Y * (1.0f / 4);
138 if (view_mval[1] < (te_hovered->
ys + margin)) {
152 if (view_mval[1] > (te_hovered->
ys + (3 * margin))) {
165 if (view_mval[1] < last->
ys) {
183 while (te !=
nullptr) {
184 if (check_type(te)) {
220 if (!collection_te) {
225 if (collection_te != te) {
234 return collection_te;
245 drop_te = drop_te->
prev;
250 drop_te = drop_te->
next;
254 if (drop_te ==
nullptr) {
276 if (potential_parent == potential_child) {
282 if (potential_parent == potential_child->
parent) {
325 if (!potential_child) {
354 const bool keep_transform)
362 if (
scene ==
nullptr) {
371 bool parent_set =
false;
372 bool linked_objects =
false;
374 for (
wmDragID *drag_id = drag; drag_id; drag_id = drag_id->
next) {
375 if (
GS(drag_id->id->name) ==
ID_OB) {
380 linked_objects =
true;
385 reports,
C,
scene,
object, parent, parent_type,
false, keep_transform,
nullptr)) {
391 if (linked_objects) {
392 BKE_report(reports,
RPT_INFO,
"Can't edit library linked or non-editable override object(s)");
414 if (
ELEM(
nullptr, ob, par)) {
441 ot->
name =
"Drop to Set Parent (hold Alt to keep transforms)";
443 ot->
idname =
"OUTLINER_OT_parent_drop";
512 if (
GS(drag_id->id->name) ==
ID_OB) {
529 ot->
name =
"Drop to Clear Parent (hold Alt to keep transforms)";
531 ot->
idname =
"OUTLINER_OT_parent_clear";
598 ot->
name =
"Drop Object to Scene";
600 ot->
idname =
"OUTLINER_OT_scene_drop";
630 if (
ELEM(
nullptr, ob, ma)) {
651 ot->
name =
"Drop Material on Object";
653 ot->
idname =
"OUTLINER_OT_material_drop";
703 StackDropData *drop_data = MEM_cnew<StackDropData>(
"datastack drop data");
711 drag->
poin = drop_data;
769 else if (ob && ob != drop_data->
ob_parent) {
770 drop_data->
drop_te = object_te;
777 else if (ob || pchan) {
785 else if (ob && ob != drop_data->
ob_parent) {
788 drop_data->
drop_te = object_te;
796 drop_data->
drop_te = te_target;
1082 ot->
name =
"Data Stack Drop";
1083 ot->
description =
"Copy or reorder modifiers, constraints, and effects";
1084 ot->
idname =
"OUTLINER_OT_datastack_drop";
1118 return ((
Scene *)
id)->master_collection;
1147 if (drag_id ==
nullptr) {
1151 ID *
id = drag_id->
id;
1167 if (
id == &to_collection->
id) {
1181 data->from = from_collection;
1182 data->to = to_collection;
1184 data->insert_type = insert_type;
1199 switch (
data.insert_type) {
1235 const bool is_link = !
data.from || (
event->modifier &
KM_CTRL);
1238 bool same_level =
false;
1240 if (
data.from == parent->collection) {
1247 const bool tooltip_link = (is_link && !same_level);
1248 const char *tooltip_before = tooltip_link ?
TIP_(
"Link before collection") :
1249 TIP_(
"Move before collection");
1250 const char *tooltip_between = tooltip_link ?
TIP_(
"Link between collections") :
1251 TIP_(
"Move between collections");
1252 const char *tooltip_after = tooltip_link ?
TIP_(
"Link after collection") :
1253 TIP_(
"Move after collection");
1256 switch (
data.insert_type) {
1284 return BLI_strdup(
TIP_(
"Move inside collection (Ctrl to link, Shift to parent)"));
1286 return BLI_strdup(
TIP_(
"Move inside collection (Ctrl to link)"));
1313 bool relative_after =
false;
1339 if (
GS(drag_id->id->name) ==
ID_OB) {
1350 else if (
GS(drag_id->id->name) ==
ID_GR) {
1354 if (collection !=
from) {
1375 ot->
name =
"Move to Collection";
1377 ot->
idname =
"OUTLINER_OT_collection_drop";
1393 #define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD 7
1425 if (!
data.drag_id) {
1449 const bool use_datastack_drag =
ELEM(tselem->
type,
1460 if (use_datastack_drag) {
1479 &space_outliner->
tree,
1487 &space_outliner->
tree,
1503 bool parent_selected =
false;
1505 te_parent = te_parent->
parent) {
1508 parent_selected =
true;
1514 if (parent_selected) {
1524 if (te_selected->
parent) {
1526 te_parent = te_parent->
parent) {
1561 ot->
name =
"Drag and Drop";
1562 ot->
idname =
"OUTLINER_OT_item_drag_drop";
1569 #undef OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
1586 "OUTLINER_OT_datastack_drop",
1592 "OUTLINER_OT_collection_drop",
bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob)
bool BKE_collection_is_empty(const struct Collection *collection)
bool BKE_collection_move(struct Main *bmain, struct Collection *to_parent, struct Collection *from_parent, struct Collection *relative, bool relative_after, struct Collection *collection)
void BKE_collection_object_move(struct Main *bmain, struct Scene *scene, struct Collection *collection_dst, struct Collection *collection_src, struct Object *ob)
struct Scene * CTX_data_scene(const bContext *C)
struct SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
struct Collection * CTX_data_collection(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
bool BKE_scene_has_object(struct Scene *scene, struct Object *ob)
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
bool BKE_id_is_editable(const struct Main *bmain, const struct 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 struct Object *ob_parent, const struct 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)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_COPY_ON_WRITE
#define ID_IS_LINKED(_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
bool ED_object_modifier_move_to_index(struct ReportList *reports, struct Object *ob, struct ModifierData *md, int index)
bool ED_object_gpencil_modifier_move_to_index(struct ReportList *reports, struct Object *ob, struct GpencilModifierData *md, int index)
void ED_object_modifier_link(struct bContext *C, struct Object *ob_dst, struct Object *ob_src)
@ CLEAR_PARENT_KEEP_TRANSFORM
void ED_object_shaderfx_link(struct Object *dst, struct Object *src)
void ED_object_modifier_copy_to_object(struct bContext *C, struct Object *ob_dst, struct Object *ob_src, struct ModifierData *md)
void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode)
bool ED_object_constraint_move_to_index(struct Object *ob, struct bConstraint *con, int index)
bool ED_object_shaderfx_move_to_index(struct ReportList *reports, struct Object *ob, struct ShaderFxData *fx, int index)
void ED_object_constraint_copy_for_pose(struct Main *bmain, struct Object *ob_dst, struct bPoseChannel *pchan, struct bConstraint *con)
void ED_object_shaderfx_copy(struct Object *dst, struct ShaderFxData *fx)
void ED_object_constraint_link(struct Main *bmain, struct Object *ob_dst, struct ListBase *dst, struct ListBase *src)
void ED_object_gpencil_modifier_copy_to_object(struct Object *ob_dst, struct GpencilModifierData *md)
void ED_object_parent_clear(struct Object *ob, int type)
void ED_object_constraint_copy_for_object(struct Main *bmain, struct Object *ob_dst, struct bConstraint *con)
bool ED_object_parent_set(struct ReportList *reports, const struct bContext *C, struct Scene *scene, struct Object *const ob, struct Object *const par, int partype, bool xmirror, bool keep_transform, const int vert_par[3])
void ED_outliner_select_sync_from_outliner(struct bContext *C, struct SpaceOutliner *space_outliner)
void ED_region_tag_redraw_no_rebuild(struct ARegion *region)
bool ED_operator_outliner_active(struct bContext *C)
Read Guarded memory(de)allocation.
void UI_view2d_region_to_view(const struct View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
float UI_view2d_region_to_view_y(const struct View2D *v2d, float y)
#define WM_DRAG_DATASTACK
SyclQueue void void * src
Collection * outliner_collection_from_tree_element(const TreeElement *te)
TreeTraversalAction outliner_find_selected_collections(TreeElement *te, void *customdata)
TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *customdata)
bool outliner_is_collection_tree_element(const TreeElement *te)
static bool allow_parenting_without_modifier_key(SpaceOutliner *space_outliner)
static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static TreeElement * outliner_data_from_tree_element_and_parents(CheckTypeFn check_type, TreeElement *te)
static void datastack_drop_copy(bContext *C, StackDropData *drop_data)
static TreeElement * outliner_drop_insert_find(bContext *C, const int xy[2], TreeElementInsertType *r_insert_type)
void OUTLINER_OT_material_drop(wmOperatorType *ot)
bool(*)(TreeElement *te) CheckTypeFn
void OUTLINER_OT_item_drag_drop(wmOperatorType *ot)
static bool is_pchan_element(TreeElement *te)
static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int scene_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static bool is_collection_element(TreeElement *te)
static ID * outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode)
static int outliner_get_insert_index(TreeElement *drag_te, TreeElement *drop_te, TreeElementInsertType insert_type, ListBase *listbase)
static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
static TreeElement * outliner_dropzone_find(const SpaceOutliner *space_outliner, const float fmval[2], const bool children)
static TreeElement * outliner_drop_insert_collection_find(bContext *C, const int xy[2], TreeElementInsertType *r_insert_type)
static int datastack_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool datastack_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static TreeElement * outliner_item_drag_element_find(SpaceOutliner *space_outliner, ARegion *region, const wmEvent *event)
static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static TreeElement * outliner_drop_find(bContext *C, const wmEvent *event)
static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool is_object_element(TreeElement *te)
static void datastack_drop_link(bContext *C, StackDropData *drop_data)
static TreeElement * outliner_dropzone_element(TreeElement *te, const float fmval[2], const bool children)
void OUTLINER_OT_parent_drop(wmOperatorType *ot)
void outliner_dropboxes(void)
static Collection * collection_parent_from_ID(ID *id)
void OUTLINER_OT_collection_drop(wmOperatorType *ot)
static bool scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static char * collection_drop_tooltip(bContext *C, wmDrag *drag, const int xy[2], wmDropBox *UNUSED(drop))
static bool datastack_drop_are_types_valid(StackDropData *drop_data)
static int material_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
static char * datastack_drop_tooltip(bContext *UNUSED(C), wmDrag *drag, const int UNUSED(xy[2]), struct wmDropBox *UNUSED(drop))
static void datastack_drop_reorder(bContext *C, ReportList *reports, StackDropData *drop_data)
static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool collection_drop_init(bContext *C, wmDrag *drag, const int xy[2], CollectionDrop *data)
static void datastack_drop_data_init(wmDrag *drag, Object *ob, bPoseChannel *pchan, TreeElement *te, TreeStoreElem *tselem, void *directdata)
@ DATA_STACK_DROP_REORDER
void OUTLINER_OT_scene_drop(wmOperatorType *ot)
static void parent_drop_set_parents(bContext *C, ReportList *reports, wmDragID *drag, Object *parent, short parent_type, const bool keep_transform)
static bool material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
void OUTLINER_OT_datastack_drop(wmOperatorType *ot)
void OUTLINER_OT_parent_clear(wmOperatorType *ot)
#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData *drop_data)
TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
bool outliner_flag_set(const SpaceOutliner &space_outliner, const short flag, const short set)
bool outliner_tree_traverse(const SpaceOutliner *space_outliner, ListBase *tree, int filter_te_flag, int filter_tselem_flag, TreeTraversalFunc func, void *customdata)
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x)
TreeElement * outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem)
TreeElement * outliner_find_item_at_y(const SpaceOutliner *space_outliner, const ListBase *tree, float view_co_y)
struct bPoseChannel * outliner_find_parent_bone(TreeElement *te, TreeElement **r_bone_te)
TreeElement * outliner_find_id(struct SpaceOutliner *space_outliner, ListBase *lb, const struct ID *id)
TreeElement * outliner_find_parent_element(ListBase *lb, TreeElement *parent_te, const TreeElement *child_te)
struct ID * outliner_search_back(TreeElement *te, short idcode)
#define TSELEM_OPEN(telm, sv)
bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2])
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
TreeElementInsertType insert_type
struct MaterialGPencilStyle * gp_style
ListBase greasepencil_modifiers
struct Collection * master_collection
eDataStackDropAction drop_action
TreeStoreElem * drag_tselem
TreeElementInsertType insert_type
bPoseChannel * pchan_parent
struct TreeElement * parent
struct TreeElement * prev
struct TreeElement * next
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmEvent * eventstate
void WM_event_start_prepared_drag(bContext *C, wmDrag *drag)
ID * WM_drag_get_local_ID(const wmDrag *drag, short idcode)
wmDrag * WM_drag_data_create(bContext *C, int icon, int type, void *poin, double value, unsigned int flags)
ListBase * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
ID * WM_drag_get_local_ID_from_event(const wmEvent *event, short idcode)
void WM_drag_add_local_ID(wmDrag *drag, ID *id, ID *from_parent)
wmDropBox * WM_dropbox_add(ListBase *lb, const char *idname, bool(*poll)(bContext *, wmDrag *, const wmEvent *), void(*copy)(bContext *, wmDrag *, wmDropBox *), void(*cancel)(Main *, wmDrag *, wmDropBox *), WMDropboxTooltipFunc tooltip)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void WM_main_add_notifier(unsigned int 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)