added canvas key
This commit is contained in:
@@ -1808,6 +1808,9 @@ func main() {
|
||||
)
|
||||
|
||||
right := container.NewMax()
|
||||
legendBar := makeMapLegendBar()
|
||||
rightSplit := container.NewHSplit(right, legendBar)
|
||||
rightSplit.Offset = 0.82
|
||||
var tappableCanvas, tappableHeightmap, tappableBumpmap *tappableImage
|
||||
|
||||
updateRightPanel := func() {
|
||||
@@ -1862,13 +1865,40 @@ func main() {
|
||||
|
||||
split := container.NewHSplit(
|
||||
left,
|
||||
right,
|
||||
rightSplit,
|
||||
)
|
||||
split.SetOffset(0.3)
|
||||
// Set the window content and start the application
|
||||
w.SetContent(split)
|
||||
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 {
|
||||
switch format {
|
||||
case "PNG":
|
||||
|
||||
Reference in New Issue
Block a user