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:
parent
eebe877d28
commit
33de5d4bd9
|
@ -62,22 +62,15 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
|
||||
#region Api
|
||||
|
||||
// TODO: extension method
|
||||
private static byte[] ImageToByte(Image img)
|
||||
{
|
||||
ImageConverter converter = new ImageConverter();
|
||||
return (byte[])converter.ConvertTo(img, typeof(byte[]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw a bitmap object at the given position
|
||||
/// </summary>
|
||||
public void DrawBitmap(Bitmap bitmap, int x, int y)
|
||||
public void DrawBitmap(Bitmap bitmap, Point point)
|
||||
{
|
||||
IntPtr hbmp = bitmap.GetHbitmap();
|
||||
var bitHDC = CreateCompatibleDC(CurrentHDC);
|
||||
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);
|
||||
DeleteDC(bitHDC);
|
||||
}
|
||||
|
|
|
@ -205,17 +205,23 @@ namespace BizHawk.Client.EmuHawk
|
|||
#region Event Handlers
|
||||
|
||||
/// <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>
|
||||
[Category("Virtual")]
|
||||
public event QueryItemTextHandler QueryItemText;
|
||||
|
||||
/// <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>
|
||||
[Category("Virtual")]
|
||||
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>
|
||||
/// Fires when the mouse moves from one cell to another (including column header cells)
|
||||
/// </summary>
|
||||
|
@ -250,6 +256,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
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 RightMouseScrollEventHandler(object sender, MouseEventArgs e);
|
||||
|
@ -602,10 +613,24 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
string text;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,26 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
#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)
|
||||
{
|
||||
var columnName = TasView.Columns[column].Name;
|
||||
|
@ -136,11 +156,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if(TasView.HorizontalOrientation)
|
||||
{
|
||||
text = " V";
|
||||
//text = " V";
|
||||
}
|
||||
else
|
||||
{
|
||||
text = ">";
|
||||
//text = ">";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
MarkerControl.Tastudio = this;
|
||||
TasView.QueryItemText += TasView_QueryItemText;
|
||||
TasView.QueryItemBkColor += TasView_QueryItemBkColor;
|
||||
TasView.QueryItemIcon += TasView_QueryItemIcon;
|
||||
|
||||
TopMost = Global.Config.TAStudioSettings.TopMost;
|
||||
TasView.InputPaintingMode = Global.Config.TAStudioDrawInput;
|
||||
|
|
Loading…
Reference in New Issue