Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f2704b6

Browse files
author
Kaushik Iska
committed
Get transform matrix relative to parent coordinate space
There was an issue where we were getting it w.r.t screen as opposed to parent.
1 parent 5636064 commit f2704b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import android.graphics.Canvas;
66
import android.graphics.Matrix;
77
import android.graphics.Path;
8+
import android.graphics.Rect;
89
import android.view.MotionEvent;
10+
import android.view.ViewGroup;
911
import android.widget.FrameLayout;
1012
import androidx.annotation.NonNull;
1113
import io.flutter.embedding.android.AndroidTouchProcessor;
@@ -122,10 +124,17 @@ public boolean onTouchEvent(MotionEvent event) {
122124
return super.onTouchEvent(event);
123125
}
124126

127+
// get the offset relative to parent.
128+
Rect offset = new Rect();
129+
getDrawingRect(offset);
130+
131+
ViewGroup parentViewGroup = (ViewGroup) getParent();
132+
parentViewGroup.offsetDescendantRectToMyCoords(this, offset);
133+
125134
// Mutator view itself doesn't rotate, scale, skew, etc.
126135
// we only need to account for translation.
127136
Matrix screenMatrix = new Matrix();
128-
screenMatrix.postTranslate(getLeft(), getTop());
137+
screenMatrix.postTranslate(offset.left, offset.top);
129138

130139
return androidTouchProcessor.onTouchEvent(event, screenMatrix);
131140
}

0 commit comments

Comments
 (0)