From d12938bf33f4b3b854b21d4c496cbdb5b5011a9d Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 11 Aug 2014 01:23:53 +0000 Subject: [PATCH] Input Roll - column highlighting --- .../tools/TAStudio/InputRoll.cs | 79 ++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index 259b4e2b39..09aa44c274 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -192,7 +192,18 @@ namespace BizHawk.Client.EmuHawk foreach (var column in Columns) { var point = new Point(CellPadding, start + CellPadding); - Gdi.DrawString(column.Text, point); + + if (IsHoveringOnColumnCell && column == CurrentCell.Column) + { + Gdi.PrepDrawString(this.Font, SystemColors.HighlightText); + Gdi.DrawString(column.Text, point); + Gdi.PrepDrawString(this.Font, this.ForeColor); + } + else + { + Gdi.DrawString(column.Text, point); + } + start += CellHeight; } } @@ -203,7 +214,18 @@ namespace BizHawk.Client.EmuHawk foreach (var column in Columns) { var point = new Point(start + CellPadding, CellPadding); - Gdi.DrawString(column.Text, point); + + if (IsHoveringOnColumnCell && column == CurrentCell.Column) + { + Gdi.PrepDrawString(this.Font, SystemColors.HighlightText); + Gdi.DrawString(column.Text, point); + Gdi.PrepDrawString(this.Font, this.ForeColor); + } + else + { + Gdi.DrawString(column.Text, point); + } + start += CalcWidth(column); } } @@ -279,6 +301,41 @@ namespace BizHawk.Client.EmuHawk Gdi.Line(start, 0, start, CellHeight); } } + + // If the user is hovering over a column + if (IsHoveringOnColumnCell) + { + if (HorizontalOrientation) + { + for (int i = 0; i < Columns.Count; i++) + { + if (Columns[i] == CurrentCell.Column) + { + Gdi.SetBrush(SystemColors.Highlight); + Gdi.FillRectangle( + 1, + (i * CellHeight) + 1, + _horizontalOrientedColumnWidth - 1, + CellHeight - 1); + } + } + } + else + { + int start = 0; + for (int i = 0; i < Columns.Count; i++) + { + var width = CalcWidth(Columns[i]); + if (Columns[i] == CurrentCell.Column) + { + Gdi.SetBrush(SystemColors.Highlight); + Gdi.FillRectangle(start + 1, 1, width - 1, CellHeight - 1); + } + + start += width; + } + } + } } private void DrawBg(PaintEventArgs e) @@ -409,6 +466,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnMouseLeave(EventArgs e) { CurrentCell = null; + Refresh(); base.OnMouseLeave(e); } @@ -416,8 +474,19 @@ namespace BizHawk.Client.EmuHawk #region Helpers + private bool IsHoveringOnColumnCell + { + get + { + return CurrentCell != null && + CurrentCell.Column != null && + !CurrentCell.RowIndex.HasValue; + } + } + private void CalculatePointedCell(int x, int y) { + bool wasHoveringColumnCell = IsHoveringOnColumnCell; var newCell = new Cell(); // If pointing to a column header @@ -472,6 +541,12 @@ namespace BizHawk.Client.EmuHawk { CellChanged(CurrentCell, newCell); CurrentCell = newCell; + + if (IsHoveringOnColumnCell || + (wasHoveringColumnCell && !IsHoveringOnColumnCell)) + { + Refresh(); + } } }