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:
authorNathan Craddock <nzcraddock@gmail.com>2019-08-08 22:40:00 +0300
committerNathan Craddock <nzcraddock@gmail.com>2019-08-16 21:30:53 +0300
commit35a5dee2ef7303124259e660f85c337289b78403 (patch)
tree1d1abb1584f8ad389b4799e871e37a6be9ea4402 /source/blender/editors/space_outliner/outliner_utils.c
parent0a903e7ab101a27b4bba47dd12005311147e7b1a (diff)
Eyedropper: Support datadropper in the outliner
Adds support for using the eyedropper in the outliner in addition to the 3D view.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_utils.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index f57dce97b38..727d9866793 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -24,11 +24,15 @@
#include "BLI_utildefines.h"
#include "DNA_action_types.h"
+#include "DNA_screen_types.h"
#include "DNA_space_types.h"
+#include "BKE_context.h"
#include "BKE_outliner_treehash.h"
+#include "BKE_layer.h"
#include "ED_armature.h"
+#include "ED_outliner.h"
#include "UI_interface.h"
#include "UI_view2d.h"
@@ -300,3 +304,27 @@ float outliner_restrict_columns_width(const SpaceOutliner *soops)
}
return (num_columns * UI_UNIT_X + V2D_SCROLL_WIDTH);
}
+
+/* Get base of object under cursor. Used for eyedropper tool */
+Base *ED_outliner_give_base_under_cursor(bContext *C, const int mval[2])
+{
+ ARegion *ar = CTX_wm_region(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ TreeElement *te;
+ Base *base = NULL;
+ float view_mval[2];
+
+ UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
+
+ te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
+ if (te) {
+ TreeStoreElem *tselem = TREESTORE(te);
+ if (tselem->type == 0) {
+ Object *ob = (Object *)tselem->id;
+ base = (te->directdata) ? (Base *)te->directdata : BKE_view_layer_base_find(view_layer, ob);
+ }
+ }
+
+ return base;
+}