Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Prowl.Editor/EditorApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Prowl.Editor.Panels;
using Prowl.PaperUI;
using Prowl.Runtime;
using Prowl.Vector;

namespace Prowl.Editor;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions Prowl.Editor/EditorTheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions Prowl.Editor/Panels/PreferencesPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<float> set)
private void SzSlider(Paper paper, EditorSettings s, string label, float value, float min, float max, Action<float> 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();
}
});
}

Expand Down
2 changes: 2 additions & 0 deletions Prowl.Editor/Settings/EditorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public void ApplyTheme()

EditorApplication.Instance?.InitializeFont();

EditorTheme.UserScale = t.UserScale;

// Sizing
EditorTheme.MenuBarHeight = t.MenuBarHeight;
EditorTheme.RowHeight = t.RowHeight;
Expand Down
2 changes: 2 additions & 0 deletions Prowl.Editor/Settings/EditorThemeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading