Skip to content

Commit

Permalink
Fix InputRoll not updating CellHeight and CellWidth on padding change
Browse files Browse the repository at this point in the history
  • Loading branch information
Morilli committed Jul 8, 2024
1 parent 5fd840e commit 57e3c47
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1952,13 +1952,11 @@ private int PixelsToRows(int pixels)
// The height of a column cell in Vertical Orientation.
private int ColumnHeight => CellHeight + 2;

// The width of a cell in Horizontal Orientation. Only can be changed by changing the Font or CellPadding.
private int CellWidth { get; set; }
// The width of a cell in Horizontal Orientation.
private int CellWidth => (int)_charSize.Width + CellWidthPadding * 4; // Double the padding for horizontal because it looks better

/// <summary>
/// Gets or sets a value indicating the height of a cell in Vertical Orientation. Only can be changed by changing the Font or CellPadding.
/// </summary>
private int CellHeight { get; set; } = 8;
// The height of a cell in Vertical Orientation.
private int CellHeight => (int)_charSize.Height + CellHeightPadding * 2;

/// <summary>
/// Call when _charSize, MaxCharactersInHorizontal, or CellPadding is changed.
Expand All @@ -1971,12 +1969,8 @@ private void UpdateCellSize()
// Measure width change to ignore extra padding at start/end
var size1 = _renderer.MeasureString("A", Font);
var size2 = _renderer.MeasureString("AA", Font);
_charSize = new SizeF(size2.Width - size1.Width, size1.Height); // TODO make this a property so changing it updates other values.
_charSize = new SizeF(size2.Width - size1.Width, size1.Height);
}

// TODO: Should we round instead of truncate?
CellHeight = (int)_charSize.Height + (CellHeightPadding * 2);
CellWidth = (int)_charSize.Width + (CellWidthPadding * 4); // Double the padding for horizontal because it looks better

if (_columns.VisibleColumns.Any())
{
Expand Down

0 comments on commit 57e3c47

Please sign in to comment.