Skip to content

Commit 480f1fb

Browse files
Fix merge issue in ToolStripRenderer (Sizing Grip).
1 parent a846464 commit 480f1fb

File tree

2 files changed

+38
-44
lines changed

2 files changed

+38
-44
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/StatusStrip.cs

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public partial class StatusStrip : ToolStrip
2121
private static readonly int s_stateCalledSpringTableLayout = BitVector32.CreateMask(s_stateSizingGrip);
2222

2323
private const int GripWidth = 12;
24+
private const int GripHeight = 22;
25+
2426
private RightToLeftLayoutGrip? _rtlLayoutGrip;
2527
private Orientation _lastOrientation = Orientation.Horizontal;
2628

@@ -70,14 +72,7 @@ protected override Padding DefaultPadding
7072
{
7173
if (Orientation == Orientation.Horizontal)
7274
{
73-
if (RightToLeft == RightToLeft.No)
74-
{
75-
return new Padding(1, 0, 14, 0);
76-
}
77-
else
78-
{
79-
return new Padding(14, 0, 1, 0);
80-
}
75+
return RightToLeft == RightToLeft.No ? new Padding(1, 0, 14, 0) : new Padding(14, 0, 1, 0);
8176
}
8277
else
8378
{
@@ -201,24 +196,30 @@ public Rectangle SizeGripBounds
201196
{
202197
get
203198
{
204-
if (SizingGrip)
199+
if (!SizingGrip)
205200
{
206-
Size statusStripSize = Size;
207-
// we can't necessarily make this the height of the status strip, as
208-
// the orientation could change.
209-
int gripHeight = Math.Min(DefaultSize.Height, statusStripSize.Height);
210-
211-
if (RightToLeft == RightToLeft.Yes)
212-
{
213-
return new Rectangle(0, statusStripSize.Height - gripHeight, GripWidth, gripHeight);
214-
}
215-
else
216-
{
217-
return new Rectangle(statusStripSize.Width - GripWidth, statusStripSize.Height - gripHeight, GripWidth, gripHeight);
218-
}
201+
return Rectangle.Empty;
219202
}
220203

221-
return Rectangle.Empty;
204+
Size statusStripSize = Size;
205+
Rectangle clientRect = ClientRectangle;
206+
207+
int scaledGripHeight = ScaleHelper.ScaleToDpi(GripHeight, DeviceDpi);
208+
int scaleGripWidth = ScaleHelper.ScaleToDpi(GripWidth, DeviceDpi);
209+
210+
scaledGripHeight = Math.Min(scaledGripHeight, clientRect.Height);
211+
212+
return RightToLeft == RightToLeft.Yes
213+
? new Rectangle(
214+
x: 0,
215+
y: statusStripSize.Height - scaledGripHeight,
216+
width: scaleGripWidth,
217+
height: scaledGripHeight)
218+
: new Rectangle(
219+
x: statusStripSize.Width - scaleGripWidth,
220+
y: statusStripSize.Height - scaledGripHeight,
221+
width: scaleGripWidth,
222+
height: scaledGripHeight);
222223
}
223224
}
224225

@@ -303,14 +304,9 @@ internal override Size GetPreferredSizeCore(Size proposedSize)
303304
proposedSize.Height = int.MaxValue;
304305
}
305306

306-
if (Orientation == Orientation.Horizontal)
307-
{
308-
return GetPreferredSizeHorizontal(this, proposedSize) + Padding.Size;
309-
}
310-
else
311-
{
312-
return GetPreferredSizeVertical(this) + Padding.Size;
313-
}
307+
return Orientation == Orientation.Horizontal
308+
? GetPreferredSizeHorizontal(this, proposedSize) + Padding.Size
309+
: GetPreferredSizeVertical(this) + Padding.Size;
314310
}
315311

316312
return base.GetPreferredSizeCore(proposedSize);
@@ -584,15 +580,9 @@ protected override void WndProc(ref Message m)
584580
PInvokeCore.GetClientRect(rootHwnd, out RECT rootHwndClientArea);
585581

586582
// map the size grip FROM statusStrip coords TO the toplevel window coords.
587-
Point gripLocation;
588-
if (RightToLeft == RightToLeft.Yes)
589-
{
590-
gripLocation = new Point(SizeGripBounds.Left, SizeGripBounds.Bottom);
591-
}
592-
else
593-
{
594-
gripLocation = new Point(SizeGripBounds.Right, SizeGripBounds.Bottom);
595-
}
583+
Point gripLocation = RightToLeft == RightToLeft.Yes
584+
? new Point(SizeGripBounds.Left, SizeGripBounds.Bottom)
585+
: new Point(SizeGripBounds.Right, SizeGripBounds.Bottom);
596586

597587
PInvokeCore.MapWindowPoints(this, rootHwnd, ref gripLocation);
598588

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripRenderer.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,11 +1056,11 @@ private protected static void OnRenderStatusStripSizingGrip(
10561056
ReadOnlySpan<Rectangle> baseRectangles = s_baseSizeGripRectangles;
10571057

10581058
// Reference height for sizing grips at 96 DPI (standard sizing)
1059-
const int DefaultGripAreaHeight = 20;
1059+
int scaledDefaultGripAreaHeight = ScaleHelper.ScaleToDpi(20, e.ToolStrip.DeviceDpi);
10601060

10611061
// Calculate scaling based on the almost half of the current height
10621062
// of the status strip's sizing grip area
1063-
float heightScale = 0.6f * ((float)sizeGripBounds.Height / DefaultGripAreaHeight);
1063+
float heightScale = ((float)sizeGripBounds.Height / scaledDefaultGripAreaHeight);
10641064

10651065
// Save the current graphics state before transformations
10661066
GraphicsState originalState = g.Save();
@@ -1078,11 +1078,15 @@ private protected static void OnRenderStatusStripSizingGrip(
10781078
// Set up the transform to scale from the bottom corner
10791079
if (isRtl)
10801080
{
1081-
g.TranslateTransform(sizeGripBounds.Left + cornerOffset, sizeGripBounds.Bottom - cornerOffset);
1081+
g.TranslateTransform(
1082+
sizeGripBounds.Left + cornerOffset,
1083+
sizeGripBounds.Bottom - cornerOffset);
10821084
}
10831085
else
10841086
{
1085-
g.TranslateTransform(sizeGripBounds.Right - cornerOffset, sizeGripBounds.Bottom - cornerOffset);
1087+
g.TranslateTransform(
1088+
sizeGripBounds.Right - cornerOffset,
1089+
sizeGripBounds.Bottom - cornerOffset);
10861090
}
10871091

10881092
// Apply scaling

0 commit comments

Comments
 (0)