@@ -123,10 +123,10 @@ private void Run()
123123 private sealed class OverlayForm : Forms . Form
124124 {
125125 private const int MarginPx = 16 ;
126- private const int PaddingPx = 14 ;
127- private const int ChipPaddingX = 14 ;
128- private const int ChipHeight = 32 ;
129- private const int GapPx = 8 ;
126+ private const int PaddingPx = 16 ;
127+ private const int ChipPaddingX = 18 ;
128+ private const int ChipHeight = 38 ;
129+ private const int GapPx = 10 ;
130130 private static readonly Color PanelColor = Color . FromArgb ( 0x1F , 0x1F , 0x23 ) ;
131131 private static readonly Color BrandRed = Color . FromArgb ( 0xD3 , 0x2F , 0x2F ) ;
132132 private readonly IWindowsNativeInput nativeInput ;
@@ -147,7 +147,7 @@ public OverlayForm(IWindowsNativeInput nativeInput)
147147 ShowInTaskbar = false ;
148148 StartPosition = Forms . FormStartPosition . Manual ;
149149 TopMost = true ;
150- chipFont = new Font ( Font . FontFamily , 9.5f , FontStyle . Bold ) ;
150+ chipFont = new Font ( Font . FontFamily , 10.0f , FontStyle . Bold ) ;
151151 }
152152
153153 protected override bool ShowWithoutActivation => true ;
@@ -175,12 +175,15 @@ public void SetActiveModifiers(IReadOnlyList<string> activeModifiers)
175175 return ;
176176 }
177177
178- using Graphics graphics = CreateGraphics ( ) ;
179178 int x = PaddingPx ;
180179 foreach ( string label in activeModifiers )
181180 {
182- SizeF textSize = graphics . MeasureString ( label , chipFont ) ;
183- int width = ( int ) Math . Ceiling ( textSize . Width ) + ChipPaddingX * 2 + 2 ;
181+ Size textSize = Forms . TextRenderer . MeasureText (
182+ label ,
183+ chipFont ,
184+ Size . Empty ,
185+ Forms . TextFormatFlags . NoPadding | Forms . TextFormatFlags . SingleLine ) ;
186+ int width = Math . Max ( MinimumChipWidth ( label ) , textSize . Width + ChipPaddingX * 2 ) ;
184187 Forms . Label chip = new ( )
185188 {
186189 AutoSize = false ,
@@ -203,6 +206,18 @@ public void SetActiveModifiers(IReadOnlyList<string> activeModifiers)
203206 ApplyTopMostNoActivate ( ) ;
204207 }
205208
209+ private static int MinimumChipWidth ( string label )
210+ {
211+ return label switch
212+ {
213+ "Ctrl" => 68 ,
214+ "Alt" => 60 ,
215+ "Shift" => 74 ,
216+ "Start" => 74 ,
217+ _ => 68
218+ } ;
219+ }
220+
206221 public void HideOverlay ( )
207222 {
208223 Controls . Clear ( ) ;
0 commit comments