浏览代码

remove gui.Button spacing when image/icon not supplied

leonsal 8 年之前
父节点
当前提交
45f34afce8
共有 1 个文件被更改,包括 4 次插入1 次删除
  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