InputRoll - cleanups and simplifications
This commit is contained in:
parent
e1f2147e65
commit
e1b91d13ab
|
@ -93,4 +93,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return c1.Column.Name.CompareTo(c2.Column.Name);
|
return c1.Column.Name.CompareTo(c2.Column.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class CellExtensions
|
||||||
|
{
|
||||||
|
public static bool IsDataCell(this Cell cell)
|
||||||
|
{
|
||||||
|
return cell != null && cell.RowIndex != null && cell.Column != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private int? _currentX;
|
private int? _currentX;
|
||||||
private int? _currentY;
|
private int? _currentY;
|
||||||
|
|
||||||
|
private Cell _lastCell; // The previous cell the mouse was in
|
||||||
|
|
||||||
private int _drawHeight;
|
private int _drawHeight;
|
||||||
private int _drawWidth;
|
private int _drawWidth;
|
||||||
|
|
||||||
|
@ -116,7 +118,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
_hoverTimer.Stop();
|
_hoverTimer.Stop();
|
||||||
|
|
||||||
CellHovered?.Invoke(this, new CellEventArgs(LastCell, CurrentCell));
|
CellHovered?.Invoke(this, new CellEventArgs(_lastCell, CurrentCell));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
|
@ -536,33 +538,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||||
public int? FirstSelectedIndex
|
public int? FirstSelectedIndex => AnyRowsSelected
|
||||||
{
|
? SelectedRows.Min()
|
||||||
get
|
: (int?)null;
|
||||||
{
|
|
||||||
if (AnyRowsSelected)
|
|
||||||
{
|
|
||||||
return SelectedRows.Min();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||||
public int? LastSelectedIndex
|
public int? LastSelectedIndex => AnyRowsSelected
|
||||||
{
|
? SelectedRows.Max()
|
||||||
get
|
: (int?)null;
|
||||||
{
|
|
||||||
if (AnyRowsSelected)
|
|
||||||
{
|
|
||||||
return SelectedRows.Max();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the current Cell that the mouse was in.
|
/// Gets or sets the current Cell that the mouse was in.
|
||||||
|
@ -571,17 +555,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||||
public Cell CurrentCell { get; set; }
|
public Cell CurrentCell { get; set; }
|
||||||
|
|
||||||
[Browsable(false)]
|
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
||||||
public bool CurrentCellIsDataCell => CurrentCell?.RowIndex != null && CurrentCell.Column != null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the previous Cell that the mouse was in.
|
|
||||||
/// </summary>
|
|
||||||
[Browsable(false)]
|
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
||||||
public Cell LastCell { get; private set; }
|
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||||
public bool IsPaintDown { get; private set; }
|
public bool IsPaintDown { get; private set; }
|
||||||
|
@ -700,8 +673,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
||||||
private int LastFullyVisibleRow
|
private int LastFullyVisibleRow
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -716,9 +687,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
private int LastVisibleRow
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
||||||
public int LastVisibleRow
|
|
||||||
{
|
{
|
||||||
get => FirstVisibleRow + VisibleRows + CountLagFramesDisplay(VisibleRows);
|
get => FirstVisibleRow + VisibleRows + CountLagFramesDisplay(VisibleRows);
|
||||||
set
|
set
|
||||||
|
@ -764,7 +733,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsVisible(int index)
|
private bool IsVisible(int index)
|
||||||
{
|
{
|
||||||
return index >= FirstVisibleRow && index <= LastFullyVisibleRow;
|
return index >= FirstVisibleRow && index <= LastFullyVisibleRow;
|
||||||
}
|
}
|
||||||
|
@ -792,12 +761,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private int FirstVisibleColumn
|
||||||
/// Gets the first visible column index, if scrolling is needed
|
|
||||||
/// </summary>
|
|
||||||
[Browsable(false)]
|
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
||||||
public int FirstVisibleColumn
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -812,13 +776,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Browsable(false)]
|
private int LastVisibleColumnIndex
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
||||||
public int LastVisibleColumnIndex
|
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
List<RollColumn> columnList = VisibleColumns.ToList();
|
var columnList = VisibleColumns.ToList();
|
||||||
|
|
||||||
if (HorizontalOrientation)
|
if (HorizontalOrientation)
|
||||||
{
|
{
|
||||||
|
@ -1509,13 +1471,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CellChanged(Cell newCell)
|
private void CellChanged(Cell newCell)
|
||||||
{
|
{
|
||||||
LastCell = CurrentCell;
|
_lastCell = CurrentCell;
|
||||||
CurrentCell = newCell;
|
CurrentCell = newCell;
|
||||||
|
|
||||||
if (PointedCellChanged != null &&
|
if (PointedCellChanged != null &&
|
||||||
(LastCell.Column != CurrentCell.Column || LastCell.RowIndex != CurrentCell.RowIndex))
|
(_lastCell.Column != CurrentCell.Column || _lastCell.RowIndex != CurrentCell.RowIndex))
|
||||||
{
|
{
|
||||||
PointedCellChanged(this, new CellEventArgs(LastCell, CurrentCell));
|
PointedCellChanged(this, new CellEventArgs(_lastCell, CurrentCell));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentCell?.Column != null && CurrentCell.RowIndex.HasValue)
|
if (CurrentCell?.Column != null && CurrentCell.RowIndex.HasValue)
|
||||||
|
@ -1605,7 +1567,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NeedsVScrollbar = ColumnHeight + (RowCount * RowHeight) > Height;
|
NeedsVScrollbar = ColumnHeight + (RowCount * CellHeight) > Height;
|
||||||
NeedsHScrollbar = TotalColWidth.HasValue && TotalColWidth.Value - _drawWidth + 1 > 0;
|
NeedsHScrollbar = TotalColWidth.HasValue && TotalColWidth.Value - _drawWidth + 1 > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1683,22 +1645,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void UpdateDrawSize()
|
private void UpdateDrawSize()
|
||||||
{
|
{
|
||||||
if (NeedsVScrollbar)
|
_drawWidth = NeedsVScrollbar
|
||||||
{
|
? Width - _vBar.Width
|
||||||
_drawWidth = Width - _vBar.Width;
|
: Width;
|
||||||
}
|
|
||||||
else
|
_drawHeight = NeedsHScrollbar
|
||||||
{
|
? Height - _hBar.Height
|
||||||
_drawWidth = Width;
|
: Height;
|
||||||
}
|
|
||||||
if (NeedsHScrollbar)
|
|
||||||
{
|
|
||||||
_drawHeight = Height - _hBar.Height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_drawHeight = Height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1759,7 +1712,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private bool IsHoveringOnDataCell => CurrentCell?.Column != null && CurrentCell.RowIndex.HasValue;
|
private bool IsHoveringOnDataCell => CurrentCell?.Column != null && CurrentCell.RowIndex.HasValue;
|
||||||
|
|
||||||
private bool WasHoveringOnColumnCell => LastCell?.Column != null && !LastCell.RowIndex.HasValue;
|
private bool WasHoveringOnColumnCell => _lastCell?.Column != null && !_lastCell.RowIndex.HasValue;
|
||||||
|
|
||||||
private bool IsPointingOnCellEdge(int? x)
|
private bool IsPointingOnCellEdge(int? x)
|
||||||
{
|
{
|
||||||
|
@ -1910,9 +1863,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// The width of a cell in Horizontal Orientation. Only can be changed by changing the Font or CellPadding.
|
// The width of a cell in Horizontal Orientation. Only can be changed by changing the Font or CellPadding.
|
||||||
private int CellWidth { get; set; }
|
private int CellWidth { get; set; }
|
||||||
|
|
||||||
[Browsable(false)]
|
|
||||||
public int RowHeight => CellHeight;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <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.
|
/// 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>
|
/// </summary>
|
||||||
|
|
|
@ -116,8 +116,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlight the branch cell a little, if hovering over it
|
// Highlight the branch cell a little, if hovering over it
|
||||||
if (BranchView.CurrentCellIsDataCell &&
|
if (BranchView.CurrentCell.IsDataCell()
|
||||||
BranchView.CurrentCell.Column.Name == BranchNumberColumnName &&
|
&& BranchView.CurrentCell.Column.Name == BranchNumberColumnName &&
|
||||||
column.Name == BranchNumberColumnName &&
|
column.Name == BranchNumberColumnName &&
|
||||||
index == BranchView.CurrentCell.RowIndex)
|
index == BranchView.CurrentCell.RowIndex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue