From ec60071926ab4c1948903bca6a67cd71a753d60a Mon Sep 17 00:00:00 2001 From: Friedrich von Never Date: Sun, 11 Aug 2019 17:52:07 +0700 Subject: [PATCH] Remove the unnecessary height setter (#100) These items are horizontal paddings, so their height shouldn't matter at all. --- .../BoxTests.nestedMatrixAtomBox.approved.txt | 64 +++++++++---------- .../BoxTests.simpleMatrixAtomBox.approved.txt | 32 +++++----- src/WpfMath/Atoms/MatrixAtom.cs | 7 +- 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/src/WpfMath.Tests/TestResults/BoxTests.nestedMatrixAtomBox.approved.txt b/src/WpfMath.Tests/TestResults/BoxTests.nestedMatrixAtomBox.approved.txt index 2d06351f..da535151 100644 --- a/src/WpfMath.Tests/TestResults/BoxTests.nestedMatrixAtomBox.approved.txt +++ b/src/WpfMath.Tests/TestResults/BoxTests.nestedMatrixAtomBox.approved.txt @@ -38,11 +38,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad0:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -126,11 +126,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad0:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -140,11 +140,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad0:1", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.39374999999999993, "Italic": 0.0, "Width": 0.39374999999999993, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -228,11 +228,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad0:1", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.39374999999999993, "Italic": 0.0, "Width": 0.39374999999999993, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -242,11 +242,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad0:2", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -330,11 +330,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad0:2", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 } @@ -387,11 +387,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad1:0", - "TotalHeight": 3.0388880000000005, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 3.0388880000000005, + "Height": 0.0, "Depth": 0.0, "Shift": 1.8416660000000002 }, @@ -475,11 +475,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad1:0", - "TotalHeight": 3.0388880000000005, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 3.0388880000000005, + "Height": 0.0, "Depth": 0.0, "Shift": 1.8416660000000002 }, @@ -489,11 +489,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad1:1", - "TotalHeight": 3.0388880000000005, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 3.0388880000000005, + "Height": 0.0, "Depth": 0.0, "Shift": 2.863888 }, @@ -553,11 +553,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad0:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -641,11 +641,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad0:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 } @@ -698,11 +698,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad1:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -786,11 +786,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad1:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 } @@ -899,11 +899,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad1:1", - "TotalHeight": 3.0388880000000005, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 3.0388880000000005, + "Height": 0.0, "Depth": 0.0, "Shift": 2.863888 }, @@ -913,11 +913,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad1:2", - "TotalHeight": 3.0388880000000005, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 3.0388880000000005, + "Height": 0.0, "Depth": 0.0, "Shift": 1.8416660000000002 }, @@ -1001,11 +1001,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad1:2", - "TotalHeight": 3.0388880000000005, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 3.0388880000000005, + "Height": 0.0, "Depth": 0.0, "Shift": 1.8416660000000002 } diff --git a/src/WpfMath.Tests/TestResults/BoxTests.simpleMatrixAtomBox.approved.txt b/src/WpfMath.Tests/TestResults/BoxTests.simpleMatrixAtomBox.approved.txt index 838b610f..68a946be 100644 --- a/src/WpfMath.Tests/TestResults/BoxTests.simpleMatrixAtomBox.approved.txt +++ b/src/WpfMath.Tests/TestResults/BoxTests.simpleMatrixAtomBox.approved.txt @@ -66,11 +66,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad0:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -154,11 +154,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad0:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -168,11 +168,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad0:1", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -256,11 +256,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad0:1", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 } @@ -313,11 +313,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad1:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -401,11 +401,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad1:0", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -415,11 +415,11 @@ "Foreground": null, "Background": null, "Tag": "CellLeftPad1:1", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 }, @@ -503,11 +503,11 @@ "Foreground": null, "Background": null, "Tag": "CellRightPad1:1", - "TotalHeight": 0.994444, + "TotalHeight": 0.0, "TotalWidth": 0.175, "Italic": 0.0, "Width": 0.175, - "Height": 0.994444, + "Height": 0.0, "Depth": 0.0, "Shift": 0.81944400000000006 } diff --git a/src/WpfMath/Atoms/MatrixAtom.cs b/src/WpfMath/Atoms/MatrixAtom.cs index ef8c59ba..02410168 100644 --- a/src/WpfMath/Atoms/MatrixAtom.cs +++ b/src/WpfMath/Atoms/MatrixAtom.cs @@ -386,12 +386,9 @@ private static List> CalculateCellGaps( for (int j = 0; j < row.Children.Count; j++) { var rowcolitem = row.Children[j]; - if (rowcolitem is StrutBox) - { - rowcolitem.Height = rowHeights[rowIndex]; - } - else if (rowcolitem is VerticalBox && rowcolitem.Tag.ToString() == $"Cell{rowIndex}:{columns}") + if (rowcolitem is VerticalBox && rowcolitem.Tag.ToString() == $"Cell{rowIndex}:{columns}") { + // TODO[F]: require the vertical box list as input double cellVShift = rowHeights[rowIndex] - rowcolitem.TotalHeight; double cellHShift = columnWidths[columns] - rowcolitem.TotalWidth;