shithub: mycel

Download patch

ref: f00d509c3efd320c795af6964d861a73761da3e9
parent: 8970feb8e2dd65bdbda47006affff7753a7ccf60
author: Philip Silva <[email protected]>
date: Mon Aug 2 10:53:45 EDT 2021

Fit overflowing tables more evenly

--- a/browser/duitx/grid.go
+++ b/browser/duitx/grid.go
@@ -90,12 +90,23 @@
 		space := spaces[col]
 		for i := col; i < len(ui.Kids); i += ui.Columns {
 			k := ui.Kids[i]
-			k.UI.Layout(dui, k, image.Pt(sizeAvail.X-width-space.Dx(), sizeAvail.Y-space.Dy()), true)
+			k.UI.Layout(dui, k, image.Pt(sizeAvail.X-space.Dx(), sizeAvail.Y-space.Dy()), true)
 			newDx = maximum(newDx, k.R.Dx()+space.Dx())
 		}
 		ui.widths[col] = newDx
 		width += ui.widths[col]
 	}
+
+	// Reduce used widths if too large
+	if width > sizeAvail.X {
+		r := float64(sizeAvail.X) / float64(width)
+		width = sizeAvail.X
+		for i := range ui.widths {
+			ui.widths[i] = int(float64(ui.widths[i])*r)
+		}
+	}
+
+	// Enable full width if activated
 	if scaledWidth < 0 && width < sizeAvail.X {
 		leftover := sizeAvail.X - width
 		given := 0