Rename GDITextRenderer to GDIRenderer, Input Roll - implement the Background color callback

This commit is contained in:
adelikat 2014-08-11 00:08:16 +00:00
parent 84e1f057fb
commit 3e9d5533e1
4 changed files with 142 additions and 87 deletions

View File

@ -443,7 +443,7 @@
<Compile Include="CustomControls\FolderBrowserDialogEx.cs"> <Compile Include="CustomControls\FolderBrowserDialogEx.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="CustomControls\GDITextRenderer.cs" /> <Compile Include="CustomControls\GDIRenderer.cs" />
<Compile Include="CustomControls\HexTextBox.cs"> <Compile Include="CustomControls\HexTextBox.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>

View File

@ -165,7 +165,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
public void FillRectangle(int x, int y, int w, int h) public void FillRectangle(int x, int y, int w, int h)
{ {
var r = new GDIRect(new Rectangle(x, y, x + w, y + h)); var r = new GDIRect(new Rectangle(x, y, w, h));
FillRect(_hdc, ref r, _currentBrush); FillRect(_hdc, ref r, _currentBrush);
} }

View File

@ -252,20 +252,20 @@ namespace BizHawk.Client.EmuHawk
if (HorizontalOrientation) if (HorizontalOrientation)
{ {
Gdi.DrawRectangle(0, 0, _horizontalOrientedColumnWidth, Height); Gdi.DrawRectangle(0, 0, _horizontalOrientedColumnWidth + 1, Height);
Gdi.FillRectangle(1, 1, _horizontalOrientedColumnWidth - 3, Height - 3); Gdi.FillRectangle(1, 1, _horizontalOrientedColumnWidth, Height - 3);
int start = 0; int start = 0;
foreach (var column in Columns) foreach (var column in Columns)
{ {
start += CellHeight; start += CellHeight;
Gdi.Line(1, start, _horizontalOrientedColumnWidth - 1, start); Gdi.Line(1, start, _horizontalOrientedColumnWidth, start);
} }
} }
else else
{ {
Gdi.DrawRectangle(0, 0, Width, CellHeight); Gdi.DrawRectangle(0, 0, Width, CellHeight);
Gdi.FillRectangle(1, 1, Width - 3, CellHeight - 3); Gdi.FillRectangle(1, 1, Width - 2, CellHeight);
int start = 0; int start = 0;
foreach (var column in Columns) foreach (var column in Columns)
@ -291,21 +291,21 @@ namespace BizHawk.Client.EmuHawk
// Columns // Columns
for (int i = 1; i < Width / CellWidth; i++) for (int i = 1; i < Width / CellWidth; i++)
{ {
var x = _horizontalOrientedColumnWidth + (i * CellWidth); var x = _horizontalOrientedColumnWidth + 1 + (i * CellWidth);
Gdi.Line(x, 1, x, Columns.Count * CellHeight); Gdi.Line(x, 1, x, Columns.Count * CellHeight);
} }
// Rows // Rows
for (int i = 1; i < Columns.Count + 1; i++) for (int i = 1; i < Columns.Count + 1; i++)
{ {
Gdi.Line(_horizontalOrientedColumnWidth, i * CellHeight, Width - 2, i * CellHeight); Gdi.Line(_horizontalOrientedColumnWidth + 1, i * CellHeight, Width - 2, i * CellHeight);
} }
} }
else else
{ {
// Columns // Columns
int x = 0; int x = 0;
int y = CellHeight; int y = CellHeight + 1;
foreach (var column in Columns) foreach (var column in Columns)
{ {
x += CalcWidth(column); x += CalcWidth(column);
@ -318,6 +318,55 @@ namespace BizHawk.Client.EmuHawk
Gdi.Line(1, (i * CellHeight) + 1, Width - 2, (i * CellHeight) + 1); Gdi.Line(1, (i * CellHeight) + 1, Width - 2, (i * CellHeight) + 1);
} }
} }
// Do background callback
if (QueryItemBkColor != null)
{
if (HorizontalOrientation)
{
var visibleRows = (Width - _horizontalOrientedColumnWidth) / CellWidth;
for (int i = 0; i < visibleRows; i++)
{
for (int j = 0; j < Columns.Count; j++)
{
Color color = Color.White;
QueryItemBkColor(i, j, ref color);
if (color != Color.White) // An easy optimization, don't draw unless the user specified something other than the default
{
Gdi.SetBrush(color);
Gdi.FillRectangle(
_horizontalOrientedColumnWidth + (i * CellWidth) + 2,
(j * CellHeight) + 1,
CellWidth - 1,
CellHeight - 1);
}
}
}
}
else
{
var visibleRows = (Height / CellHeight) - 1;
for (int i = 1; i < visibleRows; i++)
{
int x = 1;
for (int j = 0; j < Columns.Count; j++)
{
Color color = Color.White;
QueryItemBkColor(i, j, ref color);
var width = CalcWidth(Columns[j]);
if (color != Color.White) // An easy optimization, don't draw unless the user specified something other than the default
{
Gdi.SetBrush(color);
Gdi.FillRectangle(x, (i * CellHeight) + 2, width - 1, CellHeight - 1);
}
x += width;
}
}
}
}
} }
#endregion #endregion
@ -441,13 +490,13 @@ namespace BizHawk.Client.EmuHawk
{ {
if (HorizontalOrientation) if (HorizontalOrientation)
{ {
var x = _horizontalOrientedColumnWidth - 1; var x = _horizontalOrientedColumnWidth;
var y = 0; var y = 0;
return new Point(x, y); return new Point(x, y);
} }
else else
{ {
var y = CellHeight - 1; var y = CellHeight;
return new Point(0, y); return new Point(0, y);
} }
} }
@ -500,7 +549,8 @@ namespace BizHawk.Client.EmuHawk
} }
#endregion #endregion
}
#region Classes
public class RollColumns : List<RollColumn> public class RollColumns : List<RollColumn>
{ {
@ -566,4 +616,7 @@ namespace BizHawk.Client.EmuHawk
return Column.GetHashCode() + RowIndex.GetHashCode(); return Column.GetHashCode() + RowIndex.GetHashCode();
} }
} }
#endregion
}
} }

