From 6a33085ddcef07dc0e4850617886575812dcd3ac Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 3 Dec 2019 13:57:19 -0600 Subject: [PATCH] InputRoll - simplify --- .../InputRoll/InputRoll.Drawing.cs | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs index 5668a45ea9..785e0120f5 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs @@ -93,31 +93,37 @@ namespace BizHawk.Client.EmuHawk private void DrawColumnDrag(List visibleColumns) { - if (_columnDown?.Width > 0 && _columnDownMoved && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell) + if (!(_columnDown?.Width > 0) + || !_columnDownMoved + || !_currentX.HasValue + || !_currentY.HasValue + || !IsHoveringOnColumnCell) { - int columnWidth = _columnDown.Width; - int columnHeight = CellHeight; - if (HorizontalOrientation) - { - int columnIndex = visibleColumns.IndexOf(_columnDown); - columnWidth = ColumnWidth; - columnHeight = GetHColHeight(columnIndex); - } - - int x1 = _currentX.Value - (columnWidth / 2); - int y1 = _currentY.Value - (columnHeight / 2); - int textOffsetY = CellHeightPadding; - if (HorizontalOrientation) - { - int textHeight = (int)_renderer.MeasureString(_columnDown.Text, Font).Height; - textOffsetY = (columnHeight - textHeight) / 2; - } - - _renderer.SetSolidPen(_backColor); - _renderer.DrawRectangle(new Rectangle(x1, y1, columnWidth, columnHeight)); - _renderer.PrepDrawString(Font, _foreColor); - _renderer.DrawString(_columnDown.Text, new Rectangle(x1 + CellWidthPadding, y1 + textOffsetY, columnWidth, columnHeight)); + return; } + + int columnWidth = _columnDown.Width; + int columnHeight = CellHeight; + if (HorizontalOrientation) + { + int columnIndex = visibleColumns.IndexOf(_columnDown); + columnWidth = ColumnWidth; + columnHeight = GetHColHeight(columnIndex); + } + + int x1 = _currentX.Value - (columnWidth / 2); + int y1 = _currentY.Value - (columnHeight / 2); + int textOffsetY = CellHeightPadding; + if (HorizontalOrientation) + { + int textHeight = (int)_renderer.MeasureString(_columnDown.Text, Font).Height; + textOffsetY = (columnHeight - textHeight) / 2; + } + + _renderer.SetSolidPen(_backColor); + _renderer.DrawRectangle(new Rectangle(x1, y1, columnWidth, columnHeight)); + _renderer.PrepDrawString(Font, _foreColor); + _renderer.DrawString(_columnDown.Text, new Rectangle(x1 + CellWidthPadding, y1 + textOffsetY, columnWidth, columnHeight)); } private void DrawCellDrag(List visibleColumns)