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 <julian@blender.org>2020-10-15 21:23:13 +0300
committerJulian Eisel <julian@blender.org>2020-10-15 21:31:36 +0300
commitd4f94d8a31044af489d4821966854a7bc8975d23 (patch)
treea4531b783c122238f983936b6175d149f5cbc48c /source/blender/editors/space_outliner/outliner_edit.c
parent5129e2e042a057a28ea75e4342a664277c74ca34 (diff)
Cleanup: Refactor lookup for hovered Outliner element for renaming
* Use existing and optimized lookup function, rather than own duplicated logic. * Move low-level coordinate check into general function, alongside similar ones.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_edit.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index abfec4fc2aa..85e841538d6 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -363,25 +363,6 @@ void item_rename_fn(bContext *C,
do_item_rename(region, te, tselem, reports);
}
-static void do_outliner_item_rename(ReportList *reports,
- ARegion *region,
- TreeElement *te,
- const float mval[2])
-{
- if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
- TreeStoreElem *tselem = TREESTORE(te);
-
- /* click on name */
- if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) {
- do_item_rename(region, te, tselem, reports);
- }
- }
-
- LISTBASE_FOREACH (TreeElement *, te_child, &te->subtree) {
- do_outliner_item_rename(reports, region, te_child, mval);
- }
-}
-
static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
@@ -403,8 +384,11 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even
else {
UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
- LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
- do_outliner_item_rename(op->reports, region, te, fmval);
+ TreeElement *hovered = outliner_find_item_at_y(
+ space_outliner, &space_outliner->tree, fmval[1]);
+
+ if (outliner_item_is_co_over_name(hovered, fmval[0])) {
+ do_item_rename(region, hovered, TREESTORE(hovered), op->reports);
}
}