Skip to content

Commit

Permalink
Accessibility improvements #1830
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Jan 1, 2024
1 parent 0823e8e commit 82f76b8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,10 @@ public void VisualiseBattery(int limit)
{
labelBatteryTitle.Text = Properties.Strings.BatteryChargeLimit + ": " + limit.ToString() + "%";
sliderBattery.Value = limit;

sliderBattery.AccessibleName = Properties.Strings.BatteryChargeLimit + ": " + limit.ToString() + "%";
sliderBattery.AccessibilityObject.Select(AccessibleSelection.TakeFocus);

VisualiseBatteryFull();
}

Expand All @@ -1272,11 +1276,13 @@ public void VisualiseBatteryFull()
{
buttonBatteryFull.BackColor = colorStandard;
buttonBatteryFull.ForeColor = SystemColors.ControlLightLight;
buttonBatteryFull.AccessibleName = Properties.Strings.BatteryChargeLimit + "100% on";
}
else
{
buttonBatteryFull.BackColor = buttonSecond;
buttonBatteryFull.ForeColor = SystemColors.ControlDark;
buttonBatteryFull.AccessibleName = Properties.Strings.BatteryChargeLimit + "100% off";
}

}
Expand Down Expand Up @@ -1422,11 +1428,13 @@ public void VisualiseFnLock()
{
buttonFnLock.BackColor = colorStandard;
buttonFnLock.ForeColor = SystemColors.ControlLightLight;
buttonFnLock.AccessibleName = "Fn-Lock on";
}
else
{
buttonFnLock.BackColor = buttonSecond;
buttonFnLock.ForeColor = SystemColors.ControlDark;
buttonFnLock.AccessibleName = "Fn-Lock off";
}
}

Expand Down
38 changes: 38 additions & 0 deletions app/UI/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Slider()
{
// This reduces flicker
DoubleBuffered = true;
TabStop = true;
}


Expand Down Expand Up @@ -89,6 +90,41 @@ public int Value
}
}


protected override bool IsInputKey(Keys keyData)
{
switch (keyData)
{
case Keys.Right:
case Keys.Left:
case Keys.Up:
case Keys.Down:
return true;
}

return base.IsInputKey(keyData);
}

protected override void OnKeyDown(KeyEventArgs e)
{

switch (e.KeyCode)
{
case Keys.Right:
case Keys.Up:
Value = Math.Min(Max, Value + Step);
break;
case Keys.Left:
case Keys.Down:
Value = Math.Max(Min, Value - Step);
break;
}

AccessibilityNotifyClients(AccessibleEvents.Focus, 0);

base.OnKeyDown(e);
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Expand Down Expand Up @@ -131,6 +167,8 @@ protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);

Focus();

// Difference between tumb and mouse position.
_delta = new SizeF(e.Location.X - _thumbPos.X, e.Location.Y - _thumbPos.Y);
if (_delta.Width * _delta.Width + _delta.Height * _delta.Height <= _radius * _radius)
Expand Down

0 comments on commit 82f76b8

Please sign in to comment.