fyne-io / developer.fyne.io

Fyne developer documentation website

Home Page:https://developer.fyne.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image size will be changed with the Scale of fyne_settings but window size remains the Normal Size

wave-man opened this issue · comments

Description

When the fyne size is changed (Non-Normal size) by fyne_settings, the image size and font size are changed, however the window size will not be changed.
This happens with the image being resized with the original image size and "FillMode = canvas.ImageFillOriginal".

Below is a program that reproduces this bug.
Execute the following program after changing the size to "Tiny" size instead of "Normal" size with the fyne_settings command.


package main

import (
  "os"
  "image"
  "fyne.io/fyne/v2"
  "fyne.io/fyne/v2/app"
  "fyne.io/fyne/v2/canvas"
  "fyne.io/fyne/v2/container"
  "fyne.io/fyne/v2/widget"
)

func loadImage(imgFile string)*canvas.Image{
  if file,err := os.Open(imgFile); err == nil{
    defer file.Close()
    if img,_,err := image.Decode(file); err == nil{
      cnvsImg := canvas.NewImageFromImage(img)
      cnvsImg.FillMode = canvas.ImageFillOriginal
      cnvsImg.Resize(fyne.NewSize(float32(img.Bounds().Dx()), float32(img.Bounds().Dx())))
      return cnvsImg
    }
  }
  return nil
}

func main() {
  if len(os.Args) == 2{
    app := app.New()
    if img := loadImage(os.Args[1]); img != nil{
      win := app.NewWindow("Image Viewer")
      label := widget.NewLabel(os.Args[1])
      cntr := container.NewWithoutLayout(img)
      win.SetContent(container.NewVBox(cntr, label,))
      win.ShowAndRun()
    }
  }
}

Thanks for opening this issue. However, this is the wrong repository for opening bugs related to the Fyne package as this is just the developer documentation website. Would you mind opening an issue over at https://github.com/fyne-io/fyne instead?