inputroll - simplify by making column width not nullable, columns always have a width
This commit is contained in:
parent
fcc0bc19a4
commit
0762b181ce
|
@ -95,9 +95,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void DrawColumnDrag(List<RollColumn> visibleColumns)
|
private void DrawColumnDrag(List<RollColumn> visibleColumns)
|
||||||
{
|
{
|
||||||
if (_columnDown?.Width != null && _columnDownMoved && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell)
|
if (_columnDown?.Width > 0 && _columnDownMoved && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell)
|
||||||
{
|
{
|
||||||
int columnWidth = _columnDown.Width.Value;
|
int columnWidth = _columnDown.Width;
|
||||||
int columnHeight = CellHeight;
|
int columnHeight = CellHeight;
|
||||||
if (HorizontalOrientation)
|
if (HorizontalOrientation)
|
||||||
{
|
{
|
||||||
|
@ -124,8 +124,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void DrawCellDrag(List<RollColumn> visibleColumns)
|
private void DrawCellDrag(List<RollColumn> visibleColumns)
|
||||||
{
|
{
|
||||||
if (_draggingCell != null && _draggingCell.RowIndex.HasValue && _draggingCell.Column.Width.HasValue
|
if (_draggingCell?.RowIndex != null
|
||||||
&& _currentX.HasValue && _currentY.HasValue)
|
&& _draggingCell.Column.Width > 0
|
||||||
|
&& _currentX.HasValue
|
||||||
|
&& _currentY.HasValue)
|
||||||
{
|
{
|
||||||
var text = "";
|
var text = "";
|
||||||
int offsetX = 0;
|
int offsetX = 0;
|
||||||
|
@ -141,9 +143,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int columnIndex = visibleColumns.IndexOf(_draggingCell.Column);
|
int columnIndex = visibleColumns.IndexOf(_draggingCell.Column);
|
||||||
columnHeight = GetHColHeight(columnIndex);
|
columnHeight = GetHColHeight(columnIndex);
|
||||||
}
|
}
|
||||||
int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2);
|
int x1 = _currentX.Value - (_draggingCell.Column.Width / 2);
|
||||||
int y1 = _currentY.Value - (columnHeight / 2);
|
int y1 = _currentY.Value - (columnHeight / 2);
|
||||||
int x2 = x1 + _draggingCell.Column.Width.Value;
|
int x2 = x1 + _draggingCell.Column.Width;
|
||||||
int y2 = y1 + columnHeight;
|
int y2 = y1 + columnHeight;
|
||||||
|
|
||||||
_renderer.SetBrush(bgColor);
|
_renderer.SetBrush(bgColor);
|
||||||
|
@ -171,12 +173,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
|
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
|
||||||
{
|
{
|
||||||
_renderer.PrepDrawString(Font, SystemColors.HighlightText);
|
_renderer.PrepDrawString(Font, SystemColors.HighlightText);
|
||||||
DrawString(column.Text, column.Width ?? 0, strX, strY);
|
DrawString(column.Text, column.Width, strX, strY);
|
||||||
_renderer.PrepDrawString(Font, _foreColor);
|
_renderer.PrepDrawString(Font, _foreColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawString(column.Text, column.Width ?? 0, strX, strY);
|
DrawString(column.Text, column.Width, strX, strY);
|
||||||
}
|
}
|
||||||
|
|
||||||
y += columnHeight;
|
y += columnHeight;
|
||||||
|
@ -195,12 +197,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
|
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
|
||||||
{
|
{
|
||||||
_renderer.PrepDrawString(Font, SystemColors.HighlightText);
|
_renderer.PrepDrawString(Font, SystemColors.HighlightText);
|
||||||
DrawString(column.Text, column.Width ?? 0, x, y);
|
DrawString(column.Text, column.Width, x, y);
|
||||||
_renderer.PrepDrawString(Font, _foreColor);
|
_renderer.PrepDrawString(Font, _foreColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawString(column.Text, column.Width ?? 0, x, y);
|
DrawString(column.Text, column.Width, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +318,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
rePrep = true;
|
rePrep = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawString(text, col.Width ?? 0, point.X + strOffsetX, point.Y + strOffsetY);
|
DrawString(text, col.Width, point.X + strOffsetX, point.Y + strOffsetY);
|
||||||
|
|
||||||
if (rePrep)
|
if (rePrep)
|
||||||
{
|
{
|
||||||
|
@ -387,7 +389,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_renderer.FillRectangle(new Rectangle(column.Left.Value + 1 - _hBar.Value, 1, column.Width.Value - 1, ColumnHeight - 1));
|
_renderer.FillRectangle(new Rectangle(column.Left.Value + 1 - _hBar.Value, 1, column.Width - 1, ColumnHeight - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +577,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
x = cell.Column.Left.Value - _hBar.Value + 1;
|
x = cell.Column.Left.Value - _hBar.Value + 1;
|
||||||
w = cell.Column.Width.Value - 1;
|
w = cell.Column.Width - 1;
|
||||||
h = CellHeight - 1;
|
h = CellHeight - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -981,7 +981,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (_currentX != _previousX)
|
if (_currentX != _previousX)
|
||||||
{
|
{
|
||||||
_columnResizing.Width += _currentX - _previousX;
|
_columnResizing.Width += _currentX.Value - _previousX;
|
||||||
if (_columnResizing.Width <= 0)
|
if (_columnResizing.Width <= 0)
|
||||||
{
|
{
|
||||||
_columnResizing.Width = 1;
|
_columnResizing.Width = 1;
|
||||||
|
@ -1597,7 +1597,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RecalculateScrollBars();
|
RecalculateScrollBars();
|
||||||
if (_columns.VisibleColumns.Any())
|
if (_columns.VisibleColumns.Any())
|
||||||
{
|
{
|
||||||
ColumnWidth = _columns.VisibleColumns.Max(c => c.Width.Value) + CellWidthPadding * 4;
|
ColumnWidth = _columns.VisibleColumns.Max(c => c.Width) + CellWidthPadding * 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
public class RollColumn
|
public class RollColumn
|
||||||
{
|
{
|
||||||
public string Group { get; set; }
|
public string Group { get; set; }
|
||||||
public int? Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int? Left { get; set; }
|
public int? Left { get; set; }
|
||||||
public int? Right { get; set; }
|
public int? Right { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
foreach (var col in VisibleColumns)
|
foreach (var col in VisibleColumns)
|
||||||
{
|
{
|
||||||
col.Left = pos;
|
col.Left = pos;
|
||||||
pos += col.Width ?? 0;
|
pos += col.Width;
|
||||||
col.Right = pos;
|
col.Right = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue