Skip to content

Commit 5c98cf7

Browse files
committed
show the column text in an empty cell when hovering over it in TAStudio
1 parent c68a455 commit 5c98cf7

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
189189
_renderer.PrepDrawString(Font, _foreColor);
190190

191191
Cell currentCell = new();
192+
Cell mouseCell = ShowColumnTextOnHover ? CurrentCell : null;
192193
if (HorizontalOrientation)
193194
{
194195
for (int j = 0; j < visibleColumns.Count; j++)
@@ -223,20 +224,28 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
223224

224225
bool rePrep = false;
225226
Color foreColor = _foreColor;
227+
Font font = Font;
226228
currentCell.Column = col;
227229
currentCell.RowIndex = f + startRow;
228230
if (_selectedItems.Contains(currentCell))
229231
{
230232
foreColor = SystemColors.HighlightText;
231233
rePrep = true;
232234
}
235+
if (text.Length == 0 && mouseCell == currentCell)
236+
{
237+
font = new Font(Font, FontStyle.Regular);
238+
foreColor = SystemColors.GrayText;
239+
text = col.Text;
240+
rePrep = true;
241+
}
233242
if (col.Rotatable || rePrep)
234243
{
235-
_renderer.PrepDrawString(Font, foreColor, rotate: col.Rotatable);
244+
_renderer.PrepDrawString(font, foreColor, rotate: col.Rotatable);
236245
rePrep = true;
237246
}
238247

239-
int textWidth = (int)_renderer.MeasureString(text, Font).Width;
248+
int textWidth = (int)_renderer.MeasureString(text, font).Width;
240249
if (col.Rotatable)
241250
{
242251
// Center Text
@@ -287,13 +296,26 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
287296
QueryItemText(this, f + startRow, column, out var text, ref strOffsetX, ref strOffsetY);
288297

289298
bool rePrep = false;
299+
Color foreColor = _foreColor;
300+
Font font = Font;
290301
currentCell.Column = column;
291302
currentCell.RowIndex = f + startRow;
292303
if (_selectedItems.Contains(currentCell))
293304
{
294-
_renderer.PrepDrawString(Font, SystemColors.HighlightText);
305+
foreColor = SystemColors.HighlightText;
295306
rePrep = true;
296307
}
308+
if (text.Length == 0 && mouseCell == currentCell)
309+
{
310+
font = new Font(Font, FontStyle.Regular);
311+
foreColor = SystemColors.GrayText;
312+
text = column.Text;
313+
rePrep = true;
314+
}
315+
if (rePrep)
316+
{
317+
_renderer.PrepDrawString(font, foreColor);
318+
}
297319

298320
DrawString(text, new Rectangle(point.X + strOffsetX, point.Y + strOffsetY, column.Width, ColumnHeight));
299321

src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ public int CellHeightPadding
237237
[DefaultValue(true)]
238238
public bool GridLines { get; set; } = true;
239239

240+
/// <summary>
241+
/// Gets or sets a value indicating whether empty cells will display their column's text when the mouse cursor is placed over them
242+
/// </summary>
243+
[DefaultValue(false)]
244+
[Category("Appearance")]
245+
public bool ShowColumnTextOnHover { get; set; }
246+
240247
/// <summary>
241248
/// Gets or sets a value indicating whether the control is horizontal or vertical
242249
/// </summary>

src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ private InputRoll MakeInputRoll(int? insertAfter = null)
182182
InputPaintingMode = true,
183183
LetKeysModifySelection = true,
184184
Rotatable = true,
185+
ShowColumnTextOnHover = true,
185186
// user configurable
186187
AlwaysScroll = Settings.FollowCursorAlwaysScroll,
187188
Font = Settings.TasViewFont,
@@ -1280,13 +1281,9 @@ private void TasView_PointedCellChanged(object sender, InputRoll.CellEventArgs e
12801281
InputRoll roll = (InputRoll)sender;
12811282
toolTip1.SetToolTip(roll, null);
12821283

1283-
if (e.NewCell.RowIndex is null)
1284-
{
1285-
return;
1286-
}
1287-
1288-
if (!MouseButtonHeld)
1284+
if (e.NewCell.RowIndex is null || !MouseButtonHeld)
12891285
{
1286+
SetTasViewRowCount(); // redraw
12901287
return;
12911288
}
12921289

0 commit comments

Comments
 (0)