Skip to content

Commit

Permalink
fix HiDPI related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
RussKie committed May 13, 2018
1 parent 3b80052 commit aa096b0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions GitUI/CommandsDialogs/BrowseDialog/DashboardControl/Dashboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ public Dashboard()
flpnlContribute.Dock = DockStyle.Bottom;
flpnlContribute.SendToBack();

recentRepositoriesList1.GitModuleChanged += OnModuleChanged;
userRepositoriesList.GitModuleChanged += OnModuleChanged;

// apply scaling
pnlLogo.Padding = DpiUtil.Scale(pnlLogo.Padding);
flpnlStart.Padding = DpiUtil.Scale(flpnlStart.Padding);
flpnlContribute.Padding = DpiUtil.Scale(flpnlContribute.Padding);
tableLayoutPanel1.ColumnStyles[1].Width = DpiUtil.Scale(tableLayoutPanel1.ColumnStyles[1].Width);
recentRepositoriesList1.HeaderHeight = pnlLogo.Height;
userRepositoriesList.HeaderHeight = pnlLogo.Height;

this.AdjustForDpiScaling();
}

// need this to stop flickering of the background images, nothing else works
Expand All @@ -69,7 +68,7 @@ public void RefreshContent()
{
InitDashboardLayout();
ApplyTheme();
recentRepositoriesList1.ShowRecentRepositories();
userRepositoriesList.ShowRecentRepositories();

void ApplyTheme()
{
Expand All @@ -80,13 +79,13 @@ void ApplyTheme()
flpnlStart.BackColor = _selectedTheme.PrimaryLight;
flpnlContribute.BackColor = _selectedTheme.PrimaryVeryLight;
lblContribute.ForeColor = _selectedTheme.SecondaryHeadingText;
recentRepositoriesList1.BranchNameColor = AppSettings.BranchColor; // _selectedTheme.SecondaryText;
recentRepositoriesList1.FavouriteColor = _selectedTheme.AccentedText;
recentRepositoriesList1.ForeColor = _selectedTheme.PrimaryText;
recentRepositoriesList1.HeaderColor = _selectedTheme.SecondaryHeadingText;
recentRepositoriesList1.HeaderBackColor = _selectedTheme.PrimaryDark;
recentRepositoriesList1.HoverColor = _selectedTheme.PrimaryLight;
recentRepositoriesList1.MainBackColor = _selectedTheme.Primary;
userRepositoriesList.BranchNameColor = AppSettings.BranchColor; // _selectedTheme.SecondaryText;
userRepositoriesList.FavouriteColor = _selectedTheme.AccentedText;
userRepositoriesList.ForeColor = _selectedTheme.PrimaryText;
userRepositoriesList.HeaderColor = _selectedTheme.SecondaryHeadingText;
userRepositoriesList.HeaderBackColor = _selectedTheme.PrimaryDark;
userRepositoriesList.HoverColor = _selectedTheme.PrimaryLight;
userRepositoriesList.MainBackColor = _selectedTheme.Primary;
BackgroundImage = _selectedTheme.BackgroundImage;

foreach (var item in flpnlContribute.Controls.OfType<LinkLabel>().Union(flpnlStart.Controls.OfType<LinkLabel>()))
Expand Down Expand Up @@ -115,7 +114,7 @@ void InitDashboardLayout()
},
(panel, lastControl) =>
{
var height = DpiUtil.Scale(lastControl.Location.Y + lastControl.Size.Height) + panel.Padding.Bottom;
var height = lastControl.Location.Y + lastControl.Size.Height + panel.Padding.Bottom;
panel.Height = height;
panel.MinimumSize = new Size(0, height);
});
Expand All @@ -137,7 +136,7 @@ void InitDashboardLayout()
},
(panel, lastControl) =>
{
var height = DpiUtil.Scale(lastControl.Location.Y + lastControl.Size.Height) + panel.Padding.Bottom;
var height = lastControl.Location.Y + lastControl.Size.Height + panel.Padding.Bottom;
panel.MinimumSize = new Size(0, height);
});
}
Expand Down Expand Up @@ -170,7 +169,7 @@ Control CreateLink(Control container, string text, Image icon, EventHandler hand
AutoSize = true,
AutoEllipsis = true,
Font = AppSettings.Font,
Image = icon,
Image = DpiUtil.Scale(icon),
ImageAlign = ContentAlignment.MiddleLeft,
LinkBehavior = LinkBehavior.NeverUnderline,
Margin = new Padding(padding3, 0, padding3, DpiUtil.Scale(8)),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ public UserRepositoriesList()

_foreColorBrush = new SolidBrush(base.ForeColor);

_secondaryFont = new Font(AppSettings.Font.FontFamily, AppSettings.Font.SizeInPoints - DpiUtil.Scale(1f));
lblRecentRepositories.Font = new Font(AppSettings.Font.FontFamily, AppSettings.Font.SizeInPoints + DpiUtil.Scale(5.5f));
_secondaryFont = new Font(AppSettings.Font.FontFamily, AppSettings.Font.SizeInPoints - 1f);
lblRecentRepositories.Font = new Font(AppSettings.Font.FontFamily, AppSettings.Font.SizeInPoints + 5.5f);

listView1.Items.Clear();
listView1.ContextMenuStrip = contextMenuStrip;

ApplyScaling();

imageList1.Images.Clear();
imageList1.Images.Add(Resources.folder_git);
imageList1.Images.Add(Resources.folder_error);

this.AdjustForDpiScaling();
}

[Category("Appearance")]
Expand Down Expand Up @@ -275,24 +275,11 @@ protected virtual void OnModuleChanged(GitModuleEventArgs args)
handler?.Invoke(this, args);
}

private void ApplyScaling()
{
tableLayoutPanel1.ColumnStyles[1].Width *= DpiUtil.ScaleX;
pnlHeader.Padding = DpiUtil.Scale(pnlHeader.Padding);

var padding4 = DpiUtil.Scale(4);
var padding36 = DpiUtil.Scale(36);
listView1.Width = Width - (2 * padding36);
listView1.Location = new Point(padding36, pnlHeader.Height + padding4);
listView1.Size = new Size(Width - (2 * padding36), Height - pnlHeader.Height - (2 * padding4));
}

private static T FindControl<T>(IEnumerable controls, Func<T, bool> predicate) where T : Control
{
foreach (Control control in controls)
{
var result = control as T;
if (result != null && predicate(result))
if (control is T result && predicate(result))
{
return result;
}
Expand Down

0 comments on commit aa096b0

Please sign in to comment.