()
| 1228 | } |
| 1229 | |
| 1230 | func (bg *ButtonGroup) Update() { |
| 1231 | |
| 1232 | rect := bg.Rectangle() |
| 1233 | if bg.MaxButtonsPerRow > 1 { |
| 1234 | rect.W /= float32(bg.MaxButtonsPerRow) |
| 1235 | } else { |
| 1236 | rect.W /= float32(len(bg.Buttons)) |
| 1237 | } |
| 1238 | rect.H = globals.GridSize |
| 1239 | |
| 1240 | ogX := rect.X |
| 1241 | |
| 1242 | if len(bg.Labels) > 0 { |
| 1243 | for _, l := range bg.Labels { |
| 1244 | l.SetRectangle(rect) |
| 1245 | l.Update() |
| 1246 | rect.X += rect.W |
| 1247 | } |
| 1248 | rect.Y += globals.GridSize |
| 1249 | } |
| 1250 | |
| 1251 | rect.X = ogX |
| 1252 | |
| 1253 | for i, b := range bg.Buttons { |
| 1254 | if bg.MaxButtonsPerRow > 1 && i%bg.MaxButtonsPerRow == 0 && i > 0 { |
| 1255 | rect.Y += rect.H |
| 1256 | rect.X = ogX |
| 1257 | } |
| 1258 | |
| 1259 | b.SetRectangle(rect) |
| 1260 | |
| 1261 | rect.X += rect.W |
| 1262 | |
| 1263 | b.Update() |
| 1264 | } |
| 1265 | |
| 1266 | if bg.Property != nil { |
| 1267 | |
| 1268 | if prop := bg.Property.AsString(); prop != bg.Buttons[bg.ChosenIndex].Label.TextAsString() { |
| 1269 | |
| 1270 | for i, button := range bg.Buttons { |
| 1271 | if button.Label.TextAsString() == prop { |
| 1272 | bg.ChosenIndex = i |
| 1273 | break |
| 1274 | } |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | } |
| 1279 | |
| 1280 | } |
| 1281 | |
| 1282 | func (bg *ButtonGroup) Draw() { |
| 1283 |
nothing calls this directly
no test coverage detected