changed image display

This commit is contained in:
Grimsace
2026-02-09 10:35:28 -06:00
parent 2a36eb8619
commit 671cd63c6f
3 changed files with 85 additions and 5 deletions
+52 -5
View File
@@ -943,11 +943,58 @@ func main() {
tabs, tabs,
) )
right := container.NewGridWithRows(3, right := container.NewMax()
canvasImg, var tappableCanvas, tappableHeightmap, tappableBumpmap *tappableImage
heightmapImg,
bumpmapImg, updateRightPanel := func() {
) var top, bottom fyne.CanvasObject
switch settings.ImageViewState {
case 1:
top = tappableCanvas
bottom = container.NewGridWithColumns(2, tappableHeightmap, tappableBumpmap)
case 2:
top = tappableHeightmap
bottom = container.NewGridWithColumns(2, tappableCanvas, tappableBumpmap)
case 3:
top = tappableBumpmap
bottom = container.NewGridWithColumns(2, tappableCanvas, tappableHeightmap)
default:
right.Objects = []fyne.CanvasObject{container.NewGridWithRows(3, tappableCanvas, tappableHeightmap, tappableBumpmap)}
right.Refresh()
return
}
split := container.NewVSplit(top, bottom)
split.Offset = 0.8
right.Objects = []fyne.CanvasObject{split}
right.Refresh()
}
tappableCanvas = newTappableImage(container.NewMax(canvasImg), func() {
if settings.ImageViewState == 1 {
settings.ImageViewState = 0
} else {
settings.ImageViewState = 1
}
updateRightPanel()
})
tappableHeightmap = newTappableImage(container.NewMax(heightmapImg), func() {
if settings.ImageViewState == 2 {
settings.ImageViewState = 0
} else {
settings.ImageViewState = 2
}
updateRightPanel()
})
tappableBumpmap = newTappableImage(container.NewMax(bumpmapImg), func() {
if settings.ImageViewState == 3 {
settings.ImageViewState = 0
} else {
settings.ImageViewState = 3
}
updateRightPanel()
})
updateRightPanel()
split := container.NewHSplit( split := container.NewHSplit(
left, left,
+2
View File
@@ -56,6 +56,7 @@ type Settings struct {
// General settings // General settings
Seed int64 `json:"seed"` Seed int64 `json:"seed"`
LastExportPath string `json:"last_export_path"` LastExportPath string `json:"last_export_path"`
ImageViewState int `json:"image_view_state"`
} }
// Save saves the current settings to a JSON file in the user's config directory. // Save saves the current settings to a JSON file in the user's config directory.
@@ -141,6 +142,7 @@ func LoadSettings() (*Settings, error) {
MaxBuildingComplexity: 3, MaxBuildingComplexity: 3,
BuildingComplexityRatio: 50, BuildingComplexityRatio: 50,
LastExportPath: homeDir, LastExportPath: homeDir,
ImageViewState: 0,
}, nil }, nil
} }
return nil, err return nil, err
+31
View File
@@ -0,0 +1,31 @@
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/widget"
)
type tappableImage struct {
widget.BaseWidget
image *fyne.Container
onTapped func()
}
func newTappableImage(img *fyne.Container, tapped func()) *tappableImage {
ti := &tappableImage{
image: img,
onTapped: tapped,
}
ti.ExtendBaseWidget(ti)
return ti
}
func (t *tappableImage) CreateRenderer() fyne.WidgetRenderer {
return widget.NewSimpleRenderer(t.image)
}
func (t *tappableImage) Tapped(*fyne.PointEvent) {
if t.onTapped != nil {
t.onTapped()
}
}