From 1f0e529ca8abc2a6b0006bdef6d4d7064ac61beb Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Sun, 19 Nov 2023 10:09:30 -0800 Subject: [PATCH] Mac: Don't depend on ClipRectangle Starting in macOS 14 there is a new clipsToBounds property that defaults to false, which is a behavior change. This causes incompatibilities with anything that uses ClipRectangle directly or indirectly. https://developer.apple.com/documentation/macos-release-notes/appkit-release-notes-for-macos-14#NSView #227 --- NAPS2.Lib/EtoForms/Notifications/CloseButton.cs | 8 ++++---- .../EtoForms/Notifications/NotificationView.cs | 13 +++++++------ NAPS2.Lib/EtoForms/Widgets/ScrollZoomImageViewer.cs | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/NAPS2.Lib/EtoForms/Notifications/CloseButton.cs b/NAPS2.Lib/EtoForms/Notifications/CloseButton.cs index cfeedc49c2..1d87060b7a 100644 --- a/NAPS2.Lib/EtoForms/Notifications/CloseButton.cs +++ b/NAPS2.Lib/EtoForms/Notifications/CloseButton.cs @@ -57,10 +57,10 @@ public CloseButton(ColorScheme colorScheme) private void OnPaint(object? sender, PaintEventArgs e) { - var clearColor = _active && _hover ? ActiveBackground : _hover ? HoverBackground : DefaultBackground; - e.Graphics.Clear(clearColor); - var w = e.ClipRectangle.Width; - var h = e.ClipRectangle.Height; + var bgColor = _active && _hover ? ActiveBackground : _hover ? HoverBackground : DefaultBackground; + var w = Width; + var h = Height; + e.Graphics.FillRectangle(bgColor, 0, 0, w, h); var p = CLOSE_BUTTON_PADDING; var pen = new Pen(PenColor, 3); e.Graphics.DrawLine(pen, p - 1, p - 1, w - p, h - p); diff --git a/NAPS2.Lib/EtoForms/Notifications/NotificationView.cs b/NAPS2.Lib/EtoForms/Notifications/NotificationView.cs index 83b707fd4d..1f9ffe959a 100644 --- a/NAPS2.Lib/EtoForms/Notifications/NotificationView.cs +++ b/NAPS2.Lib/EtoForms/Notifications/NotificationView.cs @@ -99,23 +99,24 @@ protected virtual void NotificationClicked() private void DrawableOnPaint(object? sender, PaintEventArgs e) { - var w = e.ClipRectangle.Width; - var h = e.ClipRectangle.Height; + var drawable = (Drawable) sender!; + var w = drawable.Width; + var h = drawable.Height; e.Graphics.FillRectangle(BackgroundColor, 0, 0, w, h); e.Graphics.DrawRectangle(BorderColor, 0, 0, w - 1, h - 1); } - private void DrawWithRoundedCorners(PaintEventArgs e) + private void DrawWithRoundedCorners(Drawable drawable, PaintEventArgs e) { // TODO: We're not using this as the few pixels on the edges aren't transparent, which is a problem if there's // an image underneath. Not sure if there's a way to make that work but I don't care enough about rounded // corners at the moment. - var w = e.ClipRectangle.Width; - var h = e.ClipRectangle.Height; + var w = drawable.Width; + var h = drawable.Height; var r = BORDER_RADIUS; var d = r * 2; var q = r / 2; - e.Graphics.Clear(Manager!.ColorScheme.BackgroundColor); + e.Graphics.FillRectangle(Manager!.ColorScheme.BackgroundColor, 0, 0, w, h); // Corners e.Graphics.FillEllipse(BackgroundColor, -1, -1, d, d); e.Graphics.FillEllipse(BackgroundColor, w - d, -1, d, d); diff --git a/NAPS2.Lib/EtoForms/Widgets/ScrollZoomImageViewer.cs b/NAPS2.Lib/EtoForms/Widgets/ScrollZoomImageViewer.cs index f6da381520..e727e17201 100644 --- a/NAPS2.Lib/EtoForms/Widgets/ScrollZoomImageViewer.cs +++ b/NAPS2.Lib/EtoForms/Widgets/ScrollZoomImageViewer.cs @@ -102,8 +102,8 @@ private void OnMouseWheel(object? sender, MouseEventArgs e) private void ImagePaint(object? sender, PaintEventArgs e) { - e.Graphics.SetClip(e.ClipRectangle); - e.Graphics.Clear(ColorScheme?.BackgroundColor ?? Colors.White); + var bgColor = ColorScheme?.BackgroundColor ?? Colors.White; + e.Graphics.FillRectangle(bgColor, 0, 0, _imageView.Width, _imageView.Height); if (Image != null) { e.Graphics.DrawRectangle(