From 7428a5d2443ba19594c4330ad6c987645ee5f693 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 19 Oct 2019 11:45:18 -0500 Subject: [PATCH] InputRoll - if column resize is enabled, double clicking a column edge resizes it to fit the text --- .../CustomControls/InputRoll.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs index 01704912c0..af975a8622 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs @@ -135,6 +135,41 @@ namespace BizHawk.Client.EmuHawk base.Dispose(disposing); } + protected override void OnDoubleClick(EventArgs e) + { + if (IsHoveringOnColumnEdge) + { + if (HorizontalOrientation) + { + // TODO + } + else + { + var maxLength = CurrentCell.Column.Text?.Length ?? 0; + + + for (int i = 0; i < RowCount; i++) + { + string text = ""; + int offSetX = 0, offSetY = 0; + QueryItemText?.Invoke(i, CurrentCell.Column, out text, ref offSetX, ref offSetY); + if (text.Length > maxLength) + { + maxLength = text.Length; + } + } + + var newWidth = (maxLength * _charSize.Width) + (CellWidthPadding * 2); + CurrentCell.Column.Width = newWidth; + _columns.ColumnsChanged(); + Refresh(); + } + + } + + base.OnDoubleClick(e); + } + #region Properties ///