View File

@ -108,7 +108,10 @@ namespace BizHawk.Client.EmuHawk
private void TasView_QueryItemBkColor(int index, int column, ref Color color) private void TasView_QueryItemBkColor(int index, int column, ref Color color)
{ {
var test = r.NextDouble() > .5;
//var test = index == 2 && column == 2;
color = test ? Color.LightCyan : Color.White;
} }
private void TasStudioExperiment_Load(object sender, EventArgs e) private void TasStudioExperiment_Load(object sender, EventArgs e)
@ -121,43 +124,43 @@ namespace BizHawk.Client.EmuHawk
InputView.AddColumns(new[] InputView.AddColumns(new[]
{ {
new RollColumn new InputRoll.RollColumn
{ {
Group = "", Group = "",
Name = "Address", Name = "Address",
Text = "Address" Text = "Address"
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "", Group = "",
Name = "Value", Name = "Value",
Text = "Value" Text = "Value"
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "", Group = "",
Name = "Prev", Name = "Prev",
Text = "Prev" Text = "Prev"
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "", Group = "",
Name = "Changes", Name = "Changes",
Text = "Changes" Text = "Changes"
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "", Group = "",
Name = "Domain", Name = "Domain",
Text = "Domain" Text = "Domain"
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "", Group = "",
Name = "Diff", Name = "Diff",
Text = "Diff" Text = "Diff"
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "", Group = "",
Name = "Notes", Name = "Notes",
@ -166,78 +169,77 @@ namespace BizHawk.Client.EmuHawk
}); });
*/ */
InputView.AddColumns(new [] InputView.AddColumns(new []
{ {
new RollColumn new InputRoll.RollColumn
{ {
Group = "Core", Group = "Core",
Name = "MarkerColumn", Name = "MarkerColumn",
Text = "", Text = "",
Width = 23, Width = 23,
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "Core", Group = "Core",
Name = "FrameColumn", Name = "FrameColumn",
Text = "Frame", Text = "Frame",
Width = 50, Width = 50,
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 Up", Name = "P1 Up",
Text = "U", Text = "U",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 Down", Name = "P1 Down",
Text = "D", Text = "D",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 Left", Name = "P1 Left",
Text = "L", Text = "L",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 Right", Name = "P1 Right",
Text = "R", Text = "R",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 Select", Name = "P1 Select",
Text = "s", Text = "s",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 Start", Name = "P1 Start",
Text = "S", Text = "S",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 B", Name = "P1 B",
Text = "B", Text = "B",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
new RollColumn new InputRoll.RollColumn
{ {
Group = "P1", Group = "P1",
Name = "P1 A", Name = "P1 A",
Text = "A", Text = "A",
Type = RollColumn.InputType.Boolean Type = InputRoll.RollColumn.InputType.Boolean
}, },
}); });
} }