mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-02 22:36:00 +02:00
Added screen DPI awareness
This commit is contained in:
parent
3de10b9d73
commit
9930ae8436
6 changed files with 52 additions and 3 deletions
|
@ -121,6 +121,7 @@ namespace IDE
|
|||
public String mDbgCompileDir ~ delete _;
|
||||
public String mDbgVersionedCompileDir ~ delete _;
|
||||
public DateTime mDbgHighestTime;
|
||||
public bool mIsFirstRun;
|
||||
|
||||
//public ToolboxPanel mToolboxPanel;
|
||||
public Monitor mMonitor = new Monitor() ~ delete _;
|
||||
|
@ -9596,6 +9597,7 @@ namespace IDE
|
|||
// User setting can affect automated testing, so use default settings
|
||||
mSettings.Load();
|
||||
mSettings.Apply();
|
||||
mIsFirstRun = !mSettings.mLoadedSettings;
|
||||
}
|
||||
|
||||
DarkTheme aTheme = new DarkTheme();
|
||||
|
@ -9677,11 +9679,29 @@ namespace IDE
|
|||
LoadWorkspace(mVerb);
|
||||
}
|
||||
|
||||
if ((mRunningTestScript) || (!LoadWorkspaceUserData()))
|
||||
bool loadedWorkspaceUserData = false;
|
||||
|
||||
if ((!mRunningTestScript) && (LoadWorkspaceUserData()))
|
||||
{
|
||||
loadedWorkspaceUserData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateDefaultLayout();
|
||||
}
|
||||
|
||||
WorkspaceLoaded();
|
||||
|
||||
if ((mIsFirstRun) && (!loadedWorkspaceUserData))
|
||||
{
|
||||
GetWorkspaceRect(var workX, var workY, var workWidth, var workHeight);
|
||||
|
||||
int32 height = (int32)(workHeight * 0.85f);
|
||||
int32 width = Math.Min(4 * height / 3, (int32)(workWidth * 0.85f));
|
||||
|
||||
mRequestedWindowRect = .(workX + (workWidth - width)/2, workY + (workHeight - height)/2, width, height);
|
||||
}
|
||||
|
||||
//
|
||||
{
|
||||
BFWindow.Flags flags = .Border | .ThickFrame | .Resizable | .SysMenu |
|
||||
|
@ -9694,6 +9714,17 @@ namespace IDE
|
|||
(int32)mRequestedWindowRect.mY, (int32)mRequestedWindowRect.mWidth, (int32)mRequestedWindowRect.mHeight,
|
||||
flags, mMainFrame);
|
||||
}
|
||||
|
||||
if (mIsFirstRun)
|
||||
{
|
||||
// If this is our first time running, set up a scale based on DPI
|
||||
int dpi = mMainWindow.GetDPI();
|
||||
if (dpi >= 120)
|
||||
{
|
||||
mSettings.mEditorSettings.mUIScale = 100 * Math.Min(dpi / 96.0f, 4.0f);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTitle();
|
||||
mMainWindow.SetMinimumSize(GS!(480), GS!(360));
|
||||
mMainWindow.mIsMainWindow = true;
|
||||
|
|
|
@ -631,6 +631,8 @@ namespace IDE
|
|||
}
|
||||
}
|
||||
|
||||
public bool mLoadedSettings;
|
||||
|
||||
public CompilerSettings mCompilerSettings = new .() ~ delete _;
|
||||
public EditorSettings mEditorSettings = new .() ~ delete _;
|
||||
public VSSettings mVSSettings = new .() ~ delete _;
|
||||
|
@ -712,6 +714,7 @@ namespace IDE
|
|||
if (sd.Load(path) case .Err)
|
||||
return;
|
||||
|
||||
mLoadedSettings = true;
|
||||
using (sd.Open("Editor"))
|
||||
mEditorSettings.Deserialize(sd);
|
||||
using (sd.Open("Keys"))
|
||||
|
@ -750,7 +753,7 @@ namespace IDE
|
|||
|
||||
public void Apply()
|
||||
{
|
||||
gApp.mSettings.mEditorSettings.mUIScale = Math.Clamp(gApp.mSettings.mEditorSettings.mUIScale, 25, 400);
|
||||
gApp.mSettings.mEditorSettings.mUIScale = Math.Clamp(gApp.mSettings.mEditorSettings.mUIScale, 50, 400);
|
||||
gApp.mSettings.mEditorSettings.mFontSize = Math.Clamp(gApp.mSettings.mEditorSettings.mFontSize, 6.0f, 72.0f);
|
||||
|
||||
Font.ClearFontNameCache();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue