updateStackTop updates the [Frame.StackTop] of the stack in the switch according to the current icon. It is called automatically to keep the switch up-to-date.
()
| 231 | // according to the current icon. It is called automatically to keep the |
| 232 | // switch up-to-date. |
| 233 | func (sw *Switch) updateStackTop() { |
| 234 | st, ok := sw.ChildByName("stack", 0).(*Frame) |
| 235 | if !ok { |
| 236 | return |
| 237 | } |
| 238 | switch { |
| 239 | case sw.StateIs(states.Indeterminate): |
| 240 | st.StackTop = 2 |
| 241 | case sw.IsChecked(): |
| 242 | st.StackTop = 0 |
| 243 | default: |
| 244 | if sw.Type == SwitchChip { |
| 245 | // chips render no icon when off |
| 246 | st.StackTop = -1 |
| 247 | return |
| 248 | } |
| 249 | st.StackTop = 1 |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // SetType sets the styling type of the switch. |
| 254 | func (sw *Switch) SetType(typ SwitchTypes) *Switch { |
no test coverage detected