added canvas key

This commit is contained in:
grimsace
2026-03-24 11:39:14 -05:00
parent e4c376dc86
commit f9d597f55d
+31 -1
View File
@@ -1808,6 +1808,9 @@ func main() {
) )
right := container.NewMax() right := container.NewMax()
legendBar := makeMapLegendBar()
rightSplit := container.NewHSplit(right, legendBar)
rightSplit.Offset = 0.82
var tappableCanvas, tappableHeightmap, tappableBumpmap *tappableImage var tappableCanvas, tappableHeightmap, tappableBumpmap *tappableImage
updateRightPanel := func() { updateRightPanel := func() {
@@ -1862,13 +1865,40 @@ func main() {
split := container.NewHSplit( split := container.NewHSplit(
left, left,
right, rightSplit,
) )
split.SetOffset(0.3) split.SetOffset(0.3)
// Set the window content and start the application // Set the window content and start the application
w.SetContent(split) w.SetContent(split)
w.ShowAndRun() w.ShowAndRun()
} }
func makeMapLegendBar() fyne.CanvasObject {
content := container.NewVBox(
widget.NewLabelWithStyle("Map Legend", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
widget.NewSeparator(),
makeLegendItem(color.RGBA{R: 34, G: 139, B: 34, A: 255}, "Trees"),
makeLegendItem(color.RGBA{R: 128, G: 128, B: 128, A: 255}, "Buildings"),
makeLegendItem(color.RGBA{R: 139, G: 69, B: 19, A: 255}, "Roads"),
makeLegendItem(color.RGBA{R: 60, G: 42, B: 33, A: 255}, "Bridges"),
makeLegendItem(color.RGBA{R: 0, G: 0, B: 0, A: 255}, "Walls"),
makeLegendItem(color.RGBA{R: 220, G: 25, B: 25, A: 255}, "Turrets and Gates"),
makeLegendItem(color.RGBA{R: 30, G: 90, B: 200, A: 255}, "Water"),
)
contentWrapper := container.NewPadded(content)
contentWrapper.Resize(fyne.NewSize(185, contentWrapper.MinSize().Height))
return contentWrapper
}
func makeLegendItem(swatch color.Color, label string) fyne.CanvasObject {
rect := canvas.NewRectangle(swatch)
rect.SetMinSize(fyne.NewSize(18, 18))
outline := canvas.NewRectangle(color.Transparent)
outline.StrokeColor = color.RGBA{R: 50, G: 50, B: 50, A: 255}
outline.StrokeWidth = 1
outline.SetMinSize(fyne.NewSize(18, 18))
return container.NewHBox(container.NewStack(rect, outline), widget.NewLabel(label))
}
func encodeImageToWriter(w io.Writer, img image.Image, format string) error { func encodeImageToWriter(w io.Writer, img image.Image, format string) error {
switch format { switch format {
case "PNG": case "PNG":