-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce IVisualDiagnosticsOverlay #3351
Introduce IVisualDiagnosticsOverlay #3351
Conversation
# Conflicts: # src/Controls/samples/Controls.Sample/Pages/MainPage.xaml
src/Core/src/VisualDiagnostics/VisualDiagnosticsLayer.Android.cs
Outdated
Show resolved
Hide resolved
|
||
if (_nativeActivity.Window != null) | ||
{ | ||
_nativeActivity.Window.DecorView.LayoutChange += DecorView_LayoutChange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we unsubscribe? Also there is inconsistency with method name casing, e.g. DecorView_LayoutChange vs scroll_ScrollChange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ScrollViews should unsubscribe when we navigate pages. I also just added IDisposable
to the root view so it should handle removing the other native properties should that be called. MAUI does not have an event for when a Window is disposed of. I'm looking at the native implementations, but considering IWindow isn't disposed we could wait until a proper solution is added so our Dispose would be called.
// When it is, we will clear existing adorners. | ||
if (nativeWindow != null && nativeWindow is Frame frame) | ||
{ | ||
frame.Navigating += Frame_Navigating; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we unsubscribe? There are other event handlers like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See answer above. Added IDisposeable and unhooked the events, but I still don't know the best way to dispose these handlers yet.
src/Core/src/VisualDiagnostics/VisualDiagnosticsLayer.Windows.cs
Outdated
Show resolved
Hide resolved
src/Core/src/VisualDiagnostics/VisualDiagnosticsLayer.Windows.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # src/Core/src/Platform/Standard/ViewExtensions.cs
Co-authored-by: Rui Marinho <me@ruimarinho.net>
internal static Matrix4x4 GetViewTransform(this IView view) => new Matrix4x4(); | ||
internal static Graphics.Matrix4x4 GetViewTransform(this IView view) => new Matrix4x4(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this in System.Numerics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be updated to it.
@drasticactions needs rebase again, sorry merged the screenshot api pr |
# Conflicts: # src/Core/src/Platform/Android/ViewExtensions.cs # src/Core/src/Platform/Standard/ViewExtensions.cs # src/Core/src/Platform/Windows/ViewExtensions.cs # src/Core/src/Platform/iOS/ViewExtensions.cs
2021-11-10_8.54.04.mov
android.mp4
winui.mp4
To improve the development of UI Tooling for MAUI, we need to introduce some new concepts into the platform. This PR adds
IVisualDiagnosticsLayer
,IAdornerBorder
, and some new extension methods to allow, firstly, for drawing Adorners on top of anyIView
, but also built to be extended upon in the future.IVisualDiagnosticsLayer
is a new view that is applied toIWindow
. It consists of a Maui.Graphics layer and is added as the first layer to theIWindow
when it's created. Beyond just acceptingIAdornerBorder
items to draw on the screen, it also has an event handler for taps,OnTouch
. Whenever a touch is applied on the top layer, it gets captured and sent to the event handler. It is then passed down to the underlying view, so it should not affect any functionality.IAdornerBorder
is anIDrawable
for drawing Adorners around anyIView
. These can have their own colors and shapes for drawing adorners. I've created two,RectangleAdornerBorder
andRectangleGridAdornerBorder
.Once passed to the Visual Diagnostics Layer, the adorner will be drawn. You can have as many adorners as you want. When one is added, we request the current view to see if there are any
IScrollView
on it, and if so, we attach to the native element to check when a user scrolls. If they move, we invalidate and redraw. Likewise, when the adorner is added, if the view is not on screen, we can use the same scroll view and scroll to make it visible.To support this, I also introduced some new extension methods for
IVisualTreeElement
andIView
. These help for scanning the Visual Tree for getting elements back as a list, and help support hit testing elements. You can pass in a point, a series of points, or a rectangle and get whatever elements are contained within those points, based on the native view bounds or theFrame
of the element.