Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2017-03-10 20:23:22 +0300
committerJulian Eisel <eiseljulian@gmail.com>2017-03-10 20:24:14 +0300
commit0210df079ccb238be047c8a28e5f295a14648e00 (patch)
treec0ac6a9cf57434acc5146b118dcc9522f9824f2a /source/blender/editors/space_outliner/outliner_ops.c
parente9dd97405e545afe83f489ea5edb42ff61160198 (diff)
Outliner drag&drop: Do generic check if no custom poll callback is defined
And quite some cleanup.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_ops.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c30
1 files changed, 20 insertions, 10 deletions
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;
}