Posters: always a 2:3 box
The poster box followed the image's shape, so images Radarr/Sonarr hand out in another shape came out smaller than the others in a list. The box is now always 2:3: an image within 12% of that fills it, trimmed at the long sides (block characters too, which were stretched before); one further off is shown whole, centred in the box. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -358,3 +358,48 @@ func TestCellsStyleIsFlat(t *testing.T) {
|
||||
t.Errorf("got %q %v %v", ch, fg, bg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostersShareTheTwoByThreeBox(t *testing.T) {
|
||||
sim := tcell.NewSimulationScreen("")
|
||||
if err := sim.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer sim.Fini()
|
||||
sim.SetSize(40, 30)
|
||||
|
||||
// extent returns the columns and rows covered by poster cells (white).
|
||||
extent := func(w, h int) (x0, y0, x1, y1 int) {
|
||||
img := image.NewRGBA(image.Rect(0, 0, w, h))
|
||||
for i := range img.Pix {
|
||||
img.Pix[i] = 255
|
||||
}
|
||||
sim.Clear()
|
||||
c := newCoverView(quadrantStyle, nil, func() float64 { return 2 })
|
||||
c.setImage(img)
|
||||
c.SetRect(0, 0, 40, 30)
|
||||
c.Draw(sim)
|
||||
x0, y0, x1, y1 = 99, 99, -1, -1
|
||||
for y := 0; y < 30; y++ {
|
||||
for x := 0; x < 40; x++ {
|
||||
_, _, st, _ := sim.GetContent(x, y)
|
||||
if _, bg, _ := st.Decompose(); bg == tcell.NewRGBColor(255, 255, 255) {
|
||||
x0, y0, x1, y1 = min(x0, x), min(y0, y), max(x1, x), max(y1, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
ax0, ay0, ax1, ay1 := extent(2000, 3000) // the usual shape
|
||||
bx0, by0, bx1, by1 := extent(2100, 3000) // 5% wider: trimmed, same box
|
||||
if ax0 != bx0 || ay0 != by0 || ax1 != bx1 || ay1 != by1 {
|
||||
t.Errorf("2:3 at %d,%d-%d,%d but 0.7 at %d,%d-%d,%d", ax0, ay0, ax1, ay1, bx0, by0, bx1, by1)
|
||||
}
|
||||
if ay0 != 0 || ax1 != 39 {
|
||||
t.Errorf("the box sits at the top right: %d,%d-%d,%d", ax0, ay0, ax1, ay1)
|
||||
}
|
||||
// A square image is shown whole: as wide as the box, shorter, centred.
|
||||
sx0, sy0, sx1, sy1 := extent(1000, 1000)
|
||||
if sx0 != ax0 || sx1 != ax1 || sy1-sy0 >= ay1-ay0 || sy0 <= ay0 || (sy0-ay0)-(ay1-sy1) > 1 || (ay1-sy1)-(sy0-ay0) > 1 {
|
||||
t.Errorf("square at %d,%d-%d,%d in the box %d,%d-%d,%d", sx0, sy0, sx1, sy1, ax0, ay0, ax1, ay1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user