image popup aspect ratio matches that of image
This commit is contained in:
@@ -227,8 +227,20 @@ func (a *AlbumPageHeader) showPopUpCover() {
|
|||||||
im.FillMode = canvas.ImageFillContain
|
im.FillMode = canvas.ImageFillContain
|
||||||
pop := a.page.popUpProvider.CreatePopUp(im)
|
pop := a.page.popUpProvider.CreatePopUp(im)
|
||||||
s := a.page.popUpProvider.WindowSize()
|
s := a.page.popUpProvider.WindowSize()
|
||||||
pop.Resize(fyne.NewSize(s.Width*0.8, s.Height*0.8))
|
var popS fyne.Size
|
||||||
pop.ShowAtPosition(fyne.NewPos(0.1*s.Width, 0.1*s.Height))
|
if asp := util.ImageAspect(cover); s.Width/s.Height > asp {
|
||||||
|
// window height is limiting factor
|
||||||
|
h := s.Height * 0.8
|
||||||
|
popS = fyne.NewSize(h*asp, h)
|
||||||
|
} else {
|
||||||
|
w := s.Width * 0.8
|
||||||
|
popS = fyne.NewSize(w, w*(1/asp))
|
||||||
|
}
|
||||||
|
pop.Resize(popS)
|
||||||
|
pop.ShowAtPosition(fyne.NewPos(
|
||||||
|
(s.Width-popS.Width)/2,
|
||||||
|
(s.Height-popS.Height)/2,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatMiscLabelStr(a *subsonic.AlbumID3) string {
|
func formatMiscLabelStr(a *subsonic.AlbumID3) string {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"image"
|
||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -20,6 +21,11 @@ func SecondsToTimeString(s float64) string {
|
|||||||
return fmt.Sprintf("%d:%02d", min, sec)
|
return fmt.Sprintf("%d:%02d", min, sec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ImageAspect(im image.Image) float32 {
|
||||||
|
b := im.Bounds()
|
||||||
|
return float32(b.Max.X-b.Min.X) / float32(b.Max.Y-b.Min.Y)
|
||||||
|
}
|
||||||
|
|
||||||
func RichTextSegsFromHTMLString(s string) []widget.RichTextSegment {
|
func RichTextSegsFromHTMLString(s string) []widget.RichTextSegment {
|
||||||
tokr := html.NewTokenizer(strings.NewReader(s))
|
tokr := html.NewTokenizer(strings.NewReader(s))
|
||||||
var segs []widget.RichTextSegment
|
var segs []widget.RichTextSegment
|
||||||
|
|||||||
Reference in New Issue
Block a user