Skip to content

Conversation

mdonatas
Copy link
Contributor

Proposed changes

  • It seems that ToolStripComboBox is immune to AutoScaling things.. thus it's necessary to perform the scaling manually
    • Manually scale all instances of ToolStripComboBox
  • Fix gpg drop down width

Screenshots

Before / After

image
image


image
image


image
image

Test methodology

  • Manually at 1x and 2x scaling

Test environment(s)

  • Windows 11 4K 200% scaling

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks sensible

Co-authored-by: Michael Seibt <36601201+mstv@users.noreply.github.com>
@mdonatas
Copy link
Contributor Author

mdonatas commented Sep 1, 2024

looks sensible

I didn't include 100% scaling screenshots this time, but if by looks you mean visually then it now looks the same in 100% and 200% scaling..

I've been suffering these tiny search fields for years until I snapped 😅 I haven't had a 100% scaled screen in my life for over 5 years now

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have AdjustForDpiScaling extensions, is there a reason we can't enhance it to deal with all ToolStripComboBox?

public static class ControlDpiExtensions
{
public static void AdjustForDpiScaling(this Control control)

Comment on lines 28 to 29
tscboBranchFilter.Size = new Size(DpiUtil.Scale(tscboBranchFilter.Size.Width), tscboBranchFilter.Size.Height);
tstxtRevisionFilter.Size = new Size(DpiUtil.Scale(tstxtRevisionFilter.Size.Width), tstxtRevisionFilter.Size.Height);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we can't do the following?

Suggested change
tscboBranchFilter.Size = new Size(DpiUtil.Scale(tscboBranchFilter.Size.Width), tscboBranchFilter.Size.Height);
tstxtRevisionFilter.Size = new Size(DpiUtil.Scale(tstxtRevisionFilter.Size.Width), tstxtRevisionFilter.Size.Height);
tscboBranchFilter.Size = DpiUtil.Scale(tscboBranchFilter.Size);
tstxtRevisionFilter.Size = DpiUtil.Scale(tstxtRevisionFilter.Size);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it the way you showed at first, but when comparing with unscaled version I noticed that the toolbar was getting higher for no good reason and thus switched to only scaling the width.

When it gets higher it's with DpiUtil.Scale(tscboBranchFilter.Size) type of scaling

combobox-dpi.mp4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining this, otherwise it's a hidden knowledge. Thanks

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Sep 2, 2024
@mdonatas
Copy link
Contributor Author

mdonatas commented Sep 5, 2024

@RussKie oh wow, turns out ToolStripComboBox does not inherit from Control

Trying to add it to AdjustForDpiScaling

image

This would require to create a similar "structure" to iterate through ToolStripItem descendands e.g. toolStrip.FindDescendantItems() but not today. Unless you think it's not necessary, then I'd gladly accept such outcome too :)

@RussKie
Copy link
Member

RussKie commented Sep 6, 2024

@RussKie oh wow, turns out ToolStripComboBox does not inherit from Control

Trying to add it to AdjustForDpiScaling

image

This would require to create a similar "structure" to iterate through ToolStripItem descendands e.g. toolStrip.FindDescendantItems() but not today. Unless you think it's not necessary, then I'd gladly accept such outcome too :)

Yes, we'll need to create a new overload.

@mdonatas mdonatas requested review from mstv and RussKie September 8, 2024 07:31
@mdonatas
Copy link
Contributor Author

mdonatas commented Sep 8, 2024

Reimplemented the fix as part of ControlDpiExtensions.AdjustForDpiScaling

Regarding comment explaining why scaling is done only horizontally, here's how it would look with Size scaling
image

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff! 🚀

{
case ToolStripComboBox toolStripComboBox:
{
if (toolStripComboBox.Tag as string != "__DPI_SCALED__")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could lead to issues if Tag is set to something...
I suggest to add DebugHelpers.Fail check to alert developers in event the tag is set explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch... 🤦 don't really know yet how to solve it. Suggestions?

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes or #11865 (comment) with your message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mstv I don't see how this solves the problem. There are two separate use cases that want to use a Tag property and neither would work if the other one took over. After some googling I've seen people use a Dictionary<string, object> and some wrapper methods to add support for multiple tags on a control.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could lead to issues if Tag is set to something...

...

I don't see how this solves the problem. There are two separate use cases that want to use a Tag property and neither would work if the other one took over. After some googling I've seen people use a Dictionary<string, object> and some wrapper methods to add support for multiple tags on a control.

I was not aware that there are two usages of Tag - at least with your addition.

Then rather do not use Tag at all, which always is a good advice because it is not obvious for what Tag is used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdonatas controls should be scaled in the .ctor, which means the scaling should happen once. Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are probably not missing anything... I've just seen other cases where this tag was used and assumed that was necessary and then fell into the rabbit hole :)
Removed the check. Scaling still works as expected.

Comment on lines 115 to 117
if (toolStripComboBox.Tag as string != "__DPI_SCALED__")
{
toolStripComboBox.Tag = "__DPI_SCALED__";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (toolStripComboBox.Tag as string != "__DPI_SCALED__")
{
toolStripComboBox.Tag = "__DPI_SCALED__";
const string alreadyScaled = "__DPI_SCALED__";
if (toolStripComboBox.Tag as string != alreadyScaled)
{
Debug.Assert(toolStripComboBox.Tag is null);
toolStripComboBox.Tag = alreadyScaled;

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have not run

@RussKie RussKie merged commit 8eb5eb1 into gitextensions:master Sep 16, 2024
4 checks passed
@RussKie RussKie removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Sep 16, 2024
@RussKie RussKie added this to the 5.0.1 milestone Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants