diff --git a/Prowl.Editor/EditorApplication.cs b/Prowl.Editor/EditorApplication.cs index 7d015137..0eb29353 100644 --- a/Prowl.Editor/EditorApplication.cs +++ b/Prowl.Editor/EditorApplication.cs @@ -9,6 +9,7 @@ using Prowl.Editor.Panels; using Prowl.PaperUI; using Prowl.Runtime; +using Prowl.Vector; namespace Prowl.Editor; @@ -58,6 +59,8 @@ public override void Initialize() System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; InitializeFont(); + Resize(Window.Size.X, Window.Size.Y); + PaperInstance.TextMode = Prowl.Quill.TextRenderMode.Bitmap; // Load Font Awesome as fallback fonts for icons @@ -220,6 +223,22 @@ public void InitializeFont() } } + protected override void PreparePaperFrame() + { + var winSize = Window.InternalWindow.Size; + float cs = Math.Max(0.01f, Window.ContentScale * EditorTheme.UserScale); + PaperInstance.SetResolution(winSize.X / cs, winSize.Y / cs); + PaperInstance.DisplayFramebufferScale = new Float2(cs, cs); + + } + + protected override Float2 GetPaperMousePosition() + { + var p = Input.MousePosition; + float cs = Math.Max(0.01f, Window.ContentScale * EditorTheme.UserScale); + return new Float2(p.X / cs, p.Y / cs); + } + private void ApplyDarkTitleBar() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return; diff --git a/Prowl.Editor/EditorTheme.cs b/Prowl.Editor/EditorTheme.cs index c4959b98..6cb7de20 100644 --- a/Prowl.Editor/EditorTheme.cs +++ b/Prowl.Editor/EditorTheme.cs @@ -12,6 +12,9 @@ public static class EditorTheme public static string DefaultFontName = "segoe ui"; public static string DefaultBoldFontName = "segoe ui"; + // DPI Scaling value + public static float UserScale { get; set; } = 1f; + // Sizing — mutable so themes can override public static float MenuBarHeight = 26f; public static float StatusBarHeight = 22f; diff --git a/Prowl.Editor/Panels/PreferencesPanel.cs b/Prowl.Editor/Panels/PreferencesPanel.cs index 2b9b1349..1081d566 100644 --- a/Prowl.Editor/Panels/PreferencesPanel.cs +++ b/Prowl.Editor/Panels/PreferencesPanel.cs @@ -192,6 +192,7 @@ private void DrawTheme(Paper paper, Prowl.Scribe.FontFile font, EditorSettings s // ── Sizing ── EditorGUI.Foldout(paper, "pref_sz_general", "General Sizing", () => { + SzSlider(paper, s, "User Scale", theme.UserScale, 0.5f, 2, v => theme.UserScale = v, false); SzSlider(paper, s, "Font Size", theme.FontSize, 8, 32, v => theme.FontSize = v); SzSlider(paper, s, "Row Height", theme.RowHeight, 16, 40, v => theme.RowHeight = v); SzSlider(paper, s, "Menu Bar Height", theme.MenuBarHeight, 18, 48, v => theme.MenuBarHeight = v); @@ -270,14 +271,17 @@ private void PrefTextField(Paper paper, EditorSettings s, string label, string v } - private void SzSlider(Paper paper, EditorSettings s, string label, float value, float min, float max, Action set) + private void SzSlider(Paper paper, EditorSettings s, string label, float value, float min, float max, Action set, bool applyOnSlide = true) { EditorGUI.Slider(paper, $"pref_sz_{label.Replace(" ", "_")}", label, value, min, max) .OnValueChanged(v => { set(MathF.Round(v, 1)); - s.ApplyTheme(); - s.Save(); + if (applyOnSlide) + { + s.ApplyTheme(); + s.Save(); + } }); } diff --git a/Prowl.Editor/Settings/EditorSettings.cs b/Prowl.Editor/Settings/EditorSettings.cs index 3808712a..68ab64ce 100644 --- a/Prowl.Editor/Settings/EditorSettings.cs +++ b/Prowl.Editor/Settings/EditorSettings.cs @@ -92,6 +92,8 @@ public void ApplyTheme() EditorApplication.Instance?.InitializeFont(); + EditorTheme.UserScale = t.UserScale; + // Sizing EditorTheme.MenuBarHeight = t.MenuBarHeight; EditorTheme.RowHeight = t.RowHeight; diff --git a/Prowl.Editor/Settings/EditorThemeData.cs b/Prowl.Editor/Settings/EditorThemeData.cs index 409665b4..f50dc824 100644 --- a/Prowl.Editor/Settings/EditorThemeData.cs +++ b/Prowl.Editor/Settings/EditorThemeData.cs @@ -95,6 +95,8 @@ public class EditorThemeData public string DefaultBoldFontName { get; set; } = "bahnschrift"; + public float UserScale { get; set; } = 1f; + // Sizing public float MenuBarHeight { get; set; } = 26f; public float RowHeight { get; set; } = 22f;