[Bf-blender-cvs] [c8c85907b4e] soc-2019-outliner: Outliner cleanup: Move give base under cursor to utils
Nathan Craddock
noreply at git.blender.org
Sat Aug 3 06:08:25 CEST 2019
Commit: c8c85907b4e8e570c576e1f178e986cac9695fe2
Author: Nathan Craddock
Date: Thu Aug 1 17:37:42 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBc8c85907b4e8e570c576e1f178e986cac9695fe2
Outliner cleanup: Move give base under cursor to utils
Moving eyedropper function from select to utils for better code
organization.
===================================================================
M source/blender/editors/space_outliner/outliner_select.c
M source/blender/editors/space_outliner/outliner_utils.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 10bce2525d8..6b6272ffee0 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -62,7 +62,6 @@
#include "ED_sequencer.h"
#include "ED_undo.h"
#include "ED_gpencil.h"
-#include "ED_outliner.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -76,30 +75,6 @@
#include "outliner_intern.h"
-/* Get base of object under cursor (for eyedropper) */
-Base *ED_outliner_give_base_under_cursor(struct 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;
-}
-
static bool do_outliner_activate_common(bContext *C,
Main *bmain,
Depsgraph *depsgraph,
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index a27985939c3..5dfdf6f129b 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -27,9 +27,12 @@
#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"
@@ -364,7 +367,7 @@ bool outliner_item_is_co_within_close_toggle(TreeElement *te, float view_co_x)
return (view_co_x > te->xs) && (view_co_x < te->xs + UI_UNIT_X);
}
-/* Scroll view vertically while keeping within total bounds */
+/* Scroll view vertically while keeping within total bounds */
void outliner_scroll_view(ARegion *ar, int delta_y)
{
int y_min = MIN2(ar->v2d.cur.ymin, ar->v2d.tot.ymin);
@@ -385,3 +388,27 @@ void outliner_scroll_view(ARegion *ar, int delta_y)
ar->v2d.cur.ymin += offset;
}
}
+
+/* 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;
+}
More information about the Bf-blender-cvs
mailing list