update updates the button visual state
()
| 216 | |
| 217 | // update updates the button visual state |
| 218 | func (b *ImageButton) update() { |
| 219 | |
| 220 | if !b.Enabled() { |
| 221 | if b.stateImages[ButtonDisabled] != nil { |
| 222 | b.image.SetTexture(b.stateImages[ButtonDisabled]) |
| 223 | } |
| 224 | b.applyStyle(&b.styles.Disabled) |
| 225 | return |
| 226 | } |
| 227 | if b.pressed { |
| 228 | if b.stateImages[ButtonPressed] != nil { |
| 229 | b.image.SetTexture(b.stateImages[ButtonPressed]) |
| 230 | } |
| 231 | b.applyStyle(&b.styles.Pressed) |
| 232 | return |
| 233 | } |
| 234 | if b.mouseOver { |
| 235 | if b.stateImages[ButtonOver] != nil { |
| 236 | b.image.SetTexture(b.stateImages[ButtonOver]) |
| 237 | } |
| 238 | b.applyStyle(&b.styles.Over) |
| 239 | return |
| 240 | } |
| 241 | b.image.SetTexture(b.stateImages[ButtonNormal]) |
| 242 | b.applyStyle(&b.styles.Normal) |
| 243 | } |
| 244 | |
| 245 | // applyStyle applies the specified button style |
| 246 | func (b *ImageButton) applyStyle(bs *ImageButtonStyle) { |