Skip to content
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

[macOS] IWindowOverlayElement.Draw dirtyRect only returns initial Window Size. #21307

Closed
MartyIX opened this issue Mar 19, 2024 · 4 comments · Fixed by #21371
Closed

[macOS] IWindowOverlayElement.Draw dirtyRect only returns initial Window Size. #21307

MartyIX opened this issue Mar 19, 2024 · 4 comments · Fixed by #21371
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing i/great-reporter This issue is opened by an author who is known to open high-quality issues platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working
Milestone

Comments

@MartyIX
Copy link
Collaborator

MartyIX commented Mar 19, 2024

Description

I would expect the window overlay to redraw the overlay content when the container window is resized but it does not happen.

Steps to Reproduce

  1. Open Controls.Sample project
  2. Navigate "Others Concepts"
  3. Click "Enable Test window overlay"
  4. Resize window

I would expect the overlay to redraw the overlay content but it does not happen.

Demo:

Screen.Recording.2024-03-19.at.14.49.38.mov

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

Apple Mac M1 Sonoma 14.4

Did you find any workaround?

No.

Relevant log output

No response

@MartyIX MartyIX added t/bug Something isn't working platform/macOS 🍏 macOS / Mac Catalyst labels Mar 19, 2024
@MartyIX
Copy link
Collaborator Author

MartyIX commented Mar 19, 2024

Is this a bug or feature @drasticactions, please?

(I have noticed that you worked on #3351.)

@drasticactions
Copy link
Contributor

The answer is "Maybe" and "It depends". This is probably a bug, but I don't think it's a WindowOverlay bug, it's probably Maui.Graphics.

First, It does react to window resizing. If it didn't, the graphic wouldn't be redrawn when you resized the window.

Also, if you click on the "Add Adorner to Test Button" you would see that the Adorner (added to the VisualDiagnosticOverlay, driven by WindowOverlay) does add a adorner that does resize correctly on the screen. The actual implementation of WindowOverlay for handling the Graphics layer, I think, is fine, since it can draw fine when making the window size larger than it initially was, which could only happen if the actual UIView is pinned to the sides of the window.

So the issue is that specific IWindowOverlayElement. It uses dirtyRect for calculating its relative location, and for whatever reason it's only returning the initial size of the canvas. So that's why it's "static" in place.

Moreover, if you switch that graphic to use the Window size itself,

float centerX = (float)(_overlay.Window.Width - 50);
float centerY = (float)(_overlay.Window.Height - 50);
_circle = new Circle(centerX, centerY, 40);

and resize it, the width and height of the window only go up to the max width and height of when it was created, so it will shrink but it won't grow if you make the window bigger. My guess is that these could be related, and the calculation of the canvas width and height is incorrect. But that's not a specific WindowOverlay API thing, that's part of Maui.Graphics. So I think that's the issue, but I'm not sure.

As for it being a bug in WindowOverlay, IMO, no. You handle the location of where it's drawn on the screen, so that's working. The issue is getting the actual window size isn't working, but I'm not sure that's driven by the overlay.

If you want to map to the size If you cast ICanvas to PlatformView, that has a Rect which does match the window width and would work.

@mattleibow What do you think?

@drasticactions drasticactions changed the title [macOS] Window overlay does not react to window resizing [macOS] IWindowOverlayElement.Draw dirtyRect only returns initial Window Size. Mar 19, 2024
@PureWeen PureWeen added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Mar 19, 2024
@PureWeen PureWeen added this to the Backlog milestone Mar 19, 2024
@PureWeen PureWeen added the i/great-reporter This issue is opened by an author who is known to open high-quality issues label Mar 19, 2024
@MartyIX
Copy link
Collaborator Author

MartyIX commented Mar 20, 2024

Just for the sake of comparison, this is how it behaves on Windows:

animation

Interestingly, on Windows, I can see the fire icon in the red circle but not on macOS:

Screen.Recording.2024-03-19.at.14.49.38.mov

That's perhaps another issue.

@drasticactions
Copy link
Contributor

Yes, it should work on Windows and Android.

For the emoji, DrawString doesn't like the Emoji on Mac. That's also a SkiaSharp/Maui.Graphics thing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing i/great-reporter This issue is opened by an author who is known to open high-quality issues platform/macOS 🍏 macOS / Mac Catalyst t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants