From 7e7e7dbcb9c3ea60affa480f3aaa2e196c9b4682 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sun, 23 Jun 2024 19:14:34 -0500 Subject: [PATCH] Stop hard coding row heights (fixes #34) It seems Chinese characters are taller than 16px, who knew? --- GameData/Astrogator/Astrogator-Changelog.cfg | 5 +++++ Source/AstrogationView.cs | 8 ++++---- Source/SettingsView.cs | 2 +- Source/TransferView.cs | 12 ++++++------ Source/ViewTools.cs | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/GameData/Astrogator/Astrogator-Changelog.cfg b/GameData/Astrogator/Astrogator-Changelog.cfg index 2f725ad..6017042 100644 --- a/GameData/Astrogator/Astrogator-Changelog.cfg +++ b/GameData/Astrogator/Astrogator-Changelog.cfg @@ -15,6 +15,11 @@ KERBALCHANGELOG change = Ignore NREs from FlightGlobals.ActiveVessel type = Fix } + CHANGE + { + change = Stop hard coding row heights + type = Fix + } } VERSION { diff --git a/Source/AstrogationView.cs b/Source/AstrogationView.cs index 9233bf1..ef6d012 100644 --- a/Source/AstrogationView.cs +++ b/Source/AstrogationView.cs @@ -109,7 +109,7 @@ private void createHeaders() if (col.header != "") { ColumnHeaders.AddChild(headerButton( col.header + columnSortIndicator(col), - col.headerStyle, Localizer.Format("astrogator_columnHeaderTooltip"), width, rowHeight, () => { + col.headerStyle, Localizer.Format("astrogator_columnHeaderTooltip"), width, -1, () => { SortClicked(col.sortKey); } )); @@ -194,7 +194,7 @@ private string settingsToggleTooltip { } } } - + private Rect geometry { get { // UI_SCALE is handled by calculating distance from this Y coordinate, @@ -283,7 +283,7 @@ private static double estimateLeftEdgeLogarithmic(double scale) const double estimateConst = 0.072429060773288; return estimateCoeff * Math.Log(scale) + estimateConst; } - + /// /// Launch a PopupDialog containing the view. /// Use Dismiss() to get rid of it. @@ -332,7 +332,7 @@ public PopupDialog Show() } return dialog; } - + /// /// React to the user closing all dialogs with Esc, /// doesn't get called when dismissing programmatically diff --git a/Source/SettingsView.cs b/Source/SettingsView.cs index 2259848..650bf01 100644 --- a/Source/SettingsView.cs +++ b/Source/SettingsView.cs @@ -32,7 +32,7 @@ public SettingsView(AstrogationView.ResetCallback reset, int width) AddChild(headerButton( Localizer.Format("astrogator_manualLink"), - linkStyle, Localizer.Format("astrogator_manualLinkTooltip"), RowWidthWithoutVessel, rowHeight, + linkStyle, Localizer.Format("astrogator_manualLinkTooltip"), RowWidthWithoutVessel, -1, () => { Application.OpenURL(docsURL); } )); diff --git a/Source/TransferView.cs b/Source/TransferView.cs index bc8e2c7..f2ee42f 100644 --- a/Source/TransferView.cs +++ b/Source/TransferView.cs @@ -140,32 +140,32 @@ private void CreateLayout() case ContentEnum.PlanetName: AddChild(LabelWithStyleAndSize( Localizer.Format("astrogator_planetLabel", TheName(model.destination)), - col.contentStyle, col.width, rowHeight)); + col.contentStyle, col.width)); break; case ContentEnum.YearsTillBurn: AddChild(LabelWithStyleAndSize(getYearValue, - col.contentStyle, col.width, rowHeight)); + col.contentStyle, col.width)); break; case ContentEnum.DaysTillBurn: AddChild(LabelWithStyleAndSize(getDayValue, - col.contentStyle, col.width, rowHeight)); + col.contentStyle, col.width)); break; case ContentEnum.HoursTillBurn: AddChild(LabelWithStyleAndSize(getHourValue, - col.contentStyle, col.width, rowHeight)); + col.contentStyle, col.width)); break; case ContentEnum.MinutesTillBurn: AddChild(LabelWithStyleAndSize(getMinuteValue, - col.contentStyle, col.width, rowHeight)); + col.contentStyle, col.width)); break; case ContentEnum.SecondsTillBurn: AddChild(LabelWithStyleAndSize(getSecondValue, - col.contentStyle, col.width, rowHeight)); + col.contentStyle, col.width)); break; case ContentEnum.DeltaV: diff --git a/Source/ViewTools.cs b/Source/ViewTools.cs index 4721ce5..529c8e2 100644 --- a/Source/ViewTools.cs +++ b/Source/ViewTools.cs @@ -23,7 +23,7 @@ public static class ViewTools { /// /// Height of a row of our table. /// - public const int rowHeight = 16; + private const int rowHeight = 16; /// /// Size of font to use in our table.