From 6b012ef4333948cdbfd526ae2030abb22f4359b8 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Mon, 17 Mar 2025 13:45:50 +0100 Subject: [PATCH] differentiate between RollColumn vertical width and horizontal height don't really like this code too much, but it works. And the RollColumn has no idea what orientation it has, so it can't do the logic itself. see #3708 --- .../InputRoll/InputRoll.Drawing.cs | 25 ++++++++----------- .../CustomControls/InputRoll/InputRoll.cs | 4 +-- .../CustomControls/InputRoll/RollColumn.cs | 9 ++++++- .../tools/TAStudio/TAStudio.cs | 15 +++++++++-- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs index 6adfb6adfe..cc586e0f1b 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs @@ -142,33 +142,31 @@ namespace BizHawk.Client.EmuHawk { _renderer.PrepDrawString(Font, _foreColor); - int h = ColumnHeight; - int yOffset = HorizontalOrientation ? -_vBar.Value : 0; - for (int j = 0; j < visibleColumns.Count; j++) { var column = visibleColumns[j]; - var w = column.Width; - int x, y; + int x, y, w, h; if (HorizontalOrientation) { - var columnHeight = column.Width; var textSize = _renderer.MeasureString(column.Text, Font); x = MaxColumnWidth - CellWidthPadding - (int)textSize.Width; - y = yOffset + ((columnHeight - (int)textSize.Height) / 2); - yOffset += columnHeight; + y = column.Left + ((column.Width - (int)textSize.Height) / 2) - _vBar.Value; + w = MaxColumnWidth; + h = column.Width; } else { x = 1 + column.Left + CellWidthPadding - _hBar.Value; y = CellHeightPadding; + w = column.Width; + h = ColumnHeight; } if (IsHoveringOnColumnCell && column == CurrentCell.Column) { _renderer.PrepDrawString(Font, SystemColors.HighlightText); - DrawString(column.Text, new Rectangle(x, y, column.Width, h)); + DrawString(column.Text, new Rectangle(x, y, w, h)); _renderer.PrepDrawString(Font, _foreColor); } else @@ -301,20 +299,19 @@ namespace BizHawk.Client.EmuHawk { _renderer.FillRectangle(new Rectangle(0, 0, MaxColumnWidth + 1, rect.Height)); - int y = -_vBar.Value; for (int j = 0; j < visibleColumns.Count; j++) { + int y = visibleColumns[j].Left - _vBar.Value; _renderer.Line(1, y, MaxColumnWidth, y); - y += visibleColumns[j].Width; } if (visibleColumns.Count is not 0) { - _renderer.Line(1, y, MaxColumnWidth, y); + _renderer.Line(1, TotalColWidth, MaxColumnWidth, TotalColWidth); } - _renderer.Line(0, 0, 0, y); - _renderer.Line(MaxColumnWidth, 0, MaxColumnWidth, y); + _renderer.Line(0, 0, 0, rect.Height); + _renderer.Line(MaxColumnWidth, 0, MaxColumnWidth, rect.Height); } else { diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs index 7651ebb0a0..6d8305bce2 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs @@ -1645,7 +1645,7 @@ namespace BizHawk.Client.EmuHawk RecalculateScrollBars(); if (_columns.VisibleColumns.Any()) { - MaxColumnWidth = _columns.VisibleColumns.Max(c => c.Width); + MaxColumnWidth = _columns.VisibleColumns.Max(c => c.VerticalWidth); } } @@ -1966,7 +1966,7 @@ namespace BizHawk.Client.EmuHawk if (_columns.VisibleColumns.Any()) { - MaxColumnWidth = _columns.VisibleColumns.Max(c => c.Width); + MaxColumnWidth = _columns.VisibleColumns.Max(c => c.VerticalWidth); } } diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs index a632be9498..f1aca365f2 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs @@ -4,6 +4,8 @@ namespace BizHawk.Client.EmuHawk { public class RollColumn { + public int VerticalWidth { get; } + public int HorizontalHeight { get; } public int Width { get; set; } public int Left { get; set; } public int Right { get; set; } @@ -36,11 +38,16 @@ namespace BizHawk.Client.EmuHawk } public RollColumn(string name, int widthUnscaled, ColumnType type, string text) + : this(name, widthUnscaled, widthUnscaled, type, text) { } + + public RollColumn(string name, int verticalWidth, int horizontalHeight, ColumnType type, string text) { Name = name; Text = text; Type = type; - Width = UIHelper.ScaleX(widthUnscaled); + VerticalWidth = UIHelper.ScaleX(verticalWidth); + HorizontalHeight = UIHelper.ScaleX(horizontalHeight); + Width = VerticalWidth; } public RollColumn(string name, int widthUnscaled, string text) diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 8aeaa498d9..a9895be1d2 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -347,7 +347,8 @@ namespace BizHawk.Client.EmuHawk TasView.AllColumns.Add(new( name: name, - widthUnscaled: (maxLength * 6) + 14, // magic numbers reused in EditBranchTextPopUp() --feos // not since eb63fa5a9 (before 2.3.3) --yoshi + verticalWidth: (Math.Max(maxLength, mnemonic.Length) * 6) + 14, + horizontalHeight: (maxLength * 6) + 14, type: type, text: mnemonic) { @@ -1233,7 +1234,7 @@ namespace BizHawk.Client.EmuHawk if (axisSpec.HasValue) { string mnemonic = Bk2MnemonicLookup.LookupAxis(name, MovieSession.Movie.SystemID); - yield return (name, mnemonic, Math.Max(mnemonic.Length, axisSpec.Value.MaxDigits)); + yield return (name, mnemonic, axisSpec.Value.MaxDigits); } else { @@ -1250,12 +1251,22 @@ namespace BizHawk.Client.EmuHawk { BranchesMarkersSplit.Orientation = Orientation.Vertical; BranchesMarkersSplit.SplitterDistance = 200; + foreach (var rollColumn in TasView.AllColumns) + { + rollColumn.Width = rollColumn.HorizontalHeight; + } } else { BranchesMarkersSplit.Orientation = Orientation.Horizontal; BranchesMarkersSplit.SplitterDistance = _defaultBranchMarkerSplitDistance; + foreach (var rollColumn in TasView.AllColumns) + { + rollColumn.Width = rollColumn.VerticalWidth; + } } + + TasView.AllColumns.ColumnsChanged(); } } }