InputRoll - attempt to cleanup drawing logic a bit
This commit is contained in:
parent
5f021ca0e2
commit
290cf4c4a4
|
@ -66,7 +66,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void DrawColumnDrag()
|
private void DrawColumnDrag()
|
||||||
{
|
{
|
||||||
if (_columnDown != null && _columnDownMoved && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell)
|
if (_columnDown?.Width != null && _columnDownMoved && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell)
|
||||||
{
|
{
|
||||||
int x1 = _currentX.Value - (_columnDown.Width.Value / 2);
|
int x1 = _currentX.Value - (_columnDown.Width.Value / 2);
|
||||||
int y1 = _currentY.Value - (CellHeight / 2);
|
int y1 = _currentY.Value - (CellHeight / 2);
|
||||||
|
@ -82,7 +82,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void DrawCellDrag()
|
private void DrawCellDrag()
|
||||||
{
|
{
|
||||||
if (_draggingCell != null)
|
if (_draggingCell != null && _draggingCell.RowIndex.HasValue && _draggingCell.Column.Width.HasValue
|
||||||
|
&& _currentX.HasValue && _currentY.HasValue)
|
||||||
{
|
{
|
||||||
var text = "";
|
var text = "";
|
||||||
int offsetX = 0;
|
int offsetX = 0;
|
||||||
|
@ -398,23 +399,24 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// Rows
|
// Rows
|
||||||
for (int i = 0; i < visibleColumns.Count + 1; i++)
|
for (int i = 0; i < visibleColumns.Count + 1; i++)
|
||||||
{
|
{
|
||||||
_renderer.Line(RowsToPixels(0) + 1, i * CellHeight - _vBar.Value, DrawWidth, i * CellHeight - _vBar.Value);
|
int y = i * CellHeight - _vBar.Value;
|
||||||
|
_renderer.Line(RowsToPixels(0) + 1, y, DrawWidth, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Columns
|
// Columns
|
||||||
int y = ColumnHeight + 1;
|
int y = ColumnHeight + 1;
|
||||||
int? totalColWidth = TotalColWidth;
|
|
||||||
foreach (var column in visibleColumns)
|
foreach (var column in visibleColumns)
|
||||||
{
|
{
|
||||||
int x = column.Left.Value - _hBar.Value;
|
int x = (column.Left ?? 0) - _hBar.Value;
|
||||||
_renderer.Line(x, y, x, Height - 1);
|
_renderer.Line(x, y, x, Height - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibleColumns.Any())
|
if (visibleColumns.Any())
|
||||||
{
|
{
|
||||||
_renderer.Line(totalColWidth.Value - _hBar.Value, y, totalColWidth.Value - _hBar.Value, Height - 1);
|
int x = (TotalColWidth ?? 0) - _hBar.Value;
|
||||||
|
_renderer.Line(x, y, x, Height - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rows
|
// Rows
|
||||||
|
@ -433,7 +435,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void DoSelectionBG(List<RollColumn> visibleColumns)
|
private void DoSelectionBG(List<RollColumn> visibleColumns)
|
||||||
{
|
{
|
||||||
// SuuperW: This allows user to see other colors in selected frames.
|
|
||||||
Color rowColor = Color.White;
|
Color rowColor = Color.White;
|
||||||
int lastVisibleRow = LastVisibleRow;
|
int lastVisibleRow = LastVisibleRow;
|
||||||
int lastRow = -1;
|
int lastRow = -1;
|
||||||
|
@ -479,7 +480,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Given a cell with rowindex inbetween 0 and VisibleRows, it draws the background color specified. Do not call with absolute rowindices.
|
/// Given a cell with RowIndex in between 0 and VisibleRows, it draws the background color specified. Do not call with absolute row indices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void DrawCellBG(Color color, Cell cell, List<RollColumn> visibleColumns)
|
private void DrawCellBG(Color color, Cell cell, List<RollColumn> visibleColumns)
|
||||||
{
|
{
|
||||||
|
@ -488,30 +489,33 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (HorizontalOrientation)
|
if (HorizontalOrientation)
|
||||||
{
|
{
|
||||||
x = RowsToPixels(cell.RowIndex.Value) + 1;
|
x = RowsToPixels(cell.RowIndex.Value) + 1;
|
||||||
w = CellWidth - 1;
|
|
||||||
y = (CellHeight * visibleColumns.IndexOf(cell.Column)) + 1 - _vBar.Value; // We can't draw without row and column, so assume they exist and fail catastrophically if they don't
|
|
||||||
h = CellHeight - 1;
|
|
||||||
if (x < ColumnWidth)
|
if (x < ColumnWidth)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w = CellWidth - 1;
|
||||||
|
y = (CellHeight * visibleColumns.IndexOf(cell.Column)) + 1 - _vBar.Value; // We can't draw without row and column, so assume they exist and fail catastrophically if they don't
|
||||||
|
h = CellHeight - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = cell.Column.Width.Value - 1;
|
|
||||||
x = cell.Column.Left.Value - _hBar.Value + 1;
|
|
||||||
y = RowsToPixels(cell.RowIndex.Value) + 1; // We can't draw without row and column, so assume they exist and fail catastrophically if they don't
|
y = RowsToPixels(cell.RowIndex.Value) + 1; // We can't draw without row and column, so assume they exist and fail catastrophically if they don't
|
||||||
h = CellHeight - 1;
|
|
||||||
if (y < ColumnHeight)
|
if (y < ColumnHeight)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = cell.Column.Left.Value - _hBar.Value + 1;
|
||||||
|
w = cell.Column.Width.Value - 1;
|
||||||
|
h = CellHeight - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't draw if off screen.
|
||||||
if (x > DrawWidth || y > DrawHeight)
|
if (x > DrawWidth || y > DrawHeight)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
} // Don't draw if off screen.
|
}
|
||||||
|
|
||||||
_renderer.SetBrush(color);
|
_renderer.SetBrush(color);
|
||||||
_renderer.FillRectangle(x, y, w, h);
|
_renderer.FillRectangle(x, y, w, h);
|
||||||
|
@ -524,13 +528,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
int startIndex = FirstVisibleRow;
|
int startIndex = FirstVisibleRow;
|
||||||
int range = Math.Min(LastVisibleRow, RowCount - 1) - startIndex + 1;
|
int range = Math.Min(LastVisibleRow, RowCount - 1) - startIndex + 1;
|
||||||
int lastVisible = LastVisibleColumnIndex;
|
int lastVisibleColumn = LastVisibleColumnIndex;
|
||||||
int firstVisibleColumn = FirstVisibleColumn;
|
int firstVisibleColumn = FirstVisibleColumn;
|
||||||
|
|
||||||
// Prevent exceptions with small TAStudio windows
|
// Prevent exceptions with small TAStudio windows
|
||||||
if (firstVisibleColumn < 0)
|
if (firstVisibleColumn < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HorizontalOrientation)
|
if (HorizontalOrientation)
|
||||||
{
|
{
|
||||||
for (int i = 0, f = 0; f < range; i++, f++)
|
for (int i = 0, f = 0; f < range; i++, f++)
|
||||||
|
@ -540,7 +546,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Color rowColor = Color.White;
|
Color rowColor = Color.White;
|
||||||
QueryRowBkColor?.Invoke(f + startIndex, ref rowColor);
|
QueryRowBkColor?.Invoke(f + startIndex, ref rowColor);
|
||||||
|
|
||||||
for (int j = firstVisibleColumn; j <= lastVisible; j++)
|
for (int j = firstVisibleColumn; j <= lastVisibleColumn; j++)
|
||||||
{
|
{
|
||||||
Color itemColor = Color.White;
|
Color itemColor = Color.White;
|
||||||
QueryItemBkColor?.Invoke(f + startIndex, visibleColumns[j], ref itemColor);
|
QueryItemBkColor?.Invoke(f + startIndex, visibleColumns[j], ref itemColor);
|
||||||
|
@ -577,7 +583,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Color rowColor = Color.White;
|
Color rowColor = Color.White;
|
||||||
QueryRowBkColor?.Invoke(f + startIndex, ref rowColor);
|
QueryRowBkColor?.Invoke(f + startIndex, ref rowColor);
|
||||||
|
|
||||||
for (int j = FirstVisibleColumn; j <= lastVisible; j++) // Horizontal
|
for (int j = FirstVisibleColumn; j <= lastVisibleColumn; j++) // Horizontal
|
||||||
{
|
{
|
||||||
Color itemColor = Color.White;
|
Color itemColor = Color.White;
|
||||||
QueryItemBkColor?.Invoke(f + startIndex, visibleColumns[j], ref itemColor);
|
QueryItemBkColor?.Invoke(f + startIndex, visibleColumns[j], ref itemColor);
|
||||||
|
|
Loading…
Reference in New Issue