Windows 0.3.0 clean next-generation source delta; no private history or other platform changes
This commit is contained in:
+36
-26
@@ -4,7 +4,7 @@ internal readonly record struct DashboardGeometry(
|
||||
Rectangle WelcomeLabel, Rectangle AccountLabel, Rectangle IdentityBadge,
|
||||
Rectangle LogoutButton, Rectangle StatusCard, Rectangle NodeCard, Rectangle ModeCard,
|
||||
Rectangle[] Metrics, Rectangle TrafficCard, Rectangle TailnetTrafficCard, Rectangle DailyCard, Rectangle Footer,
|
||||
int ContentHeight, bool Compact);
|
||||
int ContentHeight, bool Compact, float VerticalScale);
|
||||
|
||||
// Logical pixels converted once, independent of WinForms autoscaling.
|
||||
internal static class DashboardLayout
|
||||
@@ -13,41 +13,49 @@ internal static class DashboardLayout
|
||||
{
|
||||
var scale = Math.Max(1f, dpi / 96f);
|
||||
int S(int n) => (int)Math.Round(n * scale);
|
||||
// Tailnet is a subdivision of the existing speed area, not another
|
||||
// dashboard row. Fit the complete canvas even on a small/high-DPI screen.
|
||||
var verticalScale = Math.Min(1f, Math.Max(1, viewport.Height) / (614f * scale));
|
||||
int Y(int n) => Math.Max(1, (int)Math.Floor(n * scale * verticalScale));
|
||||
var margin = S(20);
|
||||
var gap = S(10);
|
||||
var width = Math.Max(S(540), viewport.Width - margin * 2);
|
||||
var gap = Y(10);
|
||||
var columnGap = S(10);
|
||||
var width = Math.Max(1, viewport.Width - margin * 2);
|
||||
var compact = width < S(720);
|
||||
var half = (width - gap) / 2;
|
||||
var welcome = new Rectangle(margin, S(8), width - S(132), S(30));
|
||||
var account = new Rectangle(margin, S(38), Math.Min(S(275), width - S(230)), S(24));
|
||||
var identity = new Rectangle(account.Right + S(10), S(38), S(92), S(23));
|
||||
var logout = new Rectangle(margin + width - S(104), S(16), S(104), S(34));
|
||||
var status = new Rectangle(margin, S(72), width, S(76));
|
||||
var node = new Rectangle(margin, status.Bottom + gap, compact ? width : half, S(72));
|
||||
var mode = compact
|
||||
? new Rectangle(margin, node.Bottom + gap, width, node.Height)
|
||||
: new Rectangle(node.Right + gap, node.Top, width - half - gap, node.Height);
|
||||
var traffic = new Rectangle(margin, mode.Bottom + gap, compact ? width : half, S(276));
|
||||
var tailnet = showTailnet ? new Rectangle(traffic.Left, traffic.Bottom + gap, traffic.Width, traffic.Height) : Rectangle.Empty;
|
||||
var daily = compact
|
||||
? new Rectangle(margin, (showTailnet ? tailnet.Bottom : traffic.Bottom) + gap, width, traffic.Height)
|
||||
: new Rectangle(traffic.Right + gap, traffic.Top, width - half - gap,
|
||||
showTailnet ? tailnet.Bottom - traffic.Top : traffic.Height);
|
||||
Rectangle Metric(Rectangle parent, int column) => new(S(14) + column * ((parent.Width - S(28)) / 2), S(43), (parent.Width - S(28)) / 2 - S(2), S(82));
|
||||
var half = (width - columnGap) / 2;
|
||||
var welcome = new Rectangle(margin, Y(8), width - S(132), Y(30));
|
||||
var account = new Rectangle(margin, Y(38), Math.Min(S(275), width - S(230)), Y(24));
|
||||
var identity = new Rectangle(account.Right + S(10), Y(38), S(92), Y(23));
|
||||
var logout = new Rectangle(margin + width - S(104), Y(16), S(104), Y(34));
|
||||
var status = new Rectangle(margin, Y(72), width, Y(76));
|
||||
var node = new Rectangle(margin, status.Bottom + gap, half, Y(72));
|
||||
var mode = new Rectangle(node.Right + columnGap, node.Top, width - half - columnGap, node.Height);
|
||||
var analyticsTop = mode.Bottom + gap;
|
||||
var analyticsHeight = Y(276);
|
||||
var leftHeight = showTailnet ? (analyticsHeight - gap) / 2 : analyticsHeight;
|
||||
var traffic = new Rectangle(margin, analyticsTop, half, leftHeight);
|
||||
var tailnet = showTailnet ? new Rectangle(traffic.Left, traffic.Bottom + gap, half, analyticsHeight - leftHeight - gap) : Rectangle.Empty;
|
||||
var daily = new Rectangle(traffic.Right + columnGap, analyticsTop, width - half - columnGap, analyticsHeight);
|
||||
Rectangle Metric(Rectangle parent, int column, bool speed) => new(
|
||||
S(10) + column * ((parent.Width - S(20)) / 2),
|
||||
speed ? Math.Max(Y(38), (parent.Height - Y(82)) / 2) : Y(40),
|
||||
(parent.Width - S(20)) / 2 - S(1),
|
||||
speed ? Math.Min(Y(82), parent.Height - Y(44)) : Y(82));
|
||||
// Relative to their matching chart card: totals together; speeds together.
|
||||
Rectangle[] metrics = [Metric(daily, 0), Metric(traffic, 0), Metric(traffic, 1), Metric(daily, 1)];
|
||||
var footer = new Rectangle(margin, daily.Bottom + gap, width, S(76));
|
||||
Rectangle[] metrics = [Metric(daily, 0, false), Metric(traffic, 0, true), Metric(traffic, 1, true), Metric(daily, 1, false)];
|
||||
var footer = new Rectangle(margin, daily.Bottom + gap, width, Y(76));
|
||||
return new(welcome, account, identity, logout, status, node, mode, metrics, traffic,
|
||||
tailnet, daily, footer, footer.Bottom + S(12), compact);
|
||||
tailnet, daily, footer, Math.Min(viewport.Height, footer.Bottom + Y(12)), compact, verticalScale);
|
||||
}
|
||||
|
||||
internal static bool SelfTest()
|
||||
{
|
||||
foreach (var dpi in new[] { 96, 120, 144, 168, 192, 240, 288 })
|
||||
foreach (var width in new[] { 600, 620, 739, 760, 780, 900, 1100, 1600 })
|
||||
foreach (var height in new[] { 350, 418, 560, 720 })
|
||||
foreach (var showTailnet in new[] { false, true })
|
||||
{
|
||||
var viewport = new Size(width * dpi / 96, 560 * dpi / 96);
|
||||
var viewport = new Size(width * dpi / 96, height * dpi / 96);
|
||||
var p = Calculate(viewport, dpi, showTailnet);
|
||||
Rectangle[] cards = showTailnet
|
||||
? [p.StatusCard, p.NodeCard, p.ModeCard, p.TrafficCard, p.TailnetTrafficCard, p.DailyCard, p.Footer]
|
||||
@@ -61,9 +69,11 @@ internal static class DashboardLayout
|
||||
for (var i = 0; i < p.Metrics.Length; i++)
|
||||
if (p.Metrics[i].Right > (i == 0 || i == 3 ? p.DailyCard.Width : p.TrafficCard.Width)) return false;
|
||||
if (!showTailnet && p.TailnetTrafficCard != Rectangle.Empty) return false;
|
||||
if (p.ContentHeight > viewport.Height || p.Footer.Bottom > viewport.Height) return false;
|
||||
var baseline = Calculate(viewport, dpi, false);
|
||||
if (p.DailyCard != baseline.DailyCard || p.Footer != baseline.Footer || p.ContentHeight != baseline.ContentHeight) return false;
|
||||
if (showTailnet && (p.TailnetTrafficCard.Top <= p.TrafficCard.Bottom
|
||||
|| p.Compact && p.DailyCard.Top <= p.TailnetTrafficCard.Bottom
|
||||
|| !p.Compact && (p.DailyCard.Top != p.TrafficCard.Top || p.DailyCard.Bottom != p.TailnetTrafficCard.Bottom))) return false;
|
||||
|| p.DailyCard.Top != p.TrafficCard.Top || p.DailyCard.Bottom != p.TailnetTrafficCard.Bottom)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user