Skip to content

Commit c46fd50

Browse files
committed
Add ScaleChanged event, some improvements
1 parent 237675b commit c46fd50

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

documentation/proposals/Proposal - Windowing 3.0.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,15 +1121,20 @@ public interface ISurfaceWindow
11211121
/// </summary>
11221122
bool IsCloseRequested { get; set; }
11231123

1124+
/// <summary>
1125+
/// Raised when <see cref="IsCloseRequested" /> is set to <c>true</c>.
1126+
/// </summary>
1127+
event Action<WindowToggleEvent> CloseRequested { add; remove; }
1128+
11241129
/// <summary>
11251130
/// Gets or sets a value indicating whether the window is visible.
11261131
/// </summary>
11271132
bool IsVisible { get; set; }
11281133

11291134
/// <summary>
1130-
/// Raised when <see cref="IsCloseRequested" /> is set to <c>true</c>.
1135+
/// Raised when <see cref="IsVisible" /> changes.
11311136
/// </summary>
1132-
event Action<WindowToggleEvent> CloseRequested { add; remove; }
1137+
event Action<WindowToggleEvent> VisibilityChanged { add; remove; }
11331138

11341139
/// <summary>
11351140
/// Gets or sets a value indicating whether the window currently has input focus. If setting to <c>true</c>, the
@@ -1529,15 +1534,35 @@ their rendering code. It provides no configuration but provides extra informatio
15291534
```cs
15301535
namespace Silk.NET.Windowing;
15311536

1537+
/// <summary>
1538+
/// Contains properties pertaining to a change in a surface's scale.
1539+
/// </summary>
1540+
/// <param name="Surface">The surface to which the change in scale occurred.</param>
1541+
/// <param name="OldContent">The previous value for <see cref="ISurfaceScale.Content"/>.</param>
1542+
/// <param name="NewContent">The new value for <see cref="ISurfaceScale.Content"/>.</param>
1543+
/// <param name="OldDraw">The previous value for <see cref="ISurfaceScale.Draw"/>.</param>
1544+
/// <param name="NewDraw">The new value for <see cref="ISurfaceScale.Draw"/>.</param>
1545+
/// <param name="OldPixelDensity">The previous value for <see cref="ISurfaceScale.PixelDensity"/>.</param>
1546+
/// <param name="NewPixelDensity">The new value for <see cref="ISurfaceScale.PixelDensity"/>.</param>
1547+
public readonly record struct ScaleChangedEvent(
1548+
Surface Surface,
1549+
float OldContent,
1550+
float NewContent,
1551+
float OldDraw,
1552+
float NewDraw,
1553+
float OldPixelDensity,
1554+
float NewPixelDensity
1555+
);
1556+
15321557
/// <summary>
15331558
/// Provides information pertaining to the surface's graphical scaling.
15341559
/// </summary>
15351560
/// <remarks>
1536-
/// <see cref="ContentScale" /> is typically used to scale UI elements to the correct size for the end user.
1561+
/// <see cref="Content" /> is typically used to scale UI elements to the correct size for the end user.
15371562
/// <see cref="PixelDensity" /> on the other hand is used to scale the entire application to cover the entire client
15381563
/// area in cases where the window client size is smaller than the actual drawable size (i.e. it is high density).
15391564
/// If scaling content for legibility and scaling the application's rendering as a whole are not needed to be separated,
1540-
/// it is recommended to use <see cref="DrawScale" />. Implementations shall always request a high density surface if
1565+
/// it is recommended to use <see cref="Draw" />. Implementations shall always request a high density surface if
15411566
/// given the choice, to account for the platforms where applications may not be able to opt-out of high density.
15421567
/// </remarks>
15431568
public interface ISurfaceScale
@@ -1546,35 +1571,40 @@ public interface ISurfaceScale
15461571
/// Gets the factor with which the application should scale its content to make the content more legible for the
15471572
/// user. This has no influence on <see cref="Surface.DrawableSize" />.
15481573
/// </summary>
1549-
/// <seealso cref="DrawScale" />
1550-
float ContentScale { get; }
1574+
/// <seealso cref="Draw" />
1575+
float Content { get; }
15511576

15521577
/// <summary>
15531578
/// Gets the suggested amplification factor when drawing in terms of <see cref="Surface.DrawableSize" />. This
15541579
/// represents the scale from the pixel resolution to the desired content size, and is typically the multiplication
1555-
/// of <see cref="PixelDensity" /> and <see cref="ContentScale" />.
1580+
/// of <see cref="PixelDensity" /> and <see cref="Content" />.
15561581
/// </summary>
15571582
/// <remarks>
15581583
/// For example, if <see cref="PixelDensity" /> is <c>2.0</c> (i.e. there are 2 pixels per screen coordinate)
15591584
/// <i>and</i> the window manager requests that applications scale their content up by <c>2.0</c> to meet the user's
1560-
/// settings as per <see cref="ContentScale" />, this would be <c>4.0</c>. This is because we're scaling once to
1585+
/// settings as per <see cref="Content" />, this would be <c>4.0</c>. This is because we're scaling once to
15611586
/// account for the fact that the application has twice the amount of pixels available to it for the given window
15621587
/// size, and then scaling again so that what we are drawing appears zoomed in as per the user's request. Note that
15631588
/// it is rarely the case that an operating system employs both dense pixels <i>and</i> content scale. macOS for
1564-
/// instance, instead of setting <see cref="ContentScale" />, opts to scale the resolution in the cases where the
1589+
/// instance, instead of setting <see cref="Content" />, opts to scale the resolution in the cases where the
15651590
/// user wants magnified visuals instead of having the applications scale their content; whereas Windows sets
1566-
/// <see cref="ContentScale" /> and instead always keeps <see cref="PixelDensity" /> as <c>1.0</c>. This is down
1591+
/// <see cref="Content" /> and instead always keeps <see cref="PixelDensity" /> as <c>1.0</c>. This is down
15671592
/// to philosophical differences between the window coordinate systems on platforms as to whether they prefer to
15681593
/// deal in physical device pixels or physical content sizes.
15691594
/// </remarks>
1570-
float DrawScale { get; }
1595+
float Draw { get; }
15711596

15721597
/// <summary>
15731598
/// Gets the ratio of pixels rendered to window size. This shall be equivalent to
15741599
/// <see cref="Surface.DrawableSize" /> divided by <see cref="ISurfaceWindow.ClientSize" />.
15751600
/// </summary>
1576-
/// <seealso cref="DrawScale" />
1601+
/// <seealso cref="Draw" />
15771602
float PixelDensity { get; }
1603+
1604+
/// <summary>
1605+
/// An event raised when any scale factor changes.
1606+
/// </summary>
1607+
event Action<ScaleChangedEvent> Changed { add; remove; }
15781608
}
15791609

15801610
public abstract partial class Surface

0 commit comments

Comments
 (0)