Ver código fonte

remove gui.Button spacing when image/icon not supplied

leonsal 8 anos atrás
pai
commit
45f34afce8
1 arquivos alterados com 4 adições e 1 exclusões
  1. 4 1
      gui/button.go

+ 4 - 1
gui/button.go

@@ -218,15 +218,18 @@ func (b *Button) recalc() {
 
 	// Image or icon width
 	imgWidth := float32(0)
+	spacing := float32(4)
 	if b.image != nil {
 		imgWidth = b.image.Width()
 	} else if b.icon != nil {
 		imgWidth = b.icon.Width()
 	}
+	if imgWidth == 0 {
+		spacing = 0
+	}
 
 	// If the label is empty and an icon of image was defined ignore the label widthh
 	// to centralize the icon/image in the button
-	spacing := float32(4)
 	labelWidth := spacing + b.Label.Width()
 	if b.Label.Text() == "" && imgWidth > 0 {
 		labelWidth = 0