Input Roll - some more progress
This commit is contained in:
parent
1d38157a21
commit
480520ff6f
|
@ -11,7 +11,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
||||||
/// Wrapper for GDI text rendering functions<br/>
|
/// Wrapper for GDI text rendering functions<br/>
|
||||||
/// This class is not thread-safe as GDI function should be called from the UI thread.
|
/// This class is not thread-safe as GDI function should be called from the UI thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class NativeTextRenderer : IDisposable
|
public sealed class GDIRenderer : IDisposable
|
||||||
{
|
{
|
||||||
#region Fields and Consts
|
#region Fields and Consts
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public NativeTextRenderer(System.Windows.Forms.Control c)
|
public GDIRenderer(System.Windows.Forms.Control c)
|
||||||
{
|
{
|
||||||
_c = c;
|
_c = c;
|
||||||
_hdc = GetDC(c.Handle);
|
_hdc = GetDC(c.Handle);
|
||||||
|
@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Init.
|
/// Init.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public NativeTextRenderer(Graphics g)
|
public GDIRenderer(Graphics g)
|
||||||
{
|
{
|
||||||
_g = g;
|
_g = g;
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,28 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using BizHawk.Client.EmuHawk.CustomControls;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public class InputRoll : Control
|
public class InputRoll : Control
|
||||||
{
|
{
|
||||||
public InputRoll()
|
public InputRoll()
|
||||||
{
|
{
|
||||||
|
CellPadding = 3;
|
||||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||||
|
this.Font = new Font("Courier New", 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the amount of padding on the text inside a cell
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(3)]
|
||||||
|
public int CellPadding { get; set; }
|
||||||
|
|
||||||
// TODO: remove this, it is put here for more convenient replacing of a virtuallistview in tools with the need to refactor code
|
// TODO: remove this, it is put here for more convenient replacing of a virtuallistview in tools with the need to refactor code
|
||||||
public bool VirtualMode { get; set; }
|
public bool VirtualMode { get; set; }
|
||||||
|
|
||||||
|
@ -45,7 +55,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
[Category("Behavior")]
|
[Category("Behavior")]
|
||||||
public bool AllowColumnReorder { get; set; }
|
public bool AllowColumnReorder { get; set; }
|
||||||
|
|
||||||
// TODO: don't expose to the designer
|
/// <summary>
|
||||||
|
/// Column data
|
||||||
|
/// </summary>
|
||||||
|
[Category("Behavior")]
|
||||||
public RollColumns Columns { get; set; }
|
public RollColumns Columns { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -93,9 +106,50 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
#region Paint
|
#region Paint
|
||||||
|
|
||||||
|
private void DrawColumnBg(GDIRenderer ntr, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
if (HorizontalOrientation)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawBg(GDIRenderer ntr, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
var start = StartBg;
|
||||||
|
|
||||||
|
ntr.DrawRectangle(StartBg.X, StartBg.Y, Width, Height);
|
||||||
|
|
||||||
|
if (HorizontalOrientation)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnPaintBackground(PaintEventArgs pevent)
|
protected override void OnPaintBackground(PaintEventArgs pevent)
|
||||||
{
|
{
|
||||||
base.OnPaintBackground(pevent);
|
using (var ntr = new GDIRenderer(this))
|
||||||
|
{
|
||||||
|
if (NeedToUpdateColumn() && Columns.Any())
|
||||||
|
{
|
||||||
|
DrawColumnBg(ntr, pevent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NeedToUpdateBg())
|
||||||
|
{
|
||||||
|
DrawBg(ntr, pevent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//base.OnPaintBackground(pevent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPaint(PaintEventArgs e)
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
@ -123,7 +177,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private bool NeedToUpdateColumn()
|
private bool NeedToUpdateColumn()
|
||||||
{
|
{
|
||||||
return true;// TODO
|
return true; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool NeedToUpdateText()
|
private bool NeedToUpdateText()
|
||||||
|
@ -141,11 +195,35 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Point StartBg
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Columns.Any())
|
||||||
|
{
|
||||||
|
if (HorizontalOrientation)
|
||||||
|
{
|
||||||
|
var x = (Columns.Max(c => c.Text.Length) * TextWidth) + CellPadding;
|
||||||
|
var y = TextHeight + CellPadding;
|
||||||
|
return new Point(x, y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var x = 0;
|
||||||
|
var y = TextHeight + CellPadding;
|
||||||
|
return new Point(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Point(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int TextHeight
|
private int TextHeight
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return 13; // TODO
|
return this.Font.Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +231,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return 15; // TODO
|
return 15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,21 +253,27 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public class RollColumns : List<RollColumn>
|
public class RollColumns : List<RollColumn>
|
||||||
{
|
{
|
||||||
public void Add(string name, string text, int width)
|
public void Add(string name, string text, int width, RollColumn.InputType type = RollColumn.InputType.Boolean)
|
||||||
{
|
{
|
||||||
Add(new RollColumn
|
Add(new RollColumn
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
Text = text,
|
Text = text,
|
||||||
Width = width
|
Width = width,
|
||||||
|
Type = type
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class RollColumn
|
public class RollColumn
|
||||||
{
|
{
|
||||||
|
public enum InputType { Boolean, Float }
|
||||||
|
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
|
public InputType Type { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,65 +28,71 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.inputRoll1 = new BizHawk.Client.EmuHawk.InputRoll();
|
this.InputView = new BizHawk.Client.EmuHawk.InputRoll();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.settingsToolStripMenuItem});
|
this.settingsToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(404, 24);
|
this.menuStrip1.Size = new System.Drawing.Size(404, 24);
|
||||||
this.menuStrip1.TabIndex = 0;
|
this.menuStrip1.TabIndex = 0;
|
||||||
this.menuStrip1.Text = "menuStrip1";
|
this.menuStrip1.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// settingsToolStripMenuItem
|
// settingsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.autoloadToolStripMenuItem});
|
this.autoloadToolStripMenuItem});
|
||||||
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||||
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
||||||
this.settingsToolStripMenuItem.Text = "&Settings";
|
this.settingsToolStripMenuItem.Text = "&Settings";
|
||||||
this.settingsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.settingsToolStripMenuItem_DropDownOpened);
|
this.settingsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.settingsToolStripMenuItem_DropDownOpened);
|
||||||
//
|
//
|
||||||
// autoloadToolStripMenuItem
|
// autoloadToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
|
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
|
||||||
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
|
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
|
||||||
this.autoloadToolStripMenuItem.Text = "Autoload";
|
this.autoloadToolStripMenuItem.Text = "Autoload";
|
||||||
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
|
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// inputRoll1
|
// InputView
|
||||||
//
|
//
|
||||||
this.inputRoll1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.InputView.AllowColumnReorder = false;
|
||||||
|
this.InputView.AllowColumnResize = false;
|
||||||
|
this.InputView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.inputRoll1.Location = new System.Drawing.Point(12, 103);
|
this.InputView.Columns = null;
|
||||||
this.inputRoll1.Name = "inputRoll1";
|
this.InputView.HorizontalOrientation = false;
|
||||||
this.inputRoll1.Size = new System.Drawing.Size(380, 303);
|
this.InputView.ItemCount = 0;
|
||||||
this.inputRoll1.TabIndex = 1;
|
this.InputView.Location = new System.Drawing.Point(12, 103);
|
||||||
this.inputRoll1.Text = "inputRoll1";
|
this.InputView.Name = "InputView";
|
||||||
//
|
this.InputView.Size = new System.Drawing.Size(380, 303);
|
||||||
// TasStudioExperiment
|
this.InputView.TabIndex = 1;
|
||||||
//
|
this.InputView.Text = "inputRoll1";
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.InputView.VirtualMode = false;
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
//
|
||||||
this.ClientSize = new System.Drawing.Size(404, 418);
|
// TasStudioExperiment
|
||||||
this.Controls.Add(this.inputRoll1);
|
//
|
||||||
this.Controls.Add(this.menuStrip1);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.MainMenuStrip = this.menuStrip1;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.Name = "TasStudioExperiment";
|
this.ClientSize = new System.Drawing.Size(404, 418);
|
||||||
this.Text = "TasStudioExperiment";
|
this.Controls.Add(this.InputView);
|
||||||
this.Load += new System.EventHandler(this.TasStudioExperiment_Load);
|
this.Controls.Add(this.menuStrip1);
|
||||||
this.menuStrip1.ResumeLayout(false);
|
this.MainMenuStrip = this.menuStrip1;
|
||||||
this.menuStrip1.PerformLayout();
|
this.Name = "TasStudioExperiment";
|
||||||
this.ResumeLayout(false);
|
this.Text = "TasStudioExperiment";
|
||||||
this.PerformLayout();
|
this.Load += new System.EventHandler(this.TasStudioExperiment_Load);
|
||||||
|
this.menuStrip1.ResumeLayout(false);
|
||||||
|
this.menuStrip1.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +101,6 @@
|
||||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||||
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
|
||||||
private InputRoll inputRoll1;
|
private InputRoll InputView;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputView.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FastUpdate()
|
public void FastUpdate()
|
||||||
|
|
Loading…
Reference in New Issue