InputRoll - support a QueryItemIcon callback, and wire it up to Tastudio's current frame marker, needs to be cleaned up

This commit is contained in:
adelikat 2014-09-03 03:16:16 +00:00
parent eebe877d28
commit 33de5d4bd9
4 changed files with 55 additions and 16 deletions

View File

@ -62,22 +62,15 @@ namespace BizHawk.Client.EmuHawk.CustomControls
#region Api #region Api
// TODO: extension method
private static byte[] ImageToByte(Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
/// <summary> /// <summary>
/// Draw a bitmap object at the given position /// Draw a bitmap object at the given position
/// </summary> /// </summary>
public void DrawBitmap(Bitmap bitmap, int x, int y) public void DrawBitmap(Bitmap bitmap, Point point)
{ {
IntPtr hbmp = bitmap.GetHbitmap(); IntPtr hbmp = bitmap.GetHbitmap();
var bitHDC = CreateCompatibleDC(CurrentHDC); var bitHDC = CreateCompatibleDC(CurrentHDC);
IntPtr old = new IntPtr(SelectObject(bitHDC, hbmp)); IntPtr old = new IntPtr(SelectObject(bitHDC, hbmp));
BitBlt(CurrentHDC, x, y, bitmap.Width, bitmap.Height, bitHDC, 0, 0, 0xCC0020); BitBlt(CurrentHDC, point.X, point.Y, bitmap.Width, bitmap.Height, bitHDC, 0, 0, 0xCC0020);
SelectObject(bitHDC, old); SelectObject(bitHDC, old);
DeleteDC(bitHDC); DeleteDC(bitHDC);
} }

View File

@ -205,17 +205,23 @@ namespace BizHawk.Client.EmuHawk
#region Event Handlers #region Event Handlers
/// <summary> /// <summary>
/// Fire the QueryItemText event which requests the text for the passed Listview cell. /// Fire the QueryItemText event which requests the text for the passed cell
/// </summary> /// </summary>
[Category("Virtual")] [Category("Virtual")]
public event QueryItemTextHandler QueryItemText; public event QueryItemTextHandler QueryItemText;
/// <summary> /// <summary>
/// Fire the QueryItemBkColor event which requests the background color for the passed Listview cell /// Fire the QueryItemBkColor event which requests the background color for the passed cell
/// </summary> /// </summary>
[Category("Virtual")] [Category("Virtual")]
public event QueryItemBkColorHandler QueryItemBkColor; public event QueryItemBkColorHandler QueryItemBkColor;
/// <summary>
/// Fire the QueryItemIconHandler event which requests an icon for a given cell
/// </summary>
[Category("Virtual")]
public event QueryItemIconHandler QueryItemIcon;
/// <summary> /// <summary>
/// Fires when the mouse moves from one cell to another (including column header cells) /// Fires when the mouse moves from one cell to another (including column header cells)
/// </summary> /// </summary>
@ -250,6 +256,11 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
public delegate void QueryItemBkColorHandler(int index, int column, ref Color color); public delegate void QueryItemBkColorHandler(int index, int column, ref Color color);
/// <summary>
/// Retrive the image for a given cell
/// </summary>
public delegate void QueryItemIconHandler(int index, int column, ref Bitmap icon);
public delegate void CellChangeEventHandler(object sender, CellEventArgs e); public delegate void CellChangeEventHandler(object sender, CellEventArgs e);
public delegate void RightMouseScrollEventHandler(object sender, MouseEventArgs e); public delegate void RightMouseScrollEventHandler(object sender, MouseEventArgs e);
@ -602,10 +613,24 @@ namespace BizHawk.Client.EmuHawk
} }
string text; string text;
var point = new Point(col.Left.Value + xPadding, RowsToPixels(i)); var point = new Point(col.Left.Value + xPadding, RowsToPixels(i));
QueryItemText(i + startRow, j, out text);
if (!string.IsNullOrWhiteSpace(text)) Bitmap image = null;
if (QueryItemIcon != null)
{ {
Gdi.DrawString(text, point); QueryItemIcon(i + startRow, j, ref image);
}
if (image != null)
{
Gdi.DrawBitmap(image, point);
}
else
{
QueryItemText(i + startRow, j, out text);
if (!string.IsNullOrWhiteSpace(text))
{
Gdi.DrawString(text, point);
}
} }
} }
} }

View File

@ -41,6 +41,26 @@ namespace BizHawk.Client.EmuHawk
#region Query callbacks #region Query callbacks
private void TasView_QueryItemIcon(int index, int column, ref Bitmap bitmap)
{
var columnName = TasView.Columns[column].Name;
if (columnName == MarkerColumnName)
{
if (Global.Emulator.Frame == index)
{
if (TasView.HorizontalOrientation)
{
bitmap = Properties.Resources.te_arrow; // TODO: horizontal version
}
else
{
bitmap = Properties.Resources.te_arrow;
}
}
}
}
private void TasView_QueryItemBkColor(int index, int column, ref Color color) private void TasView_QueryItemBkColor(int index, int column, ref Color color)
{ {
var columnName = TasView.Columns[column].Name; var columnName = TasView.Columns[column].Name;
@ -136,11 +156,11 @@ namespace BizHawk.Client.EmuHawk
{ {
if(TasView.HorizontalOrientation) if(TasView.HorizontalOrientation)
{ {
text = " V"; //text = " V";
} }
else else
{ {
text = ">"; //text = ">";
} }
} }
else else

View File

@ -55,6 +55,7 @@ namespace BizHawk.Client.EmuHawk
MarkerControl.Tastudio = this; MarkerControl.Tastudio = this;
TasView.QueryItemText += TasView_QueryItemText; TasView.QueryItemText += TasView_QueryItemText;
TasView.QueryItemBkColor += TasView_QueryItemBkColor; TasView.QueryItemBkColor += TasView_QueryItemBkColor;
TasView.QueryItemIcon += TasView_QueryItemIcon;
TopMost = Global.Config.TAStudioSettings.TopMost; TopMost = Global.Config.TAStudioSettings.TopMost;
TasView.InputPaintingMode = Global.Config.TAStudioDrawInput; TasView.InputPaintingMode = Global.Config.TAStudioDrawInput;