[Bf-blender-cvs] [0210df079cc] blender2.8: Outliner drag&drop: Do generic check if no custom poll callback is defined
Julian Eisel
noreply at git.blender.org
Fri Mar 10 20:48:56 CET 2017
Commit: 0210df079ccb238be047c8a28e5f295a14648e00
Author: Julian Eisel
Date: Fri Mar 10 18:23:22 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB0210df079ccb238be047c8a28e5f295a14648e00
Outliner drag&drop: Do generic check if no custom poll callback is defined
And quite some cleanup.
===================================================================
M source/blender/editors/space_outliner/outliner_ops.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index a96f99d332a..4b0dcb143e6 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -85,14 +85,17 @@ static void outliner_item_drag_get_insert_data(
te_hovered = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
if (te_hovered) {
- TreeStoreElem *tselem_hovered = TREESTORE(te_hovered);
+ /* mouse hovers an element (ignoring x-axis), now find out how to insert the dragged item exactly */
- if (te_hovered != te_dragged) {
+ if (te_hovered == te_dragged) {
+ *r_te_insert_handle = te_dragged;
+ }
+ else if (te_hovered != te_dragged) {
const float margin = UI_UNIT_Y * (1.0f / 4);
*r_te_insert_handle = te_hovered;
if (view_mval[1] < (te_hovered->ys + margin)) {
- if (TSELEM_OPEN(tselem_hovered, soops)) {
+ if (TSELEM_OPEN(TREESTORE(te_hovered), soops)) {
/* inserting after a open item means we insert into it, but as first child */
if (BLI_listbase_is_empty(&te_hovered->subtree)) {
*r_insert_type = TE_INSERT_INTO;
@@ -113,15 +116,13 @@ static void outliner_item_drag_get_insert_data(
*r_insert_type = TE_INSERT_INTO;
}
}
- else {
- *r_te_insert_handle = te_dragged;
- }
}
else {
+ /* mouse doesn't hover any item (ignoring x-axis), so it's either above list bounds or below. */
+
TreeElement *first = soops->tree.first;
TreeElement *last = soops->tree.last;
- /* mouse doesn't hover any item (ignoring x axis), so it's either above list bounds or below. */
if (view_mval[1] < last->ys) {
*r_te_insert_handle = last;
*r_insert_type = TE_INSERT_AFTER;
@@ -144,9 +145,18 @@ static void outliner_item_drag_handle(
outliner_item_drag_get_insert_data(soops, ar, event, te_dragged, &te_insert_handle, &insert_type);
- if ((te_dragged != te_insert_handle) &&
- te_dragged->reinsert_poll &&
- !te_dragged->reinsert_poll(scene, te_dragged, &te_insert_handle, &insert_type))
+ if (!te_dragged->reinsert_poll &&
+ /* there is no reinsert_poll, so we do some generic checks (same types and reinsert callback is available) */
+ (TREESTORE(te_dragged)->type == TREESTORE(te_insert_handle)->type) &&
+ te_dragged->reinsert)
+ {
+ /* pass */
+ }
+ else if (te_dragged == te_insert_handle) {
+ /* nothing will happen anyway, no need to do poll check */
+ }
+ else if (!te_dragged->reinsert_poll ||
+ !te_dragged->reinsert_poll(scene, te_dragged, &te_insert_handle, &insert_type))
{
te_insert_handle = NULL;
}
More information about the Bf-blender-cvs
mailing list