More graphics fixes for InputRoll and overhauled how scrollbars are maintained and calculated. VScrollbar is still in rows for now.
This commit is contained in:
parent
7a720a63b1
commit
69e9bc22d2
|
@ -25,15 +25,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private int _horizontalOrientedColumnWidth = 0;
|
private int _horizontalOrientedColumnWidth = 0;
|
||||||
private bool _horizontalOrientation = false;
|
private bool _horizontalOrientation = false;
|
||||||
|
private bool _programmaticallyUpdatingScrollBarValues = false;
|
||||||
|
|
||||||
private int _rowCount = 0;
|
private int _rowCount = 0;
|
||||||
private Size _charSize;
|
private Size _charSize;
|
||||||
|
|
||||||
public InputRoll()
|
public InputRoll()
|
||||||
{
|
{
|
||||||
|
//TODO Figure out how to use the width and height properties of the scrollbars instead of 17
|
||||||
VBar = new VScrollBar
|
VBar = new VScrollBar
|
||||||
{
|
{
|
||||||
Location = new Point(Width - 16, 0),
|
Location = new Point(Width - 17, 0),
|
||||||
Visible = false,
|
Visible = false,
|
||||||
Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom,
|
Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom,
|
||||||
SmallChange = 1,
|
SmallChange = 1,
|
||||||
|
@ -42,10 +44,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
HBar = new HScrollBar
|
HBar = new HScrollBar
|
||||||
{
|
{
|
||||||
Location = new Point(0, Height - 16),
|
Location = new Point(0, Height - 17),
|
||||||
Visible = false,
|
Visible = false,
|
||||||
Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
|
Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
|
||||||
SmallChange = 5,
|
SmallChange = 1,
|
||||||
LargeChange = 20
|
LargeChange = 20
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -182,7 +184,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
FullRowSelect = true;
|
FullRowSelect = true;
|
||||||
for (int i = 0; i < RowCount; i++)
|
for (int i = 0; i < RowCount; i++)
|
||||||
{
|
{
|
||||||
SelectItem(i, true);
|
SelectRow(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
FullRowSelect = oldFullRowVal;
|
FullRowSelect = oldFullRowVal;
|
||||||
|
@ -263,8 +265,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
#region Api
|
#region Api
|
||||||
|
|
||||||
// TODO: rename this, it is named this for legacy support from VirtualListVIew
|
public void SelectRow(int index, bool val)
|
||||||
public void SelectItem(int index, bool val)
|
|
||||||
{
|
{
|
||||||
if (_columns.Any())
|
if (_columns.Any())
|
||||||
{
|
{
|
||||||
|
@ -340,6 +341,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||||
public bool UseCustomBackground { get; set; }
|
public bool UseCustomBackground { get; set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||||
|
public int DrawHeight{ get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||||
|
public int DrawWidth { get; private set; }
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||||
public bool RightButtonHeld { get; set; }
|
public bool RightButtonHeld { get; set; }
|
||||||
|
@ -395,8 +404,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _programmaticallyUpdatingScrollBarValues = false;
|
|
||||||
|
|
||||||
public int LastVisibleRow
|
public int LastVisibleRow
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -459,10 +466,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
Gdi.StartOffScreenBitmap(Width, Height);
|
Gdi.StartOffScreenBitmap(Width, Height);
|
||||||
|
|
||||||
Point startPoint = StartBg();
|
//White Background
|
||||||
Gdi.SetBrush(Color.White);
|
Gdi.SetBrush(Color.White);
|
||||||
Gdi.SetSolidPen(Color.Black);
|
Gdi.SetSolidPen(Color.White);
|
||||||
Gdi.FillRectangle(startPoint.X, startPoint.Y, Width, Height);
|
Gdi.FillRectangle(0, 0, Width, Height);
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if (_columns.Any())
|
if (_columns.Any())
|
||||||
{
|
{
|
||||||
|
@ -476,10 +484,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// ForeGround
|
// ForeGround
|
||||||
DrawData(e);
|
DrawData(e);
|
||||||
|
|
||||||
//Border
|
|
||||||
//Gdi.SetBrush(Color.none);
|
|
||||||
Gdi.SetSolidPen(Color.Black);
|
|
||||||
//Gdi.DrawRectangle(startPoint.X, startPoint.Y, Width, Height);
|
|
||||||
|
|
||||||
Gdi.CopyToScreen();
|
Gdi.CopyToScreen();
|
||||||
Gdi.EndOffScreenBitmap();
|
Gdi.EndOffScreenBitmap();
|
||||||
|
@ -618,26 +622,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Gdi.DrawRectangle(0, 0, Width, CellHeight + 1);
|
//Gray column box and black line underneath
|
||||||
Gdi.FillRectangle(1, 1, Width - 2, CellHeight);
|
Gdi.FillRectangle(0, 0, Width + 1, CellHeight + 1);
|
||||||
|
Gdi.Line(0, 0, TotalColWidth.Value + 1, 0);
|
||||||
|
Gdi.Line(0, CellHeight + 1, TotalColWidth.Value + 1, CellHeight + 1);
|
||||||
|
|
||||||
|
//Vertical black seperators
|
||||||
for (int i = 0; i < _columns.Count; i++)
|
for (int i = 0; i < _columns.Count; i++)
|
||||||
{
|
{
|
||||||
int pos = _columns[i].Left.Value - HBar.Value;
|
int pos = _columns[i].Left.Value - HBar.Value;
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
{
|
{
|
||||||
Gdi.Line(pos, 0, pos, CellHeight);
|
Gdi.Line(pos, 0, pos, CellHeight + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw right most line if visible
|
//Draw right most line
|
||||||
if (_columns.Count > 0)
|
if (_columns.Any())
|
||||||
{
|
{
|
||||||
int right = _columns.Last().Left.Value + _columns.Last().Width.Value - HBar.Value;
|
int right = TotalColWidth.Value - HBar.Value;
|
||||||
if (right <= Width)
|
Gdi.Line(right, 0, right, CellHeight + 1);
|
||||||
{
|
|
||||||
Gdi.Line(right, 0, right, CellHeight);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,17 +762,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Columns
|
// Columns
|
||||||
int y = CellHeight + 1;
|
int y = CellHeight + 2;
|
||||||
foreach (var column in _columns)
|
foreach (var column in _columns)
|
||||||
{
|
{
|
||||||
int x = column.Left.Value - HBar.Value;
|
int x = column.Left.Value - HBar.Value;
|
||||||
Gdi.Line(x, y, x, Height - 1);
|
Gdi.Line(x, y, x, Height - 1);
|
||||||
}
|
}
|
||||||
|
if (_columns.Any())
|
||||||
|
{
|
||||||
|
Gdi.Line(TotalColWidth.Value, y, TotalColWidth.Value, Height - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Rows
|
// Rows
|
||||||
for (int i = 2; i < (Height / CellHeight) + 1; i++)
|
for (int i = 2; i < (Height / CellHeight) + 1; i++)
|
||||||
{
|
{
|
||||||
Gdi.Line(1, (i * CellHeight) + 1, Width - 2, (i * CellHeight) + 1);
|
Gdi.Line(0, (i * CellHeight) + 1, Width + 1, (i * CellHeight) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1075,6 +1083,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
HBar.Maximum = temp.Maximum;
|
HBar.Maximum = temp.Maximum;
|
||||||
HBar.Minimum = temp.Minimum;
|
HBar.Minimum = temp.Minimum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call this function to change the CurrentCell to newCell
|
/// Call this function to change the CurrentCell to newCell
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1115,47 +1124,62 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
|
|
||||||
|
//ScrollBar.Maximum = DesiredValue + ScrollBar.LargeChange - 1
|
||||||
|
//See MSDN Page for more information on the dumb ScrollBar.Maximum Property
|
||||||
private void RecalculateScrollBars()
|
private void RecalculateScrollBars()
|
||||||
{
|
{
|
||||||
|
UpdateDrawSize();
|
||||||
|
|
||||||
|
if (HorizontalOrientation)
|
||||||
|
{
|
||||||
|
NeedsVScrollbar = _columns.Count > DrawHeight / CellHeight;
|
||||||
|
NeedsHScrollbar = RowCount > (DrawWidth - _horizontalOrientedColumnWidth) / CellWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NeedsVScrollbar = RowCount > DrawHeight / CellHeight;
|
||||||
|
NeedsHScrollbar = TotalColWidth.HasValue && TotalColWidth.Value - DrawWidth + 1 > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateDrawSize();
|
||||||
|
|
||||||
if (NeedsVScrollbar)
|
if (NeedsVScrollbar)
|
||||||
{
|
{
|
||||||
|
|
||||||
int max;
|
|
||||||
|
|
||||||
if (HorizontalOrientation)
|
if (HorizontalOrientation)
|
||||||
{
|
{
|
||||||
max = (((_columns.Count * CellHeight) - Height) / CellHeight) + 1;
|
VBar.Maximum = (((_columns.Count * CellHeight) - Height) / CellHeight) + VBar.LargeChange;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
max = (((RowCount * CellHeight) - Height) / CellHeight) + 1;
|
VBar.Maximum = (((RowCount * CellHeight) - Height) / CellHeight) + VBar.LargeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
VBar.Maximum = max;// +VBar.LargeChange; // TODO: why can't it be 1?
|
|
||||||
VBar.Size = new Size(VBar.Width, Height);
|
VBar.Size = new Size(VBar.Width, Height);
|
||||||
VBar.Visible = true;
|
VBar.Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
VBar.Visible = false;
|
VBar.Visible = false;
|
||||||
|
VBar.Value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NeedsHScrollbar)
|
if (NeedsHScrollbar)
|
||||||
{
|
{
|
||||||
|
|
||||||
HBar.Visible = true;
|
HBar.Visible = true;
|
||||||
if (HorizontalOrientation)
|
if (HorizontalOrientation)
|
||||||
{
|
{
|
||||||
HBar.Maximum = ((RowCount * _horizontalOrientedColumnWidth)) / CellWidth;//TODO test this
|
HBar.Maximum = ((RowCount * _horizontalOrientedColumnWidth)) / CellWidth + HBar.LargeChange - 1;//TODO test this
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HBar.Maximum = _columns.Sum(c => c.Width.Value) - Width;
|
HBar.Maximum = TotalColWidth.Value - DrawWidth + HBar.LargeChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NeedsVScrollbar)
|
if (NeedsVScrollbar)
|
||||||
{
|
{
|
||||||
HBar.Maximum += VBar.Width + 18;//TODO investigate this.
|
HBar.Size = new Size(Width - VBar.Width + 1, HBar.Height);
|
||||||
HBar.Size = new Size(Width - VBar.Width, HBar.Height);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1164,7 +1188,28 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
HBar.Visible = false;
|
HBar.Visible = false;
|
||||||
|
HBar.Value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateDrawSize()
|
||||||
|
{
|
||||||
|
if (NeedsVScrollbar)
|
||||||
|
{
|
||||||
|
DrawWidth = Width - VBar.Width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawWidth = Width;
|
||||||
|
}
|
||||||
|
if (NeedsHScrollbar) {
|
||||||
|
DrawHeight = Height - HBar.Height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DrawHeight = Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,12 +1344,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return newCell;
|
return newCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private bool NeedToUpdateScrollbar()
|
|
||||||
//{
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// TODO: Calculate this on Orientation change instead of call it every time
|
// TODO: Calculate this on Orientation change instead of call it every time
|
||||||
|
//TODO: find a different solution
|
||||||
private Point StartBg()
|
private Point StartBg()
|
||||||
{
|
{
|
||||||
if (_columns.Any())
|
if (_columns.Any())
|
||||||
|
@ -1325,6 +1366,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return new Point(0, 0);
|
return new Point(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawRectangleNoFill(GDIRenderer gdi, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
gdi.Line(x, y, x + width, y);
|
||||||
|
gdi.Line(x + width, y, x + width, y + height);
|
||||||
|
gdi.Line(x + width, y + height, x, y + height);
|
||||||
|
gdi.Line(x, y + height, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: calculate this on Cell Padding change instead of calculate it every time
|
// TODO: calculate this on Cell Padding change instead of calculate it every time
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The height of a cell. Only can be changed by changing the Font or CellPadding.
|
/// The height of a cell. Only can be changed by changing the Font or CellPadding.
|
||||||
|
@ -1352,35 +1401,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A boolean that indicates if the InputRoll is too large vertically and requires a vertical scrollbar.
|
/// A boolean that indicates if the InputRoll is too large vertically and requires a vertical scrollbar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool NeedsVScrollbar
|
private bool NeedsVScrollbar{ get; set; }
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (HorizontalOrientation)
|
|
||||||
{
|
|
||||||
return _columns.Count > Height / CellHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RowCount > Height / CellHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A boolean that indicates if the InputRoll is too large horizontally and requires a horizontal scrollbar.
|
/// A boolean that indicates if the InputRoll is too large horizontally and requires a horizontal scrollbar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool NeedsHScrollbar
|
private bool NeedsHScrollbar{ get; set; }
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (HorizontalOrientation)
|
|
||||||
{
|
|
||||||
return RowCount > (Width - _horizontalOrientedColumnWidth) / CellWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _columns.Sum(column => column.Width.Value) > Width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//TODO rename and find uses
|
||||||
//private void ColumnChanged()
|
//private void ColumnChanged()
|
||||||
//{
|
//{
|
||||||
// var text = _columns.Max(c => c.Text.Length);
|
// var text = _columns.Max(c => c.Text.Length);
|
||||||
|
@ -1399,6 +1427,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return col.Width.Value;
|
return col.Width.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the total width of all the columns by using the last column's Right property.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A nullable Int representing total width.</returns>
|
||||||
|
private int? TotalColWidth
|
||||||
|
{
|
||||||
|
get{
|
||||||
|
if (_columns.Any())
|
||||||
|
{
|
||||||
|
return _columns.Last().Right;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the RollColumn object at the specified visible x coordinate. Coordinate should be between 0 and Width of the InputRoll Control.
|
/// Returns the RollColumn object at the specified visible x coordinate. Coordinate should be between 0 and Width of the InputRoll Control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -316,7 +316,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
for (var i = startVal; i < endVal; i++)
|
for (var i = startVal; i < endVal; i++)
|
||||||
{
|
{
|
||||||
TasView.SelectItem(i, true);
|
TasView.SelectRow(i, true);
|
||||||
TasView.Refresh();
|
TasView.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -571,7 +571,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
for (int i = prev; i < next; i++)
|
for (int i = prev; i < next; i++)
|
||||||
{
|
{
|
||||||
TasView.SelectItem(i, true);
|
TasView.SelectRow(i, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
TasView.DeselectAll();
|
TasView.DeselectAll();
|
||||||
foreach (var item in _tasClipboard)
|
foreach (var item in _tasClipboard)
|
||||||
{
|
{
|
||||||
TasView.SelectItem(item.Frame, true);
|
TasView.SelectRow(item.Frame, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue